mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-12-22 21:24:28 +00:00
Support actor without URL
This commit is contained in:
parent
f92a6ea3dc
commit
42466ddfba
2 changed files with 20 additions and 13 deletions
23
app.py
23
app.py
|
@ -274,6 +274,13 @@ def domain(url):
|
||||||
return urlparse(url).netloc
|
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()
|
@app.template_filter()
|
||||||
def get_url(u):
|
def get_url(u):
|
||||||
if isinstance(u, dict):
|
if isinstance(u, dict):
|
||||||
|
@ -449,14 +456,14 @@ def handle_activitypub_error(error):
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
@app.errorhandler(Exception)
|
# @app.errorhandler(Exception)
|
||||||
def handle_other_error(error):
|
# def handle_other_error(error):
|
||||||
logger.error(
|
# logger.error(
|
||||||
f"caught error {error!r}, {traceback.format_tb(error.__traceback__)}"
|
# f"caught error {error!r}, {traceback.format_tb(error.__traceback__)}"
|
||||||
)
|
# )
|
||||||
response = flask_jsonify({})
|
# response = flask_jsonify({})
|
||||||
response.status_code = 500
|
# response.status_code = 500
|
||||||
return response
|
# return response
|
||||||
|
|
||||||
|
|
||||||
# App routes
|
# App routes
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{% macro display_actor_inline(follower, size=50) -%}
|
{% macro display_actor_inline(follower, size=50) -%}
|
||||||
<a class="actor-box" href="{{follower.url | get_url }}" style="clear:both;">
|
<a class="actor-box" href="{{follower | url_or_id | get_url }}" style="clear:both;">
|
||||||
<span style="float:left;padding-right:15px;">
|
<span style="float:left;padding-right:15px;">
|
||||||
{% if not follower.icon %}
|
{% if not follower.icon %}
|
||||||
<img class="actor-icon" src="/static/nopic.png" style="width:{{ size }}px">
|
<img class="actor-icon" src="/static/nopic.png" style="width:{{ size }}px">
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
</span>
|
</span>
|
||||||
<div class="actor-inline">
|
<div class="actor-inline">
|
||||||
<div style="font-weight:bold">{{ follower.name or follower.preferredUsername }}</div>
|
<div style="font-weight:bold">{{ follower.name or follower.preferredUsername }}</div>
|
||||||
<small class="lcolor">@{{ follower.preferredUsername }}@{{ follower.url | get_url | domain }}</small>
|
<small class="lcolor">@{{ follower.preferredUsername }}@{{ follower | url_or_id | get_url | domain }}</small>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
@ -25,14 +25,14 @@
|
||||||
<div class="note h-entry" id="activity-{{ obj.id | permalink_id }}">
|
<div class="note h-entry" id="activity-{{ obj.id | permalink_id }}">
|
||||||
|
|
||||||
<div class="h-card p-author">
|
<div class="h-card p-author">
|
||||||
<a class="u-url u-uid no-hover" href="{{ actor.url | get_url }}"><img class="u-photo" src="{% if not actor.icon %}/static/nopic.png{% else %}{{ actor.icon.url | get_actor_icon_url(50) }}{% endif %}">
|
<a class="u-url u-uid no-hover" href="{{ actor | url_or_id | get_url }}"><img class="u-photo" src="{% if not actor.icon %}/static/nopic.png{% else %}{{ actor.icon.url | get_actor_icon_url(50) }}{% endif %}">
|
||||||
</a>
|
</a>
|
||||||
<data class="p-name" value="{{ actor.name or actor.preferredUsername }}"></data>
|
<data class="p-name" value="{{ actor.name or actor.preferredUsername }}"></data>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="note-wrapper">
|
<div class="note-wrapper">
|
||||||
<a href="{{ actor.url | get_url }}" style="margin:0;text-decoration:none;" class="no-hover"><strong>{{ actor.name or actor.preferredUsername }}</strong>
|
<a href="{{ actor | url_or_id | get_url }}" style="margin:0;text-decoration:none;" class="no-hover"><strong>{{ actor.name or actor.preferredUsername }}</strong>
|
||||||
<span class="l">@{% if not no_color and obj.id | is_from_outbox %}<span class="pcolor">{{ actor.preferredUsername }}</span>{% else %}{{ actor.preferredUsername }}{% endif %}@{% if not no_color and obj.id | is_from_outbox %}<span class="pcolor">{{ actor.url | get_url | domain }}</span>{% else %}{{ actor.url | get_url | domain }}{% endif %}</span></a>
|
<span class="l">@{% if not no_color and obj.id | is_from_outbox %}<span class="pcolor">{{ actor.preferredUsername }}</span>{% else %}{{ actor.preferredUsername }}{% endif %}@{% if not no_color and obj.id | is_from_outbox %}<span class="pcolor">{{ actor | url_or_id | get_url | domain }}</span>{% else %}{{ actor | url_or_id | get_url | domain }}{% endif %}</span></a>
|
||||||
|
|
||||||
{% if not perma %}
|
{% if not perma %}
|
||||||
<span style="float:right">
|
<span style="float:right">
|
||||||
|
|
Loading…
Reference in a new issue