Add post hiding

This allows users to hide posts that they may find unsavory. On threads
themselves in the board view, this adds a minus/plus button that will
toggle back and forth if hidden. This also adds a post menu item that
will toggle a post being hidden.

This also changes the post snippet layout a little bit. This caused
minor issues with the other menu items, but it should be fixed in this
set of changes too.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-07-13 12:03:09 -07:00
parent 089913c8fe
commit f131c58d1b
5 changed files with 167 additions and 56 deletions

View File

@@ -31,9 +31,9 @@
<hr />
{# posts #}
{% for post in threads %}
<div class="row post" id="p{{post.id}}">
<div class="row thread" id="p{{post.id}}">
{# TODO we need some way to parameterize the last N threads #}
{% with reply_link=True replies_elided=post.replies.all|length|add:"-3" %}
{% with reply_link=True thread_hide_button=True replies_elided=post.replies.all|length|add:"-3" %}
{% include "board/post_snippet.html" %}
{% endwith %}

View File

@@ -40,7 +40,7 @@
</span>
<hr />
{# posts #}
<div class="row post">
<div class="row thread">
{% include "board/post_snippet.html" %}
{% for post in post.replies.all %}
<div class="row reply">

View File

@@ -2,6 +2,7 @@
{% load i18n %}
<div
id="p{{post.id}}"
class="post"
data-report-url="{% url 'board:report_form' board.url post.id %}"
{% if perms.board.add_ban %}
data-ban-url="{% url 'board:ban_create' board.url post.id %}"
@@ -11,60 +12,69 @@
{% endif %}
>
{# Post ID, status icons, username, time #}
{% if post.sticky and not post.op %}
<span title="Stickied" class="fa fa-thumb-tack"></span>
{% endif %}
{% if post.lock and not post.op %}
<span title="Locked" class="fa fa-lock"></span>
{% endif %}
<a href="#p{{post.id}}">#.</a>
<span class="post_id">{{post.id}}</span>
{% if post.subject %}
<span class="post_subject">{{post.subject}}</span>
{% endif %}
{% blocktranslate with post_name=post.name|default:"Anonymous" %}
by
<span class="post_name">{{post_name}}</span>
{% endblocktranslate %}
{% if post.capcode %}
<span class="post_capcode" style="color: {{post.capcode.color}};">{{post.capcode}}</span>
{% endif %}
{% blocktranslate with post_created=post.created %}
at {{post_created}}
{% endblocktranslate %}
{% if reply_link %}
[<a href="{{post.get_absolute_url}}">{% translate "Reply" %}</a>]
{% endif %}
<a href="#" class="post_menu_button" data-id="post_menu_button"></a>
<div class="post_title">
{# Hide post button #}
{% if thread_hide_button %}
<span class="fa fa-minus-square thread_hide_button"></span>
{% endif %}
{# Image #}
{% if post.thumbnail %}
{# Image info #}
<div class="post_image_info">
{% translate "File" %}
<a href="{{post.image.url}}" target="_blank">{{post.original_image_name}}</a>
({{post.image.size|measure_bytes}}, {{post.image_width}}x{{post.image_height}})
{# Post ID, status icons, username, time #}
<a href="#p{{post.id}}">#.</a>
<span class="post_id">{{post.id}}</span>
{% if post.subject %}
<span class="post_subject">{{post.subject}}</span>
{% endif %}
{% blocktranslate with post_name=post.name|default:"Anonymous" %}
by
<span class="post_name">{{post_name}}</span>
{% endblocktranslate %}
{% if post.capcode %}
<span class="post_capcode" style="color: {{post.capcode.color}};">{{post.capcode}}</span>
{% endif %}
{% blocktranslate with post_created=post.created %}
at {{post_created}}
{% endblocktranslate %}
{% if post.sticky and not post.op %}
<span title="Stickied" class="fa fa-thumb-tack"></span>
{% endif %}
{% if post.lock and not post.op %}
<span title="Locked" class="fa fa-lock"></span>
{% endif %}
{% if reply_link %}
[<a href="{{post.get_absolute_url}}">{% translate "Reply" %}</a>]
{% endif %}
<a href="#" class="post_menu_button" data-id="post_menu_button"></a>
</div>
{# Image thumbnail #}
<div class="post_image_thumbnail">
<a href="{{post.image.url}}" target="_blank">
<img class="post_image" src="{{post.thumbnail.url}}" data-url="{{post.image.url}}" data-thumb="{{post.thumbnail.url}}">
</a>
</div>
{% endif %}
{# "X replies elided" dialog for OPs on the board #}
<div class="post_content">
{% if replies_elided > 0 %}
<br/>
<span class="replies_elided">
({% blocktranslate %}{{replies_elided}} replies elided, click reply to view{% endblocktranslate %})
</span>
{% endif %}
{# Image #}
{% if post.thumbnail %}
{# Image info #}
<div class="post_image_info">
{% translate "File" %}
<a href="{{post.image.url}}" target="_blank">{{post.original_image_name}}</a>
({{post.image.size|measure_bytes}}, {{post.image_width}}x{{post.image_height}})
</div>
{# Post body #}
<p class="post_body">{{post|post_body|safe}}</p>
{# Image thumbnail #}
<div class="post_image_thumbnail">
<a href="{{post.image.url}}" target="_blank">
<img class="post_image" src="{{post.thumbnail.url}}" data-url="{{post.image.url}}" data-thumb="{{post.thumbnail.url}}">
</a>
</div>
{% endif %}
{# "X replies elided" dialog for OPs on the board #}
{% if replies_elided > 0 %}
<br/>
<span class="replies_elided">
({% blocktranslate %}{{replies_elided}} replies elided, click reply to view{% endblocktranslate %})
</span>
{% endif %}
{# Post body #}
<p class="post_body">{{post|post_body|safe}}</p>
</div>
</div>