Add panels for user's created photos, albums, tags, bookmarks.

This commit is contained in:
voussoir 2021-01-09 11:27:29 -08:00
parent fb65138266
commit 84bf9b90de
2 changed files with 50 additions and 8 deletions

View file

@ -1,4 +1,5 @@
import datetime import datetime
import itertools
import jinja2.filters import jinja2.filters
import voussoirkit.bytestring import voussoirkit.bytestring
@ -45,6 +46,10 @@ def file_link(photo, short=False):
basename = jinja2.filters.do_urlencode(photo.basename) basename = jinja2.filters.do_urlencode(photo.basename)
return f'/file/{photo.id}/{basename}' return f'/file/{photo.id}/{basename}'
@filter_function
def islice(gen, start, stop):
return itertools.islice(gen, start, stop)
@filter_function @filter_function
def timestamp_to_8601(timestamp): def timestamp_to_8601(timestamp):
return datetime.datetime.utcfromtimestamp(timestamp).isoformat(' ') + ' UTC' return datetime.datetime.utcfromtimestamp(timestamp).isoformat(' ') + ' UTC'

View file

@ -1,12 +1,17 @@
<!DOCTYPE html5> <!DOCTYPE html5>
<html> <html>
<head> <head>
{% import "album_card.html" as album_card %}
{% import "bookmark_card.html" as bookmark_card %}
{% import "photo_card.html" as photo_card %}
{% import "tag_card.html" as tag_card %}
{% import "header.html" as header %} {% import "header.html" as header %}
<title class="dynamic_user_display_name">{{user.display_name}}</title> <title class="dynamic_user_display_name">{{user.display_name}}</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="/static/css/common.css"> <link rel="stylesheet" href="/static/css/common.css">
<link rel="stylesheet" href="/static/css/etiquette.css"> <link rel="stylesheet" href="/static/css/etiquette.css">
<link rel="stylesheet" href="/static/css/cards.css">
{% if theme %}<link rel="stylesheet" href="/static/css/theme_{{theme}}.css">{% endif %} {% if theme %}<link rel="stylesheet" href="/static/css/theme_{{theme}}.css">{% endif %}
<script src="/static/js/common.js"></script> <script src="/static/js/common.js"></script>
<script src="/static/js/api.js"></script> <script src="/static/js/api.js"></script>
@ -30,20 +35,52 @@ h2, h3
<body> <body>
{{header.make_header(session=session)}} {{header.make_header(session=session)}}
<div id="content_body"> <div id="content_body">
<div class="panel"> <div id="hierarchy_self" class="panel">
<h2 id="display_name">{{user.display_name}}</h2> <h2 id="display_name">{{user.display_name}}</h2>
<p>ID: <a href="/userid/{{user.id}}">{{user.id}}</a></p> <p>ID: <a href="/userid/{{user.id}}">{{user.id}}</a></p>
<p>User since <span title="{{user.created|int|timestamp_to_8601}}">{{user.created|timestamp_to_naturaldate}}.</span></p> <p>User since <span title="{{user.created|int|timestamp_to_8601}}">{{user.created|timestamp_to_naturaldate}}.</span></p>
</div> </div>
<div class="panel">
{% set photos = user.get_photos(direction='desc')|islice(0, 15)|list %}
{% if photos %}
<div id="hierarchy_photos" class="panel">
<h3><a href="/search?author={{user.username}}">Photos by <span class="dynamic_user_display_name">{{user.display_name}}</span></a></h3> <h3><a href="/search?author={{user.username}}">Photos by <span class="dynamic_user_display_name">{{user.display_name}}</span></a></h3>
<iframe {% for photo in photos %}
class="embedded_search" {{photo_card.create_photo_card(photo)}}
src="/search_embed?author={{user.username}}&orderby=created-desc&yield_albums=no&limit=10" {% endfor %}
onload="return common.size_iframe_to_content(this);"
>
</iframe>
</div> </div>
{% endif %}
{% set tags = user.get_tags(direction='desc')|islice(0, 100)|list %}
{% if tags %}
<div id="hierarchy_tags" class="panel">
<h3>Tags by <span class="dynamic_user_display_name">{{user.display_name}}</span></h3>
{% for tag in tags %}
{{tag_card.create_tag_card(tag, with_alt_description=True)}}
{% endfor %}
</div>
{% endif %}
{% set albums = user.get_albums()|islice(0, 20)|list %}
{% if albums %}
<div id="hierarchy_albums" class="panel">
<h3>Albums by <span class="dynamic_user_display_name">{{user.display_name}}</span></h3>
{% for album in albums %}
{{album_card.create_album_card(album)}}
{% endfor %}
</div>
{% endif %}
{% set bookmarks = user.get_bookmarks()|islice(0, 50)|list %}
{% if bookmarks %}
<div id="hierarchy_bookmarks" class="panel">
<h3>Bookmarks by <span class="dynamic_user_display_name">{{user.display_name}}</span></h3>
{% for bookmark in bookmarks %}
{{bookmark_card.create_bookmark_card(bookmark)}}
{% endfor %}
</div>
{% endif %}
</div> </div>
</body> </body>