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

The branch, master has been updated
       via  aa68cdf4d67b05ee6b049057d6cbaaa41f0b51df (commit)
      from  1676f15cd47557cca82e1ba339ae16dbb2e16a3f (commit)


Summary of changes:
 TODO                                               |    4 +++
 project_template/hint/foo.cabal                    |    3 +-
 project_template/hint/resources/static/screen.css  |   20 ++++++++++++++++++
 .../hint/resources/templates/index.tpl             |   17 ++++++++++----
 project_template/hint/src/Config.hs                |    8 ++++--
 project_template/hint/src/Site.hs                  |   22 ++++++++++++++-----
 6 files changed, 59 insertions(+), 15 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 aa68cdf4d67b05ee6b049057d6cbaaa41f0b51df
Author: Carl Howells <[email protected]>
Date:   Mon Jun 21 13:54:07 2010 -0700

    Better base sample app

diff --git a/TODO b/TODO
index 89376ed..27cf346 100644
--- a/TODO
+++ b/TODO
@@ -15,3 +15,7 @@ document EVERYTHING.
   -- high-level design documentation
 
 Fix whatever is blocking ctrl-C in the hint server.
+
+Figure out why building the TH splices in StarterTH is SO slow.
+
+Figure out why Static.hs is generating code that reloads the config.
diff --git a/project_template/hint/foo.cabal b/project_template/hint/foo.cabal
index edac802..57c9d70 100644
--- a/project_template/hint/foo.cabal
+++ b/project_template/hint/foo.cabal
@@ -32,6 +32,7 @@ Executable projname
     snap-server >= 0.3 && < 0.4,
     heist >= 0.2.1 && < 0.3,
     hint >= 0.3.2 && < 0.4,
-    template-haskell >= 2.3 && < 2.5
+    template-haskell >= 2.3 && < 2.5,
+    time >= 1.0 && < 1.3
 
   ghc-options: -O2 -Wall -fwarn-tabs -threaded
diff --git a/project_template/hint/resources/static/screen.css 
b/project_template/hint/resources/static/screen.css
index e69de29..4393d71 100644
--- a/project_template/hint/resources/static/screen.css
+++ b/project_template/hint/resources/static/screen.css
@@ -0,0 +1,20 @@
+html {
+   padding: 0;
+   margin: 0;
+   background-color: #ffffff;
+   font-family: Verdana, Helvetica, sans-serif;
+}
+body {
+   padding: 0;
+   margin: 0;
+}
+a {
+   text-decoration: underline;
+}
+a :hover {
+   cursor: pointer;
+   text-decoration: underline;
+}
+img {
+   border: none;
+}
diff --git a/project_template/hint/resources/templates/index.tpl 
b/project_template/hint/resources/templates/index.tpl
index 7cdbf1c..042fea1 100644
--- a/project_template/hint/resources/templates/index.tpl
+++ b/project_template/hint/resources/templates/index.tpl
@@ -5,10 +5,17 @@
     <link rel="stylesheet" type="text/css" href="screen.css"/>
   </head>
   <body>
-    <h1>It works!</h1>
-    <p>
-      This is a simple demo page served using Heist and the Snap
-      framework.
-    </p>
+    <div style="padding-left: 1em;">
+      <h1>It works!</h1>
+      <p>
+        This is a simple demo page served using
+        <a href="http://snapframework.com/docs/tutorials/heist";>Heist</a>
+        and the <a href="http://snapframework.com/";>Snap</a> web framework.
+      </p>
+      <p>
+        This site's config was loaded at <loadTime/>, and this page
+        was generated at <renderTime/>.
+      </p>
+    </div>
   </body>
 </html>
diff --git a/project_template/hint/src/Config.hs 
b/project_template/hint/src/Config.hs
index 3790195..5c86e7b 100644
--- a/project_template/hint/src/Config.hs
+++ b/project_template/hint/src/Config.hs
@@ -1,15 +1,17 @@
 module Config where
 
 import Control.Applicative ((<$>))
+import Data.Time.Clock
 import Snap.Types
 import Text.Templating.Heist
 
 data Config = Config {
-      templateState :: TemplateState Snap
+      loadTime :: UTCTime
+    , templateState :: TemplateState Snap
     }
 
-
 getConfig :: IO Config
 getConfig = do
+    time <- getCurrentTime
     let ets = loadTemplates "resources/templates" emptyTemplateState
-    either error Config <$> ets
+    either error (Config time) <$> ets
diff --git a/project_template/hint/src/Site.hs 
b/project_template/hint/src/Site.hs
index 64598e0..e8289b7 100644
--- a/project_template/hint/src/Site.hs
+++ b/project_template/hint/src/Site.hs
@@ -4,8 +4,10 @@ module Site where
 import           Config
 
 import           Control.Monad (msum)
+import           Control.Monad.Trans (liftIO)
 
 import qualified Data.ByteString.Char8 as S
+import           Data.Time.Clock
 
 import           Snap.Util.FileServe (fileServe)
 import           Snap.Types
@@ -13,11 +15,19 @@ import           Snap.Types
 import           Text.Templating.Heist
 
 
-frontPage :: TemplateState Snap -> Snap ()
-frontPage ts = ifTop $ do
+frontPage :: Config -> Snap ()
+frontPage config = ifTop $ do
     modifyResponse $ setContentType "text/html; charset=utf-8"
 
-    Just rendered <- renderTemplate ts "index"
+    time <- liftIO getCurrentTime
+
+    let [loadS, renderS] = map (S.pack . show) [loadTime config, time]
+        ts = templateState config
+        ts' = bindStrings [ ("loadTime", loadS)
+                          , ("renderTime", renderS)
+                          ] ts
+
+    Just rendered <- renderTemplate ts' "index"
     writeBS rendered
     let len = fromIntegral . S.length $ rendered
     modifyResponse . setContentLength $ len
@@ -28,6 +38,6 @@ staticResources = fileServe "resources/static"
 
 
 site :: Config -> Snap ()
-site ts = msum [ frontPage $ templateState ts
-               , staticResources
-               ]
+site config = msum [ frontPage config
+                   , staticResources
+                   ]
-----------------------------------------------------------------------


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

Reply via email to