-- License: BSD3 (see LICENSE) -- Author: Dino Morelli module Grolprep.Web.Util where import Text.XHtml.Strict import Grolprep.Common.Util ( appVersion, getRelDataFilePath ) {- The base URL of the application -} baseUrl :: IO String baseUrl = getRelDataFilePath "../bin/fcc-grol-prep.cgi" createCssLinks :: [FilePath] -> IO [Html] createCssLinks paths = mapM createLink ("css/common.css" : paths) where createLink path = do cssPath <- getRelDataFilePath path return $ thelink noHtml ! [href cssPath, rel "stylesheet", thetype "text/css"] titleBar :: Html titleBar = thetitle << "GROLPrep" heading :: IO Html heading = do logoPath <- getRelDataFilePath "BTCAvionicsLogo.jpg" avionicsPicPath <- getRelDataFilePath "AvionicsPhoto.jpg" return $ p << ( image ! [src logoPath] +++ image ! [src avionicsPicPath, strAttr "style" "padding-left: 0.5em;"] ) +++ (thediv ! [theclass "banner"]) << (h1 ! [theclass "heading"]) << ( "GROLPrep" +++ (thespan ! [theclass "banner-dark-text"] << primHtml " ·") +++ thespan ! [theclass "heading-smaller"] << " FCC General Radio Operators License exam preparation" ) footer :: Html footer = thediv ! [theclass "banner"] << h2 ! [theclass "footer"] << ( "GROLPrep " +++ thespan ! [theclass "banner-dark-text"] << appVersion ) {- Convenience function to deal with some of the repetitive parts included in every HTML document -} page :: [FilePath] -> Html -> IO Html page cssPaths b = do cssLinks <- createCssLinks cssPaths h <- heading return ( (header << titleBar +++ cssLinks ) +++ body ! [strAttr "onLoad" "document.getElementById(\"enter\").focus()"] << [ h , b , footer ] )