etiquette/frontends/etiquette_flask/templates/user.html

139 lines
4.4 KiB
HTML

<!DOCTYPE html>
<html class="theme_{{theme}}">
<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">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="icon" href="/favicon.png" type="image/png"/>
<link rel="stylesheet" href="/static/css/common.css">
<link rel="stylesheet" href="/static/css/etiquette.css">
<link rel="stylesheet" href="/static/css/cards.css">
<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/http.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=request.session)}}
<div id="content_body">
<div id="hierarchy_self" class="panel">
<h1 id="display_name">{{user.display_name}}</h1>
{% if user.display_name != user.username %}
<p>Username: {{user.username}}</p>
{% endif %}
<p>ID: <a href="/userid/{{user.id}}"><code>{{user.id}}</code></a></p>
<p>User since <span title="{{user.created|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">
<h2><a href="/search?author={{user.id}}">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">
<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">
<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">
<h2>Bookmarks by <span class="dynamic_user_display_name">{{user.display_name}}</span></h2>
{% for bookmark in bookmarks %}
{{cards.create_bookmark_card(bookmark, add_author=False)}}
{% endfor %}
</div>
{% endif %}
</div>
</body>
<script type="text/javascript">
{% if user.id == request.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>