diff --git a/admin/accounthttp.go b/admin/accounthttp.go index 634bae6..1e4742b 100644 --- a/admin/accounthttp.go +++ b/admin/accounthttp.go @@ -18,12 +18,12 @@ import ( func accountHandler(app *model.AppState) http.Handler { mux := http.NewServeMux() - mux.Handle("/account/totp-setup", totpSetupHandler(app)) - mux.Handle("/account/totp-confirm", totpConfirmHandler(app)) - mux.Handle("/account/totp-delete/", http.StripPrefix("/totp-delete", totpDeleteHandler(app))) + mux.Handle("/totp-setup", totpSetupHandler(app)) + mux.Handle("/totp-confirm", totpConfirmHandler(app)) + mux.Handle("/totp-delete/", http.StripPrefix("/totp-delete", totpDeleteHandler(app))) - mux.Handle("/account/password", changePasswordHandler(app)) - mux.Handle("/account/delete", deleteAccountHandler(app)) + mux.Handle("/password", changePasswordHandler(app)) + mux.Handle("/delete", deleteAccountHandler(app)) return mux } diff --git a/admin/artisthttp.go b/admin/artisthttp.go index 9d99fd4..8c33050 100644 --- a/admin/artisthttp.go +++ b/admin/artisthttp.go @@ -10,9 +10,9 @@ import ( "arimelody-web/model" ) -func serveArtists(app *model.AppState) http.Handler { +func serveArtist(app *model.AppState) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - slices := strings.Split(strings.TrimPrefix(r.URL.Path, "/artists")[1:], "/") + slices := strings.Split(r.URL.Path[1:], "/") id := slices[0] artist, err := controller.GetArtist(app.DB, id) if err != nil { diff --git a/admin/http.go b/admin/http.go index 1094095..136309e 100644 --- a/admin/http.go +++ b/admin/http.go @@ -47,16 +47,15 @@ func Handler(app *model.AppState) http.Handler { mux.Handle("/register", registerAccountHandler(app)) mux.Handle("/account", requireAccount(accountIndexHandler(app))) - mux.Handle("/account/", requireAccount(accountHandler(app))) + mux.Handle("/account/", requireAccount(http.StripPrefix("/account", accountHandler(app)))) mux.Handle("/logs", requireAccount(logsHandler(app))) - mux.Handle("/releases", requireAccount(serveReleases(app))) - mux.Handle("/releases/", requireAccount(serveReleases(app))) - mux.Handle("/artists/", requireAccount(serveArtists(app))) - mux.Handle("/tracks/", requireAccount(serveTracks(app))) + mux.Handle("/release/", requireAccount(http.StripPrefix("/release", serveRelease(app)))) + mux.Handle("/artist/", requireAccount(http.StripPrefix("/artist", serveArtist(app)))) + mux.Handle("/track/", requireAccount(http.StripPrefix("/track", serveTrack(app)))) - mux.Handle("/static/", staticHandler()) + mux.Handle("/static/", http.StripPrefix("/static", staticHandler())) mux.Handle("/", requireAccount(AdminIndexHandler(app))) @@ -471,8 +470,7 @@ var staticFS embed.FS func staticHandler() http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - uri := strings.TrimPrefix(r.URL.Path, "/static") - file, err := staticFS.ReadFile(filepath.Join("static", filepath.Clean(uri))) + file, err := staticFS.ReadFile(filepath.Join("static", filepath.Clean(r.URL.Path))) if err != nil { http.NotFound(w, r) return diff --git a/admin/releasehttp.go b/admin/releasehttp.go index 5484609..991845f 100644 --- a/admin/releasehttp.go +++ b/admin/releasehttp.go @@ -3,7 +3,6 @@ package admin import ( "fmt" "net/http" - "os" "strings" "arimelody-web/admin/templates" @@ -11,52 +10,11 @@ import ( "arimelody-web/model" ) -func serveReleases(app *model.AppState) http.Handler { +func serveRelease(app *model.AppState) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - slices := strings.Split(strings.TrimPrefix(r.URL.Path, "/releases")[1:], "/") + slices := strings.Split(r.URL.Path[1:], "/") releaseID := slices[0] - var action string = "" - if len(slices) > 1 { - action = slices[1] - } - - if len(releaseID) > 0 { - serveRelease(app, releaseID, action).ServeHTTP(w, r) - return - } - - session := r.Context().Value("session").(*model.Session) - - type ReleasesData struct { - adminPageData - Releases []*model.Release - } - - releases, err := controller.GetAllReleases(app.DB, false, 0, true) - if err != nil { - fmt.Fprintf(os.Stderr, "WARN: Failed to pull releases: %s\n", err) - http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) - return - } - - err = templates.ReleasesTemplate.Execute(w, ReleasesData{ - adminPageData: adminPageData{ - Path: r.URL.Path, - Session: session, - }, - Releases: releases, - }) - if err != nil { - fmt.Fprintf(os.Stderr, "WARN: Failed to render releases page: %s\n", err) - http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) - return - } - }) -} - -func serveRelease(app *model.AppState, releaseID string, action string) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { session := r.Context().Value("session").(*model.Session) release, err := controller.GetRelease(app.DB, releaseID, true) @@ -70,8 +28,8 @@ func serveRelease(app *model.AppState, releaseID string, action string) http.Han return } - if len(action) > 0 { - switch action { + if len(slices) > 1 { + switch slices[1] { case "editcredits": serveEditCredits(release).ServeHTTP(w, r) return diff --git a/admin/static/admin.css b/admin/static/admin.css index ab736f2..7dad27f 100644 --- a/admin/static/admin.css +++ b/admin/static/admin.css @@ -66,13 +66,6 @@ } } -@media (prefers-color-scheme: dark) { - img.icon { - -webkit-filter: invert(1); - filter: invert(1); - } -} - body { width: calc(100% - 180px); height: calc(100vh - 1em); @@ -191,9 +184,8 @@ a:hover { } */ -img.icon { +a img.icon { height: .8em; - transition: filter .1s ease-out; } code { diff --git a/admin/static/edit-artist.js b/admin/static/edit-artist.js index 069c25d..2ca4c0d 100644 --- a/admin/static/edit-artist.js +++ b/admin/static/edit-artist.js @@ -81,7 +81,7 @@ removeAvatarBtn.addEventListener("click", () => { }); document.addEventListener('readystatechange', () => { - document.querySelectorAll('#releases .credit').forEach(el => { + document.querySelectorAll('.card#releases .credit').forEach(el => { hijackClickEvent(el, el.querySelector('.credit-name a')); }); }); diff --git a/admin/static/edit-release.css b/admin/static/edit-release.css index b8817e0..b4fe17b 100644 --- a/admin/static/edit-release.css +++ b/admin/static/edit-release.css @@ -14,8 +14,6 @@ input[type="text"] { border-radius: 8px; background: var(--bg-2); box-shadow: var(--shadow-md); - - transition: background .1s ease-out, color .1s ease-out; } .release-artwork { @@ -33,7 +31,6 @@ input[type="text"] { .release-artwork #remove-artwork { margin-top: .5em; padding: .3em .6em; - background: var(--bg-3); } .release-info { @@ -121,7 +118,6 @@ input[type="text"] { gap: .5em; flex-direction: row; justify-content: right; - color: var(--fg-3); } .release-actions button, @@ -167,7 +163,7 @@ dialog div.dialog-actions { * RELEASE CREDITS */ -#credits .credit { +.card#credits .credit { margin-bottom: .5em; padding: .5em; display: flex; @@ -182,24 +178,24 @@ dialog div.dialog-actions { cursor: pointer; transition: background .1s ease-out; } -#credits .credit:hover { +.card#credits .credit:hover { background-color: var(--bg-1); } -#credits .credit p { +.card#credits .credit p { margin: 0; } -#credits .credit .artist-avatar { +.card#credits .credit .artist-avatar { border-radius: 12px; } -#credits .credit .artist-name { +.card#credits .credit .artist-name { color: var(--fg-3); font-weight: bold; } -#credits .credit .artist-role small { +.card#credits .credit .artist-role small { font-size: inherit; opacity: .66; } @@ -318,38 +314,33 @@ dialog div.dialog-actions { * RELEASE LINKS */ -#links ul { +.card#links ul { padding: 0; display: flex; gap: .2em; } -#links a img.icon { - -webkit-filter: none; - filter: none; -} - -#links a.button:hover { +.card#links a.button:hover { color: var(--bg-3) !important; background-color: var(--fg-3) !important; } -#links a.button[data-name="spotify"] { +.card#links a.button[data-name="spotify"] { color: #101010; background-color: #8cff83 } -#links a.button[data-name="apple music"] { +.card#links a.button[data-name="apple music"] { color: #101010; background-color: #8cd9ff } -#links a.button[data-name="soundcloud"] { +.card#links a.button[data-name="soundcloud"] { color: #101010; background-color: #fdaa6d } -#links a.button[data-name="youtube"] { +.card#links a.button[data-name="youtube"] { color: #101010; background-color: #ff6e6e } @@ -437,7 +428,7 @@ dialog div.dialog-actions { * RELEASE TRACKS */ -#tracks .track { +.card#tracks .track { margin-bottom: 1em; padding: 1em; display: flex; @@ -447,51 +438,49 @@ dialog div.dialog-actions { border-radius: 16px; background: var(--bg-2); box-shadow: var(--shadow-md); - - transition: background .1s ease-out, color .1s ease-out; } -#tracks .track h3, -#tracks .track p { +.card#tracks .track h3, +.card#tracks .track p { margin: 0; } -#tracks h2.track-title { +.card#tracks h2.track-title { margin: 0; display: flex; gap: .5em; } -#tracks h2.track-title .track-number { +.card#tracks h2.track-title .track-number { opacity: .5; } -#tracks a:hover { +.card#tracks a:hover { text-decoration: underline; } -#tracks .track-album { +.card#tracks .track-album { margin-left: auto; font-style: italic; font-size: .75em; opacity: .5; } -#tracks .track-album.empty { +.card#tracks .track-album.empty { color: #ff2020; opacity: 1; } -#tracks .track-description { +.card#tracks .track-description { font-style: italic; } -#tracks .track-lyrics { +.card#tracks .track-lyrics { max-height: 10em; overflow-y: scroll; } -#tracks .track .empty { +.card#tracks .track .empty { opacity: 0.75; } diff --git a/admin/static/edit-release.js b/admin/static/edit-release.js index ca2754f..5db4bbf 100644 --- a/admin/static/edit-release.js +++ b/admin/static/edit-release.js @@ -100,7 +100,7 @@ removeArtworkBtn.addEventListener("click", () => { }); document.addEventListener("readystatechange", () => { - document.querySelectorAll("#credits .credit").forEach(el => { + document.querySelectorAll(".card#credits .credit").forEach(el => { hijackClickEvent(el, el.querySelector(".artist-name a")); }); }); diff --git a/admin/static/index.js b/admin/static/index.js index c6f6b58..c35b596 100644 --- a/admin/static/index.js +++ b/admin/static/index.js @@ -14,7 +14,7 @@ newReleaseBtn.addEventListener("click", event => { headers: { "Content-Type": "application/json" }, body: JSON.stringify({id}) }).then(res => { - if (res.ok) location = "/admin/releases/" + id; + if (res.ok) location = "/admin/release/" + id; else { res.text().then(err => { alert("Request failed: " + err); @@ -39,7 +39,7 @@ newArtistBtn.addEventListener("click", event => { }).then(res => { res.text().then(text => { if (res.ok) { - location = "/admin/artists/" + id; + location = "/admin/artist/" + id; } else { alert("Request failed: " + text); console.error(text); @@ -63,7 +63,7 @@ newTrackBtn.addEventListener("click", event => { }).then(res => { res.text().then(text => { if (res.ok) { - location = "/admin/tracks/" + text; + location = "/admin/track/" + text; } else { alert("Request failed: " + text); console.error(text); diff --git a/admin/static/release-list-item.css b/admin/static/release-list-item.css index aedd121..3481257 100644 --- a/admin/static/release-list-item.css +++ b/admin/static/release-list-item.css @@ -51,7 +51,6 @@ .release-actions { margin-top: .5em; user-select: none; - color: var(--fg-3); } .release-actions a { diff --git a/admin/templates/html/artists.html b/admin/templates/html/artists.html deleted file mode 100644 index 7b2a464..0000000 --- a/admin/templates/html/artists.html +++ /dev/null @@ -1,30 +0,0 @@ -{{define "head"}} -Artists - ari melody 💫 - - -{{end}} - -{{define "content"}} -
-

Artists

- -
-

Artists

- Create New -
- {{if .Artists}} -
- {{range $Artist := .Artists}} - - {{end}} -
- {{else}} -

There are no artists.

- {{end}} -
- - -{{end}} diff --git a/admin/templates/html/components/credits/addcredit.html b/admin/templates/html/components/credits/addcredit.html index 082ba17..c09a550 100644 --- a/admin/templates/html/components/credits/addcredit.html +++ b/admin/templates/html/components/credits/addcredit.html @@ -7,7 +7,7 @@ {{range $Artist := .Artists}}
  • diff --git a/admin/templates/html/components/credits/editcredits.html b/admin/templates/html/components/credits/editcredits.html index 38132e2..94dc268 100644 --- a/admin/templates/html/components/credits/editcredits.html +++ b/admin/templates/html/components/credits/editcredits.html @@ -3,8 +3,8 @@

    Editing: Credits

    Add diff --git a/admin/templates/html/components/release/release-list-item.html b/admin/templates/html/components/release/release-list-item.html index 7a5059d..4b8f41e 100644 --- a/admin/templates/html/components/release/release-list-item.html +++ b/admin/templates/html/components/release/release-list-item.html @@ -5,7 +5,7 @@

    - {{.Title}} + {{.Title}} {{.ReleaseDate.Year}} {{if not .Visible}}(hidden){{end}} @@ -13,9 +13,9 @@

    {{.PrintArtists true true}}

    {{.ReleaseType}} - ({{len .Tracks}} track{{if not (eq (len .Tracks) 1)}}s{{end}})

    + ({{len .Tracks}} track{{if not (eq (len .Tracks) 1)}}s{{end}})

    diff --git a/admin/templates/html/components/tracks/addtrack.html b/admin/templates/html/components/tracks/addtrack.html index 6a2360b..a6dd433 100644 --- a/admin/templates/html/components/tracks/addtrack.html +++ b/admin/templates/html/components/tracks/addtrack.html @@ -8,7 +8,7 @@
  • diff --git a/admin/templates/html/components/tracks/edittracks.html b/admin/templates/html/components/tracks/edittracks.html index c06f0c3..d03f80a 100644 --- a/admin/templates/html/components/tracks/edittracks.html +++ b/admin/templates/html/components/tracks/edittracks.html @@ -3,8 +3,8 @@

    Editing: Tracks

    Add diff --git a/admin/templates/html/edit-artist.html b/admin/templates/html/edit-artist.html index 9bb5a83..6b95de8 100644 --- a/admin/templates/html/edit-artist.html +++ b/admin/templates/html/edit-artist.html @@ -38,7 +38,7 @@
    -

    {{.Release.Title}}

    +

    {{.Release.Title}}

    {{.Release.PrintArtists true true}}

    Role: {{.Role}} diff --git a/admin/templates/html/edit-release.html b/admin/templates/html/edit-release.html index 9a16f65..309decf 100644 --- a/admin/templates/html/edit-release.html +++ b/admin/templates/html/edit-release.html @@ -99,10 +99,10 @@

    -

    Credits ({{len .Release.Credits}} total)

    +

    Credits ({{len .Release.Credits}})

    Edit @@ -111,7 +111,7 @@
    -

    {{.Artist.Name}}

    +

    {{.Artist.Name}}

    {{.Role}} {{if .Primary}} @@ -130,8 +130,8 @@

    Links ({{len .Release.Links}})

    Edit @@ -147,8 +147,8 @@

    Tracklist ({{len .Release.Tracks}})

    Edit @@ -157,7 +157,7 @@

    {{.Add $i 1}} - {{$track.Title}} + {{$track.Title}}

    Description

    diff --git a/admin/templates/html/index.html b/admin/templates/html/index.html index 581c691..dc97a3e 100644 --- a/admin/templates/html/index.html +++ b/admin/templates/html/index.html @@ -32,7 +32,7 @@ {{range $Artist := .Artists}} {{end}}
    @@ -51,7 +51,7 @@ {{range $Track := .Tracks}}

    - {{$Track.Title}} + {{$Track.Title}}

    {{if $Track.Description}}

    {{$Track.GetDescriptionHTML}}

    diff --git a/admin/templates/html/layout.html b/admin/templates/html/layout.html index 0aaf9ca..55f2359 100644 --- a/admin/templates/html/layout.html +++ b/admin/templates/html/layout.html @@ -28,14 +28,14 @@

    -