From a421eb9bdddfa7e2765456f756833d8941ac7a08 Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Mon, 16 Jun 2025 05:42:58 -0400 Subject: fig-web: Initial puzzle site --- fig-web/src/Fig/Web/Utils.hs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'fig-web/src/Fig/Web/Utils.hs') diff --git a/fig-web/src/Fig/Web/Utils.hs b/fig-web/src/Fig/Web/Utils.hs index fbe17bf..521e781 100644 --- a/fig-web/src/Fig/Web/Utils.hs +++ b/fig-web/src/Fig/Web/Utils.hs @@ -11,13 +11,14 @@ module Fig.Web.Utils , status , queryParam, queryParamMaybe, formParam, formParamMaybe, pathParam , header - , respondText, respondJSON, respondHTML + , respondText, respondJSON, respondHTMLText, respondHTML, redirect , WebsocketHandler , websocket , BusEventHandler, BusEventHandlers , busEvents , handleBusEvent , subscribeBusEvents + , module Lucid.Html5 ) where import Fig.Prelude @@ -38,6 +39,9 @@ import qualified Network.WebSockets as WS import qualified Web.Scotty as Sc +import qualified Lucid as L +import Lucid.Html5 + import qualified Toml import Fig.Bus.Binary.Client @@ -146,8 +150,14 @@ respondText = Sc.text . Text.L.fromStrict respondJSON :: Aeson.ToJSON a => a -> Sc.ActionM () respondJSON = Sc.json -respondHTML :: Text -> Sc.ActionM () -respondHTML = Sc.html . Text.L.fromStrict +respondHTMLText :: Text -> Sc.ActionM () +respondHTMLText = Sc.html . Text.L.fromStrict + +respondHTML :: L.Html () -> Sc.ActionM () +respondHTML = Sc.html . L.renderText . html_ + +redirect :: Text -> Sc.ActionM () +redirect = Sc.redirect . Text.L.fromStrict type WebsocketHandler = (ByteString, WS.Connection -> IO ()) websocket :: [WebsocketHandler] -> Sc.ScottyM () -- cgit v1.2.3