From d31e2f8d1d03bb027f40128aceb1a5af3659516c Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Tue, 3 Jul 2018 23:29:55 +0200 Subject: [PATCH] Add support for Link object --- app.py | 24 ++++++++++++++++++++++-- templates/utils.html | 10 +++++----- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/app.py b/app.py index a5eeacd..f2ec403 100644 --- a/app.py +++ b/app.py @@ -209,6 +209,14 @@ def domain(url): return urlparse(url).netloc +@app.template_filter() +def get_url(u): + if isinstance(u, dict): + return u["href"] + else: + return u + + @app.template_filter() def get_actor(url): if not url: @@ -674,6 +682,11 @@ def wellknown_nodeinfo(): ) +# @app.route('/fake_feed') +# def fake_feed(): +# return 'https://lol3.tun.a4.io/fake_feedhttps://lol3.tun.a4.io/fake' + + @app.route("/.well-known/webfinger") def wellknown_webfinger(): """Enable WebFinger support, required for Mastodon interopability.""" @@ -695,6 +708,13 @@ def wellknown_webfinger(): "rel": "http://ostatus.org/schema/1.0/subscribe", "template": BASE_URL + "/authorize_follow?profile={uri}", }, + # {"rel": "magic-public-key", "href": KEY.to_magic_key()}, + # {"rel": "salmon", "href": BASE_URL + "/salmon"}, + # { + # "rel": "http://schemas.google.com/g/2010#updates-from", + # "type": "application/atom+xml", + # "href": f"{BASE_URL}/fake_feed", + # }, ], } @@ -1258,7 +1278,7 @@ def api_new_note(): inReplyTo=reply.id if reply else None, ) - if 'file' in request.files: + if "file" in request.files: file = request.files["file"] rfilename = secure_filename(file.filename) prefix = hashlib.sha256(os.urandom(32)).hexdigest()[:6] @@ -1270,7 +1290,7 @@ def api_new_note(): if filename.lower().endswith(".jpg") or filename.lower().endswith(".jpeg"): piexif.remove(os.path.join("static", "media", filename)) - raw_note['attachment'] = [ + raw_note["attachment"] = [ { "mediaType": mtype, "name": rfilename, diff --git a/templates/utils.html b/templates/utils.html index ab61ca5..070fc9f 100644 --- a/templates/utils.html +++ b/templates/utils.html @@ -1,5 +1,5 @@ {% macro display_actor_inline(follower, size=50) -%} - + {% if not follower.icon %} @@ -8,7 +8,7 @@
{{ follower.name or follower.preferredUsername }}
-@{{ follower.preferredUsername }}@{{ follower.get_url() | domain }} +@{{ follower.preferredUsername }}@{{ follower.url | get_url | domain }}
{%- endmacro %} @@ -20,14 +20,14 @@
- +