commit cffaa503c72d25adc9062981bf1be8aa74451407 from: mtmn date: Sat Jun 20 00:26:01 2026 UTC feat: new navbar, colors, double trigger fixes, etc. commit - c4b7ce378af0cfffac7da1830a9a4f093e9e449c commit + cffaa503c72d25adc9062981bf1be8aa74451407 blob - cde7042199852340b13d1dbf1f9b8463fb00801a blob + 001c24e5c57eb72c00ca4637507b4ad114198748 --- README.md +++ README.md @@ -1,4 +1,8 @@ -# corpus +
+corpus + +
+ [![builds.sr.ht status](https://builds.sr.ht/~mtmn/corpus.svg)](https://builds.sr.ht/~mtmn/corpus?) A self-hosted [ListenBrainz](https://listenbrainz.org) and [Last.fm](https://last.fm) frontend that stores metadata and cover images. blob - /dev/null blob + 5e524a83f88b6c588a417e24969caeaa79795edd (mode 644) Binary files /dev/null and assets/cover.webp differ blob - 0b82d68ca944666469e4faf27dd30f8e7744eddf blob + 117e5c6c11447dfb307158ca9cf0565adbddf45d --- src/Api.elm +++ src/Api.elm @@ -75,11 +75,11 @@ statsUrl userSlug period mSection = "/stats?user=" ++ userSlug ++ periodPart ++ sectionPart -fetchSimilarTracks : String -> String -> Cmd Msg -fetchSimilarTracks artist track = +fetchSimilarTracks : Int -> String -> String -> Cmd Msg +fetchSimilarTracks idx artist track = Http.get { url = "/similar?artist=" ++ Url.percentEncode artist ++ "&track=" ++ Url.percentEncode track - , expect = Http.expectJson (FetchSimilarTracks artist track) similarTracksDecoder + , expect = Http.expectJson (FetchSimilarTracks idx artist track) similarTracksDecoder } blob - f93a782aaa84327b39b9e0e8969439f641a4b235 blob + dcb433e04dac789877f618236040b9f0cc9874ec --- src/Main.purs +++ src/Main.purs @@ -92,6 +92,8 @@ routeRequest metricsEnabled corsOrigin contexts req ur serveClientJs res "/favicon.png" -> serveAsset "image/png" "assets/favicon.png" res + "/cover.webp" -> + serveAsset "image/webp" "assets/cover.webp" res "/" -> serveIndex allUsers "" res "/metrics" -> blob - 624837037fccbed2979f91d77a611d1d825c2882 blob + 28cce86e825e08eb3309f5200d7d2c3a2838f295 --- src/State.elm +++ src/State.elm @@ -45,6 +45,7 @@ init flags url navKey = , allUsers = flags.allUsers , searchInput = "" , activeSearch = Nothing + , tabsVisible = False } , Cmd.batch [ fetchListens flags.userSlug 25 offset Nothing Nothing @@ -274,6 +275,9 @@ update msg model = Cmd.none ) + ToggleTabs -> + ( { model | tabsVisible = not model.tabsVisible }, Cmd.none ) + SetStatsPeriod period -> ( { model | statsPeriod = period @@ -438,23 +442,23 @@ update msg model = , Cmd.none ) - FetchSimilar artist track -> + FetchSimilar idx artist track -> let key = - artist ++ "\t" ++ track + String.fromInt idx ++ "\t" ++ artist ++ "\t" ++ track in if Dict.member key model.similarStates then ( { model | similarStates = Dict.remove key model.similarStates }, Cmd.none ) else ( { model | similarStates = Dict.insert key SimilarLoading model.similarStates } - , fetchSimilarTracks artist track + , fetchSimilarTracks idx artist track ) - FetchSimilarTracks artist track result -> + FetchSimilarTracks idx artist track result -> let key = - artist ++ "\t" ++ track + String.fromInt idx ++ "\t" ++ artist ++ "\t" ++ track newStates = case result of blob - b830780c2891d7507c99d98fca7100a840d7f200 blob + 54bedbe5c6371112153fdc17601db6681b0bb8db --- src/Templates.purs +++ src/Templates.purs @@ -22,15 +22,15 @@ indexHtml userSlug allUsers = blob - 7adb3ac7c482467cf4d8f4ce220366aeb3139639 blob + 997f7c0a7393abaea3ae558fcede5d6a046d840f --- src/Types.elm +++ src/Types.elm @@ -112,6 +112,7 @@ type alias Model = , allUsers : List UserInfo , searchInput : String , activeSearch : Maybe String + , tabsVisible : Bool } @@ -125,6 +126,7 @@ type Msg | NextPage | PrevPage | SwitchTab Tab + | ToggleTabs | SetStatsPeriod Period | OpenCustomInput | UpdateCustomInput String @@ -136,8 +138,8 @@ type Msg | ExpandSection String | ShowAllSection String | CollapseSection String - | FetchSimilar String String - | FetchSimilarTracks String String (Result Http.Error (List SimilarTrack)) + | FetchSimilar Int String String + | FetchSimilarTracks Int String String (Result Http.Error (List SimilarTrack)) | UpdateSearchInput String | SubmitSearch | ClearSearch blob - 8835b814d54daec751ea92dc61b6398a045325a2 blob + 2324b16003998db561d027d6488ba2b22d5513e0 --- src/View.elm +++ src/View.elm @@ -21,8 +21,10 @@ view model = { title = "scrobbler" , body = [ div [ class "container" ] - [ h1 [] [ text "scrobbler" ] - , div [ class "tabs" ] + [ h1 [ class "site-header", onClick ToggleTabs ] + [ img [ src "/cover.webp", Attr.alt "scrobbler" ] [] ] + , if model.tabsVisible then + div [ class "tabs" ] [ a [ class ("tab-btn" @@ -69,6 +71,9 @@ view model = ] [ text "about" ] ] + + else + text "" , case model.activeTab of ListensTab -> div [] @@ -157,7 +162,7 @@ renderContent model = Maybe.withDefault "" listen.trackName key = - artist ++ "\t" ++ trackName + String.fromInt idx ++ "\t" ++ artist ++ "\t" ++ trackName in div [ class "track-with-similar-container" ] [ ul [ class "track-item" ] @@ -182,7 +187,7 @@ renderListen userSlug currentTime failedCovers hovered Maybe.withDefault "" listen.releaseName key = - artist ++ "\t" ++ trackName + String.fromInt idx ++ "\t" ++ artist ++ "\t" ++ trackName mbid = case listen.caaReleaseMbid of @@ -278,7 +283,7 @@ renderListen userSlug currentTime failedCovers hovered "" ) ) - , onClick (FetchSimilar artist trackName) + , onClick (FetchSimilar idx artist trackName) ] [ text "similar" ]