breve/src/Views.hs

58 lines
1.8 KiB
Haskell
Raw Permalink Normal View History

2019-11-06 15:09:02 +01:00
{-|
This module contains the HTML pages used by the
web application. These are all obtained by filling
a single template with the page structure.
-}
2015-05-09 22:23:29 +02:00
module Views where
2019-11-06 00:06:50 +01:00
import Data.Text (Text)
import Text.Blaze.Html5 as H
import Text.Blaze.Html5.Attributes as A
2015-05-09 22:23:29 +02:00
2019-11-06 15:09:02 +01:00
-- | The homepage
2015-05-09 22:23:29 +02:00
index :: Html
index = template $ do
H.form ! method "POST" $ do
2015-05-10 15:36:37 +02:00
"your url:"
2015-05-09 22:23:29 +02:00
input ! type_ "text" ! name "url"
input ! type_ "submit" ! value "go"
2019-11-06 15:09:02 +01:00
-- | 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
2015-08-11 04:02:10 +02:00
message :: Text -> Html
2015-05-09 22:23:29 +02:00
message = template . toHtml
2019-11-06 15:09:02 +01:00
-- | The main Breve template
--
-- Takes HTML code and embeds it in the
-- inner page container.
2015-05-09 22:23:29 +02:00
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"
2019-11-06 00:06:50 +01:00
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"
2015-05-09 22:23:29 +02:00
body $ do
header $ do
h1 $ a ! href "/" $ "BREVE"
h2 "a url shortener"
H.div ! A.id "center" $ fill
footer $ do
2019-05-15 02:57:48 +02:00
"breve is "
a ! href "https://maxwell.ydns.eu/git/rnhmjoj/breve" $ "free software"
H.span "© rnhmjoj"