tmp
This commit is contained in:
@@ -87,22 +87,14 @@ def index():
|
||||
|
||||
@bp.route("/m/<module>")
|
||||
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)
|
||||
|
||||
@@ -27,8 +27,7 @@
|
||||
img.icon(src="https://cdn.prod.website-files.com/6257adef93867e50d84d30e2/66e3d80db9971f10a9757c99_Symbol.svg")
|
||||
| Discord
|
||||
|
||||
a.block(href="mailto:risdeveau@lair.moe")
|
||||
| Mail
|
||||
a.block(href="mailto:risdeveau@lair.moe") Mail
|
||||
|
||||
h3 Game accounts
|
||||
.blocks.badges
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
'donate',
|
||||
'88x31'
|
||||
) %}
|
||||
{% include 'risdeveau/templates/%s.pub' % m %}
|
||||
{% include 'risdeveau/templates/%s.pug' % m %}
|
||||
{% endfor %}
|
||||
</main>
|
||||
</body>
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
{% macro track_block(track, is_active=false) %}
|
||||
<div class="block track{% if is_active %} active{% endif %}">
|
||||
{% if track.cover_url %}
|
||||
<img src="{{ track.cover_url }}"/>
|
||||
{% endif %}
|
||||
<div>
|
||||
<p><b>{{ track.artist_name }}</b></p>
|
||||
<p>{{ track.track_name }}</p>
|
||||
{% if not is_active %}
|
||||
<p
|
||||
x-data="rtime({{ track.listened_at }})"
|
||||
x-text="`Listened ${timeString}`"
|
||||
:class="textColorClass"
|
||||
></p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
<div
|
||||
class="block"
|
||||
hx-get="/m/listenbrainz"
|
||||
hx-trigger="every 15s"
|
||||
hx-swap="outerHTML"
|
||||
hx-headers='{
|
||||
"If-Modified-Since": {{ lb.last_updated | int }},
|
||||
"If-None-Match": "{{ lb.etag }}"
|
||||
}'
|
||||
>
|
||||
<h2><a href="https://listenbrainz.org/user/risdeveau/">Listenbrainz</a></h2>
|
||||
{% 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 %}
|
||||
</div>
|
||||
@@ -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)
|
||||
@@ -1,69 +0,0 @@
|
||||
<div
|
||||
class="block steam"
|
||||
hx-get="/m/steam"
|
||||
hx-trigger="every 1m"
|
||||
hx-swap="outerHTML"
|
||||
hx-headers='{
|
||||
"If-Modified-Since": {{ steam.last_updated | int }},
|
||||
"If-None-Match": "{{ steam.etag }}"
|
||||
}'
|
||||
>
|
||||
<h2><a href="https://steamcommunity.com/id/risdeveau">Steam</a></h2>
|
||||
|
||||
{% if steam.caches.recent.data.games %}
|
||||
<h3>Recently played:</h3>
|
||||
{% for g in steam.caches.recent.data.games %}
|
||||
<a href="https://store.steampowered.com/app/{{ g.appid }}" class="block">
|
||||
<picture>
|
||||
<source media="(max-width: 45rem)" srcset="{{ g.v_cover }}">
|
||||
<img src="{{ g.h_cover }}">
|
||||
</picture>
|
||||
|
||||
<div>
|
||||
<strong>{{ g.name }}</strong>
|
||||
<p>Played last 2 weeks: {{ tmsmp(g.playtime_2weeks*60) }}
|
||||
<p>
|
||||
Total played:
|
||||
{{ tmsmp(g.playtime_linux_forever*60) }} (<abbr title="On Linux">L</abbr>) +
|
||||
{{ tmsmp(g.playtime_windows_forever*60) }} (<abbr title="On Windows">W</abbr>) =
|
||||
{{ tmsmp(g.playtime_forever*60) }} (<abbr title="Total">T</abbr>)
|
||||
</p>
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
<p
|
||||
x-data="rtime({{steam.caches.recent.last_updated}})"
|
||||
x-text="`Last updated: ${timeString}`"
|
||||
></p>
|
||||
{% endif %}
|
||||
|
||||
{% if steam.caches.owned.data.games %}
|
||||
<h3>Top played games:</h3>
|
||||
{% set owned_games = steam.caches.owned.data.games | sort(attribute="playtime_forever", reverse=true) %}
|
||||
{% for g in owned_games[:5] %}
|
||||
<a href="https://store.steampowered.com/app/{{ g.appid }}" class="block">
|
||||
<picture>
|
||||
<source media="(max-width: 45rem)" srcset="{{ g.v_cover }}">
|
||||
<img src="{{ g.h_cover }}">
|
||||
</picture>
|
||||
|
||||
<div>
|
||||
<strong>{{ g.name }}</strong>
|
||||
<p>
|
||||
Total played:
|
||||
{{ tmsmp(g.playtime_linux_forever*60) }} (<abbr title="On Linux">L</abbr>) +
|
||||
{{ tmsmp(g.playtime_windows_forever*60) }} (<abbr title="On Windows">W</abbr>) =
|
||||
{{ tmsmp(g.playtime_forever*60) }} (<abbr title="Total">T</abbr>)
|
||||
</p>
|
||||
{% if g.rtime_last_played != 0 %}
|
||||
<p>Last played: {{ utmsmp(g.rtime_last_played) }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
<p
|
||||
x-data="rtime({{steam.caches.owned.last_updated}})"
|
||||
x-text="`Last updated: ${timeString}`"
|
||||
></p>
|
||||
{% endif %}
|
||||
</div>
|
||||
@@ -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}`")
|
||||
Reference in New Issue
Block a user