From 42466ddfba4d47c9ceed462b7cd33ba5b5b2fc0d Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Sun, 22 Jul 2018 12:42:36 +0200 Subject: [PATCH] Support actor without URL --- app.py | 23 +++++++++++++++-------- templates/utils.html | 10 +++++----- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/app.py b/app.py index 61c65d5..5791b18 100644 --- a/app.py +++ b/app.py @@ -274,6 +274,13 @@ def domain(url): return urlparse(url).netloc +@app.template_filter() +def url_or_id(d): + if 'url' in d: + return d['url'] + return d['id'] + + @app.template_filter() def get_url(u): if isinstance(u, dict): @@ -449,14 +456,14 @@ def handle_activitypub_error(error): return response -@app.errorhandler(Exception) -def handle_other_error(error): - logger.error( - f"caught error {error!r}, {traceback.format_tb(error.__traceback__)}" - ) - response = flask_jsonify({}) - response.status_code = 500 - return response +# @app.errorhandler(Exception) +# def handle_other_error(error): +# logger.error( +# f"caught error {error!r}, {traceback.format_tb(error.__traceback__)}" +# ) +# response = flask_jsonify({}) +# response.status_code = 500 +# return response # App routes diff --git a/templates/utils.html b/templates/utils.html index db64c04..c3b586e 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.url | get_url | domain }} +@{{ follower.preferredUsername }}@{{ follower | url_or_id | get_url | domain }}
{%- endmacro %} @@ -25,14 +25,14 @@
- +