diff options
author | Profpatsch <mail@profpatsch.de> | 2024-05-16T20·26+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-06-03T14·55+0000 |
commit | 54ea3eeacb39e127f4db596c7161afc426c0bd20 (patch) | |
tree | 22ab85aeedf2432ddd27d15178ed1abc8eaa96ec /users/Profpatsch/whatcd-resolver/src | |
parent | c5555f25da1bd836f4a98cda0905d66e2c6aeb91 (diff) |
fix(users/Profpatsch/whatcd-resolver): add page chrome to artist r/8205
Change-Id: Id13553c450603b04c6bba0085d7f3246fe0d54af Reviewed-on: https://cl.tvl.fyi/c/depot/+/11682 Autosubmit: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
Diffstat (limited to 'users/Profpatsch/whatcd-resolver/src')
-rw-r--r-- | users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs | 72 |
1 files changed, 41 insertions, 31 deletions
diff --git a/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs b/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs index 122ccc11df2d..0d5867e0c0d8 100644 --- a/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs +++ b/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs @@ -24,6 +24,7 @@ import FieldParser (FieldParser, FieldParser' (..)) import FieldParser qualified as Field import Html qualified import IHP.HSX.QQ (hsx) +import IHP.HSX.ToHtml (ToHtml) import Json qualified import Json.Enc (Enc) import Json.Enc qualified as Enc @@ -259,9 +260,41 @@ htmlUi = do bestTorrentsTable <- getBestTorrentsTable Nothing -- transmissionTorrentsTable <- lift @Transaction getTransmissionTorrentsTable pure $ - Html.docTypeHtml + htmlPageChrome [hsx| + <form + hx-post="/snips/redacted/search" + hx-target="#redacted-search-results"> + <label for="redacted-search">Redacted Search</label> + <input + id="redacted-search" + type="text" + name="redacted-search" /> + <button type="submit" hx-disabled-elt="this">Search</button> + <div class="htmx-indicator">Search running!</div> + </form> + <div id="redacted-search-results"> + {bestTorrentsTable} + </div> + <!-- refresh the page if the uniqueRunId is different --> + <input + hidden + type="text" + id="autorefresh" + name="hasItBeenRestarted" + value={uniqueRunId} + hx-get="/autorefresh" + hx-trigger="every 5s" + hx-swap="none" + /> + |] + +htmlPageChrome :: (ToHtml a) => a -> Html +htmlPageChrome body = + Html.docTypeHtml $ + [hsx| <head> + <!-- TODO: set nice page title for each page --> <title>whatcd-resolver</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> @@ -277,31 +310,7 @@ htmlUi = do </style> </head> <body> - <form - hx-post="/snips/redacted/search" - hx-target="#redacted-search-results"> - <label for="redacted-search">Redacted Search</label> - <input - id="redacted-search" - type="text" - name="redacted-search" /> - <button type="submit" hx-disabled-elt="this">Search</button> - <div class="htmx-indicator">Search running!</div> - </form> - <div id="redacted-search-results"> - {bestTorrentsTable} - </div> - <!-- refresh the page if the uniqueRunId is different --> - <input - hidden - type="text" - id="autorefresh" - name="hasItBeenRestarted" - value={uniqueRunId} - hx-get="/autorefresh" - hx-trigger="every 5s" - hx-swap="none" - /> + {body} </body> |] @@ -317,12 +326,13 @@ artistPage :: m Html artistPage dat = runTransaction $ do torrents <- getBestTorrentsTable (Just $ label @"artistId" dat.dbId) - pure - [hsx| - Artist ID: {dat.dbId} + pure $ + htmlPageChrome + [hsx| + Artist ID: {dat.dbId} - {torrents} - |] + {torrents} + |] type Handlers m = HandlerResponses m -> Map Text (m ResponseReceived) |