mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-15 03:04:28 +00:00
Better Link support
This commit is contained in:
parent
364c1d9273
commit
e3284416d2
4 changed files with 15 additions and 12 deletions
4
app.py
4
app.py
|
@ -269,8 +269,10 @@ def domain(url):
|
||||||
def get_url(u):
|
def get_url(u):
|
||||||
if isinstance(u, dict):
|
if isinstance(u, dict):
|
||||||
return u["href"]
|
return u["href"]
|
||||||
else:
|
elif isinstance(u, str):
|
||||||
return u
|
return u
|
||||||
|
else:
|
||||||
|
raise ValueError(f"unexpected URL field type: {type(u)}: {u!r}")
|
||||||
|
|
||||||
|
|
||||||
@app.template_filter()
|
@app.template_filter()
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
{% set boost_actor = item.activity.actor | get_actor %}
|
{% set boost_actor = item.activity.actor | get_actor %}
|
||||||
{% if session.logged_in %}
|
{% if session.logged_in %}
|
||||||
<div style="margin-left:65px;padding-bottom:5px;margin-bottom:15px;">
|
<div style="margin-left:65px;padding-bottom:5px;margin-bottom:15px;">
|
||||||
<span class="bar-item-no-hover"><a style="color:#808080;" href="{{ boost_actor.url }}">{{ boost_actor.name }}</a> boosted</span>
|
<span class="bar-item-no-hover"><a style="color:#808080;" href="{{ boost_actor.url | get_url }}">{{ boost_actor.name }}</a> boosted</span>
|
||||||
<form action="/api/undo" class="action-form" method="POST">
|
<form action="/api/undo" class="action-form" method="POST">
|
||||||
<input type="hidden" name="redirect" value="/"/>
|
<input type="hidden" name="redirect" value="/"/>
|
||||||
<input type="hidden" name="id" value="{{ item.remote_id }}"/>
|
<input type="hidden" name="id" value="{{ item.remote_id }}"/>
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p style="margin-left:65px;padding-bottom:5px;">
|
<p style="margin-left:65px;padding-bottom:5px;">
|
||||||
<span class="bar-item-no-hover"><a style="color:#808080;" href="{{ boost_actor.url }}">{{ boost_actor.name }}</a> boosted</span>
|
<span class="bar-item-no-hover"><a style="color:#808080;" href="{{ boost_actor.url | get_url }}">{{ boost_actor.name }}</a> boosted</span>
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if item.meta.object %}
|
{% if item.meta.object %}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
{% if item | has_type('Announce') %}
|
{% if item | has_type('Announce') %}
|
||||||
{% set boost_actor = item.activity.actor | get_actor %}
|
{% set boost_actor = item.activity.actor | get_actor %}
|
||||||
<p style="margin-left:70px;padding-bottom:5px;"><span class="bar-item-no-hover"><a style="color:#808080;" href="{{ boost_actor.url }}">{{ boost_actor.name or boost_actor.preferredUsername }}</a> boosted</span></p>
|
<p style="margin-left:70px;padding-bottom:5px;"><span class="bar-item-no-hover"><a style="color:#808080;" href="{{ boost_actor.url | get_url }}">{{ boost_actor.name or boost_actor.preferredUsername }}</a> boosted</span></p>
|
||||||
{% if item.meta.object %}
|
{% if item.meta.object %}
|
||||||
{{ utils.display_note(item.meta.object, ui=True) }}
|
{{ utils.display_note(item.meta.object, ui=True) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
{% if not perma %}
|
{% if not perma %}
|
||||||
<span style="float:right">
|
<span style="float:right">
|
||||||
<a rel="noopener" class="u-url u-uid note-permalink l" href="{{ obj.url }}">
|
<a rel="noopener" class="u-url u-uid note-permalink l" href="{{ obj.url | get_url }}">
|
||||||
<time class="dt-published" title="{{ obj.published }}" datetime="{{ obj.published }}">{{ obj.published | format_timeago }}</time></a>
|
<time class="dt-published" title="{{ obj.published }}" datetime="{{ obj.published }}">{{ obj.published | format_timeago }}</time></a>
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
<ul>
|
<ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for a in obj.attachment %}
|
{% for a in obj.attachment %}
|
||||||
{% if a.url | is_img %}
|
{% if a.url | get_url | is_img %}
|
||||||
<a href="{{ a.url | get_attachment_url(None) }}"><img src="{{a.url | get_attachment_url(720) }}" class="img-attachment"></a>
|
<a href="{{ a.url | get_attachment_url(None) }}"><img src="{{a.url | get_attachment_url(720) }}" class="img-attachment"></a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li><a href="{{a.url | get_attachment_url(None) }}" class="l">{% if a.filename %}{{ a.filename }}{% else %}{{ a.url }}{% endif %}</a></li>
|
<li><a href="{{a.url | get_attachment_url(None) }}" class="l">{% if a.filename %}{{ a.filename }}{% else %}{{ a.url }}{% endif %}</a></li>
|
||||||
|
@ -61,8 +61,10 @@
|
||||||
|
|
||||||
<div class="bottom-bar">
|
<div class="bottom-bar">
|
||||||
{% if perma %}<span class="perma-item">{{ obj.published | format_time }}</span>
|
{% if perma %}<span class="perma-item">{{ obj.published | format_time }}</span>
|
||||||
{% else %}
|
{% endif %}
|
||||||
<a class ="bar-item" href="{{ obj.url }}">permalink</a>
|
{% if not obj.id | is_from_outbox %}
|
||||||
|
<a class ="bar-item" href="{{ obj.url | get_url }}">permalink</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if session.logged_in %}
|
{% if session.logged_in %}
|
||||||
{% set perma_id = obj.id | permalink_id %}
|
{% set perma_id = obj.id | permalink_id %}
|
||||||
|
@ -70,12 +72,12 @@
|
||||||
{% set aid = obj.id | quote_plus %}
|
{% set aid = obj.id | quote_plus %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if meta.count_reply and obj.id | is_from_outbox %}<a class ="bar-item" href="{{ obj.url }}"><strong>{{ meta.count_reply }}</strong> replies</a>
|
{% if meta.count_reply and obj.id | is_from_outbox %}<a class ="bar-item" href="{{ obj.url | get_url }}"><strong>{{ meta.count_reply }}</strong> replies</a>
|
||||||
{% elif meta.count_reply and session.logged_in %}
|
{% elif meta.count_reply and session.logged_in %}
|
||||||
<a class ="bar-item" href="/admin/thread?oid={{aid}}"><strong>{{ meta.count_reply }}</strong> replies</a>{% endif %}
|
<a class ="bar-item" href="/admin/thread?oid={{aid}}"><strong>{{ meta.count_reply }}</strong> replies</a>{% endif %}
|
||||||
|
|
||||||
{% if meta.count_boost and obj.id | is_from_outbox %}<a class ="bar-item" href="{{ obj.url }}"><strong>{{ meta.count_boost }}</strong> boosts</a>{% endif %}
|
{% if meta.count_boost and obj.id | is_from_outbox %}<a class ="bar-item" href="{{ obj.url | get_url }}"><strong>{{ meta.count_boost }}</strong> boosts</a>{% endif %}
|
||||||
{% if meta.count_like and obj.id | is_from_outbox %}<a class ="bar-item" href="{{ obj.url }}"><strong>{{ meta.count_like }}</strong> likes</a>{% endif %}
|
{% if meta.count_like and obj.id | is_from_outbox %}<a class ="bar-item" href="{{ obj.url | get_url }}"><strong>{{ meta.count_like }}</strong> likes</a>{% endif %}
|
||||||
|
|
||||||
{% if session.logged_in %}
|
{% if session.logged_in %}
|
||||||
{% if ui%}
|
{% if ui%}
|
||||||
|
@ -132,7 +134,6 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue