From 9d52e3cf273e1fa97051b23fbc4508b2fb574005 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sat, 27 Nov 2021 18:32:50 +1100 Subject: [PATCH 01/40] add ostatus subscribe to webfinger links --- bookwyrm/views/wellknown.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bookwyrm/views/wellknown.py b/bookwyrm/views/wellknown.py index 04aa88bf2..c9b1c1299 100644 --- a/bookwyrm/views/wellknown.py +++ b/bookwyrm/views/wellknown.py @@ -30,6 +30,10 @@ def webfinger(request): "rel": "self", "type": "application/activity+json", "href": user.remote_id, + }, + { + "rel": "http://ostatus.org/schema/1.0/subscribe", + "template": f"https://{DOMAIN}/ostatus_subscribe?acct={{uri}}" } ], } From f7c8f121b9c95f0c4ef7e68a358736f1dd209067 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sun, 28 Nov 2021 12:43:29 +1100 Subject: [PATCH 02/40] add remote follow ostatus templates --- bookwyrm/templates/ostatus/ostatus_error.html | 57 ++++++++++ .../templates/ostatus/ostatus_subscribe.html | 48 ++++++++ bookwyrm/templates/ostatus/template.html | 106 ++++++++++++++++++ 3 files changed, 211 insertions(+) create mode 100644 bookwyrm/templates/ostatus/ostatus_error.html create mode 100644 bookwyrm/templates/ostatus/ostatus_subscribe.html create mode 100644 bookwyrm/templates/ostatus/template.html diff --git a/bookwyrm/templates/ostatus/ostatus_error.html b/bookwyrm/templates/ostatus/ostatus_error.html new file mode 100644 index 000000000..5fbc8e945 --- /dev/null +++ b/bookwyrm/templates/ostatus/ostatus_error.html @@ -0,0 +1,57 @@ +{% extends 'ostatus/template.html' %} +{% load i18n %} +{% load utilities %} +{% load markdown %} + +{% block title %} +{% if not request.user.is_authenticated %} +{% trans "Log in to " %} +{% else %} +{% trans "Error following from " %} +{% endif %} +{% endblock %} + +{% block heading %} +{% if not request.user.is_authenticated %} +Let's log in first... +{% else %} +Uh oh... +{% endif %} +{% endblock %} + +{% block content %} +
+ {% if not request.user.is_authenticated %} + + {% elif error == 'ostatus_subscribe' %} +
+

{% blocktrans %}Something went wrong trying to follow {{ account }}{% endblocktrans %}

+

{% trans 'Check you have the correct username before trying again.' %}

+
+ {% endif %} +
+{% endblock %} diff --git a/bookwyrm/templates/ostatus/ostatus_subscribe.html b/bookwyrm/templates/ostatus/ostatus_subscribe.html new file mode 100644 index 000000000..7e929202e --- /dev/null +++ b/bookwyrm/templates/ostatus/ostatus_subscribe.html @@ -0,0 +1,48 @@ +{% extends 'ostatus/template.html' %} +{% load i18n %} +{% load utilities %} +{% load markdown %} + +{% if error or not request.user.is_authenticated %} + {% include 'ostatus/ostatus_error.html' %} +{% else %} + +{% block title %}{% trans "Follow from " %}{% endblock %} + +{% block heading %}Follow from {{ site.name }}{% endblock %} + +{% block content %} +
+
+ +
+ {% if user.summary %} + {{ user.summary|to_markdown|safe|truncatechars_html:120 }} + {% else %} {% endif %} +
+
+
+{% endblock %} + +{% endif %} diff --git a/bookwyrm/templates/ostatus/template.html b/bookwyrm/templates/ostatus/template.html new file mode 100644 index 000000000..2e8ee7b3c --- /dev/null +++ b/bookwyrm/templates/ostatus/template.html @@ -0,0 +1,106 @@ +{% load layout %} +{% load i18n %} +{% load static %} +{% load utilities %} +{% load markdown %} + + + + + {% block title %}{% endblock %}{{ site.name }} + + + + + + + + + + {% if preview_images_enabled is True %} + + {% else %} + + {% endif %} + + + + + + {% block opengraph_images %} + {% include 'snippets/opengraph_images.html' %} + {% endblock %} + + + + + + + +
+
+ {% block content%}{% endblock %} +
+
+ + + + + + + + + + + +{% block scripts %}{% endblock %} + + From d05e100421eaf53946e6cd420b2d32f45b35ab2f Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sun, 28 Nov 2021 13:28:58 +1100 Subject: [PATCH 03/40] update ostatus templates --- bookwyrm/templates/ostatus/ostatus_error.html | 19 ------------- .../templates/ostatus/ostatus_subscribe.html | 28 ++++++++++++++----- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/bookwyrm/templates/ostatus/ostatus_error.html b/bookwyrm/templates/ostatus/ostatus_error.html index 5fbc8e945..de2ba988b 100644 --- a/bookwyrm/templates/ostatus/ostatus_error.html +++ b/bookwyrm/templates/ostatus/ostatus_error.html @@ -1,23 +1,4 @@ -{% extends 'ostatus/template.html' %} {% load i18n %} -{% load utilities %} -{% load markdown %} - -{% block title %} -{% if not request.user.is_authenticated %} -{% trans "Log in to " %} -{% else %} -{% trans "Error following from " %} -{% endif %} -{% endblock %} - -{% block heading %} -{% if not request.user.is_authenticated %} -Let's log in first... -{% else %} -Uh oh... -{% endif %} -{% endblock %} {% block content %}
diff --git a/bookwyrm/templates/ostatus/ostatus_subscribe.html b/bookwyrm/templates/ostatus/ostatus_subscribe.html index 7e929202e..9d87d8ef8 100644 --- a/bookwyrm/templates/ostatus/ostatus_subscribe.html +++ b/bookwyrm/templates/ostatus/ostatus_subscribe.html @@ -3,15 +3,30 @@ {% load utilities %} {% load markdown %} -{% if error or not request.user.is_authenticated %} - {% include 'ostatus/ostatus_error.html' %} +{% block title %} +{% if not request.user.is_authenticated %} +{% trans "Log in to " %} +{% elif error %} +{% trans "Error following from " %} {% else %} +{% trans "Follow from " %} +{% endif %} +{% endblock %} -{% block title %}{% trans "Follow from " %}{% endblock %} - -{% block heading %}Follow from {{ site.name }}{% endblock %} +{% block heading %} +{% if not request.user.is_authenticated %} +{% trans "Let's log in first..." %} +{% elif error %} +{% trans 'Uh oh...' %} +{% else %} +{% blocktrans %}Follow from {{ site.name }}{% endblocktrans %} +{% endif %} +{% endblock %} {% block content %} +{% if error or not request.user.is_authenticated %} + {% include 'ostatus/ostatus_error.html' with error=error user=user account=account %} +{% else %}
@@ -43,6 +58,5 @@
-{% endblock %} - {% endif %} +{% endblock %} From 610114b4ebfcd27cde9f76244d559c226e4d78b5 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sun, 28 Nov 2021 16:54:25 +1100 Subject: [PATCH 04/40] rearrange ostatus templates --- .../{ostatus_error.html => error.html} | 14 +++++++- ...{ostatus_subscribe.html => subscribe.html} | 7 ++-- bookwyrm/templates/ostatus/success.html | 32 +++++++++++++++++++ 3 files changed, 49 insertions(+), 4 deletions(-) rename bookwyrm/templates/ostatus/{ostatus_error.html => error.html} (71%) rename bookwyrm/templates/ostatus/{ostatus_subscribe.html => subscribe.html} (86%) create mode 100644 bookwyrm/templates/ostatus/success.html diff --git a/bookwyrm/templates/ostatus/ostatus_error.html b/bookwyrm/templates/ostatus/error.html similarity index 71% rename from bookwyrm/templates/ostatus/ostatus_error.html rename to bookwyrm/templates/ostatus/error.html index de2ba988b..b6e858e24 100644 --- a/bookwyrm/templates/ostatus/ostatus_error.html +++ b/bookwyrm/templates/ostatus/error.html @@ -29,10 +29,22 @@
{% elif error == 'ostatus_subscribe' %} -
+

{% blocktrans %}Something went wrong trying to follow {{ account }}{% endblocktrans %}

{% trans 'Check you have the correct username before trying again.' %}

+ {% elif error == 'is_blocked' %} +
+

{% blocktrans %}You have blocked {{ account }}{% endblocktrans %}

+
+ {% elif error == 'already_following' %} +
+

{% blocktrans %}You are already following {{ account }}{% endblocktrans %}

+
+ {% elif error == 'already_requested' %} +
+

{% blocktrans %}You have already requested to follow {{ account }}{% endblocktrans %}

+
{% endif %}
{% endblock %} diff --git a/bookwyrm/templates/ostatus/ostatus_subscribe.html b/bookwyrm/templates/ostatus/subscribe.html similarity index 86% rename from bookwyrm/templates/ostatus/ostatus_subscribe.html rename to bookwyrm/templates/ostatus/subscribe.html index 9d87d8ef8..e64be6029 100644 --- a/bookwyrm/templates/ostatus/ostatus_subscribe.html +++ b/bookwyrm/templates/ostatus/subscribe.html @@ -25,7 +25,7 @@ {% block content %} {% if error or not request.user.is_authenticated %} - {% include 'ostatus/ostatus_error.html' with error=error user=user account=account %} + {% include 'ostatus/error.html' with error=error user=user account=account %} {% else %}
@@ -45,13 +45,14 @@ @{{ user|username }} -
+ {% csrf_token %} +
-
+
{% if user.summary %} {{ user.summary|to_markdown|safe|truncatechars_html:120 }} {% else %} {% endif %} diff --git a/bookwyrm/templates/ostatus/success.html b/bookwyrm/templates/ostatus/success.html new file mode 100644 index 000000000..10b4409f3 --- /dev/null +++ b/bookwyrm/templates/ostatus/success.html @@ -0,0 +1,32 @@ +{% extends 'ostatus/template.html' %} +{% load i18n %} +{% load utilities %} + +{% block content %} + +{% endblock %} From e275b98183cdaed4e33d3e11e51307aa63187def Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sun, 28 Nov 2021 16:56:21 +1100 Subject: [PATCH 05/40] ostatus remote follow views --- bookwyrm/urls.py | 3 ++ bookwyrm/views/__init__.py | 2 +- bookwyrm/views/follow.py | 82 +++++++++++++++++++++++++++++++++++++- 3 files changed, 85 insertions(+), 2 deletions(-) diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 514bb7e60..79e6e2a98 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -44,6 +44,7 @@ urlpatterns = [ re_path(r"^api/v1/instance/?$", views.instance_info), re_path(r"^api/v1/instance/peers/?$", views.peers), re_path(r"^opensearch.xml$", views.opensearch, name="opensearch"), + re_path(r"^ostatus_subscribe/?$", views.ostatus_follow_request), # polling updates re_path("^api/updates/notifications/?$", views.get_notification_count), re_path("^api/updates/stream/(?P[a-z]+)/?$", views.get_unread_status_count), @@ -450,4 +451,6 @@ urlpatterns = [ re_path(r"^unfollow/?$", views.unfollow, name="unfollow"), re_path(r"^accept-follow-request/?$", views.accept_follow_request), re_path(r"^delete-follow-request/?$", views.delete_follow_request), + # re_path(r"^ostatus_follow/?$", views.remote_follow), + re_path(r"^ostatus_success/?$", views.ostatus_follow_success, name="ostatus-success"), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/bookwyrm/views/__init__.py b/bookwyrm/views/__init__.py index d79de4248..034b1830a 100644 --- a/bookwyrm/views/__init__.py +++ b/bookwyrm/views/__init__.py @@ -58,7 +58,7 @@ from .author import Author, EditAuthor from .directory import Directory from .discover import Discover from .feed import DirectMessage, Feed, Replies, Status -from .follow import follow, unfollow +from .follow import follow, unfollow, ostatus_follow_request, ostatus_follow_success from .follow import accept_follow_request, delete_follow_request from .get_started import GetStartedBooks, GetStartedProfile, GetStartedUsers from .goal import Goal, hide_goal diff --git a/bookwyrm/views/follow.py b/bookwyrm/views/follow.py index 7d91ce5b4..471fe3079 100644 --- a/bookwyrm/views/follow.py +++ b/bookwyrm/views/follow.py @@ -1,11 +1,14 @@ """ views for actions you can take in the application """ +import urllib.parse +import re from django.contrib.auth.decorators import login_required from django.db import IntegrityError from django.shortcuts import get_object_or_404, redirect +from django.template.response import TemplateResponse from django.views.decorators.http import require_POST from bookwyrm import models -from .helpers import get_user_from_username +from .helpers import get_user_from_username, handle_remote_webfinger @login_required @@ -23,9 +26,13 @@ def follow(request): except IntegrityError: pass + if request.GET.get("next"): + return redirect(request.GET.get("next", "/")) + return redirect(to_follow.local_path) + @login_required @require_POST def unfollow(request): @@ -84,3 +91,76 @@ def delete_follow_request(request): follow_request.delete() return redirect(f"/user/{request.user.localname}") + +def ostatus_follow_request(request): + """prepare an outgoing remote follow request""" + + # parse the acct URI into a user string + uri = urllib.parse.unquote(request.GET.get("acct")) + username_parts = re.search("(?:^http(?:s?):\/\/)([\w\-\.]*)(?:.)*(?:(?:\/)([\w]*))", uri) + account = f"{username_parts[2]}@{username_parts[1]}" + user = handle_remote_webfinger(account) + error = None + + if user is None or user == "": + error = "ostatus_subscribe" + + if bool(user) and user in request.user.blocks.all(): + error = "is_blocked" + + if hasattr(user, "followers") and request.user in user.followers.all(): + error = "already_following" + + if hasattr(user, "follower_requests") and request.user in user.follower_requests.all(): + error = "already_requested" + + data = { + "account": account, + "user": user, + "error": error + } + + return TemplateResponse(request, "ostatus/subscribe.html", data) + + +@login_required +def ostatus_follow_success(request): + """display success message for remote follow""" + user = get_user_from_username(request.user, request.GET.get("following")) + data = { + "account": user.name, + "user": user, + "error": None + } + return TemplateResponse(request, "ostatus/success.html", data) + +@login_required +@require_POST +def remote_follow(request): + """complete an incoming remote follow request""" + + # this is triggered from remote follow form + # attempt the follow request + # on success [[return success page]] + # on fail return [[ostatus_error]] + + +""" +REQUEST TO FOLLOW FROM REMOTE ACCOUNT +1. click remote follow button [default checked option to open new window] +2. popup new small window +3. enter user acct to follow from (user@domain.tld) and submit form +5. GET {base_url}/.well-known/webfinger/?resource=acct:{user@domain.tld} +6. parse json for links +6.1 rel="http://ostatus.org/schema/1.0/subscribe" and return 'template' +6.2 rel="self" and return href +7. replace '{uri}' in the returned string with self.href +8. GET the URI at 6.1 + +REQUEST TO FOLLOW FROM LOCAL ACCOUNT +1. receive request to /ostatus_subscribe?acct={uri} +2. check user is logged in and present confirmation screen (remote_follow_request) +3. On confirmation, 3. parse user into info needed for a normal follow +4. send follow request, on 200 response display success else display error (remote_follow) +5. Include button inviting to close window +""" From 2e428e6ea1687c15c87856f682a572cdff098e9c Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sun, 28 Nov 2021 20:08:54 +1100 Subject: [PATCH 06/40] add remote follow templates --- bookwyrm/templates/ostatus/remote_follow.html | 43 +++++++++++++++++++ .../ostatus/remote_follow_button.html | 16 +++++++ 2 files changed, 59 insertions(+) create mode 100644 bookwyrm/templates/ostatus/remote_follow.html create mode 100644 bookwyrm/templates/ostatus/remote_follow_button.html diff --git a/bookwyrm/templates/ostatus/remote_follow.html b/bookwyrm/templates/ostatus/remote_follow.html new file mode 100644 index 000000000..ea8881e42 --- /dev/null +++ b/bookwyrm/templates/ostatus/remote_follow.html @@ -0,0 +1,43 @@ +{% extends 'ostatus/template.html' %} +{% load i18n %} +{% load utilities %} + +{% block content %} +
+
+

{% blocktrans %}Follow {{ user.display_name }} on the fediverse{% endblocktrans %}

+
+ +
+
+
+
+ {% csrf_token %} + + + +
+
+
+
+{% endblock %} diff --git a/bookwyrm/templates/ostatus/remote_follow_button.html b/bookwyrm/templates/ostatus/remote_follow_button.html new file mode 100644 index 000000000..4789d3064 --- /dev/null +++ b/bookwyrm/templates/ostatus/remote_follow_button.html @@ -0,0 +1,16 @@ +{% load i18n %} +{% if request.user == user %} +{% else %} + +
+
+
+ {% csrf_token %} + + +
+
+
+{% endif %} From 6e7d23c1aec60317e7989aaf5cafa08112d49cc0 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sun, 28 Nov 2021 20:09:29 +1100 Subject: [PATCH 07/40] add remote follow button --- bookwyrm/templates/user/layout.html | 3 +++ bookwyrm/urls.py | 3 ++- bookwyrm/views/__init__.py | 2 +- bookwyrm/views/follow.py | 34 +++++++++++++++-------------- bookwyrm/views/helpers.py | 27 +++++++++++++++++++++++ 5 files changed, 51 insertions(+), 18 deletions(-) diff --git a/bookwyrm/templates/user/layout.html b/bookwyrm/templates/user/layout.html index d7557ae7b..03e3dfce8 100755 --- a/bookwyrm/templates/user/layout.html +++ b/bookwyrm/templates/user/layout.html @@ -39,6 +39,9 @@ {% if not is_self and request.user.is_authenticated %} {% include 'snippets/follow_button.html' with user=user %} {% endif %} + {% if not is_self %} + {% include 'ostatus/remote_follow_button.html' with user=user %} + {% endif %} {% if is_self and user.follower_requests.all %}
diff --git a/bookwyrm/templates/ostatus/template.html b/bookwyrm/templates/ostatus/template.html index 2e8ee7b3c..cb922f9bd 100644 --- a/bookwyrm/templates/ostatus/template.html +++ b/bookwyrm/templates/ostatus/template.html @@ -92,7 +92,6 @@ - diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 48fe0f6cc..45837ec13 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -453,5 +453,7 @@ urlpatterns = [ re_path(r"^delete-follow-request/?$", views.delete_follow_request), re_path(r"^ostatus_follow/?$", views.remote_follow, name="remote-follow"), re_path(r"^remote_follow/?$", views.remote_follow_page, name="remote-follow-page"), - re_path(r"^ostatus_success/?$", views.ostatus_follow_success, name="ostatus-success"), + re_path( + r"^ostatus_success/?$", views.ostatus_follow_success, name="ostatus-success" + ), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/bookwyrm/views/__init__.py b/bookwyrm/views/__init__.py index 3b5bf8232..4a92578c2 100644 --- a/bookwyrm/views/__init__.py +++ b/bookwyrm/views/__init__.py @@ -58,7 +58,14 @@ from .author import Author, EditAuthor from .directory import Directory from .discover import Discover from .feed import DirectMessage, Feed, Replies, Status -from .follow import follow, unfollow, ostatus_follow_request, ostatus_follow_success, remote_follow, remote_follow_page +from .follow import ( + follow, + unfollow, + ostatus_follow_request, + ostatus_follow_success, + remote_follow, + remote_follow_page, +) from .follow import accept_follow_request, delete_follow_request from .get_started import GetStartedBooks, GetStartedProfile, GetStartedUsers from .goal import Goal, hide_goal diff --git a/bookwyrm/views/follow.py b/bookwyrm/views/follow.py index 2ebe0ce04..58d979854 100644 --- a/bookwyrm/views/follow.py +++ b/bookwyrm/views/follow.py @@ -8,7 +8,11 @@ from django.template.response import TemplateResponse from django.views.decorators.http import require_POST from bookwyrm import models -from .helpers import get_user_from_username, handle_remote_webfinger, subscribe_remote_webfinger +from .helpers import ( + get_user_from_username, + handle_remote_webfinger, + subscribe_remote_webfinger, +) @login_required @@ -32,7 +36,6 @@ def follow(request): return redirect(to_follow.local_path) - @login_required @require_POST def unfollow(request): @@ -92,12 +95,15 @@ def delete_follow_request(request): follow_request.delete() return redirect(f"/user/{request.user.localname}") + def ostatus_follow_request(request): """prepare an outgoing remote follow request""" # parse the acct URI into a user string uri = urllib.parse.unquote(request.GET.get("acct")) - username_parts = re.search("(?:^http(?:s?):\/\/)([\w\-\.]*)(?:.)*(?:(?:\/)([\w]*))", uri) + username_parts = re.search( + "(?:^http(?:s?):\/\/)([\w\-\.]*)(?:.)*(?:(?:\/)([\w]*))", uri + ) account = f"{username_parts[2]}@{username_parts[1]}" user = handle_remote_webfinger(account) error = None @@ -111,14 +117,13 @@ def ostatus_follow_request(request): if hasattr(user, "followers") and request.user in user.followers.all(): error = "already_following" - if hasattr(user, "follower_requests") and request.user in user.follower_requests.all(): + if ( + hasattr(user, "follower_requests") + and request.user in user.follower_requests.all() + ): error = "already_requested" - data = { - "account": account, - "user": user, - "error": error - } + data = {"account": account, "user": user, "error": error} return TemplateResponse(request, "ostatus/subscribe.html", data) @@ -127,21 +132,17 @@ def ostatus_follow_request(request): def ostatus_follow_success(request): """display success message for remote follow""" user = get_user_from_username(request.user, request.GET.get("following")) - data = { - "account": user.name, - "user": user, - "error": None - } + data = {"account": user.name, "user": user, "error": None} return TemplateResponse(request, "ostatus/success.html", data) + def remote_follow_page(request): """Display remote follow page""" user = get_user_from_username(request.user, request.GET.get("user")) - data = { - "user": user - } + data = {"user": user} return TemplateResponse(request, "ostatus/remote_follow.html", data) + @require_POST def remote_follow(request): """direct user to follow from remote account using ostatus subscribe protocol""" diff --git a/bookwyrm/views/helpers.py b/bookwyrm/views/helpers.py index 607181489..650087ec0 100644 --- a/bookwyrm/views/helpers.py +++ b/bookwyrm/views/helpers.py @@ -84,6 +84,7 @@ def handle_remote_webfinger(query): return None return user + def subscribe_remote_webfinger(query): """get subscribe template from other servers""" template = None @@ -112,6 +113,7 @@ def subscribe_remote_webfinger(query): return template + def get_edition(book_id): """look up a book in the db and return an edition""" book = models.Book.objects.select_subclasses().get(id=book_id) diff --git a/bookwyrm/views/wellknown.py b/bookwyrm/views/wellknown.py index c9b1c1299..03e619dfd 100644 --- a/bookwyrm/views/wellknown.py +++ b/bookwyrm/views/wellknown.py @@ -32,9 +32,9 @@ def webfinger(request): "href": user.remote_id, }, { - "rel": "http://ostatus.org/schema/1.0/subscribe", - "template": f"https://{DOMAIN}/ostatus_subscribe?acct={{uri}}" - } + "rel": "http://ostatus.org/schema/1.0/subscribe", + "template": f"https://{DOMAIN}/ostatus_subscribe?acct={{uri}}", + }, ], } ) From 6abf5d69107c4440e1809e34458e169e823d7e92 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sun, 28 Nov 2021 21:48:03 +1100 Subject: [PATCH 10/40] add submit button to remote follow form --- bookwyrm/templates/ostatus/remote_follow.html | 1 + 1 file changed, 1 insertion(+) diff --git a/bookwyrm/templates/ostatus/remote_follow.html b/bookwyrm/templates/ostatus/remote_follow.html index ea8881e42..3ff769432 100644 --- a/bookwyrm/templates/ostatus/remote_follow.html +++ b/bookwyrm/templates/ostatus/remote_follow.html @@ -36,6 +36,7 @@ + From feaf0d5e52ec8d2887b2d14e3bcd3bfc49446cf4 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Mon, 29 Nov 2021 07:11:57 +1100 Subject: [PATCH 11/40] handle username errors in remote follow form --- bookwyrm/templates/ostatus/error.html | 5 +++++ bookwyrm/views/follow.py | 3 +++ 2 files changed, 8 insertions(+) diff --git a/bookwyrm/templates/ostatus/error.html b/bookwyrm/templates/ostatus/error.html index b6e858e24..cb1aec408 100644 --- a/bookwyrm/templates/ostatus/error.html +++ b/bookwyrm/templates/ostatus/error.html @@ -33,6 +33,11 @@

{% blocktrans %}Something went wrong trying to follow {{ account }}{% endblocktrans %}

{% trans 'Check you have the correct username before trying again.' %}

+ {% elif error == 'remote_subscribe' %} +
+

{% blocktrans %}Something went wrong trying to follow from {{ account }}{% endblocktrans %}

+

{% trans 'Check you have the correct username before trying again.' %}

+
{% elif error == 'is_blocked' %}

{% blocktrans %}You have blocked {{ account }}{% endblocktrans %}

diff --git a/bookwyrm/views/follow.py b/bookwyrm/views/follow.py index 58d979854..fcab5d6ac 100644 --- a/bookwyrm/views/follow.py +++ b/bookwyrm/views/follow.py @@ -148,5 +148,8 @@ def remote_follow(request): """direct user to follow from remote account using ostatus subscribe protocol""" remote_user = request.POST.get("remote_user") template = subscribe_remote_webfinger(remote_user) + if template is None: + data = {"account": remote_user, "user": None, "error": "remote_subscribe"} + return TemplateResponse(request, "ostatus/subscribe.html", data) url = template.replace("{uri}", request.POST.get("user")) return redirect(url) From 46f32944315b9add4f04776668bbf7c2117efc12 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Mon, 29 Nov 2021 07:56:09 +1100 Subject: [PATCH 12/40] fix remote follow template --- bookwyrm/templates/ostatus/remote_follow.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/templates/ostatus/remote_follow.html b/bookwyrm/templates/ostatus/remote_follow.html index 3ff769432..98442547e 100644 --- a/bookwyrm/templates/ostatus/remote_follow.html +++ b/bookwyrm/templates/ostatus/remote_follow.html @@ -24,7 +24,7 @@ @{{ user|username }} -

Follow {{ user.name }} from another Fediverse account like Bookwyrm, Mastodon, or Pleroma.

+

Follow {{ user.display_name }} from another Fediverse account like Bookwyrm, Mastodon, or Pleroma.

From c7242b6022c9e70725e9445255fe766ecedee2ed Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Mon, 29 Nov 2021 07:56:31 +1100 Subject: [PATCH 13/40] add popup warning --- bookwyrm/templates/ostatus/remote_follow_button.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bookwyrm/templates/ostatus/remote_follow_button.html b/bookwyrm/templates/ostatus/remote_follow_button.html index 2848fde0e..fc869229a 100644 --- a/bookwyrm/templates/ostatus/remote_follow_button.html +++ b/bookwyrm/templates/ostatus/remote_follow_button.html @@ -4,9 +4,12 @@ {% endif %} From 4a9713b812d65d2bc2f9ef4ecbc1eeec8f6a617f Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Mon, 29 Nov 2021 08:03:01 +1100 Subject: [PATCH 14/40] fix template for remote follower error --- bookwyrm/templates/ostatus/error.html | 2 +- bookwyrm/templates/ostatus/subscribe.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/ostatus/error.html b/bookwyrm/templates/ostatus/error.html index cb1aec408..442c35b9e 100644 --- a/bookwyrm/templates/ostatus/error.html +++ b/bookwyrm/templates/ostatus/error.html @@ -2,7 +2,7 @@ {% block content %}
- {% if not request.user.is_authenticated %} + {% if not request.user.is_authenticated and not error == 'remote_subscribe' %}
diff --git a/bookwyrm/templates/ostatus/success.html b/bookwyrm/templates/ostatus/success.html index 10b4409f3..d8c311829 100644 --- a/bookwyrm/templates/ostatus/success.html +++ b/bookwyrm/templates/ostatus/success.html @@ -22,11 +22,14 @@ @{{ user|username }} - - - {% include 'snippets/avatar.html' with user=user large=True %} - +

+ + {% trans 'You are now following ' %}{{ user.display_name }}! +

+ {% endblock %} From 3d73ea92e85b84bfc4f7e2fc5a8fab5179767e00 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Mon, 29 Nov 2021 18:08:25 +1100 Subject: [PATCH 17/40] handle user blocks properly --- bookwyrm/templates/ostatus/error.html | 4 +++ bookwyrm/views/follow.py | 36 +++++++++++++++++++-------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/bookwyrm/templates/ostatus/error.html b/bookwyrm/templates/ostatus/error.html index 91bb6a0a4..8a047172f 100644 --- a/bookwyrm/templates/ostatus/error.html +++ b/bookwyrm/templates/ostatus/error.html @@ -42,6 +42,10 @@

{% blocktrans %}You have blocked {{ account }}{% endblocktrans %}

+ {% elif error == 'has_blocked' %} +
+

{% blocktrans %}{{ account }} has blocked you{% endblocktrans %}

+
{% elif error == 'already_following' %}

{% blocktrans %}You are already following {{ account }}{% endblocktrans %}

diff --git a/bookwyrm/views/follow.py b/bookwyrm/views/follow.py index 1555fc5e4..83b900354 100644 --- a/bookwyrm/views/follow.py +++ b/bookwyrm/views/follow.py @@ -109,17 +109,33 @@ def ostatus_follow_request(request): if user is None or user == "": error = "ostatus_subscribe" - if hasattr(request.user, "blocks") and user in request.user.blocks.all(): - error = "is_blocked" + # don't do these checks for AnonymousUser before they sign in + if request.user.id: - if hasattr(user, "followers") and request.user in user.followers.all(): - error = "already_following" - - if ( - hasattr(user, "follower_requests") - and request.user in user.follower_requests.all() - ): - error = "already_requested" + # you have blocked them so you probably don't want to follow + if ( + hasattr(request.user, "blocks") + and user in request.user.blocks.all() + ): + error = "is_blocked" + # they have blocked you + if ( + hasattr(user, "blocks") + and request.user in user.blocks.all() + ): + error = "has_blocked" + # you're already following them + if ( + hasattr(user, "followers") + and request.user in user.followers.all() + ): + error = "already_following" + # you're not following yet but you already asked + if ( + hasattr(user, "follower_requests") + and request.user in user.follower_requests.all() + ): + error = "already_requested" data = {"account": account, "user": user, "error": error} From f5d9a204ebfd0045a04046200feaeaa3b21d68d8 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Mon, 29 Nov 2021 19:37:56 +1100 Subject: [PATCH 18/40] clean up ostatus templates --- bookwyrm/templates/ostatus/error.html | 46 +++--- bookwyrm/templates/ostatus/remote_follow.html | 67 +++++---- bookwyrm/templates/ostatus/success.html | 46 +++--- bookwyrm/templates/ostatus/template.html | 133 +++++++++--------- 4 files changed, 145 insertions(+), 147 deletions(-) diff --git a/bookwyrm/templates/ostatus/error.html b/bookwyrm/templates/ostatus/error.html index 8a047172f..085fa3454 100644 --- a/bookwyrm/templates/ostatus/error.html +++ b/bookwyrm/templates/ostatus/error.html @@ -4,30 +4,28 @@
{% if not request.user.is_authenticated and not error == 'remote_subscribe' %} +
+
+
+ {% csrf_token %} +
+
+ + +
+
+ + +

{% trans "Forgot your password?" %}

+
+
+ +
+
+
+
+
+
{% elif error == 'ostatus_subscribe' %}

{% blocktrans %}Something went wrong trying to follow {{ account }}{% endblocktrans %}

diff --git a/bookwyrm/templates/ostatus/remote_follow.html b/bookwyrm/templates/ostatus/remote_follow.html index ef8f1b90f..6a4e565ac 100644 --- a/bookwyrm/templates/ostatus/remote_follow.html +++ b/bookwyrm/templates/ostatus/remote_follow.html @@ -4,41 +4,40 @@ {% block content %}
-
-

{% blocktrans %}Follow {{ user.display_name }} on the fediverse{% endblocktrans %}

-
-
-
- - {% include 'snippets/avatar.html' with user=user large=True %} - -
- - - {{ user.display_name }} - {% if user.manually_approves_followers %} - - {% trans "Locked account" %} - - {% endif %} - - @{{ user|username }} - -

{% blocktrans %}Follow {{ user.display_name }} from another Fediverse account like Bookwyrm, Mastodon, or Pleroma.{% endblocktrans %}

-
-
+
+

{% blocktrans %}Follow {{ user.display_name }} on the fediverse{% endblocktrans %}

+
+
+
+ + {% include 'snippets/avatar.html' with user=user large=True %} + +
+ + + {{ user.display_name }} + {% if user.manually_approves_followers %} + + {% trans "Locked account" %} + + {% endif %} + + @{{ user|username }} + +

{% blocktrans %}Follow {{ user.display_name }} from another Fediverse account like Bookwyrm, Mastodon, or Pleroma.{% endblocktrans %}

+
+
-
-
-
- {% csrf_token %} - - - - -
-
-
+
+
+
+ {% csrf_token %} + + + + +
+
{% endblock %} diff --git a/bookwyrm/templates/ostatus/success.html b/bookwyrm/templates/ostatus/success.html index d8c311829..89f662735 100644 --- a/bookwyrm/templates/ostatus/success.html +++ b/bookwyrm/templates/ostatus/success.html @@ -4,29 +4,29 @@ {% block content %}
-
diff --git a/bookwyrm/templates/ostatus/template.html b/bookwyrm/templates/ostatus/template.html index cb922f9bd..1dbb32a36 100644 --- a/bookwyrm/templates/ostatus/template.html +++ b/bookwyrm/templates/ostatus/template.html @@ -7,45 +7,46 @@ - {% block title %}{% endblock %}{{ site.name }} - - - - + {% block title %}{% endblock %}{{ site.name }} + + + + - + - + - {% if preview_images_enabled is True %} - - {% else %} - - {% endif %} - - - - + {% if preview_images_enabled is True %} + + {% else %} + + {% endif %} + + + + - {% block opengraph_images %} - {% include 'snippets/opengraph_images.html' %} - {% endblock %} - - + {% block opengraph_images %} + {% include 'snippets/opengraph_images.html' %} + {% endblock %} + + @@ -57,43 +58,43 @@ From 9a3ec4362b85ce7920632ff6a74ee44f4b99d9ff Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Mon, 29 Nov 2021 19:45:52 +1100 Subject: [PATCH 19/40] code cleanup --- bookwyrm/static/js/bookwyrm.js | 13 ++++++------- bookwyrm/views/follow.py | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/bookwyrm/static/js/bookwyrm.js b/bookwyrm/static/js/bookwyrm.js index 86a021af8..ebac78a91 100644 --- a/bookwyrm/static/js/bookwyrm.js +++ b/bookwyrm/static/js/bookwyrm.js @@ -376,12 +376,11 @@ let BookWyrm = new class { * @param {string} windowName windowName * @return {undefined} */ - displayPopUp(url, windowName){ - - window.open( - url, - windowName, - "left=100,top=100,width=430,height=600" - ) + displayPopUp(url, windowName) { + window.open( + url, + windowName, + "left=100,top=100,width=430,height=600" + ); } }(); diff --git a/bookwyrm/views/follow.py b/bookwyrm/views/follow.py index 83b900354..11bff60a3 100644 --- a/bookwyrm/views/follow.py +++ b/bookwyrm/views/follow.py @@ -100,7 +100,7 @@ def ostatus_follow_request(request): """prepare an outgoing remote follow request""" uri = urllib.parse.unquote(request.GET.get("acct")) username_parts = re.search( - "(?:^http(?:s?):\/\/)([\w\-\.]*)(?:.)*(?:(?:\/)([\w]*))", uri + r"(?:^http(?:s?):\/\/)([\w\-\.]*)(?:.)*(?:(?:\/)([\w]*))", uri ) account = f"{username_parts[2]}@{username_parts[1]}" user = handle_remote_webfinger(account) From 1211fda7ff82a2eca793981cb5fbddda4643af5b Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Mon, 29 Nov 2021 19:53:13 +1100 Subject: [PATCH 20/40] beautiful code quality, pylint will be pleased --- bookwyrm/templates/ostatus/template.html | 2 +- bookwyrm/views/follow.py | 19 ++++--------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/bookwyrm/templates/ostatus/template.html b/bookwyrm/templates/ostatus/template.html index 1dbb32a36..7d670b0a5 100644 --- a/bookwyrm/templates/ostatus/template.html +++ b/bookwyrm/templates/ostatus/template.html @@ -33,7 +33,7 @@ diff --git a/bookwyrm/views/follow.py b/bookwyrm/views/follow.py index 11bff60a3..7af8b0db7 100644 --- a/bookwyrm/views/follow.py +++ b/bookwyrm/views/follow.py @@ -113,22 +113,13 @@ def ostatus_follow_request(request): if request.user.id: # you have blocked them so you probably don't want to follow - if ( - hasattr(request.user, "blocks") - and user in request.user.blocks.all() - ): + if hasattr(request.user, "blocks") and user in request.user.blocks.all(): error = "is_blocked" # they have blocked you - if ( - hasattr(user, "blocks") - and request.user in user.blocks.all() - ): + if hasattr(user, "blocks") and request.user in user.blocks.all(): error = "has_blocked" # you're already following them - if ( - hasattr(user, "followers") - and request.user in user.followers.all() - ): + if hasattr(user, "followers") and request.user in user.followers.all(): error = "already_following" # you're not following yet but you already asked if ( @@ -165,8 +156,6 @@ def remote_follow(request): if template is None: data = {"account": remote_user, "user": None, "error": "remote_subscribe"} return TemplateResponse(request, "ostatus/subscribe.html", data) - user = get_object_or_404( - models.User, id=request.POST.get("user") - ) + user = get_object_or_404(models.User, id=request.POST.get("user")) url = template.replace("{uri}", urllib.parse.quote(user.remote_id)) return redirect(url) From 1d90ca6fa62362e840ca2ba9fd0306b0ea8a2752 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Mon, 29 Nov 2021 20:35:26 +1100 Subject: [PATCH 21/40] keep footer DRY Pulls footer and scripts after it into a separate component template. This allows ostatus/template to use the footer without having to use layout without repeating the same code. --- bookwyrm/templates/components/footer.html | 49 +++++++++++++++++++++++ bookwyrm/templates/layout.html | 45 +-------------------- bookwyrm/templates/ostatus/template.html | 48 +--------------------- 3 files changed, 51 insertions(+), 91 deletions(-) create mode 100644 bookwyrm/templates/components/footer.html diff --git a/bookwyrm/templates/components/footer.html b/bookwyrm/templates/components/footer.html new file mode 100644 index 000000000..047d7bfad --- /dev/null +++ b/bookwyrm/templates/components/footer.html @@ -0,0 +1,49 @@ +{% load layout %} +{% load i18n %} +{% load static %} + + + + + + + + + +{% block scripts %}{% endblock %} diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index f2d04f961..50a7ae6d1 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -222,50 +222,7 @@
- +{% include 'components/footer.html' %} - - - - - - -{% block scripts %}{% endblock %} diff --git a/bookwyrm/templates/ostatus/template.html b/bookwyrm/templates/ostatus/template.html index 7d670b0a5..04e432aaa 100644 --- a/bookwyrm/templates/ostatus/template.html +++ b/bookwyrm/templates/ostatus/template.html @@ -48,59 +48,13 @@
- -
{% block content%}{% endblock %}
- - +{% include 'components/footer.html' %} - - - - - - -{% block scripts %}{% endblock %} From 1636dfd308ca8eb8827a6aa8f6be9587bc902656 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Mon, 29 Nov 2021 20:42:16 +1100 Subject: [PATCH 22/40] fix footer indentation --- bookwyrm/templates/components/footer.html | 68 +++++++++++------------ 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/bookwyrm/templates/components/footer.html b/bookwyrm/templates/components/footer.html index 047d7bfad..df11e9d55 100644 --- a/bookwyrm/templates/components/footer.html +++ b/bookwyrm/templates/components/footer.html @@ -3,43 +3,43 @@ {% load static %} From 386371baa3ee85e54c1f918c41297dc3c0681120 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Tue, 30 Nov 2021 12:42:52 +1100 Subject: [PATCH 23/40] improve a11y on notifications Also change close link to a button. Co-authored-by: Joachim --- bookwyrm/templates/ostatus/error.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bookwyrm/templates/ostatus/error.html b/bookwyrm/templates/ostatus/error.html index 085fa3454..99a2a9acb 100644 --- a/bookwyrm/templates/ostatus/error.html +++ b/bookwyrm/templates/ostatus/error.html @@ -27,34 +27,34 @@
{% elif error == 'ostatus_subscribe' %} -
+

{% blocktrans %}Something went wrong trying to follow {{ account }}{% endblocktrans %}

{% trans 'Check you have the correct username before trying again.' %}

{% elif error == 'remote_subscribe' %} -
+

{% blocktrans %}Something went wrong trying to follow from {{ account }}{% endblocktrans %}

{% trans 'Check you have the correct username before trying again.' %}

{% elif error == 'is_blocked' %} -
+

{% blocktrans %}You have blocked {{ account }}{% endblocktrans %}

{% elif error == 'has_blocked' %} -
+

{% blocktrans %}{{ account }} has blocked you{% endblocktrans %}

{% elif error == 'already_following' %} -
+

{% blocktrans %}You are already following {{ account }}{% endblocktrans %}

{% elif error == 'already_requested' %} -
+

{% blocktrans %}You have already requested to follow {{ account }}{% endblocktrans %}

{% endif %}
- Close window +
{% endblock %} From 4ee234258a15edb56485306480cb141f291e6c1b Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Tue, 30 Nov 2021 12:47:04 +1100 Subject: [PATCH 24/40] remove OG meta in ostatus template It's just a temporary popup so would be weird to share and just gunks things up. Co-authored-by: Joachim --- bookwyrm/templates/ostatus/template.html | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/bookwyrm/templates/ostatus/template.html b/bookwyrm/templates/ostatus/template.html index 04e432aaa..68284a35f 100644 --- a/bookwyrm/templates/ostatus/template.html +++ b/bookwyrm/templates/ostatus/template.html @@ -17,20 +17,6 @@ - {% if preview_images_enabled is True %} - - {% else %} - - {% endif %} - - - - - - {% block opengraph_images %} - {% include 'snippets/opengraph_images.html' %} - {% endblock %} - - - - - - -{% block scripts %}{% endblock %} diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index 50a7ae6d1..bc85e678e 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -222,7 +222,51 @@
-{% include 'components/footer.html' %} + + + + + + + + +{% block scripts %}{% endblock %} From 7848ff792766b67d171e27dcab13f485cbf23bd4 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Tue, 30 Nov 2021 20:46:41 +1100 Subject: [PATCH 26/40] fix translation strings --- bookwyrm/templates/ostatus/remote_follow.html | 11 +++++++---- bookwyrm/templates/ostatus/subscribe.html | 10 +++++----- bookwyrm/templates/ostatus/success.html | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/bookwyrm/templates/ostatus/remote_follow.html b/bookwyrm/templates/ostatus/remote_follow.html index 6a4e565ac..96c7f9452 100644 --- a/bookwyrm/templates/ostatus/remote_follow.html +++ b/bookwyrm/templates/ostatus/remote_follow.html @@ -2,11 +2,12 @@ {% load i18n %} {% load utilities %} +{% block heading %} +{% blocktrans with username=user.localname sitename=site.name %}Follow {{ username }} on the fediverse{% endblocktrans %} +{% endblock %} + {% block content %}
-
-

{% blocktrans %}Follow {{ user.display_name }} on the fediverse{% endblocktrans %}

-
@@ -24,11 +25,13 @@ @{{ user|username }} -

{% blocktrans %}Follow {{ user.display_name }} from another Fediverse account like Bookwyrm, Mastodon, or Pleroma.{% endblocktrans %}

+
+

{% blocktrans with username=user.display_name %}Follow {{ username }} from another Fediverse account like Bookwyrm, Mastodon, or Pleroma.{% endblocktrans %}

+
diff --git a/bookwyrm/templates/ostatus/subscribe.html b/bookwyrm/templates/ostatus/subscribe.html index d41ce6743..51dec4382 100644 --- a/bookwyrm/templates/ostatus/subscribe.html +++ b/bookwyrm/templates/ostatus/subscribe.html @@ -5,11 +5,11 @@ {% block title %} {% if not request.user.is_authenticated %} -{% trans "Log in to " %} +{% blocktrans with sitename=site.name %}Log in to {{ sitename }}{% endblocktrans %} {% elif error %} -{% trans "Error following from " %} +{% blocktrans with sitename=site.name %}Error following from {{ sitename }}{% endblocktrans %} {% else %} -{% trans "Follow from " %} +{% blocktrans with sitename=site.name %}Follow from {{ sitename }}{% endblocktrans %} {% endif %} {% endblock %} @@ -19,7 +19,7 @@ {% elif error %} {% trans 'Uh oh...' %} {% else %} -{% trans 'Follow from ' %}{{ site.name }} +{% blocktrans with sitename=site.name %}Follow from {{ sitename }}{% endblocktrans %} {% endif %} {% endblock %} @@ -48,7 +48,7 @@ {% csrf_token %} - +
diff --git a/bookwyrm/templates/ostatus/success.html b/bookwyrm/templates/ostatus/success.html index 89f662735..a652989be 100644 --- a/bookwyrm/templates/ostatus/success.html +++ b/bookwyrm/templates/ostatus/success.html @@ -25,7 +25,7 @@

- {% trans 'You are now following ' %}{{ user.display_name }}! + {% blocktrans with display_name=user.display_name %}You are now following {{ display_name }}!{% endblocktrans %}

From 080fa72c84b6608d0788e2fc1b31cf0e34ed2b1c Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Tue, 30 Nov 2021 21:01:07 +1100 Subject: [PATCH 27/40] ostatus template fixes - remove unnecessary links - remove footer - remove unnecessary JS scripts - make block title and block heading empty --- bookwyrm/templates/ostatus/template.html | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/bookwyrm/templates/ostatus/template.html b/bookwyrm/templates/ostatus/template.html index 68284a35f..8d2d193ec 100644 --- a/bookwyrm/templates/ostatus/template.html +++ b/bookwyrm/templates/ostatus/template.html @@ -7,16 +7,11 @@ - {% block title %}{% endblock %}{{ site.name }} + {% block title %}{% endblock %} - - - - - + From 461c35f416e1838c470824d03f10c8eed8a7ff73 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Tue, 30 Nov 2021 21:02:39 +1100 Subject: [PATCH 28/40] fix buttons --- bookwyrm/templates/ostatus/error.html | 2 +- bookwyrm/templates/ostatus/success.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/ostatus/error.html b/bookwyrm/templates/ostatus/error.html index 99a2a9acb..0c8d6f768 100644 --- a/bookwyrm/templates/ostatus/error.html +++ b/bookwyrm/templates/ostatus/error.html @@ -55,6 +55,6 @@ {% endif %}
- +
{% endblock %} diff --git a/bookwyrm/templates/ostatus/success.html b/bookwyrm/templates/ostatus/success.html index a652989be..a4f78ace8 100644 --- a/bookwyrm/templates/ostatus/success.html +++ b/bookwyrm/templates/ostatus/success.html @@ -30,6 +30,6 @@
- Close window +
{% endblock %} From 9be1a8f4557e98e9bfe4aee072f074fed3fc4d5a Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Wed, 1 Dec 2021 07:45:30 +1100 Subject: [PATCH 29/40] keep close button simple --- bookwyrm/templates/ostatus/error.html | 2 +- bookwyrm/templates/ostatus/success.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/ostatus/error.html b/bookwyrm/templates/ostatus/error.html index 0c8d6f768..b5a3bf406 100644 --- a/bookwyrm/templates/ostatus/error.html +++ b/bookwyrm/templates/ostatus/error.html @@ -55,6 +55,6 @@ {% endif %}
- +
{% endblock %} diff --git a/bookwyrm/templates/ostatus/success.html b/bookwyrm/templates/ostatus/success.html index a4f78ace8..66577e83f 100644 --- a/bookwyrm/templates/ostatus/success.html +++ b/bookwyrm/templates/ostatus/success.html @@ -30,6 +30,6 @@
- +
{% endblock %} From c77edab79c1b53404a83f8e8bcc33de37ec55648 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sun, 5 Dec 2021 18:09:51 +1100 Subject: [PATCH 30/40] minor functionality fixes --- bookwyrm/templates/ostatus/remote_follow.html | 4 ++-- bookwyrm/views/follow.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bookwyrm/templates/ostatus/remote_follow.html b/bookwyrm/templates/ostatus/remote_follow.html index 96c7f9452..ca47c529b 100644 --- a/bookwyrm/templates/ostatus/remote_follow.html +++ b/bookwyrm/templates/ostatus/remote_follow.html @@ -30,7 +30,7 @@
-

{% blocktrans with username=user.display_name %}Follow {{ username }} from another Fediverse account like Bookwyrm, Mastodon, or Pleroma.{% endblocktrans %}

+

{% blocktrans with username=user.display_name %}Follow {{ username }} from another Fediverse account like BookWyrm, Mastodon, or Pleroma.{% endblocktrans %}

@@ -38,7 +38,7 @@ {% csrf_token %} - +
diff --git a/bookwyrm/views/follow.py b/bookwyrm/views/follow.py index 7af8b0db7..7a9d7bad1 100644 --- a/bookwyrm/views/follow.py +++ b/bookwyrm/views/follow.py @@ -110,7 +110,7 @@ def ostatus_follow_request(request): error = "ostatus_subscribe" # don't do these checks for AnonymousUser before they sign in - if request.user.id: + if request.user.is_authenticated: # you have blocked them so you probably don't want to follow if hasattr(request.user, "blocks") and user in request.user.blocks.all(): From 781fe69470125f888f5c7583db157e0ecc8129f9 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Mon, 6 Dec 2021 09:29:51 +1100 Subject: [PATCH 31/40] more descriptive remote follow errors - distinguish between invalid username, user not found, and remote follow not supported - make helpers DRYer --- bookwyrm/templates/ostatus/error.html | 28 ++++++++++--- bookwyrm/templates/ostatus/subscribe.html | 6 +-- bookwyrm/views/follow.py | 36 +++++++++++++--- bookwyrm/views/helpers.py | 51 +++++++++++++---------- 4 files changed, 83 insertions(+), 38 deletions(-) diff --git a/bookwyrm/templates/ostatus/error.html b/bookwyrm/templates/ostatus/error.html index b5a3bf406..a603529fe 100644 --- a/bookwyrm/templates/ostatus/error.html +++ b/bookwyrm/templates/ostatus/error.html @@ -2,7 +2,28 @@ {% block content %}
- {% if not request.user.is_authenticated and not error == 'remote_subscribe' %} + {% if error == 'invalid_username' %} +
+ {% blocktrans %} +

{{ account }} is not a valid username.

+

Check you have the correct username before trying again.

+ {% endblocktrans %} +
+ {% elif error == 'user_not_found' %} +
+ {% blocktrans %} +

{{ account }} could not be found or {{ remote_domain }} does not support identity discovery.

+

Check you have the correct username before trying again.

+ {% endblocktrans %} +
+ {% elif error == 'not_supported' %} +
+ {% blocktrans %} +

{{ account }} was found but {{ remote_domain }} does not support 'remote follow'.

+

Try searching for {{ user }} on {{ remote_domain }} instead.

+ {% endblocktrans %} +
+ {% elif not request.user.is_authenticated %}