Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 89cb7531c0
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 45 lines (37 sloc) 1.548 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
{-# LANGUAGE OverloadedStrings #-}

module Layouts where

import Data.Maybe
import Data.IterIO.Http.Support

import Prelude hiding (head, id, div, span)
import Text.Blaze.Html5 hiding (map)
import Text.Blaze.Html5.Attributes hiding (title, span, content)
import qualified Text.Blaze.Renderer.Utf8 as R (renderHtml)

import Control.Monad.Trans
import System.Environment

renderHtml :: Html -> Action t b IO ()
renderHtml htmlBody = do
  env <- liftIO getEnvironment
  let brand = fromMaybe "Hails Authentication" $ lookup "BRAND" env
      brandUrl = fromMaybe "#" $ lookup "BRAND_URL" env
  render "text/html" $ R.renderHtml $ application brand brandUrl htmlBody

stylesheet :: String -> Html
stylesheet uri = link ! rel "stylesheet" ! type_ "text/css" ! href (toValue uri)

application :: String -> String -> Html -> Html
application brand brandUrl content = docTypeHtml $ do
  head $ do
    title $ "GitStar"
    stylesheet "/css/bootstrap.css"
    stylesheet "/css/application.css"
    body $ do
     div ! class_ "navbar navbar-fixed-top" $ do
       div ! class_ "navbar-inner" $ do
         div ! class_ "container" $ do
           a ! href (toValue brandUrl) ! class_ "brand" $ toHtml brand
     div ! class_ "row" $
       div ! id "flash-messages" ! class_ "span4 offset4" $ ""
     div ! class_ "container" $ content
     script ! src "/js/jquery.js" $ ""
     script ! src "/js/jquery.cookie.js" $ ""
     script ! src "/js/bootstrap.min.js" $ ""
     script ! src "/js/bootstrap-typeahead.js" $ ""
     script ! src "/js/flash.js" $ ""
Something went wrong with that request. Please try again.