etiquette/frontends/etiquette_flask/templates/user.html

136 lines
4.2 KiB
HTML
Raw Normal View History

2021-06-22 20:38:08 +00:00
<!DOCTYPE html>
<html>
<head>
{% import "header.html" as header %}
{% import "cards.html" as cards %}
<title class="dynamic_user_display_name">{{user.display_name}}</title>
<meta charset="UTF-8">
2017-07-21 06:10:48 +00:00
<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/etiquette.css">
<link rel="stylesheet" href="/static/css/cards.css">
{% if theme %}<link rel="stylesheet" href="/static/css/theme_{{theme}}.css">{% endif %}
2018-08-18 05:23:40 +00:00
<script src="/static/js/common.js"></script>
<script src="/static/js/api.js"></script>
<script src="/static/js/editor.js"></script>
<script src="/static/js/spinners.js"></script>
<style>
#content_body
{
grid-row-gap: 8px;
grid-auto-rows: max-content;
}
</style>
</head>
<body>
{{header.make_header(session=session)}}
<div id="content_body">
<div id="hierarchy_self" class="panel">
<h1 id="display_name">{{user.display_name}}</h1>
<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>
</div>
{% set photos = user.get_photos(direction='desc')|islice(0, 15)|list %}
{% if photos %}
<div id="hierarchy_photos" class="panel">
2021-10-31 23:28:34 +00:00
<h2><a href="/search?author={{user.username}}">Photos by <span class="dynamic_user_display_name">{{user.display_name}}</span></a></h2>
{% for photo in photos %}
{{cards.create_photo_card(photo)}}
{% endfor %}
</div>
{% endif %}
{% set tags = user.get_tags(direction='desc')|islice(0, 100)|list %}
{% if tags %}
<div id="hierarchy_tags" class="panel">
2021-10-31 23:28:34 +00:00
<h2>Tags by <span class="dynamic_user_display_name">{{user.display_name}}</span></h2>
{% for tag in tags %}
{{cards.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">
2021-10-31 23:28:34 +00:00
<h2>Albums by <span class="dynamic_user_display_name">{{user.display_name}}</span></h2>
{% for album in albums %}
{{cards.create_album_card(album)}}
{% endfor %}
</div>
{% endif %}
{% set bookmarks = user.get_bookmarks()|islice(0, 50)|list %}
{% if bookmarks %}
<div id="hierarchy_bookmarks" class="panel">
2021-10-31 23:28:34 +00:00
<h2>Bookmarks by <span class="dynamic_user_display_name">{{user.display_name}}</span></h2>
{% for bookmark in bookmarks %}
2021-10-24 01:48:27 +00:00
{{cards.create_bookmark_card(bookmark, add_author=False)}}
{% endfor %}
</div>
{% endif %}
</div>
</body>
<script type="text/javascript">
{% if user.id == session.user.id %}
const USERNAME = "{{user.username}}";
profile_ed_on_open = undefined;
function profile_ed_on_save(ed)
{
function callback(response)
{
ed.hide_spinner();
if (! response.meta.json_ok)
{
alert(JSON.stringify(response));
return;
}
if ("error_type" in response.data)
{
ed.show_error(`${response.data.error_type} ${response.data.error_message}`);
return;
}
// The data that comes back from the server will have been normalized.
const new_display_name = response.data.display_name;
common.update_dynamic_elements("dynamic_user_display_name", new_display_name);
ed.elements["display_name"].edit.value = new_display_name;
ed.save();
}
ed.show_spinner();
api.users.edit(USERNAME, ed.elements["display_name"].edit.value, callback);
}
profile_ed_on_cancel = undefined;
const profile_ed_elements = [
{
"id": "display_name",
"element": document.getElementById("display_name"),
"placeholder": "Display name",
"empty_text": USERNAME,
"autofocus": true,
},
];
const profile_ed = new editor.Editor(
profile_ed_elements,
profile_ed_on_open,
profile_ed_on_save,
profile_ed_on_cancel,
);
{% endif %}
</script>
</html>