mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-12-22 13:14:28 +00:00
Improve show more/display sensitive content behavior
This commit is contained in:
parent
88c81b2682
commit
d8a56cec49
1 changed files with 34 additions and 5 deletions
|
@ -97,6 +97,17 @@
|
|||
</form>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro hide_sensitive_button(permalink_id) %}
|
||||
<form action="{{ request.url }}#{{ permalink_id }}" method="GET">
|
||||
{% for k, v in request.query_params.items() %}
|
||||
{% if not (k == "show_sensitive" and v == permalink_id) %}
|
||||
<input type="hidden" name="{{k}}" value="{{v}}">
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<button type="submit" class="show-sensitive-btn">hide sensitive content</button>
|
||||
</form>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro show_more_button(permalink_id) %}
|
||||
<form action="{{ request.url }}#{{ permalink_id }}" method="GET">
|
||||
<input type="hidden" name="show_more" value="{{ permalink_id }}">
|
||||
|
@ -107,6 +118,18 @@
|
|||
</form>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro show_less_button(permalink_id) %}
|
||||
<form action="{{ request.url }}#{{ permalink_id }}" method="GET">
|
||||
{% for k, v in request.query_params.items() %}
|
||||
{% if not (k == "show_more" and v == permalink_id) %}
|
||||
<input type="hidden" name="{{k}}" value="{{v}}">
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<button type="submit" class="show-more-btn">show less</button>
|
||||
</form>
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
|
||||
{% macro admin_reply_button(ap_object_id) %}
|
||||
<form action="/admin/new" method="GET">
|
||||
|
@ -215,11 +238,14 @@
|
|||
|
||||
|
||||
{% macro display_attachments(object) %}
|
||||
{% if object.attachments and object.sensitive and not request.query_params.show_sensitive == object.permalink_id %}
|
||||
{{ sensitive_button(object.permalink_id )}}
|
||||
{% if object.attachments and object.sensitive and not object.permalink_id in request.query_params.getlist("show_sensitive") %}
|
||||
{{ sensitive_button(object.permalink_id )}}
|
||||
{% endif %}
|
||||
|
||||
{% if object.attachments and (not object.sensitive or (object.sensitive and request.query_params["show_sensitive"] == object.permalink_id)) %}
|
||||
{% if object.attachments and (not object.sensitive or (object.sensitive and object.permalink_id in request.query_params.getlist("show_sensitive"))) %}
|
||||
{% if object.sensitive %}
|
||||
{{ hide_sensitive_button(object.permalink_id) }}
|
||||
{% endif %}
|
||||
{% for attachment in object.attachments %}
|
||||
{% if attachment.type == "Image" or (attachment | has_media_type("image")) %}
|
||||
<img src="{{ attachment.resized_url or attachment.proxied_url }}"{% if attachment.name %} alt="{{ attachment.name }}"{% endif %} class="attachment">
|
||||
|
@ -250,11 +276,14 @@
|
|||
<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 %}
|
||||
{% if object.sensitive and object.summary and object.permalink_id not in request.query_params.getlist("show_more") %}
|
||||
{{ 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) %}
|
||||
{% if not object.sensitive or (object.sensitive and object.summary and object.permalink_id in request.query_params.getlist("show_more")) %}
|
||||
{% if object.sensitive and object.summary %}
|
||||
{{ show_less_button(object.permalink_id) }}
|
||||
{% endif %}
|
||||
<div class="e-content">
|
||||
{{ object.content | clean_html(object) | safe }}
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue