diff options
| author | LLLL Colonq <llll@colonq> | 2023-12-19 13:08:22 -0500 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2023-12-19 13:08:22 -0500 |
| commit | 0be357bb60a2bc4523056aba34add78b715211f5 (patch) | |
| tree | 5c401183dc05342ee6efc8a4bd163e60a0c17298 /fig-frontend/src/Fig/Frontend.hs | |
| parent | 40a3ac0bd9188139c2cd6b8b1b116e20b6ed8446 (diff) | |
Add fig-frontend
Diffstat (limited to 'fig-frontend/src/Fig/Frontend.hs')
| -rw-r--r-- | fig-frontend/src/Fig/Frontend.hs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/fig-frontend/src/Fig/Frontend.hs b/fig-frontend/src/Fig/Frontend.hs new file mode 100644 index 0000000..fa1965a --- /dev/null +++ b/fig-frontend/src/Fig/Frontend.hs @@ -0,0 +1,42 @@ +module Fig.Frontend where + +import Fig.Prelude + +import qualified Network.Wai.Middleware.Static as Wai.Static +import qualified Network.Wai.Handler.Warp as Warp + +import qualified Web.Twain as Tw + +import qualified Lucid as L + +import Fig.Frontend.Utils +import Fig.Frontend.Auth + +server :: Config -> IO () +server cfg = do + log $ "Frontend server running on port " <> tshow cfg.port + Warp.run cfg.port $ app cfg + +app :: Config -> Tw.Application +app cfg = foldr' @[] ($) + (Tw.notFound . Tw.send $ Tw.text "not found") + [ Wai.Static.staticPolicy $ Wai.Static.addBase cfg.assetPath + , Tw.get "/" + . Tw.send . Tw.html + . L.renderBS + $ L.doctypehtml_ do + L.head_ do + L.title_ "The Junkyard" + L.link_ [L.rel_ "stylesheet", L.href_ "js/index.css"] + L.link_ [L.rel_ "stylesheet", L.href_ "https://fonts.googleapis.com/css?family=Rubik+Maps"] + L.link_ [L.rel_ "icon", L.href_ "data:;base64,iVBORw0KGgo="] + L.script_ [L.type_ "module", L.src_ "js/index.js"] ("" :: L.Html ()) + L.body_ do + L.term "fig-backdrop" "" + L.term "fig-header" "" + L.term "fig-login" "" + L.term "fig-window" do + L.h1_ "hello" + , Tw.get "/api/check" $ authed cfg \auth -> do + Tw.send $ Tw.json @[Text] [auth.id, auth.name] + ] |
