-- | support for using HSP+Happstack for rendering HTML {-# LANGUAGE FlexibleInstances, FlexibleContexts #-} {-# OPTIONS_GHC -fno-warn-orphans -F -pgmFtrhsx #-} module Happstack.Server.HSP.HTML ( defaultTemplate , webHSP , webHSP' , module HSP ) where import Control.Monad.Trans (MonadIO(), liftIO) import qualified Data.ByteString.Char8 as P import qualified Data.ByteString.Lazy.UTF8 as L import Control.Monad (liftM) import Happstack.Server ( ToMessage(toMessage, toContentType, toResponse) , Response ) import HSP import HSP.ServerPartT () import qualified HSX.XMLGenerator as HSX instance ToMessage XML where toContentType _ = P.pack "text/html;charset=utf-8" toMessage xml = toMessage (html4Strict, xml) instance ToMessage (Maybe XMLMetaData, XML) where toContentType (Just md,_) = P.pack (contentType md) toContentType _ = P.pack "text/html;charset=utf-8" toMessage (Just (XMLMetaData (showDt, dt) _ pr), xml) = L.fromString ((if showDt then (dt ++) else id) (pr xml)) toMessage (Nothing, xml) = L.fromString (renderAsHTML xml) -- | A generic webpage template defaultTemplate :: (XMLGenerator m, EmbedAsChild m headers, EmbedAsChild m body) => String -- ^ text to use in \