From 011844b7acdeca0921188ac8218f569afc2700c4 Mon Sep 17 00:00:00 2001 From: Jacob Torrey Date: Wed, 5 Apr 2023 15:45:22 +0000 Subject: [PATCH 01/10] Small quality of life improvements to list handling Signed-off-by: Jacob Torrey --- bookwyrm/templates/lists/created_text.html | 2 +- bookwyrm/views/list/list.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bookwyrm/templates/lists/created_text.html b/bookwyrm/templates/lists/created_text.html index f5405b64a..b9e188686 100644 --- a/bookwyrm/templates/lists/created_text.html +++ b/bookwyrm/templates/lists/created_text.html @@ -3,7 +3,7 @@ {% if list.curation == 'group' %} {% blocktrans with username=list.user.display_name userpath=list.user.local_path groupname=list.group.name grouppath=list.group.local_path %}Created by {{ username }} and managed by {{ groupname }}{% endblocktrans %} -{% elif list.curation != 'open' %} +{% elif list.curation == 'curated' %} {% blocktrans with username=list.user.display_name path=list.user.local_path %}Created and curated by {{ username }}{% endblocktrans %} {% else %} {% blocktrans with username=list.user.display_name path=list.user.local_path %}Created by {{ username }}{% endblocktrans %} diff --git a/bookwyrm/views/list/list.py b/bookwyrm/views/list/list.py index 24d44d183..30d6f970a 100644 --- a/bookwyrm/views/list/list.py +++ b/bookwyrm/views/list/list.py @@ -8,7 +8,7 @@ from django.db import transaction from django.db.models import Avg, DecimalField, Q, Max from django.db.models.functions import Coalesce from django.http import HttpResponseBadRequest, HttpResponse -from django.shortcuts import get_object_or_404 +from django.shortcuts import get_object_or_404, redirect from django.template.response import TemplateResponse from django.urls import reverse from django.utils.decorators import method_decorator @@ -183,7 +183,7 @@ def delete_list(request, list_id): book_list.raise_not_deletable(request.user) book_list.delete() - return redirect_to_referer(request, "lists") + return redirect("/list") @require_POST From 36c14655ecfd5b414c5b41be161a3d1e05437a1e Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Thu, 6 Apr 2023 11:37:19 +0200 Subject: [PATCH 02/10] =?UTF-8?q?Use=20the=20translated=20shelf=20name=20i?= =?UTF-8?q?n=20a=20book=E2=80=99s=20shelf=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously in the list of shelves on the page for a book it was always using the English name of the shelf for the shelf of the reading status. --- bookwyrm/templates/book/book.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index e9eff99ab..1ebb3159e 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -4,6 +4,7 @@ {% load humanize %} {% load utilities %} {% load static %} +{% load shelf_tags %} {% block title %}{{ book|book_title }}{% endblock %} @@ -239,7 +240,7 @@
    {% for shelf in user_shelfbooks %}
  • - {{ shelf.shelf.name }} + {{ shelf.shelf|translate_shelf_name }}
    {% include 'snippets/shelf_selector.html' with shelf=shelf.shelf class="is-small" readthrough=readthrough %}
    From b0f90d05f24c997d326ce625c69337e383eeb8c8 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Thu, 6 Apr 2023 15:55:11 +0200 Subject: [PATCH 03/10] Move the shelf names to a dict instead of a chain of if statements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The main reason to do this is that if we try to add another name then pylint will complain that there are too many return statements. It might be slightly faster too. If I understand correctly it doesn’t matter that the _ function is being called at module load time because it is mapped to gettext_lazy so the actual translation will be done when the string is used. --- bookwyrm/templatetags/shelf_tags.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/bookwyrm/templatetags/shelf_tags.py b/bookwyrm/templatetags/shelf_tags.py index 1fb799883..ea093b8a5 100644 --- a/bookwyrm/templatetags/shelf_tags.py +++ b/bookwyrm/templatetags/shelf_tags.py @@ -9,6 +9,14 @@ from bookwyrm.utils import cache register = template.Library() +SHELF_NAMES = { + "all": _("All books"), + "to-read": _("To Read"), + "reading": _("Currently Reading"), + "read": _("Read"), +} + + @register.filter(name="is_book_on_shelf") def get_is_book_on_shelf(book, shelf): """is a book on a shelf""" @@ -42,15 +50,11 @@ def get_translated_shelf_name(shelf): return "" # support obj or dict identifier = shelf["identifier"] if isinstance(shelf, dict) else shelf.identifier - if identifier == "all": - return _("All books") - if identifier == "to-read": - return _("To Read") - if identifier == "reading": - return _("Currently Reading") - if identifier == "read": - return _("Read") - return shelf["name"] if isinstance(shelf, dict) else shelf.name + + try: + return SHELF_NAMES[identifier] + except KeyError: + return shelf["name"] if isinstance(shelf, dict) else shelf.name @register.simple_tag(takes_context=True) From 9092c9c80c06154f3bd2394b68ca6599ea4ee4e6 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Thu, 6 Apr 2023 11:53:17 +0200 Subject: [PATCH 04/10] Add a translatable name for the "stopped-reading" status shelf --- bookwyrm/templatetags/shelf_tags.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bookwyrm/templatetags/shelf_tags.py b/bookwyrm/templatetags/shelf_tags.py index ea093b8a5..6243fcae2 100644 --- a/bookwyrm/templatetags/shelf_tags.py +++ b/bookwyrm/templatetags/shelf_tags.py @@ -14,6 +14,7 @@ SHELF_NAMES = { "to-read": _("To Read"), "reading": _("Currently Reading"), "read": _("Read"), + "stopped-reading": _("Stopped Reading"), } From 912d0a0149d0f3a16fe5c0d2e179ade1c51ef527 Mon Sep 17 00:00:00 2001 From: Wesley Aptekar-Cassels Date: Fri, 7 Apr 2023 05:51:00 -0400 Subject: [PATCH 05/10] Fix Accept header for requesting ActivityPub objects This is the header described in the ActivityPub spec, which should fix some federation problems with GoToSocial and potentially other picky services. Related: #2794, superseriousbusiness/gotosocial#1676 --- bookwyrm/activitypub/base_activity.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bookwyrm/activitypub/base_activity.py b/bookwyrm/activitypub/base_activity.py index 840dab6a4..ef7ecd0b2 100644 --- a/bookwyrm/activitypub/base_activity.py +++ b/bookwyrm/activitypub/base_activity.py @@ -384,7 +384,8 @@ def get_activitypub_data(url): resp = requests.get( url, headers={ - "Accept": "application/json; charset=utf-8", + # pylint: disable=line-too-long + "Accept": 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', "Date": now, "Signature": make_signature("get", sender, url, now), }, From 1048638e3033cbed474dbdba8c5d2da86a9a0a6f Mon Sep 17 00:00:00 2001 From: Wesley Aptekar-Cassels Date: Fri, 7 Apr 2023 21:51:44 -0400 Subject: [PATCH 06/10] Stop ignoring task results This is essentially a revert of 9cbff312a. The commit was at the advice of the Celery docs for optimization, but I've since decided that the downsides in terms of making things harder to debug (it makes Flower nearly useless, for instance) are bigger than the upsides in performance gain (which seem extremely small in practice, given how long our tasks take, and the number of tasks we have). --- bookwyrm/activitypub/base_activity.py | 2 +- bookwyrm/activitystreams.py | 16 ++++++++-------- bookwyrm/connectors/connector_manager.py | 4 ++-- bookwyrm/emailing.py | 2 +- bookwyrm/lists_stream.py | 10 +++++----- bookwyrm/models/activitypub_mixin.py | 2 +- bookwyrm/models/antispam.py | 2 +- bookwyrm/models/import_job.py | 4 ++-- bookwyrm/models/user.py | 4 ++-- bookwyrm/preview_images.py | 8 ++++---- bookwyrm/suggested_users.py | 12 ++++++------ bookwyrm/views/inbox.py | 2 +- 12 files changed, 34 insertions(+), 34 deletions(-) diff --git a/bookwyrm/activitypub/base_activity.py b/bookwyrm/activitypub/base_activity.py index 44361f0d0..908475e73 100644 --- a/bookwyrm/activitypub/base_activity.py +++ b/bookwyrm/activitypub/base_activity.py @@ -241,7 +241,7 @@ class ActivityObject: return data -@app.task(queue=MEDIUM, ignore_result=True) +@app.task(queue=MEDIUM) @transaction.atomic def set_related_field( model_name, origin_model_name, related_field_name, related_remote_id, data diff --git a/bookwyrm/activitystreams.py b/bookwyrm/activitystreams.py index 92076e6b8..0dcb5262e 100644 --- a/bookwyrm/activitystreams.py +++ b/bookwyrm/activitystreams.py @@ -497,7 +497,7 @@ def remove_statuses_on_unshelve(sender, instance, *args, **kwargs): # ---- TASKS -@app.task(queue=LOW, ignore_result=True) +@app.task(queue=LOW) def add_book_statuses_task(user_id, book_id): """add statuses related to a book on shelve""" user = models.User.objects.get(id=user_id) @@ -505,7 +505,7 @@ def add_book_statuses_task(user_id, book_id): BooksStream().add_book_statuses(user, book) -@app.task(queue=LOW, ignore_result=True) +@app.task(queue=LOW) def remove_book_statuses_task(user_id, book_id): """remove statuses about a book from a user's books feed""" user = models.User.objects.get(id=user_id) @@ -513,7 +513,7 @@ def remove_book_statuses_task(user_id, book_id): BooksStream().remove_book_statuses(user, book) -@app.task(queue=MEDIUM, ignore_result=True) +@app.task(queue=MEDIUM) def populate_stream_task(stream, user_id): """background task for populating an empty activitystream""" user = models.User.objects.get(id=user_id) @@ -521,7 +521,7 @@ def populate_stream_task(stream, user_id): stream.populate_streams(user) -@app.task(queue=MEDIUM, ignore_result=True) +@app.task(queue=MEDIUM) def remove_status_task(status_ids): """remove a status from any stream it might be in""" # this can take an id or a list of ids @@ -536,7 +536,7 @@ def remove_status_task(status_ids): ) -@app.task(queue=HIGH, ignore_result=True) +@app.task(queue=HIGH) def add_status_task(status_id, increment_unread=False): """add a status to any stream it should be in""" status = models.Status.objects.select_subclasses().get(id=status_id) @@ -548,7 +548,7 @@ def add_status_task(status_id, increment_unread=False): stream.add_status(status, increment_unread=increment_unread) -@app.task(queue=MEDIUM, ignore_result=True) +@app.task(queue=MEDIUM) def remove_user_statuses_task(viewer_id, user_id, stream_list=None): """remove all statuses by a user from a viewer's stream""" stream_list = [streams[s] for s in stream_list] if stream_list else streams.values() @@ -558,7 +558,7 @@ def remove_user_statuses_task(viewer_id, user_id, stream_list=None): stream.remove_user_statuses(viewer, user) -@app.task(queue=MEDIUM, ignore_result=True) +@app.task(queue=MEDIUM) def add_user_statuses_task(viewer_id, user_id, stream_list=None): """add all statuses by a user to a viewer's stream""" stream_list = [streams[s] for s in stream_list] if stream_list else streams.values() @@ -568,7 +568,7 @@ def add_user_statuses_task(viewer_id, user_id, stream_list=None): stream.add_user_statuses(viewer, user) -@app.task(queue=MEDIUM, ignore_result=True) +@app.task(queue=MEDIUM) def handle_boost_task(boost_id): """remove the original post and other, earlier boosts""" instance = models.Status.objects.get(id=boost_id) diff --git a/bookwyrm/connectors/connector_manager.py b/bookwyrm/connectors/connector_manager.py index d7e2aad4b..56a222ba1 100644 --- a/bookwyrm/connectors/connector_manager.py +++ b/bookwyrm/connectors/connector_manager.py @@ -143,7 +143,7 @@ def get_or_create_connector(remote_id): return load_connector(connector_info) -@app.task(queue=LOW, ignore_result=True) +@app.task(queue=LOW) def load_more_data(connector_id, book_id): """background the work of getting all 10,000 editions of LoTR""" connector_info = models.Connector.objects.get(id=connector_id) @@ -152,7 +152,7 @@ def load_more_data(connector_id, book_id): connector.expand_book_data(book) -@app.task(queue=LOW, ignore_result=True) +@app.task(queue=LOW) def create_edition_task(connector_id, work_id, data): """separate task for each of the 10,000 editions of LoTR""" connector_info = models.Connector.objects.get(id=connector_id) diff --git a/bookwyrm/emailing.py b/bookwyrm/emailing.py index 1640c0b73..2271077b1 100644 --- a/bookwyrm/emailing.py +++ b/bookwyrm/emailing.py @@ -75,7 +75,7 @@ def format_email(email_name, data): return (subject, html_content, text_content) -@app.task(queue=HIGH, ignore_result=True) +@app.task(queue=HIGH) def send_email(recipient, subject, html_content, text_content): """use a task to send the email""" email = EmailMultiAlternatives( diff --git a/bookwyrm/lists_stream.py b/bookwyrm/lists_stream.py index 2a92103e5..2b08010b1 100644 --- a/bookwyrm/lists_stream.py +++ b/bookwyrm/lists_stream.py @@ -217,14 +217,14 @@ def add_list_on_account_create_command(user_id): # ---- TASKS -@app.task(queue=MEDIUM, ignore_result=True) +@app.task(queue=MEDIUM) def populate_lists_task(user_id): """background task for populating an empty list stream""" user = models.User.objects.get(id=user_id) ListsStream().populate_lists(user) -@app.task(queue=MEDIUM, ignore_result=True) +@app.task(queue=MEDIUM) def remove_list_task(list_id, re_add=False): """remove a list from any stream it might be in""" stores = models.User.objects.filter(local=True, is_active=True).values_list( @@ -239,14 +239,14 @@ def remove_list_task(list_id, re_add=False): add_list_task.delay(list_id) -@app.task(queue=HIGH, ignore_result=True) +@app.task(queue=HIGH) def add_list_task(list_id): """add a list to any stream it should be in""" book_list = models.List.objects.get(id=list_id) ListsStream().add_list(book_list) -@app.task(queue=MEDIUM, ignore_result=True) +@app.task(queue=MEDIUM) def remove_user_lists_task(viewer_id, user_id, exclude_privacy=None): """remove all lists by a user from a viewer's stream""" viewer = models.User.objects.get(id=viewer_id) @@ -254,7 +254,7 @@ def remove_user_lists_task(viewer_id, user_id, exclude_privacy=None): ListsStream().remove_user_lists(viewer, user, exclude_privacy=exclude_privacy) -@app.task(queue=MEDIUM, ignore_result=True) +@app.task(queue=MEDIUM) def add_user_lists_task(viewer_id, user_id): """add all lists by a user to a viewer's stream""" viewer = models.User.objects.get(id=viewer_id) diff --git a/bookwyrm/models/activitypub_mixin.py b/bookwyrm/models/activitypub_mixin.py index 3350a4f6b..e76433189 100644 --- a/bookwyrm/models/activitypub_mixin.py +++ b/bookwyrm/models/activitypub_mixin.py @@ -506,7 +506,7 @@ def unfurl_related_field(related_field, sort_field=None): return related_field.remote_id -@app.task(queue=BROADCAST, ignore_result=True) +@app.task(queue=BROADCAST) def broadcast_task(sender_id: int, activity: str, recipients: List[str]): """the celery task for broadcast""" user_model = apps.get_model("bookwyrm.User", require_ready=True) diff --git a/bookwyrm/models/antispam.py b/bookwyrm/models/antispam.py index c3afadf28..1e20df340 100644 --- a/bookwyrm/models/antispam.py +++ b/bookwyrm/models/antispam.py @@ -65,7 +65,7 @@ class AutoMod(AdminModel): created_by = models.ForeignKey("User", on_delete=models.PROTECT) -@app.task(queue=LOW, ignore_result=True) +@app.task(queue=LOW) def automod_task(): """Create reports""" if not AutoMod.objects.exists(): diff --git a/bookwyrm/models/import_job.py b/bookwyrm/models/import_job.py index 5f564d390..bdd88c687 100644 --- a/bookwyrm/models/import_job.py +++ b/bookwyrm/models/import_job.py @@ -327,7 +327,7 @@ class ImportItem(models.Model): ) -@app.task(queue=IMPORTS, ignore_result=True) +@app.task(queue=IMPORTS) def start_import_task(job_id): """trigger the child tasks for each row""" job = ImportJob.objects.get(id=job_id) @@ -346,7 +346,7 @@ def start_import_task(job_id): job.save() -@app.task(queue=IMPORTS, ignore_result=True) +@app.task(queue=IMPORTS) def import_item_task(item_id): """resolve a row into a book""" item = ImportItem.objects.get(id=item_id) diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py index 6d26b7b17..85e1f0edb 100644 --- a/bookwyrm/models/user.py +++ b/bookwyrm/models/user.py @@ -469,7 +469,7 @@ class KeyPair(ActivitypubMixin, BookWyrmModel): return super().save(*args, **kwargs) -@app.task(queue=LOW, ignore_result=True) +@app.task(queue=LOW) def set_remote_server(user_id): """figure out the user's remote server in the background""" user = User.objects.get(id=user_id) @@ -513,7 +513,7 @@ def get_or_create_remote_server(domain, refresh=False): return server -@app.task(queue=LOW, ignore_result=True) +@app.task(queue=LOW) def get_remote_reviews(outbox): """ingest reviews by a new remote bookwyrm user""" outbox_page = outbox + "?page=true&type=Review" diff --git a/bookwyrm/preview_images.py b/bookwyrm/preview_images.py index c218d87df..549e12472 100644 --- a/bookwyrm/preview_images.py +++ b/bookwyrm/preview_images.py @@ -420,7 +420,7 @@ def save_and_cleanup(image, instance=None): # pylint: disable=invalid-name -@app.task(queue=LOW, ignore_result=True) +@app.task(queue=LOW) def generate_site_preview_image_task(): """generate preview_image for the website""" if not settings.ENABLE_PREVIEW_IMAGES: @@ -445,7 +445,7 @@ def generate_site_preview_image_task(): # pylint: disable=invalid-name -@app.task(queue=LOW, ignore_result=True) +@app.task(queue=LOW) def generate_edition_preview_image_task(book_id): """generate preview_image for a book""" if not settings.ENABLE_PREVIEW_IMAGES: @@ -470,7 +470,7 @@ def generate_edition_preview_image_task(book_id): save_and_cleanup(image, instance=book) -@app.task(queue=LOW, ignore_result=True) +@app.task(queue=LOW) def generate_user_preview_image_task(user_id): """generate preview_image for a user""" if not settings.ENABLE_PREVIEW_IMAGES: @@ -496,7 +496,7 @@ def generate_user_preview_image_task(user_id): save_and_cleanup(image, instance=user) -@app.task(queue=LOW, ignore_result=True) +@app.task(queue=LOW) def remove_user_preview_image_task(user_id): """remove preview_image for a user""" if not settings.ENABLE_PREVIEW_IMAGES: diff --git a/bookwyrm/suggested_users.py b/bookwyrm/suggested_users.py index 0ae2a1b15..05e05891c 100644 --- a/bookwyrm/suggested_users.py +++ b/bookwyrm/suggested_users.py @@ -244,20 +244,20 @@ def domain_level_update(sender, instance, created, update_fields=None, **kwargs) # ------------------- TASKS -@app.task(queue=LOW, ignore_result=True) +@app.task(queue=LOW) def rerank_suggestions_task(user_id): """do the hard work in celery""" suggested_users.rerank_user_suggestions(user_id) -@app.task(queue=LOW, ignore_result=True) +@app.task(queue=LOW) def rerank_user_task(user_id, update_only=False): """do the hard work in celery""" user = models.User.objects.get(id=user_id) suggested_users.rerank_obj(user, update_only=update_only) -@app.task(queue=LOW, ignore_result=True) +@app.task(queue=LOW) def remove_user_task(user_id): """do the hard work in celery""" user = models.User.objects.get(id=user_id) @@ -266,14 +266,14 @@ def remove_user_task(user_id): ) -@app.task(queue=MEDIUM, ignore_result=True) +@app.task(queue=MEDIUM) def remove_suggestion_task(user_id, suggested_user_id): """remove a specific user from a specific user's suggestions""" suggested_user = models.User.objects.get(id=suggested_user_id) suggested_users.remove_suggestion(user_id, suggested_user) -@app.task(queue=LOW, ignore_result=True) +@app.task(queue=LOW) def bulk_remove_instance_task(instance_id): """remove a bunch of users from recs""" for user in models.User.objects.filter(federated_server__id=instance_id): @@ -282,7 +282,7 @@ def bulk_remove_instance_task(instance_id): ) -@app.task(queue=LOW, ignore_result=True) +@app.task(queue=LOW) def bulk_add_instance_task(instance_id): """remove a bunch of users from recs""" for user in models.User.objects.filter(federated_server__id=instance_id): diff --git a/bookwyrm/views/inbox.py b/bookwyrm/views/inbox.py index 2fb36507f..42a8dc78e 100644 --- a/bookwyrm/views/inbox.py +++ b/bookwyrm/views/inbox.py @@ -115,7 +115,7 @@ def sometimes_async_activity_task(activity_json, queue=MEDIUM): activity_task.apply_async(args=(activity_json,), queue=queue) -@app.task(queue=MEDIUM, ignore_result=True) +@app.task(queue=MEDIUM) def activity_task(activity_json): """do something with this json we think is legit""" # lets see if the activitypub module can make sense of this json From 41633090baaa16a5255170caab6792e5975af771 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Sat, 8 Apr 2023 17:02:04 +0200 Subject: [PATCH 07/10] Don't show the series as a link if the book has no author The series link needs an author so if it doesn't have one, instead of showing a server error let's just show the series details as plain text without a link. Fixes: #2797 --- bookwyrm/templates/book/book.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index e9eff99ab..1024255e6 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -46,7 +46,13 @@ - ({{ book.series }}{% if book.series_number %} #{{ book.series_number }}{% endif %}) + {% if book.authors.exists %} + + {% endif %} + {{ book.series }}{% if book.series_number %} #{{ book.series_number }}{% endif %} + {% if book.authors.exists %} + + {% endif %} {% endif %}

    {% endif %} From 43b34610a6082857f87a0c8126be44552d89e4f0 Mon Sep 17 00:00:00 2001 From: Wesley Aptekar-Cassels Date: Tue, 11 Apr 2023 21:51:31 -0400 Subject: [PATCH 08/10] Choose installed docker compose command in bw-dev Docker is removing support for docker-compose, and it doesn't appear to be possible to install it anymore. Instead, it has been replaced with compose V2 which is a docker plugin called with 'docker compose' (no hyphen). See https://docs.docker.com/compose/compose-v2/ Thanks to @Neriderc for noticing this in #2781. --- bw-dev | 54 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/bw-dev b/bw-dev index 3e804943b..df88b06c6 100755 --- a/bw-dev +++ b/bw-dev @@ -23,21 +23,27 @@ trap showerr EXIT source .env trap - EXIT +if docker compose &> /dev/null ; then + DOCKER_COMPOSE="docker compose" +else + DOCKER_COMPOSE="docker-compose" +fi + function clean { - docker-compose stop - docker-compose rm -f + $DOCKER_COMPOSE stop + $DOCKER_COMPOSE rm -f } function runweb { - docker-compose run --rm web "$@" + $DOCKER_COMPOSE run --rm web "$@" } function execdb { - docker-compose exec db $@ + $DOCKER_COMPOSE exec db $@ } function execweb { - docker-compose exec web "$@" + $DOCKER_COMPOSE exec web "$@" } function initdb { @@ -75,23 +81,23 @@ set -x case "$CMD" in up) - docker-compose up --build "$@" + $DOCKER_COMPOSE up --build "$@" ;; down) - docker-compose down + $DOCKER_COMPOSE down ;; service_ports_web) prod_error - docker-compose run --rm --service-ports web + $DOCKER_COMPOSE run --rm --service-ports web ;; initdb) initdb "@" ;; resetdb) prod_error - docker-compose rm -svf + $DOCKER_COMPOSE rm -svf docker volume rm -f bookwyrm_media_volume bookwyrm_pgdata bookwyrm_redis_activity_data bookwyrm_redis_broker_data bookwyrm_static_volume - docker-compose build + $DOCKER_COMPOSE build migrate migrate django_celery_beat initdb @@ -116,7 +122,7 @@ case "$CMD" in execdb psql -U ${POSTGRES_USER} ${POSTGRES_DB} ;; restart_celery) - docker-compose restart celery_worker + $DOCKER_COMPOSE restart celery_worker ;; pytest) prod_error @@ -164,7 +170,7 @@ case "$CMD" in runweb django-admin compilemessages --ignore venv ;; build) - docker-compose build + $DOCKER_COMPOSE build ;; clean) prod_error @@ -172,7 +178,7 @@ case "$CMD" in ;; black) prod_error - docker-compose run --rm dev-tools black celerywyrm bookwyrm + $DOCKER_COMPOSE run --rm dev-tools black celerywyrm bookwyrm ;; pylint) prod_error @@ -181,25 +187,25 @@ case "$CMD" in ;; prettier) prod_error - docker-compose run --rm dev-tools npx prettier --write bookwyrm/static/js/*.js + $DOCKER_COMPOSE run --rm dev-tools npx prettier --write bookwyrm/static/js/*.js ;; eslint) prod_error - docker-compose run --rm dev-tools npx eslint bookwyrm/static --ext .js + $DOCKER_COMPOSE run --rm dev-tools npx eslint bookwyrm/static --ext .js ;; stylelint) prod_error - docker-compose run --rm dev-tools npx stylelint \ + $DOCKER_COMPOSE run --rm dev-tools npx stylelint \ bookwyrm/static/css/bookwyrm.scss bookwyrm/static/css/bookwyrm/**/*.scss --fix \ --config dev-tools/.stylelintrc.js ;; formatters) prod_error runweb pylint bookwyrm/ - docker-compose run --rm dev-tools black celerywyrm bookwyrm - docker-compose run --rm dev-tools npx prettier --write bookwyrm/static/js/*.js - docker-compose run --rm dev-tools npx eslint bookwyrm/static --ext .js - docker-compose run --rm dev-tools npx stylelint \ + $DOCKER_COMPOSE run --rm dev-tools black celerywyrm bookwyrm + $DOCKER_COMPOSE run --rm dev-tools npx prettier --write bookwyrm/static/js/*.js + $DOCKER_COMPOSE run --rm dev-tools npx eslint bookwyrm/static --ext .js + $DOCKER_COMPOSE run --rm dev-tools npx stylelint \ bookwyrm/static/css/bookwyrm.scss bookwyrm/static/css/bookwyrm/**/*.scss --fix \ --config dev-tools/.stylelintrc.js ;; @@ -209,14 +215,14 @@ case "$CMD" in ;; update) git pull - docker-compose build + $DOCKER_COMPOSE build # ./update.sh runweb python manage.py migrate runweb python manage.py compile_themes runweb python manage.py collectstatic --no-input - docker-compose up -d - docker-compose restart web - docker-compose restart celery_worker + $DOCKER_COMPOSE up -d + $DOCKER_COMPOSE restart web + $DOCKER_COMPOSE restart celery_worker ;; populate_streams) runweb python manage.py populate_streams "$@" From f520d1b7f8c2ebca690ac3e246c39b3a5e70045a Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Fri, 14 Apr 2023 16:40:50 +0200 Subject: [PATCH 09/10] Make the text on the search button translatable --- bookwyrm/templates/search/layout.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/templates/search/layout.html b/bookwyrm/templates/search/layout.html index a2f64ad07..340911cb0 100644 --- a/bookwyrm/templates/search/layout.html +++ b/bookwyrm/templates/search/layout.html @@ -29,7 +29,7 @@
    From 3619d8960bf951bbc69f8aa23ce7d0f27d3d117d Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Fri, 14 Apr 2023 16:49:00 +0200 Subject: [PATCH 10/10] Mark two strings as translatable in the getting started questionnaire --- bookwyrm/templates/get_started/books.html | 2 +- bookwyrm/templates/get_started/users.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/get_started/books.html b/bookwyrm/templates/get_started/books.html index 9613508b9..93196dbcf 100644 --- a/bookwyrm/templates/get_started/books.html +++ b/bookwyrm/templates/get_started/books.html @@ -30,7 +30,7 @@
    {% if book_results %}
    -

    Search results

    +

    {% trans "Search results" %}

    {% for book in book_results %} diff --git a/bookwyrm/templates/get_started/users.html b/bookwyrm/templates/get_started/users.html index 7ec7ed9d3..4f95882f5 100644 --- a/bookwyrm/templates/get_started/users.html +++ b/bookwyrm/templates/get_started/users.html @@ -5,7 +5,7 @@

    {% trans "Who to follow" %}

    -

    You can follow users on other BookWyrm instances and federated services like Mastodon.

    +

    {% trans "You can follow users on other BookWyrm instances and federated services like Mastodon." %}