{-| This module contains the HTML pages used by the web application. These are all obtained by filling a single template with the page structure. -} module Views where import Data.Text (Text) import Text.Blaze.Html5 as H import Text.Blaze.Html5.Attributes as A -- | The homepage index :: Html index = template $ do H.form ! method "POST" $ do "your url:" input ! type_ "text" ! name "url" input ! type_ "submit" ! value "go" -- | The page shown when a new url has been -- submitted successfully. Takes the resulting -- url as an argument. done :: Text -> Html done url = template $ do "here's your new link: " a ! href (toValue url) $ (toHtml url) -- | Displays a text message in the page center message :: Text -> Html message = template . toHtml -- | The main Breve template -- -- Takes HTML code and embeds it in the -- inner page container. template :: Html -> Html template fill = docTypeHtml $ do H.head $ do H.title "breve: url shortener" meta ! name "description" ! content "url shortener" meta ! name "keywords" ! content "url, shortener" meta ! name "author" ! content "Michele Guerini Rocco" meta ! charset "utf-8" link ! rel "stylesheet" ! href "/static/main.css" ! type_ "text/css" link ! rel "apple-touch-icon" ! href "static/icon-big.png" link ! rel "icon" ! type_ "image/png" ! href "/static/icon-medium.png" ! sizes "96x96" link ! rel "icon" ! type_ "image/png" ! href "/static/icon-small.png" ! sizes "16x16" body $ do header $ do h1 $ a ! href "/" $ "BREVE" h2 "a url shortener" H.div ! A.id "center" $ fill footer $ do "breve is " a ! href "https://maxwell.ydns.eu/git/rnhmjoj/breve" $ "free software" H.span "© rnhmjoj"