add user bookmarks view
This commit is contained in:
@@ -4,7 +4,7 @@ from flask import (
|
|||||||
from functools import wraps
|
from functools import wraps
|
||||||
from ..db import db
|
from ..db import db
|
||||||
from ..lib.babycode import babycode_to_html, BABYCODE_VERSION
|
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 ..constants import InfoboxKind, PermissionLevel
|
||||||
from ..auth import digest, verify
|
from ..auth import digest, verify
|
||||||
from wand.image import Image
|
from wand.image import Image
|
||||||
@@ -260,6 +260,8 @@ def sign_up_post():
|
|||||||
"permission": PermissionLevel.GUEST.value,
|
"permission": PermissionLevel.GUEST.value,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
BookmarkCollections.create_default(new_user.id)
|
||||||
|
|
||||||
if current_app.config['DISABLE_SIGNUP']:
|
if current_app.config['DISABLE_SIGNUP']:
|
||||||
invite_key = InviteKeys.find({'key': key})
|
invite_key = InviteKeys.find({'key': key})
|
||||||
new_user.update({
|
new_user.update({
|
||||||
@@ -688,3 +690,14 @@ def revoke_invite_link(username):
|
|||||||
invite.delete()
|
invite.delete()
|
||||||
|
|
||||||
return redirect(url_for('.invite_links', username=target_user.username))
|
return redirect(url_for('.invite_links', username=target_user.username))
|
||||||
|
|
||||||
|
|
||||||
|
@bp.get('/<username>/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)
|
||||||
|
|||||||
@@ -91,7 +91,7 @@
|
|||||||
</form>
|
</form>
|
||||||
{% endmacro %}
|
{% 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" %}
|
{% set postclass = "post" %}
|
||||||
{% if editing %}
|
{% if editing %}
|
||||||
{% set postclass = postclass + " editing" %}
|
{% set postclass = postclass + " editing" %}
|
||||||
@@ -112,6 +112,11 @@
|
|||||||
|
|
||||||
<div class="post-content-container" {{ "id=latest-post" if is_latest else "" }}>
|
<div class="post-content-container" {{ "id=latest-post" if is_latest else "" }}>
|
||||||
<div class="post-info">
|
<div class="post-info">
|
||||||
|
<span>
|
||||||
|
{% if show_thread_title %}
|
||||||
|
<a href="{{ url_for('threads.thread', slug=post.thread_slug) }}">Thread: {{ post.thread_title }}</a>
|
||||||
|
•
|
||||||
|
{% endif %}
|
||||||
<a href="{{ post_permalink }}" title="Permalink"><i>
|
<a href="{{ post_permalink }}" title="Permalink"><i>
|
||||||
{% if (post['edited_at'] | int) > (post['created_at'] | int) %}
|
{% if (post['edited_at'] | int) > (post['created_at'] | int) %}
|
||||||
Edited on {{ timestamp(post['edited_at']) }}
|
Edited on {{ timestamp(post['edited_at']) }}
|
||||||
@@ -119,6 +124,7 @@
|
|||||||
Posted on {{ timestamp(post['edited_at']) }}
|
Posted on {{ timestamp(post['edited_at']) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</i></a>
|
</i></a>
|
||||||
|
</span>
|
||||||
<span>
|
<span>
|
||||||
{% set show_edit = false %}
|
{% set show_edit = false %}
|
||||||
{% if active_user %}
|
{% if active_user %}
|
||||||
|
|||||||
@@ -20,6 +20,10 @@
|
|||||||
•
|
•
|
||||||
<a href="{{ url_for('users.invite_links', username=user.username )}}">Invite to {{ config.SITE_NAME }}</a>
|
<a href="{{ url_for('users.invite_links', username=user.username )}}">Invite to {{ config.SITE_NAME }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if not user.is_guest() %}
|
||||||
|
•
|
||||||
|
<a href="{{ url_for('users.bookmarks', username=user.username) }}">Bookmarks</a>
|
||||||
|
{% endif %}
|
||||||
{% if user.is_mod() %}
|
{% if user.is_mod() %}
|
||||||
•
|
•
|
||||||
<a href="{{ url_for("mod.user_list") }}">User list</a>
|
<a href="{{ url_for("mod.user_list") }}">User list</a>
|
||||||
|
|||||||
35
app/templates/users/bookmarks.html
Normal file
35
app/templates/users/bookmarks.html
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
{% from "common/macros.html" import accordion, full_post %}
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% block title %}bookmarks{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
<div class="darkbg inbox-container">
|
||||||
|
{% for collection in collections %}
|
||||||
|
{% call(section) accordion(disabled=collection.is_empty()) %}
|
||||||
|
{% if section == 'header' %}
|
||||||
|
<h1 class="thread-title">{{ collection.name }}</h1>{{" (no bookmarks)" if collection.is_empty() else ""}}
|
||||||
|
{% else %}
|
||||||
|
{% call(inner_section) accordion(disabled=not collection.has_threads()) %}
|
||||||
|
{% if inner_section == 'header' %}
|
||||||
|
Threads{{" (no bookmarks)" if not collection.has_threads() else ""}}
|
||||||
|
{% else %}
|
||||||
|
<ul>
|
||||||
|
{% for thread in collection.get_threads()|sort(attribute='created_at', reverse=true) %}
|
||||||
|
<li><a href="{{ url_for('threads.thread', slug=thread.slug) }}">{{ thread.title }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
{% endcall %}
|
||||||
|
{% call(inner_section) accordion(disabled=not collection.has_posts()) %}
|
||||||
|
{% if inner_section == 'header' %}
|
||||||
|
Posts{{" (no bookmarks)" if not collection.has_posts() else ""}}
|
||||||
|
{% else %}
|
||||||
|
{% for post in collection.get_posts()|sort(attribute='created_at', reverse=true) %}
|
||||||
|
{{ full_post(post.get_full_post_view(), no_reply=false, render_sig=false, show_thread_title=true) }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endcall %}
|
||||||
|
{% endif %}
|
||||||
|
{% endcall %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user