From 485af1d460be0979b7093da307f379ef088a98db Mon Sep 17 00:00:00 2001 From: stuebinm Date: Thu, 10 Feb 2022 00:14:43 +0100 Subject: server: simple servant-lucid stuff --- server/Server.hs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'server/Server.hs') diff --git a/server/Server.hs b/server/Server.hs index a5a820a..536350f 100644 --- a/server/Server.hs +++ b/server/Server.hs @@ -27,12 +27,14 @@ import GHC.Generics (Generic) import Lens.Micro (over) import Lens.Micro.TH import LintConfig (LintConfig') +import Lucid (ToHtml (..)) +import Lucid.Html5 +import Orphans () import System.Exit.Compat (exitFailure) import Toml (TomlCodec) import qualified Toml import Toml.Codec ((.=)) - -- | a reference in a remote git repository data RemoteRef = RemoteRef { repourl :: Text @@ -69,6 +71,23 @@ data State = State , _registry :: Map UUID RemoteRef } +instance ToHtml JobStatus where + toHtml status = html_ $ do + head_ $ do + title_ "Job Status" + link_ [rel_ "stylesheet", type_ "text/css", href_ "/styles.css"] + body_ $ div_ [class_ "main-content"] $ case status of + Pending -> do + h2_ "Pending …" + p_ "(please note that this site won't auto-reload, you'll have to refresh it yourself)" + Linted res -> do + p_ "Linted" + toHtml res + Failed err -> do + h2_ "System Error" + p_ $ "error: " <> toHtml err + p_ "you should probably ping an admin about this or sth" + makeLenses ''State defaultState :: State -- cgit v1.2.3