From ebf3c8e4f2025ad3da896ac71ebe9d18a546acd1 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Sun, 31 Aug 2014 00:22:34 +0300 Subject: [PATCH 1/2] Scaffolding update for #814 --- yesod-bin/hsfiles/mongo.hsfiles | 4 ++++ yesod-bin/hsfiles/mysql.hsfiles | 4 ++++ yesod-bin/hsfiles/postgres-fay.hsfiles | 4 ++++ yesod-bin/hsfiles/postgres.hsfiles | 4 ++++ yesod-bin/hsfiles/simple.hsfiles | 4 ++++ yesod-bin/hsfiles/sqlite.hsfiles | 4 ++++ 6 files changed, 24 insertions(+) diff --git a/yesod-bin/hsfiles/mongo.hsfiles b/yesod-bin/hsfiles/mongo.hsfiles index 65a997ee..6fce7882 100644 --- a/yesod-bin/hsfiles/mongo.hsfiles +++ b/yesod-bin/hsfiles/mongo.hsfiles @@ -436,6 +436,10 @@ library , fast-logger >= 2.2 && < 2.3 , wai-logger >= 2.2 && < 2.3 + -- see https://github.com/yesodweb/yesod/issues/814 + if !os(windows) + build-depends: unix + executable PROJECTNAME if flag(library-only) Buildable: False diff --git a/yesod-bin/hsfiles/mysql.hsfiles b/yesod-bin/hsfiles/mysql.hsfiles index 6616cb4b..d02bfadb 100644 --- a/yesod-bin/hsfiles/mysql.hsfiles +++ b/yesod-bin/hsfiles/mysql.hsfiles @@ -440,6 +440,10 @@ library , fast-logger >= 2.2 && < 2.3 , wai-logger >= 2.2 && < 2.3 + -- see https://github.com/yesodweb/yesod/issues/814 + if !os(windows) + build-depends: unix + executable PROJECTNAME if flag(library-only) Buildable: False diff --git a/yesod-bin/hsfiles/postgres-fay.hsfiles b/yesod-bin/hsfiles/postgres-fay.hsfiles index 7ac52a23..a8920c3b 100644 --- a/yesod-bin/hsfiles/postgres-fay.hsfiles +++ b/yesod-bin/hsfiles/postgres-fay.hsfiles @@ -477,6 +477,10 @@ library , fast-logger >= 2.2 && < 2.3 , wai-logger >= 2.2 && < 2.3 + -- see https://github.com/yesodweb/yesod/issues/814 + if !os(windows) + build-depends: unix + executable PROJECTNAME if flag(library-only) Buildable: False diff --git a/yesod-bin/hsfiles/postgres.hsfiles b/yesod-bin/hsfiles/postgres.hsfiles index f9f65603..bb8e1346 100644 --- a/yesod-bin/hsfiles/postgres.hsfiles +++ b/yesod-bin/hsfiles/postgres.hsfiles @@ -440,6 +440,10 @@ library , fast-logger >= 2.2 && < 2.3 , wai-logger >= 2.2 && < 2.3 + -- see https://github.com/yesodweb/yesod/issues/814 + if !os(windows) + build-depends: unix + executable PROJECTNAME if flag(library-only) Buildable: False diff --git a/yesod-bin/hsfiles/simple.hsfiles b/yesod-bin/hsfiles/simple.hsfiles index 4124f8fe..449a2e4f 100644 --- a/yesod-bin/hsfiles/simple.hsfiles +++ b/yesod-bin/hsfiles/simple.hsfiles @@ -364,6 +364,10 @@ library , fast-logger >= 2.2 && < 2.3 , wai-logger >= 2.2 && < 2.3 + -- see https://github.com/yesodweb/yesod/issues/814 + if !os(windows) + build-depends: unix + executable PROJECTNAME if flag(library-only) Buildable: False diff --git a/yesod-bin/hsfiles/sqlite.hsfiles b/yesod-bin/hsfiles/sqlite.hsfiles index e379455e..bd288dd8 100644 --- a/yesod-bin/hsfiles/sqlite.hsfiles +++ b/yesod-bin/hsfiles/sqlite.hsfiles @@ -440,6 +440,10 @@ library , fast-logger >= 2.2 && < 2.3 , wai-logger >= 2.2 && < 2.3 + -- see https://github.com/yesodweb/yesod/issues/814 + if !os(windows) + build-depends: unix + executable PROJECTNAME if flag(library-only) Buildable: False From 1e76a28f6d8118fb2fde4aed437ac1fe1a2ff68f Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Sun, 31 Aug 2014 02:24:08 +0300 Subject: [PATCH 2/2] withUrlRenderer --- yesod-core/Yesod/Core/Class/Yesod.hs | 2 +- yesod-core/Yesod/Core/Handler.hs | 22 ++++++++++++++++------ yesod-core/yesod-core.cabal | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/yesod-core/Yesod/Core/Class/Yesod.hs b/yesod-core/Yesod/Core/Class/Yesod.hs index 140600b9..8631d27e 100644 --- a/yesod-core/Yesod/Core/Class/Yesod.hs +++ b/yesod-core/Yesod/Core/Class/Yesod.hs @@ -94,7 +94,7 @@ class RenderRoute site => Yesod site where defaultLayout w = do p <- widgetToPageContent w mmsg <- getMessage - giveUrlRenderer [hamlet| + withUrlRenderer [hamlet| $newline never $doctype 5 diff --git a/yesod-core/Yesod/Core/Handler.hs b/yesod-core/Yesod/Core/Handler.hs index 7347d4f3..d2b196b4 100644 --- a/yesod-core/Yesod/Core/Handler.hs +++ b/yesod-core/Yesod/Core/Handler.hs @@ -139,6 +139,7 @@ module Yesod.Core.Handler -- ** Hamlet , hamletToRepHtml , giveUrlRenderer + , withUrlRenderer -- ** Misc , newIdent -- * Lifting @@ -854,7 +855,7 @@ redirectToPost :: (MonadHandler m, RedirectUrl (HandlerSite m) url) -> m a redirectToPost url = do urlText <- toTextUrl url - giveUrlRenderer [hamlet| + withUrlRenderer [hamlet| $newline never $doctype 5 @@ -870,17 +871,26 @@ $doctype 5 -- | Wraps the 'Content' generated by 'hamletToContent' in a 'RepHtml'. hamletToRepHtml :: MonadHandler m => HtmlUrl (Route (HandlerSite m)) -> m Html -hamletToRepHtml = giveUrlRenderer -{-# DEPRECATED hamletToRepHtml "Use giveUrlRenderer instead" #-} +hamletToRepHtml = withUrlRenderer +{-# DEPRECATED hamletToRepHtml "Use withUrlRenderer instead" #-} --- | Provide a URL rendering function to the given function and return the --- result. Useful for processing Shakespearean templates. +-- | Deprecated synonym for 'withUrlRenderer'. -- -- Since 1.2.0 giveUrlRenderer :: MonadHandler m => ((Route (HandlerSite m) -> [(Text, Text)] -> Text) -> output) -> m output -giveUrlRenderer f = do +giveUrlRenderer = withUrlRenderer +{-# DEPRECATED giveUrlRenderer "Use withUrlRenderer instead" #-} + +-- | Provide a URL rendering function to the given function and return the +-- result. Useful for processing Shakespearean templates. +-- +-- Since 1.2.20 +withUrlRenderer :: MonadHandler m + => ((Route (HandlerSite m) -> [(Text, Text)] -> Text) -> output) + -> m output +withUrlRenderer f = do render <- getUrlRenderParams return $ f render diff --git a/yesod-core/yesod-core.cabal b/yesod-core/yesod-core.cabal index f9045626..4ef36767 100644 --- a/yesod-core/yesod-core.cabal +++ b/yesod-core/yesod-core.cabal @@ -1,5 +1,5 @@ name: yesod-core -version: 1.2.19.2 +version: 1.2.20 license: MIT license-file: LICENSE author: Michael Snoyman