From 297648d4a26d878db74099c4bc7ec9c65cf989ec Mon Sep 17 00:00:00 2001 From: Sweetbread Date: Tue, 31 Mar 2026 19:42:43 +0300 Subject: [PATCH] tmp --- blueprints/risdeveau/__init__.py | 12 +--- blueprints/risdeveau/templates/contacts.pug | 19 +++-- blueprints/risdeveau/templates/index.html | 2 +- .../risdeveau/templates/listenbrainz.htm | 39 ----------- .../risdeveau/templates/listenbrainz.pug | 31 +++++++++ blueprints/risdeveau/templates/steam.htm | 69 ------------------- blueprints/risdeveau/templates/steam.pug | 52 ++++++++++++++ 7 files changed, 95 insertions(+), 129 deletions(-) delete mode 100644 blueprints/risdeveau/templates/listenbrainz.htm create mode 100644 blueprints/risdeveau/templates/listenbrainz.pug delete mode 100644 blueprints/risdeveau/templates/steam.htm create mode 100644 blueprints/risdeveau/templates/steam.pug diff --git a/blueprints/risdeveau/__init__.py b/blueprints/risdeveau/__init__.py index 765d0f3..dcf100c 100644 --- a/blueprints/risdeveau/__init__.py +++ b/blueprints/risdeveau/__init__.py @@ -87,22 +87,14 @@ def index(): @bp.route("/m/") def module(module): - if modified_since := request.headers.get('if-modified-since'): - modified_since = int(modified_since) - none_match = request.headers.get('if-none-match') - - if any((modified_since, none_match)): + if none_match := request.headers.get('if-none-match'): match module: case "listenbrainz": - if modified_since >= int(lb_data['last_updated']): - return '', 304 if none_match == lb_data['etag']: return '', 304 case "steam": - if modified_since >= int(steam_data['last_updated']): - return '', 304 if none_match == steam_data['etag']: return '', 304 - return render_tmpl(f'{module}.htm', **args) + return render_tmpl(f'{module}.pug', **args) diff --git a/blueprints/risdeveau/templates/contacts.pug b/blueprints/risdeveau/templates/contacts.pug index 03e2d19..9f1bedf 100644 --- a/blueprints/risdeveau/templates/contacts.pug +++ b/blueprints/risdeveau/templates/contacts.pug @@ -3,39 +3,38 @@ .blocks.badges a.block(href="//g.lair.moe/Sweetbread") img.icon(src="/static/icon/service/gitea.webp") - | Gitea + | Gitea a.block(href="https://github.com/VerySweetBread") img.icon(src="https://github.githubassets.com/assets/GitHub-Mark-ea2971cee799.png") - | GitHub + | GitHub a.block(href="https://git.kolibrios.org/Sweetbread") img.icon(src="https://git.kolibrios.org/assets/img/logo.svg") - | KolibriOS Git + | KolibriOS Git h3 Contacts .blocks.badges a.block(href="https://matrix.to/#/@risdeveau:lair.moe") img.icon(src="https://matrix.org/assets/favicon.ico") - | Matrix + | Matrix a.block(href="//b.lair.moe/@risdeveau") img.icon(src="/static/icon/service/sharkey.webp") - | Fediverse + | Fediverse a.block(href="https://discord.com/users/459823895256498186") img.icon(src="https://cdn.prod.website-files.com/6257adef93867e50d84d30e2/66e3d80db9971f10a9757c99_Symbol.svg") - | Discord + | Discord - a.block(href="mailto:risdeveau@lair.moe") - | Mail + a.block(href="mailto:risdeveau@lair.moe") Mail h3 Game accounts .blocks.badges a.block(href="https://steamcommunity.com/id/risdeveau") img.icon(src="https://store.steampowered.com/favicon.ico") - | Steam + | Steam a.block(href="https://gamebanana.com/members/3899828") img.icon(src="https://images.gamebanana.com/static/img/favicon/favicon.ico") - | GameBanana + | GameBanana diff --git a/blueprints/risdeveau/templates/index.html b/blueprints/risdeveau/templates/index.html index 25b88f2..4f4487b 100644 --- a/blueprints/risdeveau/templates/index.html +++ b/blueprints/risdeveau/templates/index.html @@ -50,7 +50,7 @@ 'donate', '88x31' ) %} - {% include 'risdeveau/templates/%s.pub' % m %} + {% include 'risdeveau/templates/%s.pug' % m %} {% endfor %} diff --git a/blueprints/risdeveau/templates/listenbrainz.htm b/blueprints/risdeveau/templates/listenbrainz.htm deleted file mode 100644 index 8611771..0000000 --- a/blueprints/risdeveau/templates/listenbrainz.htm +++ /dev/null @@ -1,39 +0,0 @@ -{% macro track_block(track, is_active=false) %} -
- {% if track.cover_url %} - - {% endif %} -
-

{{ track.artist_name }}

-

{{ track.track_name }}

- {% if not is_active %} -

- {% endif %} -
-
-{% endmacro %} - -
-

Listenbrainz

- {% if lb.caches.now.data and lb.caches.now.data.listens.0 %} - {{ track_block(lb.caches.now.data.listens.0, is_active=true) }} - {% endif %} - {% if lb.caches.listens.data and lb.caches.listens.data.listens %} - {% for track in lb.caches.listens.data.listens %} - {{ track_block(track) }} - {% endfor %} - {% endif %} -
diff --git a/blueprints/risdeveau/templates/listenbrainz.pug b/blueprints/risdeveau/templates/listenbrainz.pug new file mode 100644 index 0000000..021094a --- /dev/null +++ b/blueprints/risdeveau/templates/listenbrainz.pug @@ -0,0 +1,31 @@ +mixin track_block(track, is_active=false) + .block.track + if track.cover_url + img(src=track.cover_url) + div + p + b= track.artist_name + p= track.track_name + + if not is_active + p( + x-data="rtime(#{track.listened_at})", + x-text="`Listened ${timeString}`", + :class="textColorClass" + ) + +.block( + hx-get="/m/listenbrainz", + hx-trigger="every 15s", + hx-swap="outerHTML", + hx-headers='{ "If-None-Match": "#{lb.etag}" }' +) + h2 + a(href="https://listenbrainz.org/user/risdeveau/") Listenbrainz + + if lb.caches.now.data and lb.caches.now.data.listens[0] + +track_block.active(lb.caches.now.data.listens[0]) + + if lb.caches.listens.data and lb.caches.listens.data.listens + each track in lb.caches.listens.data.listens + +track_block(track) diff --git a/blueprints/risdeveau/templates/steam.htm b/blueprints/risdeveau/templates/steam.htm deleted file mode 100644 index b02be66..0000000 --- a/blueprints/risdeveau/templates/steam.htm +++ /dev/null @@ -1,69 +0,0 @@ -
-

Steam

- - {% if steam.caches.recent.data.games %} -

Recently played:

- {% for g in steam.caches.recent.data.games %} - - - - - - -
- {{ g.name }} -

Played last 2 weeks: {{ tmsmp(g.playtime_2weeks*60) }} -

- Total played: - {{ tmsmp(g.playtime_linux_forever*60) }} (L) + - {{ tmsmp(g.playtime_windows_forever*60) }} (W) = - {{ tmsmp(g.playtime_forever*60) }} (T) -

-
-
- {% endfor %} -

- {% endif %} - - {% if steam.caches.owned.data.games %} -

Top played games:

- {% set owned_games = steam.caches.owned.data.games | sort(attribute="playtime_forever", reverse=true) %} - {% for g in owned_games[:5] %} - - - - - - -
- {{ g.name }} -

- Total played: - {{ tmsmp(g.playtime_linux_forever*60) }} (L) + - {{ tmsmp(g.playtime_windows_forever*60) }} (W) = - {{ tmsmp(g.playtime_forever*60) }} (T) -

- {% if g.rtime_last_played != 0 %} -

Last played: {{ utmsmp(g.rtime_last_played) }}

- {% endif %} -
-
- {% endfor %} -

- {% endif %} -
diff --git a/blueprints/risdeveau/templates/steam.pug b/blueprints/risdeveau/templates/steam.pug new file mode 100644 index 0000000..c8ec9d1 --- /dev/null +++ b/blueprints/risdeveau/templates/steam.pug @@ -0,0 +1,52 @@ +mixin game_block(g, show_last_played=false) + a.block(href="https://store.steampowered.com/app/#{g.appid}", target="_blank") + picture + source(media="(max-width: 45rem)", srcset=g.v_cover) + img(src=g.h_cover) + div + strong= g.name + if g.playtime_2weeks + p Played last 2 weeks: #{tmsmp(g.playtime_2weeks * 60)} + p + - var lin = g.playtime_linux_forever > 0; + - var win = g.playtime_windows_forever > 0; + | Total played: + if lin + = tmsmp(g.playtime_linux_forever * 60) + | ( + abbr(title="On Linux") L + | ) + if lin and win + | + + if win + = tmsmp(g.playtime_windows_forever * 60) + | ( + abbr(title="On Windows") W + | ) + if lin and win + | = + = tmsmp(g.playtime_forever * 60) + if show_last_played and g.rtime_last_played != 0 + p Last played: #{utmsmp(g.rtime_last_played)} + +.block.steam( + hx-get="/m/steam", + hx-trigger="every 1m", + hx-swap="outerHTML", + hx-headers='{ "If-None-Match": "#{steam.etag}" }' +) + h2 + a(href="https://steamcommunity.com/id/risdeveau") Steam + + if steam.caches.recent.data.games + h3 Recently played: + each g in steam.caches.recent.data.games + +game_block(g) + p(x-data="rtime(#{steam.caches.recent.last_updated})", x-text="`Last updated: ${timeString}`") + + if steam.caches.owned.data.games + h3 Top played games: + - var owned_games = steam.caches.owned.data.games | sort(attribute="playtime_forever", reverse=true) + each g in owned_games[:5] + +game_block(g, true) + p(x-data="rtime(#{steam.caches.owned.last_updated})", x-text="`Last updated: ${timeString}`")