More design tweaks

This commit is contained in:
Thomas Sileo 2022-07-14 19:05:45 +02:00
parent c32bcdad8e
commit 61c3c3e214
5 changed files with 7 additions and 221 deletions

View file

@ -14,8 +14,6 @@ from app.key import get_pubkey_as_pem
if TYPE_CHECKING:
from app.actor import Actor
_HTTPX_TRANSPORT = httpx.AsyncHTTPTransport(retries=1)
RawObject = dict[str, Any]
AS_CTX = "https://www.w3.org/ns/activitystreams"
AS_PUBLIC = "https://www.w3.org/ns/activitystreams#Public"
@ -110,7 +108,7 @@ class NotAnObjectError(Exception):
async def fetch(url: str, params: dict[str, Any] | None = None) -> RawObject:
async with httpx.AsyncClient(transport=_HTTPX_TRANSPORT) as client:
async with httpx.AsyncClient() as client:
resp = await client.get(
url,
headers={

View file

@ -104,7 +104,7 @@ class CustomMiddleware:
await self.app(scope, receive, send)
return
response_details = {}
response_details = {"status_code": None}
start_time = time.perf_counter()
request_id = os.urandom(8).hex()

View file

@ -45,7 +45,7 @@ a {
div.highlight {
background: #f0f0f0;
padding: 10px;
padding: 0 10px;
overflow: auto;
display: block;
margin: 20px 0;

View file

@ -14,6 +14,6 @@
{% if ap_object and ap_object.ap_type in actor_types %}
{{ utils.display_actor(ap_object, actors_metadata) }}
{% elif ap_object %}
{{ utils.display_object_expanded(ap_object) }}
{{ utils.display_object(ap_object, actors_metadata=actors_metadata) }}
{% endif %}
{% endblock %}

View file

@ -234,103 +234,10 @@
{% endif %}
{% endmacro %}
{% macro display_object_expanded(object, likes=[], shares=[], webmentions=[]) %}
<div class="activity-expanded h-entry">
{{ display_actor(object.actor, {}) }}
{% if object.summary %}
<p class="p-summary">{{ object.summary | clean_html(object) | safe }}</p>
{% endif %}
{% if object.sensitive and object.summary and not request.query_params.show_more == object.permalink_id %}
{{ show_more_button(object.permalink_id) }}
{% endif %}
{% if not object.sensitive or (object.sensitive and object.summary and request.query_params.show_more == object.permalink_id) %}
<div class="e-content">
{{ object.content | clean_html(object) | safe }}
</div>
{% endif %}
{{ display_og_meta(object) }}
<nav class="flexbox">
<ul>
<li>
<a href="{{ object.url }}" class="u-url u-uid"><time class="dt-published" datetime="{{ object.ap_published_at }}">{{ object.ap_published_at | format_date }}</time></a>
</li>
{% if is_admin %}
<li>
{{ object.visibility.value }}
</li>
{% if object.is_from_outbox %}
<li>
<strong>{{ object.likes_count }}</strong> likes
</li>
<li>
<strong>{{ object.announces_count }}</strong> shares
</li>
<li>
<strong>{{ object.replies_count }}</strong> replies
</li>
{% endif %}
{% endif %}
</ul>
</nav>
<div class="activity-attachment">
{{ display_attachments(object) }}
</div>
{% if likes or shares %}
<div style="display: flex;column-gap: 20px;margin:20px 0;">
{% if likes %}
<div style="flex: 0 1 50%;max-width: 50%;">Likes
<div style="display: flex;column-gap: 20px;row-gap:20px;flex-wrap: wrap;margin-top:20px;">
{% for like in likes %}
<a href="{% if is_admin %}{{ url_for("admin_profile") }}?actor_id={{ like.actor.ap_id }}{% else %}{{ like.actor.url }}{% endif %}" title="{{ like.actor.handle }}" style="height:50px;" rel="noreferrer">
<img src="{{ like.actor.resized_icon_url }}" alt="{{ like.actor.handle}}" style="max-width:50px;">
</a>
{% endfor %}
</div>
</div>
{% endif %}
{% if shares %}
<div style="flex: 0 1 50%;max-width: 50%;">Shares
<div style="display: flex;column-gap: 20px;row-gap:20px;flex-wrap: wrap;margin-top:20px;">
{% for share in shares %}
<a href="{% if is_admin %}{{ url_for("admin_profile") }}?actor_id={{ share.actor.ap_id }}{% else %}{{ share.actor.url }}{% endif %}" title="{{ share.actor.handle }}" style="height:50px;" rel="noreferrer">
<img src="{{ share.actor.resized_icon_url }}" alt="{{ share.actor.handle}}" style="max-width:50px;">
</a>
{% endfor %}
</div>
</div>
{% endif %}
{% if webmentions %}
<div style="flex: 0 1 50%;max-width: 50%;">Webmentions
<div style="display: flex;column-gap: 20px;row-gap:20px;flex-wrap: wrap;margin-top:20px;">
{% for webmention in webmentions %}
<a href="{{ webmention.url }}" style="height:50px;" rel="noreferrer">
<img src="{{ webmention.actor_icon_url | media_proxy_url }}" alt="{{ webmention.actor_name }}" style="max-width:50px;">
</a>
{% endfor %}
</div>
</div>
{% endif %}
</div>
{% endif %}
</div>
{% endmacro %}
{% macro display_object(object, likes=[], shares=[], webmentions=[], expanded=False) %}
{% macro display_object(object, likes=[], shares=[], webmentions=[], expanded=False, actors_metadata={}) %}
{% if object.ap_type in ["Note", "Article", "Video"] %}
<div class="ap-object {% if expanded %}ap-object-expanded {% endif %}h-entry" id="{{ object.permalink_id }}">
{{ display_actor(object.actor, {}, embedded=True) }}
{{ display_actor(object.actor, actors_metadata, embedded=True) }}
{% if object.in_reply_to %}
<a href="{% if is_admin %}{{ url_for("get_lookup") }}?query={% endif %}{{ object.in_reply_to }}" title="{{ object.in_reply_to }}" class="in-reply-to" rel="nofollow">
@ -403,7 +310,7 @@
</ul>
</nav>
{% if is_admin %}
{% if is_admin and (object.is_from_outbox or object.is_from_inbox) %}
<nav class="flexbox activity-bar">
<ul>
{% if object.is_from_outbox %}
@ -507,122 +414,3 @@
</div>
{% endif %}
{% endmacro %}
{% macro display_object_bak(object) %}
{% if object.ap_type in ["Note", "Article", "Video"] %}
<div class="activity-wrap h-entry" id="{{ object.permalink_id }}">
<div class="activity-content">
<img src="{{ object.actor.resized_icon_url }}" alt="" class="actor-icon">
<div class="activity-header">
<strong>{{ object.actor.display_name }}</strong>
<a href="{{ object.actor.url}}" class="actor-handle p-author h-card">{{ object.actor.handle }}</a>
<span class="activity-date" title="{{ object.ap_published_at.isoformat() }}">
<a href="{{ object.url }}" class="u-url u-uid"><time class="dt-published" datetime="{{ object.ap_published_at }}">{{ object.ap_published_at | timeago }}</time></a>
</span>
{% if is_admin %}<span class="object-visibility">{{ object.visibility.value }}</span>{% endif %}
{% if object.summary %}
<p class="p-summary">{{ object.summary | clean_html(object) | safe }}</p>
{% endif %}
{% if object.sensitive and object.summary and not request.query_params.show_more == object.permalink_id %}
{{ show_more_button(object.permalink_id) }}
{% endif %}
{% if not object.sensitive or (object.sensitive and object.summary and request.query_params.show_more == object.permalink_id) %}
<div class="activity-main e-content">
{{ object.content | clean_html(object) | safe }}
</div>
{% endif %}
</div>
</div>
<div style="padding-left:60px">
{{ display_og_meta(object) }}
</div>
<div class="activity-attachment">
{{ display_attachments(object) }}
</div>
<nav class="flexbox activity-bar">
<ul>
{% if object.in_reply_to and is_admin %}
<li>
<a href="{{ url_for("get_lookup") }}?query={{ object.in_reply_to }}" title="{{ object.in_reply_to }}">in reply to {{ object.in_reply_to|truncate(16, True) }}</a>
</li>
{% endif %}
{% if not is_admin or object.is_from_outbox %}<li><div><a href="{{ object.url }}"{% if object.is_from_inbox %} rel="nofollow"{% endif %}>permalink</a></div></li>{% endif %}
{% if object.is_from_outbox %}
{% if object.likes_count %}
<li>
<a href="{{ object.url }}"><strong>{{ object.likes_count }}</strong> like{{ object.likes_count | pluralize }}</a>
</li>
{% endif %}
{% if object.announces_count %}
<li>
<a href="{{ object.url }}"><strong>{{ object.announces_count }}</strong> share{{ object.announces_count | pluralize }}</a
</li>
{% endif %}
{% if object.replies_count %}
<li>
<a href="{{ object.url }}"><strong>{{ object.replies_count }}</strong> repl{{ object.replies_count | pluralize("y", "ies") }}</a>
</li>
{% endif %}
{% if is_admin %}
<li>
{{ admin_delete_button(object.ap_id) }}
</li>
<li>
{{ admin_reply_button(object.ap_id) }}
</li>
<li>
{% if object.is_pinned %}
{{ admin_unpin_button(object.ap_id) }}
{% else %}
{{ admin_pin_button(object.ap_id) }}
{% endif %}
</li>
{% endif %}
{% endif %}
{% if object.is_from_inbox and is_admin %}
<li>
{% if object.liked_via_outbox_object_ap_id %}
{{ admin_undo_button(object.liked_via_outbox_object_ap_id, "unlike") }}
{% else %}
{{ admin_like_button(object.ap_id) }}
{% endif %}
</li>
<li>
{% if object.is_bookmarked %}
{{ admin_unbookmark_button(object.ap_id) }}
{% else %}
{{ admin_bookmark_button(object.ap_id) }}
{% endif %}
</li>
<li>
{% if object.announced_via_outbox_object_ap_id %}
{{ admin_undo_button(object.liked_via_outbox_object_ap_id, "unshare") }}
{% else %}
{{ admin_announce_button(object.ap_id, disabled=object.visibility not in [visibility_enum.PUBLIC, visibility_enum.UNLISTED]) }}
{% endif %}
</li>
<li>
{{ admin_reply_button(object.ap_id) }}
</li>
<li>
{{ admin_profile_button(object.actor.ap_id) }}
</li>
<li>
{{ admin_expand_button(object.ap_id) }}
</li>
{% endif %}
</ul>
</nav>
</div>
{% endif %}
{% endmacro %}