This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "snap-static-pages".

The branch, master has been updated
       via  dfbe3afe0527a693616e09d902cf8923ee5599f0 (commit)
      from  fc28474ea5c0ae5fa389c2c8d8e94f0686ea8b68 (commit)


Summary of changes:
 src/Snap/StaticPages.hs                   |   25 ++++++++++++++++---------
 src/Snap/StaticPages/Internal/Handlers.hs |   14 ++++++++++++--
 2 files changed, 28 insertions(+), 11 deletions(-)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit dfbe3afe0527a693616e09d902cf8923ee5599f0
Author: Gregory Collins <[email protected]>
Date:   Sat Jun 19 00:13:27 2010 -0400

    More work on snap-static-pages

diff --git a/src/Snap/StaticPages.hs b/src/Snap/StaticPages.hs
index 607d74e..ef82b11 100644
--- a/src/Snap/StaticPages.hs
+++ b/src/Snap/StaticPages.hs
@@ -7,6 +7,7 @@ FIXME: document this.
 module Snap.StaticPages
   ( loadStaticPages
   , reloadStaticPages
+  , reloadStaticPages'
   , initStaticPages
   , serveStaticPages
 --  , runStaticPagesHandler
@@ -46,8 +47,14 @@ loadStaticPages f = initStaticPages f >>= newMVar
 
 reloadStaticPages :: MVar StaticPagesState -> IO ()
 reloadStaticPages mv = modifyMVar_ mv $ \st -> do
-    let path = staticPagesPath st
-    initStaticPages path
+    let p = staticPagesPath st
+    initStaticPages p
+
+
+reloadStaticPages' :: TemplateState Snap -> MVar StaticPagesState -> IO ()
+reloadStaticPages' ts mv = modifyMVar_ mv $ \st -> do
+    let p = staticPagesPath st
+    initStaticPages' ts p
 
 
 {-|
@@ -65,9 +72,9 @@ initStaticPages = initStaticPages' emptyTemplateState
 initStaticPages' :: TemplateState Snap -- ^ root template state
                  -> FilePath           -- ^ path to staticPages directory
                  -> IO StaticPagesState
-initStaticPages' ts path = do
+initStaticPages' ts pth = do
     -- make sure directories exist
-    mapM_ failIfNotDir [path, contentDir, templateDir]
+    mapM_ failIfNotDir [pth, contentDir, templateDir]
 
     (feed, siteURL, baseURL, excludeList) <- readConfig configFilePath
 
@@ -82,7 +89,7 @@ initStaticPages' ts path = do
                         etemplates
 
     return StaticPagesState {
-                      staticPagesPath          = path
+                      staticPagesPath          = pth
                     , staticPagesSiteURL       = siteURL
                     , staticPagesBaseURL       = baseURL
                     , staticPagesPostMap       = cmap
@@ -101,12 +108,12 @@ initStaticPages' ts path = do
     failIfNotDir :: FilePath -> IO ()
     failIfNotDir d = unlessM (doesDirectoryExist d)
                              (throwIO $ StaticPagesException
-                                      $ printf "'%s' is not a directory" path)
+                                      $ printf "'%s' is not a directory" pth)
 
     --------------------------------------------------------------------------
-    configFilePath = path </> "config"
-    contentDir     = path </> "content"
-    templateDir    = path </> "templates"
+    configFilePath = pth </> "config"
+    contentDir     = pth </> "content"
+    templateDir    = pth </> "templates"
 
 
 ------------------------------------------------------------------------------
diff --git a/src/Snap/StaticPages/Internal/Handlers.hs 
b/src/Snap/StaticPages/Internal/Handlers.hs
index bce17fe..a777234 100644
--- a/src/Snap/StaticPages/Internal/Handlers.hs
+++ b/src/Snap/StaticPages/Internal/Handlers.hs
@@ -341,9 +341,19 @@ serveIndex soFar content = do
 
         -- here we take the tag's children as a bit of markup to be run for
         -- every post. We'll bind a fresh copy of the post for each run.
-        let perEach = X.getChildren node
+        let perEach' = X.getChildren node
 
-        allNodes <- liftM concat $ mapM (doOne state perEach) posts
+        -- the exception to this is when there are no posts; then we fetch the
+        -- <no-posts> tag, otherwise we filter it out.
+        let (noPosts,perEach) =
+                partition (\x -> X.getName x == "no-posts") perEach'
+
+        let noPost = if null noPosts then [] else X.getChildren $ head noPosts
+
+        allNodes <-
+            if null posts
+              then runNodeList noPost
+              else liftM concat $ mapM (doOne state perEach) posts
 
         stopRecursion
         restoreTS ts
-----------------------------------------------------------------------


hooks/post-receive
-- 
snap-static-pages
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap

Reply via email to