diff --git a/src/lib/api/game.ts b/src/lib/api/game.ts index 7b099d9f..7fdd88bc 100644 --- a/src/lib/api/game.ts +++ b/src/lib/api/game.ts @@ -53,6 +53,11 @@ export interface RankedUser { lastSeen: string } +export interface PopularSongItem { + musicId: number, + weight: number +} + const Routes = { ...Slug( { @@ -89,6 +94,13 @@ const Routes = { }) }, response: Json() + }, + "{}/song-pop": { + authenticated: false, + request: { + method: "GET" + }, + response: Json() } }, games diff --git a/src/lib/i18n/en/index.ts b/src/lib/i18n/en/index.ts index 0467ced0..cf1d163d 100644 --- a/src/lib/i18n/en/index.ts +++ b/src/lib/i18n/en/index.ts @@ -43,6 +43,7 @@ const en = { "Turnstile failed to validate your network. Disable any VPNs or proxies and please try again." } }, + missing: `unknown {id:number}`, // TODO: replace with markdown return: `Get support or return home.` }, @@ -110,7 +111,13 @@ const en = { }, home: { welcome: "Hello, {name:string}!", - songLeaderboard: "{game:string} Top 10 songs", + leaderboard: { + header: "{game:string} Global Song Leaderboard", + playsSuffix: "{plays:number} plays", + }, + rankings: { + header: "{game:string} User Rankings" + }, banner: { title: "Welcome to {aquanet: string}", description: diff --git a/src/lib/i18n/i18n-types.ts b/src/lib/i18n/i18n-types.ts index 26b8004b..8706191c 100644 --- a/src/lib/i18n/i18n-types.ts +++ b/src/lib/i18n/i18n-types.ts @@ -132,6 +132,11 @@ type RootTranslation = { error: string } } + /** + * u​n​k​n​o​w​n​ ​{​i​d​} + * @param {number} id + */ + missing: RequiredParams<'id'> /** * <​a​ ​h​r​e​f​=​"​/​s​u​p​p​o​r​t​"​>​G​e​t​ ​s​u​p​p​o​r​t​<​/​a​>​ ​o​r​ ​<​a​ ​h​r​e​f​=​"​/​"​>​r​e​t​u​r​n​ ​h​o​m​e​<​/​a​>​. */ @@ -329,11 +334,25 @@ type RootTranslation = { * @param {string} name */ welcome: RequiredParams<'name'> - /** - * {​g​a​m​e​}​ ​T​o​p​ ​1​0​ ​s​o​n​g​s - * @param {string} game - */ - songLeaderboard: RequiredParams<'game'> + leaderboard: { + /** + * {​g​a​m​e​}​ ​G​l​o​b​a​l​ ​S​o​n​g​ ​L​e​a​d​e​r​b​o​a​r​d + * @param {string} game + */ + header: RequiredParams<'game'> + /** + * {​p​l​a​y​s​}​ ​p​l​a​y​s + * @param {number} plays + */ + playsSuffix: RequiredParams<'plays'> + } + rankings: { + /** + * {​g​a​m​e​}​ ​U​s​e​r​ ​R​a​n​k​i​n​g​s + * @param {string} game + */ + header: RequiredParams<'game'> + } banner: { /** * W​e​l​c​o​m​e​ ​t​o​ ​{​a​q​u​a​n​e​t​} @@ -803,6 +822,10 @@ export type TranslationFunctions = { error: () => LocalizedString } } + /** + * unknown {id} + */ + missing: (arg: { id: number }) => LocalizedString /** * Get support or return home. */ @@ -997,10 +1020,22 @@ export type TranslationFunctions = { * Hello, {name}! */ welcome: (arg: { name: string }) => LocalizedString - /** - * {game} Top 10 songs - */ - songLeaderboard: (arg: { game: string }) => LocalizedString + leaderboard: { + /** + * {game} Global Song Leaderboard + */ + header: (arg: { game: string }) => LocalizedString + /** + * {plays} plays + */ + playsSuffix: (arg: { plays: number }) => LocalizedString + } + rankings: { + /** + * {game} User Rankings + */ + header: (arg: { game: string }) => LocalizedString + } banner: { /** * Welcome to {aquanet} diff --git a/src/routes/(app)/(nonuser)/home/+page.server.ts b/src/routes/(app)/(nonuser)/home/+page.server.ts index c90635f4..bda41bc5 100644 --- a/src/routes/(app)/(nonuser)/home/+page.server.ts +++ b/src/routes/(app)/(nonuser)/home/+page.server.ts @@ -1,5 +1,21 @@ +import { api } from "$lib/api" +import { music } from "$lib/api/data" +import { coerceToGame } from "$lib/app/formatting.js" +import pickKeys from "$lib/utility/pickKeys" import { redirect } from "@sveltejs/kit" -export function load({ locals: { user } }) { +export async function load({ locals: { user }, parent }) { if (!user) throw redirect(307, "/") + + const { cardUserGames, activeGame } = await parent() + const targetGame = coerceToGame(activeGame) || "mai2" + + let songLeaderboard = (await api(`game/${targetGame}/song-pop`, {})).slice(0, 5) + + return { + songLeaderboard, + music: pickKeys(await music(targetGame!), + songLeaderboard.map(v => v.musicId) + ) + } } diff --git a/src/routes/(app)/(nonuser)/home/+page.svelte b/src/routes/(app)/(nonuser)/home/+page.svelte index 7f6c733d..cd98858a 100644 --- a/src/routes/(app)/(nonuser)/home/+page.svelte +++ b/src/routes/(app)/(nonuser)/home/+page.svelte @@ -1,14 +1,22 @@

- {$LL.home.songLeaderboard({game: $LL.games[data.activeGame as keyof typeof $LL.games]()})} + {$LL.home.leaderboard.header({game: $LL.games[data.activeGame as keyof typeof $LL.games]()})}

-
- {#each {length: 10} as _} - - {/each} -
- \ No newline at end of file + +

+ {$LL.home.rankings.header({game: $LL.games[data.activeGame as keyof typeof $LL.games]()})} +

+ \ No newline at end of file diff --git a/src/routes/(app)/(nonuser)/home/SongLeaderboard.svelte b/src/routes/(app)/(nonuser)/home/SongLeaderboard.svelte new file mode 100644 index 00000000..0ae5078c --- /dev/null +++ b/src/routes/(app)/(nonuser)/home/SongLeaderboard.svelte @@ -0,0 +1,84 @@ + +
+ {#each songLeaderboard as song, index} +
+ Jacket + Background + +
+ + {index + 1}. + + {music[song.musicId]?.name ?? $LL.errors.missing({id: song.musicId})} +
+
+ {$LL.home.leaderboard.playsSuffix({plays: song.weight})} +
+
+ {/each} +
+ \ No newline at end of file diff --git a/static/asset/fallback/jacket.webp b/static/asset/fallback/jacket.webp new file mode 100644 index 00000000..c7d9c2c2 Binary files /dev/null and b/static/asset/fallback/jacket.webp differ diff --git a/static/asset/sample/banner-sample.jpg b/static/asset/sample/banner-sample.jpg deleted file mode 100644 index d5a5b64a..00000000 Binary files a/static/asset/sample/banner-sample.jpg and /dev/null differ diff --git a/static/asset/sample/onimai.png b/static/asset/sample/onimai.png deleted file mode 100644 index 8ae2c01b..00000000 Binary files a/static/asset/sample/onimai.png and /dev/null differ diff --git a/static/asset/sample/sample.png b/static/asset/sample/sample.png deleted file mode 100644 index d3ee8353..00000000 Binary files a/static/asset/sample/sample.png and /dev/null differ