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> <body>
@partial partials/header @partial partials/header
<h1>{{.album}}</h1> <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) @partial partials/newtable(T: ColumnChoices, table_data: .songs, columns: columns)
</body> </body>
</html> </html>

View file

@ -10,8 +10,9 @@
<body> <body>
@partial partials/header @partial partials/header
<h1>{{.artist.name}}</h1> <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> <h2>Albums</h2>
@partial partials/newtable(T: ColumnChoices, table_data: .albums, columns: columns) @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> <div>
{{scrobbles}} scrobbles ({{rank}} place) {{scrobbles}} scrobbles ({{rank}} place)
<br> <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> <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> </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>