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-core".

The branch, master has been updated
       via  e97491ec289a6e594fc535ac3e3582183080ba73 (commit)
       via  fc0551b44e40917f03454ed165de3f342eaa4920 (commit)
       via  2831e593236b6b6ddf0d41b2866627a269524a04 (commit)
       via  8d75a66768ea1cdb4d826120abbc9497ff833c98 (commit)
      from  f622aa8a7c1de18f9ca0455e57309bf54c0c4c75 (commit)


Summary of changes:
 CONTRIBUTORS                                      |    2 +-
 project_template/barebones/foo.cabal              |    2 +
 project_template/barebones/src/Common.hs          |   59 --------
 project_template/barebones/src/Main.hs            |   15 +--
 project_template/barebones/src/Server.hs          |  111 +++++++++++++++
 project_template/default/src/Common.hs            |  151 ---------------------
 project_template/default/src/Glue.hs              |   49 +++++++
 project_template/default/src/Main.hs              |   27 ++---
 project_template/default/src/Server.hs            |  111 +++++++++++++++
 project_template/default/src/TemplateDirectory.hs |   78 +++++++++++
 10 files changed, 365 insertions(+), 240 deletions(-)
 delete mode 100644 project_template/barebones/src/Common.hs
 create mode 100644 project_template/barebones/src/Server.hs
 delete mode 100644 project_template/default/src/Common.hs
 create mode 100644 project_template/default/src/Glue.hs
 create mode 100644 project_template/default/src/Server.hs
 create mode 100644 project_template/default/src/TemplateDirectory.hs

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 e97491ec289a6e594fc535ac3e3582183080ba73
Author: Shane <[email protected]>
Date:   Sun Jun 13 17:32:34 2010 +0100

    Completely reoganised the project_template files. Now there is 
TemplateDirectory, which should be merged into Heist, Server, which should be 
merged into snap-server (I think), and Glue which probably cannot be easily 
merged into either.

diff --git a/project_template/barebones/foo.cabal 
b/project_template/barebones/foo.cabal
index 9bd4e50..a61c523 100644
--- a/project_template/barebones/foo.cabal
+++ b/project_template/barebones/foo.cabal
@@ -21,7 +21,9 @@ Executable projname
     bytestring >= 0.9.1 && <0.10,
     snap-core >= 0.2 && <0.3,
     snap-server >= 0.2 && <0.3,
+    xhtml-combinators,
     unix,
+    text,
     containers,
     MonadCatchIO-transformers,
     filepath >= 1.1 && <1.2
diff --git a/project_template/barebones/src/Common.hs 
b/project_template/barebones/src/Common.hs
deleted file mode 100644
index 5dcc3e7..0000000
--- a/project_template/barebones/src/Common.hs
+++ /dev/null
@@ -1,59 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE OverloadedStrings #-}
-
-module Common where
-
-import           Control.Concurrent
-import           Control.Exception (SomeException)
-import           Control.Monad
-import           Control.Monad.CatchIO
-import           Prelude hiding (catch)
-import           Snap.Http.Server
-import           Snap.Types
-import           Snap.Util.GZip
-import           System
-import           System.Posix.Env
-
-setLocaleToUTF8 :: IO ()
-setLocaleToUTF8 = do
-    mapM_ (\k -> setEnv k "en_US.UTF-8" True)
-          [ "LANG"
-          , "LC_CTYPE"
-          , "LC_NUMERIC"
-          , "LC_TIME"
-          , "LC_COLLATE"
-          , "LC_MONETARY"
-          , "LC_MESSAGES"
-          , "LC_PAPER"
-          , "LC_NAME"
-          , "LC_ADDRESS"
-          , "LC_TELEPHONE"
-          , "LC_MEASUREMENT"
-          , "LC_IDENTIFICATION"
-          , "LC_ALL" ]
-
-data AppConfig = AppConfig {
-    accessLog :: Maybe FilePath,
-    errorLog :: Maybe FilePath
-}
-
-quickServer :: AppConfig -> Snap () -> IO ()
-quickServer config siteHandlers = do
-    args   <- getArgs
-    port   <- case args of
-                []       -> error "You must specify a port!" >> exitFailure
-                (port:_) -> return $ read port
-
-    setLocaleToUTF8
-
-    (try $ httpServe "*" port "myserver"
-             (accessLog config)
-             (errorLog config)
-             (withCompression siteHandlers))
-             :: IO (Either SomeException ())
-
-    threadDelay 1000000
-    putStrLn "exiting"
-    return ()
-
diff --git a/project_template/barebones/src/Main.hs 
b/project_template/barebones/src/Main.hs
index 464348b..1c72738 100644
--- a/project_template/barebones/src/Main.hs
+++ b/project_template/barebones/src/Main.hs
@@ -5,20 +5,10 @@ import           Control.Applicative
 import           Snap.Types
 import           Snap.Util.FileServe
 
-import           Common
-
-config :: AppConfig
-config = AppConfig {
-  accessLog = Just "access.log",
-  errorLog = Just "error.log"
-}
+import           Server
 
 main :: IO ()
-main = do
-    quickServer config site
-
-site :: Snap ()
-site =
+main = quickServer $
     ifTop (writeBS "hello world") <|>
     route [ ("foo", writeBS "bar")
           , ("echo/:echoparam", echoHandler)
@@ -30,4 +20,3 @@ echoHandler = do
     param <- getParam "echoparam"
     maybe (writeBS "must specify echo/param in URL")
           writeBS param
-
diff --git a/project_template/barebones/src/Server.hs 
b/project_template/barebones/src/Server.hs
new file mode 100644
index 0000000..2dd625b
--- /dev/null
+++ b/project_template/barebones/src/Server.hs
@@ -0,0 +1,111 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Server
+    ( ServerConfig(..)
+    , emptyServerConfig
+    , commandLineConfig
+    , server
+    , quickServer
+    ) where
+import qualified Data.ByteString.Char8 as B
+import           Data.ByteString.Char8 (ByteString)
+import           Data.Char
+import           Control.Concurrent
+import           Control.Exception (SomeException)
+import           Control.Monad.CatchIO
+import qualified Data.Text as T
+import           Prelude hiding (catch)
+import           Snap.Http.Server
+import           Snap.Types
+import           Snap.Util.GZip
+import           System hiding (getEnv)
+import           System.Posix.Env
+import qualified Text.XHtmlCombinators.Escape as XH
+
+
+data ServerConfig = ServerConfig
+    { locale          :: String
+    , interface       :: ByteString
+    , port            :: Int
+    , hostname        :: ByteString
+    , accessLog       :: Maybe FilePath
+    , errorLog        :: Maybe FilePath
+    , compression     :: Bool
+    , error500Handler :: SomeException -> Snap ()
+    }
+
+
+emptyServerConfig :: ServerConfig
+emptyServerConfig = ServerConfig
+    { locale          = "en_US"
+    , interface       = "0.0.0.0"
+    , port            = 8000
+    , hostname        = "myserver"
+    , accessLog       = Just "access.log"
+    , errorLog        = Just "error.log"
+    , compression     = True
+    , error500Handler = \e -> do
+        let t = T.pack $ show e
+            r = setContentType "text/html; charset=utf-8" $
+                setResponseStatus 500 "Internal Server Error" emptyResponse
+        putResponse r
+        writeBS "<html><head><title>Internal Server Error</title></head>"
+        writeBS "<body><h1>Internal Server Error</h1>"
+        writeBS "<p>A web handler threw an exception. Details:</p>"
+        writeBS "<pre>\n"
+        writeText $ XH.escape t
+        writeBS "\n</pre></body></html>"
+    }
+
+
+commandLineConfig :: IO ServerConfig
+commandLineConfig = do
+    args <- getArgs
+    let conf = case args of
+         []        -> emptyServerConfig
+         (port':_) -> emptyServerConfig { port = read port' }
+    locale' <- getEnv "LANG"
+    return $ case locale' of
+        Nothing -> conf
+        Just l  -> conf {locale = takeWhile (\c -> isAlpha c || c == '_') l}
+
+server :: ServerConfig -> Snap () -> IO ()
+server config handler = do
+    putStrLn $ "Listening on " ++ (B.unpack $ interface config)
+             ++ ":" ++ show (port config)
+    setUTF8Locale (locale config)
+    try $ httpServe
+             (interface config)
+             (port      config)
+             (hostname  config)
+             (accessLog config)
+             (errorLog  config)
+             (catch500 $ compress $ handler)
+             :: IO (Either SomeException ())
+    threadDelay 1000000
+    putStrLn "Shutting down"
+  where
+    catch500 = (`catch` (error500Handler config))
+    compress = if compression config then withCompression else id
+
+
+quickServer :: Snap () -> IO ()
+quickServer = (commandLineConfig >>=) . flip server
+
+
+setUTF8Locale :: String -> IO ()
+setUTF8Locale locale' = do
+    mapM_ (\k -> setEnv k (locale' ++ ".UTF-8") True)
+          [ "LANG"
+          , "LC_CTYPE"
+          , "LC_NUMERIC"
+          , "LC_TIME"
+          , "LC_COLLATE"
+          , "LC_MONETARY"
+          , "LC_MESSAGES"
+          , "LC_PAPER"
+          , "LC_NAME"
+          , "LC_ADDRESS"
+          , "LC_TELEPHONE"
+          , "LC_MEASUREMENT"
+          , "LC_IDENTIFICATION"
+          , "LC_ALL" ]
diff --git a/project_template/default/src/Common.hs 
b/project_template/default/src/Common.hs
deleted file mode 100644
index 7235693..0000000
--- a/project_template/default/src/Common.hs
+++ /dev/null
@@ -1,151 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE OverloadedStrings #-}
-
-module Common where
-
-import           Data.ByteString.Char8 (ByteString)
-import qualified Data.ByteString.Char8 as B
-import           Data.Maybe
-import qualified Data.Text as T
-import           Control.Applicative
-import           Control.Concurrent
-import           Control.Exception (SomeException)
-import           Control.Monad
-import           Control.Monad.CatchIO
-import           Control.Monad.Trans
-import           Prelude hiding (catch)
-import           Snap.Http.Server
-import           Snap.Types
-import           Snap.Util.FileServe
-import           Snap.Util.GZip
-import           System
-import           System.Posix.Env
-import           Text.Templating.Heist
-import           Text.Templating.Heist.Splices.Static
-import qualified Text.XHtmlCombinators.Escape as XH
-
-
-setLocaleToUTF8 :: IO ()
-setLocaleToUTF8 = do
-    mapM_ (\k -> setEnv k "en_US.UTF-8" True)
-          [ "LANG"
-          , "LC_CTYPE"
-          , "LC_NUMERIC"
-          , "LC_TIME"
-          , "LC_COLLATE"
-          , "LC_MONETARY"
-          , "LC_MESSAGES"
-          , "LC_PAPER"
-          , "LC_NAME"
-          , "LC_ADDRESS"
-          , "LC_TELEPHONE"
-          , "LC_MEASUREMENT"
-          , "LC_IDENTIFICATION"
-          , "LC_ALL" ]
-
-
-------------------------------------------------------------------------------
--- General purpose code.  This code will eventually get moved into Snap once
--- we have a good place to put it.
-------------------------------------------------------------------------------
-
-------------------------------------------------------------------------------
--- |
-renderTmpl :: MVar (TemplateState Snap)
-           -> ByteString
-           -> Snap ()
-renderTmpl tsMVar n = do
-    ts <- liftIO $ readMVar tsMVar
-    maybe pass writeBS =<< renderTemplate ts n
-
-
-templateServe :: TemplateState Snap
-              -> MVar (TemplateState Snap)
-              -> StaticTagState
-              -> Snap ()
-templateServe orig tsMVar staticState = do
-    p
-    modifyResponse $ setContentType "text/html; charset=utf-8"
-
-  where
-    p = ifTop (renderTmpl tsMVar "index") <|>
-        path "admin/reload" (reloadTemplates orig tsMVar staticState) <|>
-        (renderTmpl tsMVar . B.pack =<< getSafePath)
-
-
-loadError :: String -> String
-loadError str = "Error loading templates\n"++str
-
-reloadTemplates :: TemplateState Snap
-                -> MVar (TemplateState Snap)
-                -> StaticTagState
-                -> Snap ()
-reloadTemplates origTs tsMVar staticState = do
-    liftIO $ clearStaticTagCache staticState
-    ts <- liftIO $ loadTemplates "templates" origTs
-    either bad good ts
-  where
-    bad msg = do writeBS $ B.pack $ loadError msg ++ "Keeping old templates."
-    good ts = do liftIO $ modifyMVar_ tsMVar (const $ return ts)
-                 writeBS "Templates loaded successfully"
-
-
-basicHandlers :: TemplateState Snap
-              -> MVar (TemplateState Snap)
-              -> StaticTagState
-              -> Snap ()
-              -> Snap ()
-basicHandlers origTs tsMVar staticState userHandlers =
-    catch500 $ withCompression $
-        userHandlers <|>
-        templateServe origTs tsMVar staticState
-
-
-catch500 :: Snap a -> Snap ()
-catch500 m = (m >> return ()) `catch` \(e::SomeException) -> do
-    let t = T.pack $ show e
-    putResponse r
-    writeBS "<html><head><title>Internal Server Error</title></head>"
-    writeBS "<body><h1>Internal Server Error</h1>"
-    writeBS "<p>A web handler threw an exception. Details:</p>"
-    writeBS "<pre>\n"
-    writeText $ XH.escape t
-    writeBS "\n</pre></body></html>"
-
-  where
-    r = setContentType "text/html" $
-        setResponseStatus 500 "Internal Server Error" emptyResponse
-
-data AppConfig = AppConfig {
-    templateDir :: FilePath,
-    accessLog :: Maybe FilePath,
-    errorLog :: Maybe FilePath
-}
-
-quickServer :: AppConfig -> Snap () -> IO ()
-quickServer config siteHandlers = do
-    args   <- getArgs
-    port   <- case args of
-                []       -> error "You must specify a port!" >> exitFailure
-                (port:_) -> return $ read port
-
-    setLocaleToUTF8
-
-    (origTs,staticState) <- bindStaticTag emptyTemplateState
-
-    ets <- loadTemplates (templateDir config) origTs
-    let ts = either error id ets
-    either (\s -> putStrLn (loadError s) >> exitFailure) (const $ return ()) 
ets
-    tsMVar <- newMVar $ ts
-
-    (try $ httpServe "*" port "myserver"
-             (accessLog config)
-             (errorLog config)
-             (basicHandlers origTs tsMVar staticState siteHandlers))
-             :: IO (Either SomeException ())
-
-    threadDelay 1000000
-    putStrLn "exiting"
-    return ()
-
diff --git a/project_template/default/src/Glue.hs 
b/project_template/default/src/Glue.hs
new file mode 100644
index 0000000..e2513ba
--- /dev/null
+++ b/project_template/default/src/Glue.hs
@@ -0,0 +1,49 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Glue
+    ( templateHandler
+    , newTemplateDirectory'
+    , defaultReloadHandler
+    , templateServe
+    , render
+    , bindSplices
+    , withSplices
+    ) where
+import           Control.Applicative
+import           Control.Monad
+import           Data.ByteString.Char8 (ByteString)
+import qualified Data.ByteString.Char8 as B
+import           Prelude hiding (catch)
+import           Snap.Types hiding (dir)
+import           Snap.Util.FileServe
+import           Text.Templating.Heist
+
+import           TemplateDirectory
+
+
+templateHandler :: TemplateDirectory Snap
+                -> (TemplateDirectory Snap -> Snap ())
+                -> (TemplateState Snap -> Snap ())
+                -> Snap ()
+templateHandler td reload f = reload td <|> (f =<< getTemplateState td)
+
+
+defaultReloadHandler :: TemplateDirectory Snap -> Snap ()
+defaultReloadHandler td = path "admin/reload" $ do
+    e <- reloadTemplateDirectory td
+    modifyResponse $ setContentType "text/plain; charset=utf-8"
+    writeBS . B.pack $ either id (const "Templates loaded successfully.") e
+
+
+render :: TemplateState Snap -> ByteString -> Snap ()
+render ts template = do
+    bytes <- renderTemplate ts template
+    flip (maybe pass) bytes $ \x -> do
+        modifyResponse $ setContentType "text/html; charset=utf-8"
+        writeBS x
+
+
+templateServe :: TemplateState Snap -> Snap ()
+templateServe ts = ifTop (render ts "index") <|> do
+    path' <- getSafePath
+    when (head path' == '_') pass
+    render ts $ B.pack path'
diff --git a/project_template/default/src/Main.hs 
b/project_template/default/src/Main.hs
index 4699c3f..5b74e26 100644
--- a/project_template/default/src/Main.hs
+++ b/project_template/default/src/Main.hs
@@ -4,31 +4,26 @@ module Main where
 import           Control.Applicative
 import           Snap.Types
 import           Snap.Util.FileServe
+import           Text.Templating.Heist
 
-import           Common
+import           Glue
+import           Server
 
-config :: AppConfig
-config = AppConfig {
-  templateDir = "templates",
-  accessLog = Just "access.log",
-  errorLog = Just "error.log"
-}
 
 main :: IO ()
 main = do
-    quickServer config site
+    td <- newTemplateDirectory' "templates" emptyTemplateState
+    quickServer $ templateHandler td defaultReloadHandler $ \ts ->
+        ifTop (writeBS "hello world") <|>
+        route [ ("foo", writeBS "bar")
+              , ("echo/:echoparam", echoHandler)
+              ] <|>
+        templateServe ts <|>
+        dir "static" (fileServe ".")
 
-site :: Snap ()
-site =
-    ifTop (writeBS "hello world") <|>
-    route [ ("foo", writeBS "bar")
-          , ("echo/:echoparam", echoHandler)
-          ] <|>
-    dir "static" (fileServe ".")
 
 echoHandler :: Snap ()
 echoHandler = do
     param <- getParam "echoparam"
     maybe (writeBS "must specify echo/param in URL")
           writeBS param
-
diff --git a/project_template/default/src/Server.hs 
b/project_template/default/src/Server.hs
new file mode 100644
index 0000000..2dd625b
--- /dev/null
+++ b/project_template/default/src/Server.hs
@@ -0,0 +1,111 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Server
+    ( ServerConfig(..)
+    , emptyServerConfig
+    , commandLineConfig
+    , server
+    , quickServer
+    ) where
+import qualified Data.ByteString.Char8 as B
+import           Data.ByteString.Char8 (ByteString)
+import           Data.Char
+import           Control.Concurrent
+import           Control.Exception (SomeException)
+import           Control.Monad.CatchIO
+import qualified Data.Text as T
+import           Prelude hiding (catch)
+import           Snap.Http.Server
+import           Snap.Types
+import           Snap.Util.GZip
+import           System hiding (getEnv)
+import           System.Posix.Env
+import qualified Text.XHtmlCombinators.Escape as XH
+
+
+data ServerConfig = ServerConfig
+    { locale          :: String
+    , interface       :: ByteString
+    , port            :: Int
+    , hostname        :: ByteString
+    , accessLog       :: Maybe FilePath
+    , errorLog        :: Maybe FilePath
+    , compression     :: Bool
+    , error500Handler :: SomeException -> Snap ()
+    }
+
+
+emptyServerConfig :: ServerConfig
+emptyServerConfig = ServerConfig
+    { locale          = "en_US"
+    , interface       = "0.0.0.0"
+    , port            = 8000
+    , hostname        = "myserver"
+    , accessLog       = Just "access.log"
+    , errorLog        = Just "error.log"
+    , compression     = True
+    , error500Handler = \e -> do
+        let t = T.pack $ show e
+            r = setContentType "text/html; charset=utf-8" $
+                setResponseStatus 500 "Internal Server Error" emptyResponse
+        putResponse r
+        writeBS "<html><head><title>Internal Server Error</title></head>"
+        writeBS "<body><h1>Internal Server Error</h1>"
+        writeBS "<p>A web handler threw an exception. Details:</p>"
+        writeBS "<pre>\n"
+        writeText $ XH.escape t
+        writeBS "\n</pre></body></html>"
+    }
+
+
+commandLineConfig :: IO ServerConfig
+commandLineConfig = do
+    args <- getArgs
+    let conf = case args of
+         []        -> emptyServerConfig
+         (port':_) -> emptyServerConfig { port = read port' }
+    locale' <- getEnv "LANG"
+    return $ case locale' of
+        Nothing -> conf
+        Just l  -> conf {locale = takeWhile (\c -> isAlpha c || c == '_') l}
+
+server :: ServerConfig -> Snap () -> IO ()
+server config handler = do
+    putStrLn $ "Listening on " ++ (B.unpack $ interface config)
+             ++ ":" ++ show (port config)
+    setUTF8Locale (locale config)
+    try $ httpServe
+             (interface config)
+             (port      config)
+             (hostname  config)
+             (accessLog config)
+             (errorLog  config)
+             (catch500 $ compress $ handler)
+             :: IO (Either SomeException ())
+    threadDelay 1000000
+    putStrLn "Shutting down"
+  where
+    catch500 = (`catch` (error500Handler config))
+    compress = if compression config then withCompression else id
+
+
+quickServer :: Snap () -> IO ()
+quickServer = (commandLineConfig >>=) . flip server
+
+
+setUTF8Locale :: String -> IO ()
+setUTF8Locale locale' = do
+    mapM_ (\k -> setEnv k (locale' ++ ".UTF-8") True)
+          [ "LANG"
+          , "LC_CTYPE"
+          , "LC_NUMERIC"
+          , "LC_TIME"
+          , "LC_COLLATE"
+          , "LC_MONETARY"
+          , "LC_MESSAGES"
+          , "LC_PAPER"
+          , "LC_NAME"
+          , "LC_ADDRESS"
+          , "LC_TELEPHONE"
+          , "LC_MEASUREMENT"
+          , "LC_IDENTIFICATION"
+          , "LC_ALL" ]
diff --git a/project_template/default/src/TemplateDirectory.hs 
b/project_template/default/src/TemplateDirectory.hs
new file mode 100644
index 0000000..36362c4
--- /dev/null
+++ b/project_template/default/src/TemplateDirectory.hs
@@ -0,0 +1,78 @@
+module TemplateDirectory
+    ( TemplateDirectory
+    , newTemplateDirectory
+    , newTemplateDirectory'
+
+    , getTemplateState
+    , reloadTemplateDirectory
+
+    , bindSplices
+    , withSplices
+    ) where
+import           Control.Concurrent
+import           Control.Monad
+import           Control.Monad.Trans
+import           Data.ByteString.Char8 (ByteString)
+import           Text.Templating.Heist
+import           Text.Templating.Heist.Splices.Static
+
+
+data TemplateDirectory m
+    = TemplateDirectory
+        FilePath
+        (TemplateState m)
+        (MVar (TemplateState m))
+        StaticTagState
+
+
+newTemplateDirectory :: (MonadIO m, MonadIO n)
+                     => FilePath
+                     -> TemplateState m
+                     -> n (Either String (TemplateDirectory m))
+newTemplateDirectory dir templateState = liftIO $ do
+    (origTs,sts) <- bindStaticTag templateState
+    ets <- loadTemplates dir origTs
+    leftPass ets $ \ts -> do
+        tsMVar <- newMVar $ ts
+        return $ TemplateDirectory dir origTs tsMVar sts
+
+
+newTemplateDirectory' :: (MonadIO m, MonadIO n)
+                      => FilePath
+                      -> TemplateState m
+                      -> n (TemplateDirectory m)
+newTemplateDirectory' = ((either fail return =<<) .) . newTemplateDirectory
+
+
+getTemplateState :: (Monad m, MonadIO n)
+                 => TemplateDirectory m
+                 -> n (TemplateState m)
+getTemplateState (TemplateDirectory _ _ tsMVar _) = liftIO $ readMVar $ tsMVar
+
+
+reloadTemplateDirectory :: (MonadIO m, MonadIO n)
+                        => TemplateDirectory m
+                        -> n (Either String ())
+reloadTemplateDirectory (TemplateDirectory p origTs tsMVar sts) = liftIO $ do
+    clearStaticTagCache sts
+    ets <- loadTemplates p origTs
+    leftPass ets $ \ts -> modifyMVar_ tsMVar (const $ return ts)
+
+
+bindSplices :: Monad m
+           => [(ByteString, Splice m)]
+           -> TemplateState m
+           -> TemplateState m
+bindSplices = flip $ foldr (uncurry bindSplice)
+
+
+withSplices :: MonadIO m
+            => [(ByteString, Splice m)]
+            -> TemplateState m
+withSplices = foldr (uncurry bindSplice) emptyTemplateState
+
+
+leftPass :: Monad m => Either String b -> (b -> m c) -> m (Either String c)
+leftPass e m = either (return . Left . loadError) (liftM Right . m) e
+  where
+    loadError = (++) "Error loading templates: "
commit fc0551b44e40917f03454ed165de3f342eaa4920
Merge: 2831e59 f622aa8
Author: Shane <[email protected]>
Date:   Fri Jun 11 11:25:47 2010 +0100

    Merge branch 'master' of http://github.com/snapframework/snap-core

commit 2831e593236b6b6ddf0d41b2866627a269524a04
Author: Shane <[email protected]>
Date:   Thu Jun 10 14:50:51 2010 +0100

    Added my email address to CONTRIBUTORS

diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index f3a2189..67fb731 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -2,6 +2,6 @@ Doug Beardsley <[email protected]>
 Gregory Collins <[email protected]>
 Shu-yu Guo <[email protected]>
 Carl Howells
-Shane O'Brien
+Shane O'Brien <[email protected]>
 James Sanders <[email protected]>
 Jacob Stanley <[email protected]>
commit 8d75a66768ea1cdb4d826120abbc9497ff833c98
Author: Shane <[email protected]>
Date:   Thu Jun 10 14:47:22 2010 +0100

    Changed templateServe to always serve templates as UTF-8

diff --git a/project_template/default/src/Common.hs 
b/project_template/default/src/Common.hs
index 1df3d36..7235693 100644
--- a/project_template/default/src/Common.hs
+++ b/project_template/default/src/Common.hs
@@ -66,7 +66,7 @@ templateServe :: TemplateState Snap
               -> Snap ()
 templateServe orig tsMVar staticState = do
     p
-    modifyResponse $ setContentType "text/html"
+    modifyResponse $ setContentType "text/html; charset=utf-8"
 
   where
     p = ifTop (renderTmpl tsMVar "index") <|>
-----------------------------------------------------------------------


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

Reply via email to