snap-app 0.3.2 → 0.4.0
raw patch · 3 files changed
+8/−7 lines, 3 filesdep +blaze-markupdep ~blaze-html
Dependencies added: blaze-markup
Dependency ranges changed: blaze-html
Files
- snap-app.cabal +3/−2
- src/Snap/App/Cache.hs +3/−3
- src/Snap/App/Controller.hs +2/−2
snap-app.cabal view
@@ -1,5 +1,5 @@ name: snap-app-version: 0.3.2+version: 0.4.0 synopsis: Simple modules for writing apps with Snap, abstracted from hpaste. homepage: Simple modules for writing apps with Snap, abstracted from hpaste. license: BSD3@@ -24,7 +24,8 @@ network, postgresql-simple, mtl,- blaze-html == 0.4.3.4,+ blaze-html >= 0.6,+ blaze-markup >= 0.5, safe, text, utf8-string,
src/Snap/App/Cache.hs view
@@ -31,7 +31,7 @@ getCacheDir :: config -> FilePath -- | Cache conditionally.-cacheIf :: (CacheDir c,Key key) => Bool -> key -> Controller c s (Maybe Html) -> Controller c s (Maybe Text)+cacheIf :: (CacheDir c,Key key) => Bool -> key -> Controller c s (Maybe Markup) -> Controller c s (Maybe Text) cacheIf pred key generate = if pred then cache key generate@@ -39,7 +39,7 @@ -- | Generate and save into the cache, or retrieve existing from the -- | cache.-cache :: (CacheDir c,Key key) => key -> Controller c s (Maybe Html) -> Controller c s (Maybe Text)+cache :: (CacheDir c,Key key) => key -> Controller c s (Maybe Markup) -> Controller c s (Maybe Text) cache key generate = do tmpdir <- asks (getCacheDir . controllerStateConfig) let cachePath = tmpdir ++ "/" ++ keyToString key@@ -85,7 +85,7 @@ io = liftIO -- | View some HTML generator cached.-viewCached :: (CacheDir c,Key key) => key -> Controller c s Html -> Controller c s ()+viewCached :: (CacheDir c,Key key) => key -> Controller c s Markup -> Controller c s () viewCached key generate = do text <- cache key (fmap Just generate) maybe (return ()) outputText text
src/Snap/App/Controller.hs view
@@ -32,7 +32,7 @@ import Data.Text.Lazy (Text,toStrict) import Database.PostgreSQL.Simple import Safe (readMay)-import Text.Blaze (Html)+import Text.Blaze (Markup) import Text.Blaze.Renderer.Text (renderHtml) import Text.Blaze.Pagination (PN(..)) @@ -48,7 +48,7 @@ -- | Strictly renders HTML to Text before outputting it via Snap. -- This ensures that any lazy exceptions are caught by the Snap -- handler.-output :: Html -> Controller c s ()+output :: Markup -> Controller c s () output html = outputText $ renderHtml $ html -- | Strictly renders text before outputting it via Snap.