diff --git a/docker-compose.yml b/docker-compose.yml index 0681b2d..14b5d6e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,4 +7,19 @@ services: ports: - "8007:8007" restart: unless-stopped + networks: + - proxy + labels: + - "traefik.enable=true" + - "traefik.http.routers.music.rule=Host(`music.araozu.dev`)" + - "traefik.http.routers.music.entrypoints=websecure" + - "traefik.http.routers.music.tls=true" + - "traefik.http.routers.music.tls.certresolver=araozu-wildcard" + - "traefik.http.routers.music.tls.domains[0].main=araozu.dev" + - "traefik.http.routers.music.tls.domains[0].sans=*.araozu.dev" + + +networks: + proxy: + external: true diff --git a/src/modules/album/album.go b/src/modules/album/album.go index 0cd2daf..13d42fa 100644 --- a/src/modules/album/album.go +++ b/src/modules/album/album.go @@ -52,6 +52,7 @@ func allAlbumsPage(c echo.Context) error { func albumPage(c echo.Context) error { token, server := utils.Credentials(c) + isHtmxRequest := c.Request().Header.Get("HX-Request") == "true" albumId := c.Param("id") // load album info and song list on the background @@ -110,5 +111,9 @@ func albumPage(c echo.Context) error { } clientSongsJson := buff.String() - return utils.RenderTempl(c, http.StatusOK, albumTempl(albumId, album, songs, string(clientSongsJson))) + if isHtmxRequest { + return utils.RenderTempl(c, http.StatusOK, albumTemplFragment(albumId, album, songs, string(clientSongsJson))) + } else { + return utils.RenderTempl(c, http.StatusOK, albumTempl(albumId, album, songs, string(clientSongsJson))) + } } diff --git a/src/modules/album/album.templ b/src/modules/album/album.templ index 9fe0cab..29f680d 100644 --- a/src/modules/album/album.templ +++ b/src/modules/album/album.templ @@ -59,31 +59,35 @@ templ albumsFragment(albums []utils.Album) { // Renders the page of a single Album templ albumTempl(albumId string, album *utils.Album, songs []utils.Song, songsJson string) { @utils.SkeletonTempl() { -
- -

- { album.Name } -

-

- { album.Artist } -

-
- for i, song := range songs { - - } -
-
- @utils.MusicPlayer() + @albumTemplFragment(albumId, album, songs, songsJson) } } + +// Renders the page of a single album, but as a fragment without a skeleton +templ albumTemplFragment(albumId string, album *utils.Album, songs []utils.Song, songsJson string) { +
+ +

+ { album.Name } +

+

+ { album.Artist } +

+
+ for i, song := range songs { + + } +
+
+} diff --git a/src/modules/index/index.templ b/src/modules/index/index.templ index f8f128e..edc7235 100644 --- a/src/modules/index/index.templ +++ b/src/modules/index/index.templ @@ -23,7 +23,6 @@ templ IndexTempl(albums []utils.Album) { @AlbumCard(album) } - @utils.MusicPlayer() } } diff --git a/src/utils/utils.templ b/src/utils/utils.templ index 54459a0..accbdd6 100644 --- a/src/utils/utils.templ +++ b/src/utils/utils.templ @@ -16,13 +16,15 @@ templ SkeletonTempl() { + -
+
{ children... }
+ @MusicPlayer() } @@ -31,6 +33,7 @@ templ MusicPlayer() {
@fullMusicPlayer()