From c1e09d4ada65150d6bd9c391dd1aa4a1bf20b539 Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Tue, 19 Sep 2023 11:12:36 +1200 Subject: [PATCH] Render onscreen keyboards (not interactive yet). --- bureaucromancy.cabal | 2 +- src/Text/HTML/Form/WebApp.hs | 19 +++++++++++++++++-- src/Text/HTML/Form/WebApp/Ginger.hs | 8 +++++--- tpl/base.html | 4 ++++ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/bureaucromancy.cabal b/bureaucromancy.cabal index 82121a4..1fddcb0 100644 --- a/bureaucromancy.cabal +++ b/bureaucromancy.cabal @@ -74,7 +74,7 @@ library -- Other library packages from which modules are imported. build-depends: base ^>=4.16.4.0, ginger, file-embed-lzma, file-embed, mtl, bytestring, text, xml-conduit, network-uri, regex-tdfa, containers, - filepath + filepath, directory -- Directories containing source files. hs-source-dirs: src diff --git a/src/Text/HTML/Form/WebApp.hs b/src/Text/HTML/Form/WebApp.hs index 687facd..a984614 100644 --- a/src/Text/HTML/Form/WebApp.hs +++ b/src/Text/HTML/Form/WebApp.hs @@ -6,9 +6,12 @@ import Data.Text as Txt import Data.Text.Encoding as Txt import Text.Read (readMaybe) import Network.URI (unEscapeString) +import System.IO (readFile') +import System.FilePath (()) +import System.Directory (XdgDirectory(..), getXdgDirectory, doesFileExist) import Text.HTML.Form (Form(..), Input(..)) -import Text.HTML.Form.WebApp.Ginger (template) +import Text.HTML.Form.WebApp.Ginger (template, resolveSource) import Text.HTML.Form.Query (renderQueryString) renderPage :: Form -> [Text] -> [(ByteString, Maybe ByteString)] -> IO (Maybe Text) @@ -16,7 +19,7 @@ renderPage form (n:path) query | Just ix <- readMaybe $ Txt.unpack n, ix < Prelude.length (inputs form) = renderInput form ix (inputs form !! ix) path query renderPage form [] _ = return $ Just $ Txt.concat [ - "Start!"] + "Start!"] renderPage _ _ _ = return Nothing renderInput :: Form -> Int -> Input -> [Text] -> [(ByteString, Maybe ByteString)] -> @@ -44,6 +47,18 @@ renderInput form ix input@Input {inputType="radio", inputName=k', value=v'} [] q template "checkbox.html" form ix input $ set k' v' qs renderInput form ix input@Input { inputType="