2015-05-09 22:23:29 +02:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
|
|
|
|
module Views where
|
|
|
|
|
|
|
|
import Data.Text (Text)
|
|
|
|
import Data.Text.Lazy (toStrict)
|
|
|
|
import Text.Blaze.Html.Renderer.Text (renderHtml)
|
2015-06-29 21:42:12 +02:00
|
|
|
import Text.Blaze.Html5 as H
|
|
|
|
import Text.Blaze.Html5.Attributes as A
|
2017-01-13 23:21:56 +01:00
|
|
|
import qualified Web.Spock.Core as S
|
2015-05-09 22:23:29 +02:00
|
|
|
|
2015-05-10 15:37:33 +02:00
|
|
|
render :: Html -> S.ActionT IO ()
|
|
|
|
render = S.html . toStrict . renderHtml
|
2015-05-09 22:23:29 +02:00
|
|
|
|
2015-08-11 04:02:10 +02:00
|
|
|
done :: Text -> Html
|
2015-05-09 22:23:29 +02:00
|
|
|
done url = template $ do
|
|
|
|
"here's your new link: "
|
|
|
|
a ! href (toValue url) $ (toHtml url)
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
2015-08-11 04:02:10 +02:00
|
|
|
message :: Text -> Html
|
2015-05-09 22:23:29 +02:00
|
|
|
message = template . toHtml
|
|
|
|
|
|
|
|
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 "main.css" ! type_ "text/css"
|
|
|
|
link ! rel "apple-touch-icon" ! href "icon-big.png"
|
|
|
|
link ! rel "icon" ! type_ "image/png" ! href "/icon-medium.png" ! sizes "96x96"
|
|
|
|
link ! rel "icon" ! type_ "image/png" ! href "/icon-small.png" ! sizes "16x16"
|
|
|
|
script ! src "https://cdn.rawgit.com/LeaVerou/prefixfree/gh-pages/prefixfree.min.js" $ mempty
|
|
|
|
body $ do
|
|
|
|
header $ do
|
|
|
|
h1 $ a ! href "/" $ "BREVE"
|
|
|
|
h2 "a url shortener"
|
|
|
|
H.div ! A.id "center" $ fill
|
|
|
|
footer $ do
|
2015-05-10 03:29:17 +02:00
|
|
|
"breve is open "
|
2015-05-09 22:23:29 +02:00
|
|
|
a ! href "https://github.com/rnhmjoj/breve" $ "source"
|
2015-06-29 21:42:12 +02:00
|
|
|
H.span "© Rnhmjoj"
|