{-# LANGUAGE FlexibleContexts, OverloadedStrings, RecordWildCards #-} {-# OPTIONS_GHC -F -pgmFtrhsx #-} module Theme where import Clckwrks import Clckwrks.Monad import Clckwrks.ProfileData.Acid (HasRole(..)) import Data.Maybe (fromMaybe) import qualified Data.Set as Set import Data.Text (Text, unpack) -- import Happstack.Server import HSP import Paths_clckwrks_theme_happstack (getDataDir) theme :: Theme theme = Theme { themeName = "happstack" , _themeTemplate = pageTemplate , themeBlog = blog , themeDataDir = getDataDir } pageTemplate :: ( EmbedAsChild (ClckT ClckURL (ServerPartT IO)) headers , EmbedAsChild (ClckT ClckURL (ServerPartT IO)) body ) => Text -> headers -> body -> XMLGenT (ClckT ClckURL (ServerPartT IO)) XML pageTemplate ttl hdr bdy = do pid <- XMLGenT $ getPageId case pid of (PageId 1) -> home ttl hdr bdy _ -> standardTemplate ttl hdr

<% ttl %>

<% bdy %>
------------------------------------------------------------------------------ -- standard template ------------------------------------------------------------------------------ standardTemplate :: ( EmbedAsChild (ClckT ClckURL (ServerPartT IO)) headers , EmbedAsChild (ClckT ClckURL (ServerPartT IO)) body ) => Text -> headers -> body -> XMLGenT (ClckT ClckURL (ServerPartT IO)) XML standardTemplate ttl hdrs bdy = <% ttl %> <% hdrs %> <% googleAnalytics %> <% bdy %> ------------------------------------------------------------------------------ -- Home ------------------------------------------------------------------------------ summaryBox :: PageId -> String -> String -> GenXML (Clck ClckURL) summaryBox pid title iconURL =

<% title %>

<% getPageSummary pid %>

read more...

home ttl hdr bdy = standardTemplate "happstack.com" hdr $ <%> <% twitter %>

The relentless, uncompromised power and beauty of Haskell in a web framework.

<% bdy %>
<% summaryBox (PageId 5) "Happstack Philosophy" "philosophy-icon.png" %> <% summaryBox (PageId 6) "Happstack 7 Release Notes" "7-icon.png" %> <% summaryBox (PageId 7) "Happstack 8 Roadmap" "8-icon.png" %>
twitter =
Tweets by @happstack
------------------------------------------------------------------------------ -- Blog ------------------------------------------------------------------------------ -- | create a list of of all the blog posts postsHTML :: XMLGenT (Clck ClckURL) XML postsHTML = do posts <- getPosts
    <% mapM postHTML posts %>
-- | create a the \ for a single blog post postHTML :: Page -> XMLGenT (Clck ClckURL) XML postHTML Page{..} =
  • <% pageTitle %>

    Posted on <% pageDate %> by <% authorName %> <% pageSrc %>

    permalink

  • where authorName :: Clck ClckURL Text authorName = do mu <- getUsername pageAuthor return $ fromMaybe "Anonymous" mu blog :: XMLGenT (Clck ClckURL) XML blog = do ttl <- lift getBlogTitle standardTemplate ttl () $ <%>

    <% ttl %>

    <% postsHTML %>