webpage 0.0.3.1 → 0.0.4
raw patch · 6 files changed
+54/−42 lines, 6 filesdep −hastachesetup-changed
Dependencies removed: hastache
Files
- Setup.hs +0/−2
- src/Web/Page/Blaze.hs +7/−5
- src/Web/Page/Hastache.hs +5/−4
- src/Web/Page/Lucid.hs +10/−9
- src/Web/Page/Types.hs +31/−19
- webpage.cabal +1/−3
− Setup.hs
@@ -1,2 +0,0 @@-import Distribution.Simple-main = defaultMain
src/Web/Page/Blaze.hs view
@@ -1,13 +1,15 @@-{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE+ OverloadedStrings+ #-} module Web.Page.Blaze- ( module Web.Page.Types- , template ) where+ ( module X+ , template+ ) where -import Web.Page.Types+import Web.Page.Types as X import qualified Text.Blaze.Html5 as H-import qualified Text.Blaze.Html5.Attributes as A import qualified Data.Text as T
src/Web/Page/Hastache.hs view
@@ -1,11 +1,12 @@ {-# LANGUAGE OverloadedStrings #-} -module Web.Page.Hastache where+module Web.Page.Hastache+ ( module X+ , template+ ) where -import Web.Page.Types+import Web.Page.Types as X -import Text.Hastache-import Text.Hastache.Context import qualified Data.Text as T import qualified Data.Text.Lazy as LT
src/Web/Page/Lucid.hs view
@@ -1,25 +1,26 @@-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE ExtendedDefaultRules #-}-{-# LANGUAGE BangPatterns #-}+{-# LANGUAGE+ OverloadedStrings+ , ExtendedDefaultRules+ , BangPatterns+ #-} module Web.Page.Lucid- ( module Web.Page.Types- , template ) where+ ( module X+ , template+ ) where -import Web.Page.Types+import Web.Page.Types as X import Lucid-import Lucid.Base import qualified Data.Text as T -import Data.Monoid -- | Generic page template implemented in Lucid. template :: Monad m => WebPage (HtmlT m ()) T.Text -- ^ Page information -> HtmlT m () -- ^ Content to insert in @\<body\>@- -> HtmlT m () + -> HtmlT m () template page content = doctypehtml_ $ mconcat $ [ head_ [] $ mconcat $ [ initScripts page
src/Web/Page/Types.hs view
@@ -1,12 +1,12 @@-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE ExtendedDefaultRules #-}-{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE+ OverloadedStrings+ , ExtendedDefaultRules+ #-} module Web.Page.Types where import Data.Default import Data.Monoid--- import Control.Lens -- | Generic layout for a web page. We keep the data type purely parametric to -- allow for record-syntax overloading / reassignment, like this:@@ -15,22 +15,34 @@ -- > page :: WebPage (Html ()) T.Text -- @ page' = page \{pageTitle = "foo!"\}@ ---data WebPage markup attr = WebPage { pageTitle :: attr -- ^ Page title- , favicon :: markup -- ^ Favicon tags- , metaVars :: markup -- ^ @\<meta\>@ tags- , initScripts :: markup -- ^ JavaScript to include at the top of the page- , beforeStylesScripts :: markup -- ^ JavaScript to include before @\<style\>@ tags- , styles :: markup -- ^ Styles- , afterStylesScripts :: markup -- ^ JavaScript to include after @\<style\>@ tags - ie: <http://modernizr.com Modernizr>- , bodyScripts :: markup -- ^ JavaScript to include at the base of @\<body\>@- }- deriving Show+data WebPage markup attr = WebPage+ { pageTitle :: attr -- ^ Page title+ , favicon :: markup -- ^ Favicon tags+ , metaVars :: markup -- ^ @\<meta\>@ tags+ , initScripts :: markup -- ^ JavaScript to include at the top of the page+ , beforeStylesScripts :: markup -- ^ JavaScript to include before @\<style\>@ tags+ , styles :: markup -- ^ Styles+ , afterStylesScripts :: markup -- ^ JavaScript to include after @\<style\>@ tags - ie: <http://modernizr.com Modernizr>+ , bodyScripts :: markup -- ^ JavaScript to include at the base of @\<body\>@+ } deriving (Show, Eq, Ord) --- makeLenses ''WebPage +instance ( Monoid m+ , Monoid a+ ) => Monoid (WebPage m a) where+ mempty = WebPage mempty mempty mempty mempty mempty mempty mempty mempty+ mappend (WebPage t1 f1 m1 is1 bs1 s1 as1 b1) (WebPage t2 f2 m2 is2 bs2 s2 as2 b2) =+ WebPage (t1 `mappend` t2)+ (f1 `mappend` f2)+ (m1 `mappend` m2)+ (is1 `mappend` is2)+ (bs1 `mappend` bs2)+ (s1 `mappend` s2)+ (as1 `mappend` as2)+ (b1 `mappend` b2) -instance (Monoid m, Monoid a) => Default (WebPage m a) where- def = WebPage mempty mempty mempty mempty mempty mempty mempty mempty -emptyPage :: (Monoid m, Monoid a) => WebPage m a-emptyPage = WebPage mempty mempty mempty mempty mempty mempty mempty mempty+instance ( Monoid m+ , Monoid a+ ) => Default (WebPage m a) where+ def = mempty
webpage.cabal view
@@ -1,5 +1,5 @@ Name: webpage-Version: 0.0.3.1+Version: 0.0.4 Author: Athan Clark <athan.clark@gmail.com> Maintainer: Athan Clark <athan.clark@gmail.com> License: MIT@@ -51,10 +51,8 @@ Build-Depends: base >= 4 && < 5 , lucid >= 2.5 , blaze-html- , hastache , text , data-default- -- , lens Source-Repository head Type: git