improved snippets feat

main
Dominik Madarász 2023-01-12 15:45:49 +00:00
parent 84c908bb08
commit 0b39dd8678
3 changed files with 57 additions and 30 deletions

View File

@ -9,6 +9,6 @@
{% for anybox_object in threads %} {% for anybox_object in threads %}
<div class="actor-action"></div> <div class="actor-action"></div>
{{ utils.display_object(anybox_object) }} {{ utils.display_object(anybox_object, is_code=True) }}
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}

View File

@ -54,7 +54,7 @@
{% if custom_footer %} {% if custom_footer %}
{{ custom_footer | safe }} {{ custom_footer | safe }}
{% else %} {% else %}
<a href="{{ url_for("login") }}">Admin</a>. Runs a modified version of <a href="https://microblog.pub/" target="_blank">microblog.pub</a>. <a href="{{ url_for("login") }}">Admin</a>.
{% if is_admin %} {% if is_admin %}
{{ header_link("followers", "Followers") }} <span class="counter">{{ followers_count }}</span>. {{ header_link("followers", "Followers") }} <span class="counter">{{ followers_count }}</span>.
{% endif %} {% endif %}

View File

@ -154,6 +154,15 @@
{% endblock %} {% endblock %}
{% endmacro %} {% endmacro %}
{% macro admin_raw_button(ap_object) %}
{% block admin_raw_button scoped %}
<form action="{{ BASE_URL }}/raw_object" method="GET">
<input type="hidden" name="ap_id" value="{{ ap_object.ap_id }}">
<input type="submit" value="raw">
</form>
{% endblock %}
{% endmacro %}
{% macro admin_force_delete_button(ap_object_id, permalink_id=None) %} {% macro admin_force_delete_button(ap_object_id, permalink_id=None) %}
{% block admin_force_delete_button scoped %} {% block admin_force_delete_button scoped %}
<form action="{{ request.url_for("admin_actions_force_delete") }}" class="object-delete-form" method="POST"> <form action="{{ request.url_for("admin_actions_force_delete") }}" class="object-delete-form" method="POST">
@ -536,7 +545,7 @@
{% endblock %} {% endblock %}
{% endmacro %} {% endmacro %}
{% macro display_object(object, likes=[], shares=[], webmentions=[], expanded=False, actors_metadata={}, is_object_page=False, is_h_entry=True) %} {% macro display_object(object, likes=[], shares=[], webmentions=[], expanded=False, actors_metadata={}, is_object_page=False, is_h_entry=True, is_code=False) %}
{% block display_object scoped %} {% block display_object scoped %}
{% set is_article_mode = object.is_from_outbox and object.ap_type == "Article" and is_object_page %} {% set is_article_mode = object.is_from_outbox and object.ap_type == "Article" and is_object_page %}
{% if object.ap_type in ["Note", "Article", "Video", "Page", "Question", "Event"] %} {% if object.ap_type in ["Note", "Article", "Video", "Page", "Question", "Event"] %}
@ -599,7 +608,15 @@
{% endif %} {% endif %}
<div class="obj-content"> <div class="obj-content">
<div class="e-content"> <div class="e-content">
{% if not is_code %}
{{ object.content | clean_html(object) | safe }} {{ object.content | clean_html(object) | safe }}
{% elif object.source %}
<div class="form admin-new">
<textarea name="content" rows="10" cols="50" designMode="on" readonly aria-readonly="true">{{ object.source }}</textarea>
</div>
{% else %}
Snippets can not be previewed on this page!
{% endif %}
</div> </div>
{% if object.ap_type == "Question" %} {% if object.ap_type == "Question" %}
@ -665,6 +682,7 @@
<nav class="flexbox activity-bar"> <nav class="flexbox activity-bar">
<ul> <ul>
{% if not is_code %}
<li> <li>
<div> <div>
<a href="{{ object.url }}"{% if object.is_from_inbox %} rel="nofollow"{% endif %} class="object-permalink u-url u-uid">permalink</a> <a href="{{ object.url }}"{% if object.is_from_inbox %} rel="nofollow"{% endif %} class="object-permalink u-url u-uid">permalink</a>
@ -677,6 +695,7 @@
</div> </div>
</li> </li>
{% endif %} {% endif %}
{% endif %}
{% if object.is_from_outbox and is_object_page and not is_admin and not request.url.path.startswith("/remote_interaction") %} {% if object.is_from_outbox and is_object_page and not is_admin and not request.url.path.startswith("/remote_interaction") %}
<li> <li>
@ -749,6 +768,7 @@
{{ admin_delete_button(object) }} {{ admin_delete_button(object) }}
</li> </li>
{% if not is_code %}
<li> <li>
{% if object.is_pinned %} {% if object.is_pinned %}
{{ admin_unpin_button(object.ap_id, object.permalink_id) }} {{ admin_unpin_button(object.ap_id, object.permalink_id) }}
@ -756,13 +776,19 @@
{{ admin_pin_button(object.ap_id, object.permalink) }} {{ admin_pin_button(object.ap_id, object.permalink) }}
{% endif %} {% endif %}
</li> </li>
{% endif %}
<li> <li>
{{ admin_reply_button(object.ap_id) }} {{ admin_reply_button(object.ap_id) }}
</li> </li>
{% else %}
<li>
{{ admin_raw_button(object) }}
</li>
{% endif %}
{% endif %}
{% if not object.is_from_outbox %} {% if not object.is_from_outbox %}
{% if not is_code %}
<li> <li>
{% if object.liked_via_outbox_object_ap_id %} {% if object.liked_via_outbox_object_ap_id %}
{{ admin_undo_button(object.liked_via_outbox_object_ap_id, "unlike", object.permalink_id) }} {{ admin_undo_button(object.liked_via_outbox_object_ap_id, "unlike", object.permalink_id) }}
@ -800,6 +826,7 @@
{{ admin_expand_button(object) }} {{ admin_expand_button(object) }}
</li> </li>
{% endif %} {% endif %}
{% endif %}
{% if object.is_from_inbox and not object.announced_via_outbox_object_ap_id and object.is_local_reply %} {% if object.is_from_inbox and not object.announced_via_outbox_object_ap_id and object.is_local_reply %}
<li> <li>
{{ admin_force_delete_button(object.ap_id) }} {{ admin_force_delete_button(object.ap_id) }}