Add timescale partial

Bad name, idk what else to call it
This commit is contained in:
mitteneer 2025-05-24 13:58:31 -04:00
parent 1734e6a4bb
commit 09f542e26e
4 changed files with 32 additions and 5 deletions

View file

@ -10,6 +10,10 @@
<body>
@partial partials/header
<h1>{{.album}}</h1>
@partial partials/firstlast_listens(scrobbles: .album.scrobbles, rank: .album.rank, firstlast: .firstlast)
<h3>Yearly Performance</h3>
@partial partials/timescale(range: .yearly)
<h2>Songs</h2>
@partial partials/newtable(T: ColumnChoices, table_data: .songs, columns: columns)
</body>
</html>

View file

@ -10,8 +10,9 @@
<body>
@partial partials/header
<h1>{{.artist.name}}</h1>
@partial partials/firstlast_listens(scrobbles: .artist.scrobbles, rank: .artist.rank, last_song: .last, first_song: .first)
@partial partials/firstlast_listens(scrobbles: .artist.scrobbles, rank: .artist.rank, firstlast: .firstlast)
<h3>Yearly Performance</h3>
@partial partials/timescale(range: .yearly)
<h2>Albums</h2>
@partial partials/newtable(T: ColumnChoices, table_data: .albums, columns: columns)

View file

@ -1,9 +1,13 @@
@args scrobbles: i64, rank: []const u8, last_song: *ZmplValue, first_song: *ZmplValue
@args scrobbles: i64, rank: []const u8, firstlast: *ZmplValue
@zig {
const songs = firstlast.items(.array);
}
<div>
{{scrobbles}} scrobbles ({{rank}} place)
<br>
First listen: <a href="/songs/{{first_song.id}}">{{first_song.name}}</a> ({{first_song.date}})
First listen: <a href="/songs/{{songs[0].id}}">{{songs[0].name}}</a> ({{songs[0].date}})
<br>
Most recent listen: <a href="/songs/{{last_song.id}}">{{last_song.name}}</a> ({{last_song.date}})
Most recent listen: <a href="/songs/{{songs[1].id}}">{{songs[1].name}}</a> ({{songs[1].date}})
</div>

View file

@ -0,0 +1,18 @@
@args range: *ZmplValue
<table>
<thead>
<tr>
<th>Year</th>
<th>Scrobbles</th>
</tr>
</thead>
<tbody>
@for (range) |itm| {
<tr>
<td>{{itm.year}}:</td>
<td>{{itm.scrobbles}}</td>
</tr>
}
</tbody>
</table>