Skip to content

Commit 68f72eb

Browse files
committed
update
1 parent aecb780 commit 68f72eb

File tree

8 files changed

+307
-319
lines changed

8 files changed

+307
-319
lines changed

client/src/rpc/chalgen/base_pb.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,20 +240,30 @@ export class AudioPlayer extends Message$1<AudioPlayer> {
240240
*/
241241
export class Song extends Message$1<Song> {
242242
/**
243-
* @generated from field: string title = 1;
243+
* @generated from field: string name = 1;
244244
*/
245-
title = "";
245+
name = "";
246246

247247
/**
248248
* @generated from field: string artist = 2;
249249
*/
250250
artist = "";
251251

252252
/**
253-
* @generated from field: string url = 3;
253+
* @generated from field: string album = 3;
254+
*/
255+
album = "";
256+
257+
/**
258+
* @generated from field: string url = 4;
254259
*/
255260
url = "";
256261

262+
/**
263+
* @generated from field: string cover_art_url = 5;
264+
*/
265+
coverArtUrl = "";
266+
257267
constructor(data?: PartialMessage<Song>) {
258268
super();
259269
proto3.util.initPartial(data, this);
@@ -262,9 +272,11 @@ export class Song extends Message$1<Song> {
262272
static readonly runtime: typeof proto3 = proto3;
263273
static readonly typeName = "chalgen.Song";
264274
static readonly fields: FieldList = proto3.util.newFieldList(() => [
265-
{ no: 1, name: "title", kind: "scalar", T: 9 /* ScalarType.STRING */ },
275+
{ no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ },
266276
{ no: 2, name: "artist", kind: "scalar", T: 9 /* ScalarType.STRING */ },
267-
{ no: 3, name: "url", kind: "scalar", T: 9 /* ScalarType.STRING */ },
277+
{ no: 3, name: "album", kind: "scalar", T: 9 /* ScalarType.STRING */ },
278+
{ no: 4, name: "url", kind: "scalar", T: 9 /* ScalarType.STRING */ },
279+
{ no: 5, name: "cover_art_url", kind: "scalar", T: 9 /* ScalarType.STRING */ },
268280
]);
269281

270282
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Song {

pkg/chals/chals.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ func (s *Handler) Handle() (string, http.Handler) {
198198
case *chalgen.Node_Base:
199199
switch t := u.Base.Type.(type) {
200200
case *chalgen.Challenge_Audioplayer:
201+
t.Audioplayer.Songs = append(t.Audioplayer.Songs, &chalgen.Song{
202+
Name: n.Meta.Flag,
203+
Artist: "flag",
204+
})
201205
templ.Handler(tmpl.Page(tmpl.AudioPlayer(t.Audioplayer))).ServeHTTP(w, r)
202206
return
203207
case *chalgen.Challenge_Data:

pkg/chals/tmpl/audioplayer.templ

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,18 @@ import (
66

77
type AudioPlayerState struct {
88
BaseURL string
9+
Songs []Song
910
}
1011

11-
script Player() {
12+
type Song struct {
13+
Name string
14+
Artist string
15+
Album string
16+
URL string
17+
CoverArtURL string
18+
}
19+
20+
script Player(songs []*chalgen.Song) {
1221
let theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
1322

1423
if( theme == 'dark' ){
@@ -47,43 +56,7 @@ script Player() {
4756
slider.style.backgroundSize = percentage + '% 100%';
4857
}
4958
},
50-
"songs": [
51-
{
52-
"name": "First Snow",
53-
"artist": "Emancipator",
54-
"album": "Soon It Will Be Cold Enough",
55-
"url": "https://521dimensions.com/song/FirstSnow-Emancipator.mp3",
56-
"cover_art_url": "https://521dimensions.com/img/open-source/amplitudejs/album-art/soon-it-will-be-cold-enough.jpg"
57-
},
58-
{
59-
"name": "Intro / Sweet Glory",
60-
"artist": "Jimkata",
61-
"album": "Die Digital",
62-
"url": "https://521dimensions.com/song/IntroSweetGlory-Jimkata.mp3",
63-
"cover_art_url": "https://521dimensions.com/img/open-source/amplitudejs/album-art/die-digital.jpg"
64-
},
65-
{
66-
"name": "Offcut #6",
67-
"artist": "Little People",
68-
"album": "We Are But Hunks of Wood Remixes",
69-
"url": "https://521dimensions.com/song/Offcut6-LittlePeople.mp3",
70-
"cover_art_url": "https://521dimensions.com/img/open-source/amplitudejs/album-art/we-are-but-hunks-of-wood.jpg"
71-
},
72-
{
73-
"name": "Dusk To Dawn",
74-
"artist": "Emancipator",
75-
"album": "Dusk To Dawn",
76-
"url": "https://521dimensions.com/song/DuskToDawn-Emancipator.mp3",
77-
"cover_art_url": "https://521dimensions.com/img/open-source/amplitudejs/album-art/from-dusk-to-dawn.jpg"
78-
},
79-
{
80-
"name": "Anthem",
81-
"artist": "Emancipator",
82-
"album": "Soon It Will Be Cold Enough",
83-
"url": "https://521dimensions.com/song/Anthem-Emancipator.mp3",
84-
"cover_art_url": "https://521dimensions.com/img/open-source/amplitudejs/album-art/soon-it-will-be-cold-enough.jpg"
85-
}
86-
]
59+
"songs": songs,
8760
});
8861

8962
window.onkeydown = function(e) {
@@ -1186,5 +1159,5 @@ div.amplitude-repeat-song.amplitude-repeat-song-on svg path{
11861159
</div>
11871160
</div>
11881161
</div>
1189-
@Player()
1162+
@Player(a.Songs)
11901163
}

pkg/chals/tmpl/audioplayer_templ.go

Lines changed: 16 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)