add bookmark button to thread and posts in thread view

This commit is contained in:
2025-11-21 06:59:59 +03:00
parent 10934c557d
commit 831eb32b8a
7 changed files with 54 additions and 6 deletions

View File

@@ -1,12 +1,15 @@
{% from 'common/macros.html' import pager, babycode_editor_form, full_post %}
{% from 'common/icons.html' import icn_bookmark %}
{% extends "base.html" %}
{% block title %}{{ thread.title }}{% endblock %}
{% block content %}
{% set can_post = false %}
{% set can_lock = false %}
{% set can_subscribe = false %}
{% set can_bookmark = false %}
{% if active_user %}
{% set can_subscribe = true %}
{% set can_bookmark = not active_user.is_guest() %}
{% set can_post = (not thread.is_locked and not active_user.is_guest()) or active_user.is_mod() %}
{% set can_lock = ((active_user.id | int) == (thread.user_id | int)) or active_user.is_mod() %}
{% endif %}
@@ -18,7 +21,7 @@
&bullet; <i>stickied, so it's probably important</i>
{% endif %}
</span>
<div>
<div class="thread-actions">
{% if can_subscribe %}
<form class="modform" action="{{ url_for('threads.subscribe', slug=thread.slug) }}" method="post">
<input type='hidden' name='last_visible_post' value='{{posts[-1].id}}'>
@@ -26,6 +29,9 @@
<input type='submit' value='{{ 'Unsubscribe' if is_subscribed else 'Subscribe' }}'>
</form>
{% endif %}
{% if can_bookmark %}
<button type="button" class="contain-svg inline icon">{{ icn_bookmark(20) }}Bookmark</button>
{% endif %}
{% if can_lock %}
<form class="modform" action="{{ url_for("threads.lock", slug=thread.slug) }}" method="post">
<input type=hidden name='target_op' value="{{ (not thread.is_locked) | int }}">
@@ -50,7 +56,7 @@
</div>
</nav>
{% for post in posts %}
{{ full_post(post = post, active_user = active_user, is_latest = loop.index == (posts | length), Reactions = Reactions) }}
{{ full_post(post = post, active_user = active_user, is_latest = loop.index == (posts | length), Reactions = Reactions, show_bookmark = can_bookmark) }}
{% endfor %}
</main>