From 941557cba8dcf2aae9b08e2f61420437f5603b0c Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 4 Mar 2025 21:22:14 +0900 Subject: change port --- frontend/app/.client/audio/SoundEffect.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'frontend/app/.client/audio') diff --git a/frontend/app/.client/audio/SoundEffect.ts b/frontend/app/.client/audio/SoundEffect.ts index 7e40da6..fb003fa 100644 --- a/frontend/app/.client/audio/SoundEffect.ts +++ b/frontend/app/.client/audio/SoundEffect.ts @@ -14,7 +14,7 @@ export type SoundEffect = const BASE_URL = process.env.NODE_ENV === "development" - ? `http://localhost:8002/iosdc-japan/2024/code-battle/files/audio` + ? `http://localhost:8003/iosdc-japan/2024/code-battle/files/audio` : `/iosdc-japan/2024/code-battle/files/audio`; export function getFileUrl(soundEffect: SoundEffect): string { -- cgit v1.2.3-70-g09d2 From 9b1049e39b2e6e45371930832b421be21297dcb5 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 4 Mar 2025 21:26:39 +0900 Subject: change base path --- README.md | 2 +- backend/admin/handler.go | 2 +- backend/main.go | 14 +++++++------- docs/DEV.md | 2 +- frontend/app/.client/audio/SoundEffect.ts | 4 ++-- frontend/app/.server/api/client.ts | 4 ++-- frontend/app/components/GolfPlayApp.client.tsx | 4 ++-- frontend/app/components/GolfWatchApp.client.tsx | 4 ++-- frontend/app/components/UserIcon.tsx | 4 ++-- frontend/app/root.tsx | 2 +- frontend/app/routes/_index.tsx | 2 +- frontend/app/routes/dashboard.tsx | 4 ++-- frontend/vite.config.ts | 4 ++-- nginx.conf | 10 +++++----- 14 files changed, 31 insertions(+), 31 deletions(-) (limited to 'frontend/app/.client/audio') diff --git a/README.md b/README.md index 0f168a9..d0f4c3b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ 2024-08-22 から 2024-08-24 にかけて開催された [iOSDC Japan 2024](https://iosdc.jp/2024/) の中の企画、Swift コードバトルのシステムです。 -[サイトはこちら (現在は新規にプレイすることはできません)](https://t.nil.ninja/iosdc-japan/2024/code-battle/) +[サイトはこちら (現在は新規にプレイすることはできません)](https://t.nil.ninja/phperkaigi/2025/code-battle/) # サンドボックス化の仕組み diff --git a/backend/admin/handler.go b/backend/admin/handler.go index 235e0be..c3e40e9 100644 --- a/backend/admin/handler.go +++ b/backend/admin/handler.go @@ -18,7 +18,7 @@ import ( ) const ( - basePath = "/iosdc-japan/2024/code-battle" + basePath = "/phperkaigi/2025/code-battle" ) var jst = time.FixedZone("Asia/Tokyo", 9*60*60) diff --git a/backend/main.go b/backend/main.go index f0448f1..1218b19 100644 --- a/backend/main.go +++ b/backend/main.go @@ -38,7 +38,7 @@ func main() { log.Fatalf("Error loading env %v", err) } - openAPISpec, err := api.GetSwaggerWithPrefix("/iosdc-japan/2024/code-battle/api") + openAPISpec, err := api.GetSwaggerWithPrefix("/phperkaigi/2025/code-battle/api") if err != nil { log.Fatalf("Error loading OpenAPI spec\n: %s", err) } @@ -69,7 +69,7 @@ func main() { log.Fatalf("Error restoring game hubs from db %v", err) } defer gameHubs.Close() - sockGroup := e.Group("/iosdc-japan/2024/code-battle/sock") + sockGroup := e.Group("/phperkaigi/2025/code-battle/sock") sockHandler := gameHubs.SockHandler() sockGroup.GET("/golf/:gameID/play", func(c echo.Context) error { return sockHandler.HandleSockGolfPlay(c) @@ -78,19 +78,19 @@ func main() { return sockHandler.HandleSockGolfWatch(c) }) - apiGroup := e.Group("/iosdc-japan/2024/code-battle/api") + apiGroup := e.Group("/phperkaigi/2025/code-battle/api") apiGroup.Use(oapimiddleware.OapiRequestValidator(openAPISpec)) apiHandler := api.NewHandler(queries, gameHubs) api.RegisterHandlers(apiGroup, api.NewStrictHandler(apiHandler, nil)) adminHandler := admin.NewHandler(queries, gameHubs) - adminGroup := e.Group("/iosdc-japan/2024/code-battle/admin") + adminGroup := e.Group("/phperkaigi/2025/code-battle/admin") adminHandler.RegisterHandlers(adminGroup) if config.isLocal { // For local dev: This is never used in production because the reverse // proxy directly handles /files. - filesGroup := e.Group("/iosdc-japan/2024/code-battle/files") + filesGroup := e.Group("/phperkaigi/2025/code-battle/files") filesGroup.Use(middleware.StaticWithConfig(middleware.StaticConfig{ Root: "/", Filesystem: http.Dir("/data/files"), @@ -99,10 +99,10 @@ func main() { // For local dev: This is never used in production because the reverse // proxy sends these paths to the app server. - e.GET("/iosdc-japan/2024/code-battle/*", func(c echo.Context) error { + e.GET("/phperkaigi/2025/code-battle/*", func(c echo.Context) error { return c.Redirect(http.StatusPermanentRedirect, "http://localhost:5173"+c.Request().URL.Path) }) - e.POST("/iosdc-japan/2024/code-battle/*", func(c echo.Context) error { + e.POST("/phperkaigi/2025/code-battle/*", func(c echo.Context) error { return c.Redirect(http.StatusPermanentRedirect, "http://localhost:5173"+c.Request().URL.Path) }) } diff --git a/docs/DEV.md b/docs/DEV.md index e91c6dc..7f79840 100644 --- a/docs/DEV.md +++ b/docs/DEV.md @@ -20,7 +20,7 @@ 1. `cd path/to/the/repo` 1. `make init` 1. `make up` -1. Access to http://localhost:5173/iosdc-japan/2024/code-battle/. +1. Access to http://localhost:5173/phperkaigi/2025/code-battle/. * User `a`, `b` and `c` can log in with `pass` password. * User `a` and `b` are players. * User `c` is an administrator. diff --git a/frontend/app/.client/audio/SoundEffect.ts b/frontend/app/.client/audio/SoundEffect.ts index fb003fa..99eccdd 100644 --- a/frontend/app/.client/audio/SoundEffect.ts +++ b/frontend/app/.client/audio/SoundEffect.ts @@ -14,8 +14,8 @@ export type SoundEffect = const BASE_URL = process.env.NODE_ENV === "development" - ? `http://localhost:8003/iosdc-japan/2024/code-battle/files/audio` - : `/iosdc-japan/2024/code-battle/files/audio`; + ? `http://localhost:8003/phperkaigi/2025/code-battle/files/audio` + : `/phperkaigi/2025/code-battle/files/audio`; export function getFileUrl(soundEffect: SoundEffect): string { switch (soundEffect) { diff --git a/frontend/app/.server/api/client.ts b/frontend/app/.server/api/client.ts index d69b617..edcffc1 100644 --- a/frontend/app/.server/api/client.ts +++ b/frontend/app/.server/api/client.ts @@ -4,8 +4,8 @@ import type { paths } from "./schema"; const apiClient = createClient({ baseUrl: process.env.NODE_ENV === "development" - ? "http://localhost:8003/iosdc-japan/2024/code-battle/api/" - : "http://api-server/iosdc-japan/2024/code-battle/api/", + ? "http://localhost:8003/phperkaigi/2025/code-battle/api/" + : "http://api-server/phperkaigi/2025/code-battle/api/", }); export async function apiPostLogin( diff --git a/frontend/app/components/GolfPlayApp.client.tsx b/frontend/app/components/GolfPlayApp.client.tsx index 48c2c89..c81fe7e 100644 --- a/frontend/app/components/GolfPlayApp.client.tsx +++ b/frontend/app/components/GolfPlayApp.client.tsx @@ -42,8 +42,8 @@ export default function GolfPlayApp({ }: Props) { const socketUrl = process.env.NODE_ENV === "development" - ? `ws://localhost:8003/iosdc-japan/2024/code-battle/sock/golf/${game.game_id}/play?token=${sockToken}` - : `wss://t.nil.ninja/iosdc-japan/2024/code-battle/sock/golf/${game.game_id}/play?token=${sockToken}`; + ? `ws://localhost:8003/phperkaigi/2025/code-battle/sock/golf/${game.game_id}/play?token=${sockToken}` + : `wss://t.nil.ninja/phperkaigi/2025/code-battle/sock/golf/${game.game_id}/play?token=${sockToken}`; const gameStateKind = useAtomValue(gameStateKindAtom); const setCurrentTimestamp = useSetAtom(setCurrentTimestampAtom); diff --git a/frontend/app/components/GolfWatchApp.client.tsx b/frontend/app/components/GolfWatchApp.client.tsx index 72db9e5..e80a009 100644 --- a/frontend/app/components/GolfWatchApp.client.tsx +++ b/frontend/app/components/GolfWatchApp.client.tsx @@ -33,8 +33,8 @@ export type Props = { export default function GolfWatchApp({ game, sockToken }: Props) { const socketUrl = process.env.NODE_ENV === "development" - ? `ws://localhost:8003/iosdc-japan/2024/code-battle/sock/golf/${game.game_id}/watch?token=${sockToken}` - : `wss://t.nil.ninja/iosdc-japan/2024/code-battle/sock/golf/${game.game_id}/watch?token=${sockToken}`; + ? `ws://localhost:8003/phperkaigi/2025/code-battle/sock/golf/${game.game_id}/watch?token=${sockToken}` + : `wss://t.nil.ninja/phperkaigi/2025/code-battle/sock/golf/${game.game_id}/watch?token=${sockToken}`; const gameStateKind = useAtomValue(gameStateKindAtom); const setCurrentTimestamp = useSetAtom(setCurrentTimestampAtom); diff --git a/frontend/app/components/UserIcon.tsx b/frontend/app/components/UserIcon.tsx index a4ee5e6..e14a571 100644 --- a/frontend/app/components/UserIcon.tsx +++ b/frontend/app/components/UserIcon.tsx @@ -9,8 +9,8 @@ export default function UserIcon({ iconPath, displayName, className }: Props) { {`${displayName} [ - { rel: "icon", href: "/iosdc-japan/2024/code-battle/favicon.svg" }, + { rel: "icon", href: "/phperkaigi/2025/code-battle/favicon.svg" }, ]; export function Layout({ children }: { children: React.ReactNode }) { diff --git a/frontend/app/routes/_index.tsx b/frontend/app/routes/_index.tsx index 808302d..ec4dfcb 100644 --- a/frontend/app/routes/_index.tsx +++ b/frontend/app/routes/_index.tsx @@ -16,7 +16,7 @@ export default function Index() { return (
iOSDC Japan 2024 diff --git a/frontend/app/routes/dashboard.tsx b/frontend/app/routes/dashboard.tsx index 53b32e0..a68d5c5 100644 --- a/frontend/app/routes/dashboard.tsx +++ b/frontend/app/routes/dashboard.tsx @@ -86,8 +86,8 @@ export default function Dashboard() { diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 983190a..004af2c 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -3,7 +3,7 @@ import { defineConfig } from "vite"; import tsconfigPaths from "vite-tsconfig-paths"; export default defineConfig({ - base: "/iosdc-japan/2024/code-battle/", + base: "/phperkaigi/2025/code-battle/", plugins: [ remix({ future: { @@ -11,7 +11,7 @@ export default defineConfig({ v3_relativeSplatPath: true, v3_throwAbortReason: true, }, - basename: "/iosdc-japan/2024/code-battle/", + basename: "/phperkaigi/2025/code-battle/", }), tsconfigPaths(), ], diff --git a/nginx.conf b/nginx.conf index f421647..4796bbf 100644 --- a/nginx.conf +++ b/nginx.conf @@ -12,11 +12,11 @@ http { server { listen 80; - location /iosdc-japan/2024/code-battle/files/ { + location /phperkaigi/2025/code-battle/files/ { alias /var/www/files/; } - location /iosdc-japan/2024/code-battle/api/ { + location /phperkaigi/2025/code-battle/api/ { proxy_pass http://api-server; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -24,7 +24,7 @@ http { proxy_set_header X-Forwarded-Proto $scheme; } - location /iosdc-japan/2024/code-battle/admin/ { + location /phperkaigi/2025/code-battle/admin/ { proxy_pass http://api-server; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -32,7 +32,7 @@ http { proxy_set_header X-Forwarded-Proto $scheme; } - location /iosdc-japan/2024/code-battle/sock/ { + location /phperkaigi/2025/code-battle/sock/ { proxy_pass http://api-server; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; @@ -43,7 +43,7 @@ http { proxy_set_header X-Forwarded-Proto $scheme; } - location /iosdc-japan/2024/code-battle/ { + location /phperkaigi/2025/code-battle/ { proxy_pass http://app-server; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; -- cgit v1.2.3-70-g09d2 From 5062cb9460915624e3f7b808c8f814ba9c31db75 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 4 Mar 2025 21:37:22 +0900 Subject: rm audio feature --- backend/admin/handler.go | 22 ----- backend/admin/templates/audio.html | 14 --- backend/admin/templates/dashboard.html | 3 - frontend/app/.client/audio/AudioController.ts | 105 --------------------- frontend/app/.client/audio/SoundEffect.ts | 47 --------- .../GolfWatchAppWithAudioPlayRequest.client.tsx | 34 ------- frontend/app/routes/golf.$gameId.watch.tsx | 4 +- frontend/app/states/watch.ts | 3 - 8 files changed, 2 insertions(+), 230 deletions(-) delete mode 100644 backend/admin/templates/audio.html delete mode 100644 frontend/app/.client/audio/AudioController.ts delete mode 100644 frontend/app/.client/audio/SoundEffect.ts delete mode 100644 frontend/app/components/GolfWatchAppWithAudioPlayRequest.client.tsx (limited to 'frontend/app/.client/audio') diff --git a/backend/admin/handler.go b/backend/admin/handler.go index c3e40e9..ca70639 100644 --- a/backend/admin/handler.go +++ b/backend/admin/handler.go @@ -69,7 +69,6 @@ func (h *Handler) RegisterHandlers(g *echo.Group) { g.GET("/games", h.getGames) g.GET("/games/:gameID", h.getGameEdit) g.POST("/games/:gameID", h.postGameEdit) - g.GET("/audio", h.getAudioTest) } func (h *Handler) getDashboard(c echo.Context) error { @@ -290,24 +289,3 @@ func (h *Handler) postGameEdit(c echo.Context) error { return c.Redirect(http.StatusSeeOther, basePath+"/admin/games") } - -func (h *Handler) getAudioTest(c echo.Context) error { - return c.Render(http.StatusOK, "audio", echo.Map{ - "BasePath": basePath, - "Title": "Audio Test", - "Audio": []echo.Map{ - {"FileName": "EX_33.wav", "Label": "終了"}, - {"FileName": "EX_34.wav", "Label": "勝敗1"}, - {"FileName": "EX_35.wav", "Label": "勝敗2"}, - {"FileName": "EX_36.wav", "Label": "グッド1"}, - {"FileName": "EX_37.wav", "Label": "グッド2"}, - {"FileName": "EX_38.wav", "Label": "グッド3"}, - {"FileName": "EX_39.wav", "Label": "グッド4"}, - {"FileName": "EX_40.wav", "Label": "スコア更新1"}, - {"FileName": "EX_41.wav", "Label": "スコア更新2"}, - {"FileName": "EX_42.wav", "Label": "スコア更新3"}, - {"FileName": "EX_43.wav", "Label": "コンパイルエラー1"}, - {"FileName": "EX_44.wav", "Label": "コンパイルエラー2"}, - }, - }) -} diff --git a/backend/admin/templates/audio.html b/backend/admin/templates/audio.html deleted file mode 100644 index 21ec463..0000000 --- a/backend/admin/templates/audio.html +++ /dev/null @@ -1,14 +0,0 @@ -{{ template "base.html" . }} - -{{ define "breadcrumb" }} -Dashboard -{{ end }} - -{{ define "content" }} - {{ range .Audio }} -
-
{{ .Label }}
- -
- {{ end }} -{{ end }} diff --git a/backend/admin/templates/dashboard.html b/backend/admin/templates/dashboard.html index 0f1fbaf..15b10ff 100644 --- a/backend/admin/templates/dashboard.html +++ b/backend/admin/templates/dashboard.html @@ -7,9 +7,6 @@

Games

-

- Audio Test -

diff --git a/frontend/app/.client/audio/AudioController.ts b/frontend/app/.client/audio/AudioController.ts deleted file mode 100644 index 296f685..0000000 --- a/frontend/app/.client/audio/AudioController.ts +++ /dev/null @@ -1,105 +0,0 @@ -import { SoundEffect, getFileUrl } from "./SoundEffect"; - -export class AudioController { - audioElements: Record; - - constructor() { - this.audioElements = { - finish: null, - winner_1: null, - winner_2: null, - good_1: null, - good_2: null, - good_3: null, - good_4: null, - new_score_1: null, - new_score_2: null, - new_score_3: null, - compile_error_1: null, - compile_error_2: null, - }; - } - - loadAll(): Promise { - return new Promise((resolve) => { - const files = Object.keys(this.audioElements).map( - (se) => [se as SoundEffect, getFileUrl(se as SoundEffect)] as const, - ); - const totalCount = files.length; - let loadedCount = 0; - - files.forEach(([se, fileUrl]) => { - const audio = new Audio(fileUrl); - - audio.addEventListener( - "canplaythrough", - () => { - loadedCount++; - this.audioElements[se] = audio; - if (loadedCount === totalCount) { - resolve(); - } - }, - { once: true }, - ); - - audio.addEventListener("error", () => { - console.log(`Failed to load audio file: ${fileUrl}`); - // Ignore the error and continue loading other files. - }); - }); - }); - } - - async playDummySoundEffect(): Promise { - const audio = this.audioElements["good_1"]; - if (!audio) { - return; - } - audio.muted = true; - audio.currentTime = 0; - await audio.play(); - audio.muted = false; - } - - async playSoundEffect(soundEffect: SoundEffect): Promise { - const audio = this.audioElements[soundEffect]; - if (!audio) { - return; - } - audio.currentTime = 0; - await audio.play(); - } - - async playSoundEffectFinish(): Promise { - await this.playSoundEffect("finish"); - } - - async playSoundEffectWinner(winner: 1 | 2): Promise { - await this.playSoundEffect(`winner_${winner}`); - } - - async playSoundEffectGood(): Promise { - const variant = Math.floor(Math.random() * 4) + 1; - if (variant !== 1 && variant !== 2 && variant !== 3 && variant !== 4) { - return; // unreachable - } - return await this.playSoundEffect(`good_${variant}`); - } - - async playSoundEffectNewScore(): Promise { - const variant = Math.floor(Math.random() * 3) + 1; - if (variant !== 1 && variant !== 2 && variant !== 3) { - return; // unreachable - } - return await this.playSoundEffect(`new_score_${variant}`); - } - - async playSoundEffectCompileError(): Promise { - const variant = Math.floor(Math.random() * 2) + 1; - if (variant !== 1 && variant !== 2) { - return; // unreachable - } - return await this.playSoundEffect(`compile_error_${variant}`); - } -} diff --git a/frontend/app/.client/audio/SoundEffect.ts b/frontend/app/.client/audio/SoundEffect.ts deleted file mode 100644 index 99eccdd..0000000 --- a/frontend/app/.client/audio/SoundEffect.ts +++ /dev/null @@ -1,47 +0,0 @@ -export type SoundEffect = - | "finish" - | "winner_1" - | "winner_2" - | "good_1" - | "good_2" - | "good_3" - | "good_4" - | "new_score_1" - | "new_score_2" - | "new_score_3" - | "compile_error_1" - | "compile_error_2"; - -const BASE_URL = - process.env.NODE_ENV === "development" - ? `http://localhost:8003/phperkaigi/2025/code-battle/files/audio` - : `/phperkaigi/2025/code-battle/files/audio`; - -export function getFileUrl(soundEffect: SoundEffect): string { - switch (soundEffect) { - case "finish": - return `${BASE_URL}/EX_33.wav`; - case "winner_1": - return `${BASE_URL}/EX_34.wav`; - case "winner_2": - return `${BASE_URL}/EX_35.wav`; - case "good_1": - return `${BASE_URL}/EX_36.wav`; - case "good_2": - return `${BASE_URL}/EX_37.wav`; - case "good_3": - return `${BASE_URL}/EX_38.wav`; - case "good_4": - return `${BASE_URL}/EX_39.wav`; - case "new_score_1": - return `${BASE_URL}/EX_40.wav`; - case "new_score_2": - return `${BASE_URL}/EX_41.wav`; - case "new_score_3": - return `${BASE_URL}/EX_42.wav`; - case "compile_error_1": - return `${BASE_URL}/EX_43.wav`; - case "compile_error_2": - return `${BASE_URL}/EX_44.wav`; - } -} diff --git a/frontend/app/components/GolfWatchAppWithAudioPlayRequest.client.tsx b/frontend/app/components/GolfWatchAppWithAudioPlayRequest.client.tsx deleted file mode 100644 index ce5a59c..0000000 --- a/frontend/app/components/GolfWatchAppWithAudioPlayRequest.client.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { useAtom } from "jotai"; -import { AudioController } from "../.client/audio/AudioController"; -import { audioControllerAtom } from "../states/watch"; -import GolfWatchApp, { type Props } from "./GolfWatchApp.client"; -import SubmitButton from "./SubmitButton"; - -export default function GolfWatchAppWithAudioPlayRequest({ - game, - sockToken, -}: Omit) { - const [audioController, setAudioController] = useAtom(audioControllerAtom); - const audioPlayPermitted = audioController !== null; - - if (audioPlayPermitted) { - return ; - } else { - return ( -
-
- { - const audioController = new AudioController(); - await audioController.loadAll(); - await audioController.playDummySoundEffect(); - setAudioController(audioController); - }} - > - 開始 - -
-
- ); - } -} diff --git a/frontend/app/routes/golf.$gameId.watch.tsx b/frontend/app/routes/golf.$gameId.watch.tsx index f04f6b0..cdfc908 100644 --- a/frontend/app/routes/golf.$gameId.watch.tsx +++ b/frontend/app/routes/golf.$gameId.watch.tsx @@ -3,7 +3,7 @@ import { ClientLoaderFunctionArgs, useLoaderData } from "@remix-run/react"; import { useHydrateAtoms } from "jotai/utils"; import { apiGetGame, apiGetToken } from "../.server/api/client"; import { ensureUserLoggedIn } from "../.server/auth"; -import GolfWatchAppWithAudioPlayRequest from "../components/GolfWatchAppWithAudioPlayRequest.client"; +import GolfWatchApp from "../components/GolfWatchApp.client"; import GolfWatchAppConnecting from "../components/GolfWatchApps/GolfWatchAppConnecting"; import { codeAAtom, @@ -183,5 +183,5 @@ export default function GolfWatch() { [submitResultBAtom, playerStateB.submitResult], ]); - return ; + return ; } diff --git a/frontend/app/states/watch.ts b/frontend/app/states/watch.ts index 5f5c4db..cb719eb 100644 --- a/frontend/app/states/watch.ts +++ b/frontend/app/states/watch.ts @@ -1,5 +1,4 @@ import { atom } from "jotai"; -import { AudioController } from "../.client/audio/AudioController"; import type { components } from "../.server/api/schema"; import type { SubmitResult } from "../types/SubmitResult"; @@ -251,5 +250,3 @@ export const handleWsSubmitResultMessageAtom = atom( callback(player_id, newResult, score); }, ); - -export const audioControllerAtom = atom(null); -- cgit v1.2.3-70-g09d2