diff --git a/README.md b/README.md index 1d3eb543..cf40d284 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ If you'd like to join an instance, you can check out the [instances](https://joi ## Contributing -See [contributing](https://docs.joinbookwyrm.com/how-to-contribute.html) for code, translation or monetary contributions. +See [contributing](https://docs.joinbookwyrm.com/contributing.html) for code, translation or monetary contributions. ## About BookWyrm ### What it is and isn't @@ -76,4 +76,4 @@ Deployment ## Set up BookWyrm -The [documentation website](https://docs.joinbookwyrm.com/) has instruction on how to set up BookWyrm in a [developer environment](https://docs.joinbookwyrm.com/developer-environment.html) or [production](https://docs.joinbookwyrm.com/installing-in-production.html). +The [documentation website](https://docs.joinbookwyrm.com/) has instruction on how to set up BookWyrm in a [developer environment](https://docs.joinbookwyrm.com/install-dev.html) or [production](https://docs.joinbookwyrm.com/install-prod.html). diff --git a/bookwyrm/activitystreams.py b/bookwyrm/activitystreams.py index f2dd43fb..a90d7943 100644 --- a/bookwyrm/activitystreams.py +++ b/bookwyrm/activitystreams.py @@ -298,8 +298,9 @@ def add_status_on_create_command(sender, instance, created): priority = HIGH # check if this is an old status, de-prioritize if so # (this will happen if federation is very slow, or, more expectedly, on csv import) - one_day = 60 * 60 * 24 - if (instance.created_date - instance.published_date).seconds > one_day: + if instance.published_date < timezone.now() - timedelta( + days=1 + ) or instance.created_date < instance.published_date - timedelta(days=1): priority = LOW add_status_task.apply_async( diff --git a/bookwyrm/models/base_model.py b/bookwyrm/models/base_model.py index f8d3b781..eeb2e940 100644 --- a/bookwyrm/models/base_model.py +++ b/bookwyrm/models/base_model.py @@ -8,6 +8,7 @@ from django.db.models import Q from django.dispatch import receiver from django.http import Http404 from django.utils.translation import gettext_lazy as _ +from django.utils.text import slugify from bookwyrm.settings import DOMAIN from .fields import RemoteIdField @@ -35,10 +36,11 @@ class BookWyrmModel(models.Model): remote_id = RemoteIdField(null=True, activitypub_field="id") def get_remote_id(self): - """generate a url that resolves to the local object""" + """generate the url that resolves to the local object, without a slug""" base_path = f"https://{DOMAIN}" if hasattr(self, "user"): base_path = f"{base_path}{self.user.local_path}" + model_name = type(self).__name__.lower() return f"{base_path}/{model_name}/{self.id}" @@ -49,8 +51,20 @@ class BookWyrmModel(models.Model): @property def local_path(self): - """how to link to this object in the local app""" - return self.get_remote_id().replace(f"https://{DOMAIN}", "") + """how to link to this object in the local app, with a slug""" + local = self.get_remote_id().replace(f"https://{DOMAIN}", "") + + name = None + if hasattr(self, "name_field"): + name = getattr(self, self.name_field) + elif hasattr(self, "name"): + name = self.name + + if name: + slug = slugify(name) + local = f"{local}/s/{slug}" + + return local def raise_visible_to_user(self, viewer): """is a user authorized to view an object?""" diff --git a/bookwyrm/models/shelf.py b/bookwyrm/models/shelf.py index 320d495d..8ea274ea 100644 --- a/bookwyrm/models/shelf.py +++ b/bookwyrm/models/shelf.py @@ -6,6 +6,7 @@ from django.db import models from django.utils import timezone from bookwyrm import activitypub +from bookwyrm.settings import DOMAIN from .activitypub_mixin import CollectionItemMixin, OrderedCollectionMixin from .base_model import BookWyrmModel from . import fields @@ -65,6 +66,11 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel): identifier = self.identifier or self.get_identifier() return f"{base_path}/books/{identifier}" + @property + def local_path(self): + """No slugs""" + return self.get_remote_id().replace(f"https://{DOMAIN}", "") + def raise_not_deletable(self, viewer): """don't let anyone delete a default shelf""" super().raise_not_deletable(viewer) diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index 453480f9..e7d10f4f 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -284,7 +284,7 @@ {% if user_statuses.review_count or user_statuses.comment_count or user_statuses.quotation_count %}