From 3cff4e4507509696ce8fa64828043cdaa0ba9ead Mon Sep 17 00:00:00 2001 From: Kevin Wallace Date: Thu, 17 Nov 2022 21:35:02 -0800 Subject: [PATCH 1/3] Use BASE_URL when generating {proxied,resized}_image_url Necessary when running at a non-root path --- app/actor.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/actor.py b/app/actor.py index ecf53f1..271b88b 100644 --- a/app/actor.py +++ b/app/actor.py @@ -12,6 +12,7 @@ from sqlalchemy.orm import joinedload from app import activitypub as ap from app import media +from app.config import BASE_URL from app.database import AsyncSession from app.utils.datetime import as_utc from app.utils.datetime import now @@ -111,14 +112,14 @@ class Actor: if self.icon_url: return media.proxied_media_url(self.icon_url) else: - return "/static/nopic.png" + return BASE_URL + "/static/nopic.png" @property def resized_icon_url(self) -> str: if self.icon_url: return media.resized_media_url(self.icon_url, 50) else: - return "/static/nopic.png" + return BASE_URL + "/static/nopic.png" @property def tags(self) -> list[ap.RawObject]: From 2151733e4fee2491f0e60dcfd798d759142e5151 Mon Sep 17 00:00:00 2001 From: Kevin Wallace Date: Thu, 17 Nov 2022 21:35:03 -0800 Subject: [PATCH 2/3] Add robots meta tags on pages in robots.txt Useful when app is at a non-root path and we're not handling top-level /robots.txt requests. --- app/templates/followers.html | 1 + app/templates/following.html | 1 + app/templates/login.html | 3 +++ app/templates/remote_follow.html | 1 + app/templates/remote_interact.html | 1 + 5 files changed, 7 insertions(+) diff --git a/app/templates/followers.html b/app/templates/followers.html index a5df2bb..dabd049 100644 --- a/app/templates/followers.html +++ b/app/templates/followers.html @@ -3,6 +3,7 @@ {% block head %} {{ local_actor.display_name }}'s followers + {% endblock %} {% block content %} diff --git a/app/templates/following.html b/app/templates/following.html index b8db603..3341725 100644 --- a/app/templates/following.html +++ b/app/templates/following.html @@ -3,6 +3,7 @@ {% block head %} {{ local_actor.display_name }}'s follows + {% endblock %} {% block content %} diff --git a/app/templates/login.html b/app/templates/login.html index bc0512d..8f3940a 100644 --- a/app/templates/login.html +++ b/app/templates/login.html @@ -1,5 +1,8 @@ {%- import "utils.html" as utils with context -%} {% extends "layout.html" %} +{% block head %} + +{% endblock %} {% block main_tag %} class="main-flex"{% endblock %} {% block content %}
diff --git a/app/templates/remote_follow.html b/app/templates/remote_follow.html index bfe5ecc..ed25be0 100644 --- a/app/templates/remote_follow.html +++ b/app/templates/remote_follow.html @@ -3,6 +3,7 @@ {% block head %} Remote follow {{ local_actor.display_name }} + {% endblock %} {% block content %} diff --git a/app/templates/remote_interact.html b/app/templates/remote_interact.html index 517fb0b..0fbfe26 100644 --- a/app/templates/remote_interact.html +++ b/app/templates/remote_interact.html @@ -3,6 +3,7 @@ {% block head %} Interact from your instance + {% endblock %} {% block content %} From a2254f2674676155b7e98a5efafb5f73702566f9 Mon Sep 17 00:00:00 2001 From: Kevin Wallace Date: Thu, 17 Nov 2022 21:35:04 -0800 Subject: [PATCH 3/3] Add return type to hmac_sha256 --- app/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config.py b/app/config.py index 14bb913..0dc868a 100644 --- a/app/config.py +++ b/app/config.py @@ -257,5 +257,5 @@ def verify_csrf_token( return None -def hmac_sha256(): +def hmac_sha256() -> hmac.HMAC: return hmac.new(CONFIG.secret.encode(), digestmod=hashlib.sha256)