38 lines
1.4 KiB
Haskell
38 lines
1.4 KiB
Haskell
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
module HtmlPrimitives where
|
|
|
|
import Control.Monad.RWS (lift)
|
|
|
|
openingTag tag = "<" <> tag <> ">"
|
|
closingTag tag = "</" <> tag <> ">"
|
|
wrapContent tag content = openingTag tag <> content <> closingTag tag
|
|
wrapContentWithArgs tag arg content = openingTag (tag <> arg) <> content <> closingTag tag
|
|
singleWrap content = "<" <> content <> "/>"
|
|
|
|
docType = "<!DOCTYPE html>"
|
|
h1 = wrapContent "h1"
|
|
h2 = wrapContent "h2"
|
|
h3 = wrapContent "h3"
|
|
link = wrapContent "a"
|
|
li = wrapContent "li"
|
|
p = wrapContent "p"
|
|
|
|
checkboxPrimitive id name True = singleWrap $ "input type='checkbox' id=" <> id <> " name=" <> name <> " checked"
|
|
checkboxPrimitive id name False = singleWrap $ "input type='checkbox' id=" <> id <> " name=" <> name
|
|
|
|
label for = wrapContentWithArgs "label " ("for=" <> for)
|
|
|
|
checkbox id name checked = checkboxPrimitive id name checked <> label id name
|
|
|
|
-- | Takes a raw line as in untouched from the file
|
|
item rawLine = "<form action=\"/post/" <> rawLine <> "\" method=\"POST\"><button type=\"submit\">" <> rawLine <> "</button></form>"
|
|
|
|
path = "./app/res/b"
|
|
|
|
simpleSite fileContent =
|
|
docType
|
|
<> h1 "Bienvenue sur la todo liste"
|
|
<> p "this website is a simple example of how haskell can quickly become a great tool to write websites fast"
|
|
|
|
ul content = wrapContent "ul" $ concatMap (wrapContent "li") content
|