packages feed

webpage 0.0.1 → 0.0.2

raw patch · 3 files changed

+55/−15 lines, 3 filesdep +data-defaultdep +hastache

Dependencies added: data-default, hastache

Files

+ src/Web/Page/Hastache.hs view
@@ -0,0 +1,37 @@+{-# LANGUAGE OverloadedStrings #-}++module Web.Page.Hastache where++import Web.Page.Types++import Text.Hastache+import Text.Hastache.Context+import qualified Data.Text as T+import qualified Data.Text.Lazy as LT++import Data.Monoid++-- | We choose to not interpolate the @WebPage@ data type as a JSON Hastache+-- template value because I don't want the portions of @WebPage@ visible by+-- @content@.+template :: WebPage LT.Text T.Text+         -> LT.Text+         -> LT.Text+template page content = mconcat+  [ "<!DOCTYPE html>"+  , "<html>"+  , "<head>"+  , initScripts page+  , "<title>" <> (LT.fromStrict $ pageTitle page) <> "</title>"+  , metaVars page+  , "<link rel=\"icon\" href=\"" <> (LT.fromStrict $ favicon page) <> "\">"+  , beforeStylesScripts page+  , styles page+  , afterStylesScripts page+  , "</head>"+  , "<body>"+  , content+  , bodyScripts page+  , "</body>"+  , "</html>"+  ]
src/Web/Page/Types.hs view
@@ -1,18 +1,18 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ExtendedDefaultRules #-}-{-# LANGUAGE BangPatterns #-}  module Web.Page.Types where -+import Data.Default import Data.Monoid --- | Generic layout for a web page. We keep the data type purely parametric to +-- | Generic layout for a web page. We keep the data type purely parametric to -- allow for record-syntax overloading / reassignment, like this: -- .--- > page :: WebPage (Html ()) T.Text--- >--- > page' = page {pageTitle = "foo!"}+--+-- >  page :: WebPage (Html ()) T.Text+-- @ page' = page \{pageTitle = "foo!"\}@+-- data WebPage markup attr = WebPage {           pageTitle :: attr -- ^ Page title                                    ,             favicon :: attr -- ^ Favicon url                                    ,            metaVars :: markup -- ^ @\<meta\>@ tags@@ -22,7 +22,7 @@                                    ,  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 -instance (Monoid m, Monoid a) => Monoid (WebPage m a) where-  mempty = WebPage mempty mempty mempty mempty mempty mempty mempty mempty-  mappend x _ = x -- Some people just want to watch the world burn.+instance (Monoid m, Monoid a) => Default (WebPage m a) where+  def = WebPage mempty mempty mempty mempty mempty mempty mempty mempty
webpage.cabal view
@@ -1,21 +1,21 @@ Name:                   webpage-Version:                0.0.1+Version:                0.0.2 Author:                 Athan Clark <athan.clark@gmail.com> Maintainer:             Athan Clark <athan.clark@gmail.com> License:                MIT License-File:           LICENSE Synopsis:               Organized and simple web page scaffold for blaze and lucid Description:-  This is a general organization scheme for web pages, implemented for Lucid, +  This is a general organization scheme for web pages, implemented for Lucid,   and adapted for Blaze-html.   .   It's as easy as 1-2-3:   .   >  import Web.Page.Lucid   >-  >  λ> renderText $ template mempty "some content"+  >  λ> renderText $ template def "some content"   >-  >  ↪ "<!DOCTYPE HTML><html><head><title></title><link href +  >  ↪ "<!DOCTYPE HTML><html><head><title></title><link href   >    rel="icon"></head><body>some content</body></html>"   .   overload the particular areas with record syntax and stuff:@@ -33,8 +33,8 @@   >   >  λ> template page "some content"   >-  >  ↪ "<!DOCTYPE HTML><html><head><title>foo</title><link href -  >    rel=\"icon\"></head><body>some content<script +  >  ↪ "<!DOCTYPE HTML><html><head><title>foo</title><link href+  >    rel=\"icon\"></head><body>some content<script   >    src=\"jquery.js\"></script></body></html>"   . Cabal-Version:          >= 1.10@@ -47,10 +47,13 @@   Exposed-Modules:      Web.Page.Types                         Web.Page.Lucid                         Web.Page.Blaze+                        Web.Page.Hastache   Build-Depends:        base >= 4 && < 5                       , lucid >= 2.5                       , blaze-html+                      , hastache                       , text+                      , data-default  Source-Repository head   Type:                 git