packages feed

Phsu-0.1.0.1: src/Template.hs

{-# LANGUAGE OverloadedStrings #-}
module Template(template, myPolicy) where

import Control.Monad.Trans  (MonadIO(..))
import Data.String.Conversions (cs)
import Data.Text (Text)
import Happstack.Server
import Text.Blaze.Html5 (Html, (!), toHtml)
import qualified Text.Blaze.Html5 as H
import qualified Text.Blaze.Html5.Attributes as A

template :: Text -> Html -> Response
template title body = toResponse $
   H.html $ do
     H.head $ do
       H.title (toHtml title)
       H.style $ H.toHtml $ unlines [ "table { margin: 0 auto; border-collapse: collapse; font-family: 'sans-serif'; }"
                                              , "table, th, td { border: 1px solid #353948; }"
                                              , "td.size { text-align: right; font-size: 0.7em; }"
                                              , "td.date { text-align: right; font-size: 0.7em; }"
                                              , "td { padding-right: 1em; padding-left: 1em; }"
                                              , "th.first { background-color: white; }"
                                              , "td.first { padding-right: 0; padding-left: 0; text-align: center }"
                                              , "tr { background-color: white; }"
                                              , "tr.alt { background-color: #A3B5BA}"
                                              , "th { background-color: #3C4569; color: white; font-size: 1.125em; }"
                                              , "h1 { width: 760px; margin: 1.4em auto; font-size: 1em; font-family: sans-serif }"
                                              , "img { width: 20px }"
                                              , "a { text-decoration: none }"
                                              ]
     H.body $ do
       body
       H.p $ H.a ! A.href ("/") $ "back home"

myPolicy :: BodyPolicy
myPolicy = (defaultBodyPolicy "/tmp/" 0 10000 10000)