From 95decd9a560d5b1a4c9d398e26c1435b5e87f3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Thu, 20 Nov 2025 03:49:44 +0300 Subject: [PATCH] add user bookmarks view --- app/routes/users.py | 15 ++++++++++++- app/templates/common/macros.html | 8 ++++++- app/templates/common/topnav.html | 4 ++++ app/templates/users/bookmarks.html | 35 ++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 app/templates/users/bookmarks.html diff --git a/app/routes/users.py b/app/routes/users.py index 8ed04af..1e1803e 100644 --- a/app/routes/users.py +++ b/app/routes/users.py @@ -4,7 +4,7 @@ from flask import ( from functools import wraps from ..db import db from ..lib.babycode import babycode_to_html, BABYCODE_VERSION -from ..models import Users, Sessions, Subscriptions, Avatars, PasswordResetLinks, InviteKeys +from ..models import Users, Sessions, Subscriptions, Avatars, PasswordResetLinks, InviteKeys, BookmarkCollections from ..constants import InfoboxKind, PermissionLevel from ..auth import digest, verify from wand.image import Image @@ -260,6 +260,8 @@ def sign_up_post(): "permission": PermissionLevel.GUEST.value, }) + BookmarkCollections.create_default(new_user.id) + if current_app.config['DISABLE_SIGNUP']: invite_key = InviteKeys.find({'key': key}) new_user.update({ @@ -688,3 +690,14 @@ def revoke_invite_link(username): invite.delete() return redirect(url_for('.invite_links', username=target_user.username)) + + +@bp.get('//bookmarks') +@login_required +def bookmarks(username): + target_user = Users.find({'username': username}) + if not target_user or target_user.username != get_active_user().username: + return redirect(url_for('.bookmarks', username=get_active_user().username)) + + collections = target_user.get_bookmark_collections() + return render_template('users/bookmarks.html', collections=collections) diff --git a/app/templates/common/macros.html b/app/templates/common/macros.html index f3bbda6..67e68c4 100644 --- a/app/templates/common/macros.html +++ b/app/templates/common/macros.html @@ -91,7 +91,7 @@ {% endmacro %} -{% macro full_post(post, render_sig = True, is_latest = False, editing = False, active_user = None, no_reply = false, Reactions = none) %} +{% macro full_post(post, render_sig = True, is_latest = False, editing = False, active_user = None, no_reply = false, Reactions = none, show_thread_title = false) %} {% set postclass = "post" %} {% if editing %} {% set postclass = postclass + " editing" %} @@ -112,6 +112,11 @@