From 2470a0fd1c8dcf6acf19308c3f43833225a294ba Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 22 Feb 2023 09:36:39 -0800 Subject: [PATCH 01/35] Create notifications for link domains that need approval --- bookwyrm/models/notification.py | 28 +++++++++++++++++++--- bookwyrm/templates/notifications/item.html | 2 ++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/bookwyrm/models/notification.py b/bookwyrm/models/notification.py index fa2ce54e2..29f7b0c2d 100644 --- a/bookwyrm/models/notification.py +++ b/bookwyrm/models/notification.py @@ -2,8 +2,8 @@ from django.db import models, transaction from django.dispatch import receiver from .base_model import BookWyrmModel -from . import Boost, Favorite, GroupMemberInvitation, ImportJob, ListItem, Report -from . import Status, User, UserFollowRequest +from . import Boost, Favorite, GroupMemberInvitation, ImportJob, LinkDomain +from . import ListItem, Report, Status, User, UserFollowRequest class Notification(BookWyrmModel): @@ -28,6 +28,7 @@ class Notification(BookWyrmModel): # Admin REPORT = "REPORT" + LINK_DOMAIN = "LINK_DOMAIN" # Groups INVITE = "INVITE" @@ -43,7 +44,7 @@ class Notification(BookWyrmModel): NotificationType = models.TextChoices( # there has got be a better way to do this "NotificationType", - f"{FAVORITE} {REPLY} {MENTION} {TAG} {FOLLOW} {FOLLOW_REQUEST} {BOOST} {IMPORT} {ADD} {REPORT} {INVITE} {ACCEPT} {JOIN} {LEAVE} {REMOVE} {GROUP_PRIVACY} {GROUP_NAME} {GROUP_DESCRIPTION}", + f"{FAVORITE} {REPLY} {MENTION} {TAG} {FOLLOW} {FOLLOW_REQUEST} {BOOST} {IMPORT} {ADD} {REPORT} {LINK_DOMAIN} {INVITE} {ACCEPT} {JOIN} {LEAVE} {REMOVE} {GROUP_PRIVACY} {GROUP_NAME} {GROUP_DESCRIPTION}", ) user = models.ForeignKey("User", on_delete=models.CASCADE) @@ -64,6 +65,7 @@ class Notification(BookWyrmModel): "ListItem", symmetrical=False, related_name="notifications" ) related_reports = models.ManyToManyField("Report", symmetrical=False) + related_link_domains = models.ManyToManyField("LinkDomain", symmetrical=False) @classmethod @transaction.atomic @@ -241,6 +243,26 @@ def notify_admins_on_report(sender, instance, created, *args, **kwargs): notification.related_reports.add(instance) +@receiver(models.signals.post_save, sender=LinkDomain) +@transaction.atomic +# pylint: disable=unused-argument +def notify_admins_on_link_domain(sender, instance, created, *args, **kwargs): + """a new link domain needs to be verified""" + if not created: + # otherwise you'll get a notification when you approve a domain + return + + # moderators and superusers should be notified + admins = User.admins() + for admin in admins: + notification, _ = Notification.objects.get_or_create( + user=admin, + notification_type=Notification.LINK_DOMAIN, + read=False, + ) + notification.related_link_domains.add(instance) + + @receiver(models.signals.post_save, sender=GroupMemberInvitation) # pylint: disable=unused-argument def notify_user_on_group_invite(sender, instance, *args, **kwargs): diff --git a/bookwyrm/templates/notifications/item.html b/bookwyrm/templates/notifications/item.html index e8e2dcb26..b53abe3d1 100644 --- a/bookwyrm/templates/notifications/item.html +++ b/bookwyrm/templates/notifications/item.html @@ -17,6 +17,8 @@ {% include 'notifications/items/add.html' %} {% elif notification.notification_type == 'REPORT' %} {% include 'notifications/items/report.html' %} +{% elif notification.notification_type == 'LINK_DOMAIN' %} + {% include 'notifications/items/link_domain.html' %} {% elif notification.notification_type == 'INVITE' %} {% include 'notifications/items/invite.html' %} {% elif notification.notification_type == 'ACCEPT' %} From 268946a77c2019003f3449315a75e793a732652d Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 22 Feb 2023 10:43:49 -0800 Subject: [PATCH 02/35] Adds missing template and migration files --- .../migrations/0174_auto_20230222_1742.py | 46 +++++++++++++++++++ .../notifications/items/link_domain.html | 20 ++++++++ 2 files changed, 66 insertions(+) create mode 100644 bookwyrm/migrations/0174_auto_20230222_1742.py create mode 100644 bookwyrm/templates/notifications/items/link_domain.html diff --git a/bookwyrm/migrations/0174_auto_20230222_1742.py b/bookwyrm/migrations/0174_auto_20230222_1742.py new file mode 100644 index 000000000..0f2f89ec5 --- /dev/null +++ b/bookwyrm/migrations/0174_auto_20230222_1742.py @@ -0,0 +1,46 @@ +# Generated by Django 3.2.18 on 2023-02-22 17:42 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0173_default_user_auth_group_setting"), + ] + + operations = [ + migrations.AddField( + model_name="notification", + name="related_link_domains", + field=models.ManyToManyField(to="bookwyrm.LinkDomain"), + ), + migrations.AlterField( + model_name="notification", + name="notification_type", + field=models.CharField( + choices=[ + ("FAVORITE", "Favorite"), + ("REPLY", "Reply"), + ("MENTION", "Mention"), + ("TAG", "Tag"), + ("FOLLOW", "Follow"), + ("FOLLOW_REQUEST", "Follow Request"), + ("BOOST", "Boost"), + ("IMPORT", "Import"), + ("ADD", "Add"), + ("REPORT", "Report"), + ("LINK_DOMAIN", "Link Domain"), + ("INVITE", "Invite"), + ("ACCEPT", "Accept"), + ("JOIN", "Join"), + ("LEAVE", "Leave"), + ("REMOVE", "Remove"), + ("GROUP_PRIVACY", "Group Privacy"), + ("GROUP_NAME", "Group Name"), + ("GROUP_DESCRIPTION", "Group Description"), + ], + max_length=255, + ), + ), + ] diff --git a/bookwyrm/templates/notifications/items/link_domain.html b/bookwyrm/templates/notifications/items/link_domain.html new file mode 100644 index 000000000..aaed830ed --- /dev/null +++ b/bookwyrm/templates/notifications/items/link_domain.html @@ -0,0 +1,20 @@ +{% extends 'notifications/items/layout.html' %} +{% load humanize %} +{% load i18n %} + +{% block primary_link %}{% spaceless %} +{% url 'settings-link-domain' %} +{% endspaceless %}{% endblock %} + +{% block icon %} + +{% endblock %} + +{% block description %} + {% url 'settings-link-domain' as path %} + {% blocktrans trimmed count counter=notification.related_link_domains.count with display_count=notification.related_link_domains.count|intcomma %} + A new link domain needs review + {% plural %} + {{ display_count }} new link domains need moderation + {% endblocktrans %} +{% endblock %} From 99fc2b7a3660707c8830fcdc54d4c255a2dcee8e Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 25 Feb 2023 15:56:03 -0800 Subject: [PATCH 03/35] Only use chronological pagination sometimes The timeline uses chronological buttons, but other paginated pages do not (by default). This also reversed the chronology. --- bookwyrm/templates/feed/layout.html | 2 +- bookwyrm/templates/snippets/pagination.html | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/bookwyrm/templates/feed/layout.html b/bookwyrm/templates/feed/layout.html index 16a868c2a..b70ed99ea 100644 --- a/bookwyrm/templates/feed/layout.html +++ b/bookwyrm/templates/feed/layout.html @@ -23,7 +23,7 @@ {% block panel %}{% endblock %} {% if activities %} - {% include 'snippets/pagination.html' with page=activities path=path anchor="#feed" %} + {% include 'snippets/pagination.html' with page=activities path=path anchor="#feed" mode="chronological" %} {% endif %} diff --git a/bookwyrm/templates/snippets/pagination.html b/bookwyrm/templates/snippets/pagination.html index 85f966f50..5ab724c06 100644 --- a/bookwyrm/templates/snippets/pagination.html +++ b/bookwyrm/templates/snippets/pagination.html @@ -9,7 +9,11 @@ {% endif %}> - {% trans "Older" %} + {% if mode == "chronological" %} + {% trans "Newer" %} + {% else %} + {% trans "Previous" %} + {% endif %} From d1110630db91c0349a4d90d6e9155f102aa1998c Mon Sep 17 00:00:00 2001 From: Christof Dorner Date: Sun, 26 Feb 2023 11:24:00 +0100 Subject: [PATCH 04/35] Use chronological pagination on user profile activity lists --- bookwyrm/templates/user/reviews_comments.html | 2 +- bookwyrm/templates/user/user.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bookwyrm/templates/user/reviews_comments.html b/bookwyrm/templates/user/reviews_comments.html index f5c5c9265..d85f8f512 100644 --- a/bookwyrm/templates/user/reviews_comments.html +++ b/bookwyrm/templates/user/reviews_comments.html @@ -25,6 +25,6 @@ {% endif %} - {% include 'snippets/pagination.html' with page=activities path=path %} + {% include 'snippets/pagination.html' with page=activities path=path mode="chronological" %} {% endblock %} diff --git a/bookwyrm/templates/user/user.html b/bookwyrm/templates/user/user.html index 42b0ffbb5..0d015760c 100755 --- a/bookwyrm/templates/user/user.html +++ b/bookwyrm/templates/user/user.html @@ -87,7 +87,7 @@ {% trans "Back" %} - + {% endblock %} From 9c92ba169861ebea0948af627f8e2f0686098515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Jaenisch?= Date: Wed, 1 Mar 2023 14:14:42 +0100 Subject: [PATCH 05/35] Add attributes to images to hint async load MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was suggested on Matrix a while ago but I only found the time now to move forward with it. Signed-off-by: André Jaenisch --- bookwyrm/templates/book/book.html | 2 ++ bookwyrm/templates/book/cover_show_modal.html | 2 +- bookwyrm/templates/email/html_layout.html | 2 +- bookwyrm/templates/embed-layout.html | 2 +- bookwyrm/templates/get_started/layout.html | 2 ++ bookwyrm/templates/layout.html | 2 +- bookwyrm/templates/ostatus/template.html | 2 +- bookwyrm/templates/setup/layout.html | 2 ++ bookwyrm/templates/snippets/about.html | 2 +- bookwyrm/templates/snippets/avatar.html | 2 ++ bookwyrm/templates/snippets/book_cover.html | 2 ++ bookwyrm/templates/snippets/status/content_status.html | 2 ++ bookwyrm/templates/two_factor_auth/two_factor_login.html | 2 +- bookwyrm/templates/two_factor_auth/two_factor_prompt.html | 2 +- 14 files changed, 20 insertions(+), 8 deletions(-) diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index d27c7ec54..e9eff99ab 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -82,6 +82,8 @@ src="{% static "images/no_cover.jpg" %}" alt="" aria-hidden="true" + loading="lazy" + decoding="async" > {{ book.alt_text }} diff --git a/bookwyrm/templates/book/cover_show_modal.html b/bookwyrm/templates/book/cover_show_modal.html index f244aa535..7ab4dbf29 100644 --- a/bookwyrm/templates/book/cover_show_modal.html +++ b/bookwyrm/templates/book/cover_show_modal.html @@ -5,7 +5,7 @@ diff --git a/bookwyrm/templates/email/html_layout.html b/bookwyrm/templates/email/html_layout.html index 01e2f35c6..b9f88732f 100644 --- a/bookwyrm/templates/email/html_layout.html +++ b/bookwyrm/templates/email/html_layout.html @@ -2,7 +2,7 @@
- logo + logo
{{ site_name }}
diff --git a/bookwyrm/templates/embed-layout.html b/bookwyrm/templates/embed-layout.html index 6a8d77016..c619bf2dc 100644 --- a/bookwyrm/templates/embed-layout.html +++ b/bookwyrm/templates/embed-layout.html @@ -17,7 +17,7 @@
- + {{ site.name }}
diff --git a/bookwyrm/templates/get_started/layout.html b/bookwyrm/templates/get_started/layout.html index b8e7c861b..4eea59fe7 100644 --- a/bookwyrm/templates/get_started/layout.html +++ b/bookwyrm/templates/get_started/layout.html @@ -15,6 +15,8 @@ src="{% if site.logo_small %}{% get_media_prefix %}{{ site.logo_small }}{% else %}{% static "images/logo-small.png" %}{% endif %}" aria-hidden="true" alt="{{ site.name }}" + loading="lazy" + decoding="async" >

{% blocktrans %}Welcome to {{ site_name }}!{% endblocktrans %} diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index c3408f44e..239137b8a 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -28,7 +28,7 @@ {% with notification_count=request.user.unread_notification_count has_unread_mentions=request.user.has_unread_mentions %}