deal with yesod's second gratuitous rename of the same function in a year

This commit is contained in:
Joey Hess 2014-10-23 20:26:46 -04:00
parent 31a1f061c6
commit ce9076370e
7 changed files with 23 additions and 11 deletions

View file

@ -125,7 +125,7 @@ getBuddyListR nid = do
waitNotifier getBuddyListBroadcaster nid waitNotifier getBuddyListBroadcaster nid
p <- widgetToPageContent buddyListDisplay p <- widgetToPageContent buddyListDisplay
giveUrlRenderer $ [hamlet|^{pageBody p}|] withUrlRenderer $ [hamlet|^{pageBody p}|]
buddyListDisplay :: Widget buddyListDisplay :: Widget
buddyListDisplay = do buddyListDisplay = do

View file

@ -66,7 +66,7 @@ getTransfersR nid = do
waitNotifier getTransferBroadcaster nid waitNotifier getTransferBroadcaster nid
p <- widgetToPageContent transfersDisplay p <- widgetToPageContent transfersDisplay
giveUrlRenderer $ [hamlet|^{pageBody p}|] withUrlRenderer $ [hamlet|^{pageBody p}|]
{- The main dashboard. -} {- The main dashboard. -}
dashboard :: Bool -> Widget dashboard :: Bool -> Widget

View file

@ -66,7 +66,7 @@ customPage' with_longpolling navbaritem content = do
when with_longpolling $ when with_longpolling $
addScript $ StaticR js_longpolling_js addScript $ StaticR js_longpolling_js
$(widgetFile "page") $(widgetFile "page")
giveUrlRenderer $(Hamlet.hamletFile $ hamletTemplate "bootstrap") withUrlRenderer $(Hamlet.hamletFile $ hamletTemplate "bootstrap")
Just msg -> error msg Just msg -> error msg
where where
navdetails i = (navBarName i, navBarRoute i, Just i == navbaritem) navdetails i = (navBarName i, navBarRoute i, Just i == navbaritem)

View file

@ -91,7 +91,7 @@ getRepoListR :: NotificationId -> RepoSelector -> Handler Html
getRepoListR nid reposelector = do getRepoListR nid reposelector = do
waitNotifier getRepoListBroadcaster nid waitNotifier getRepoListBroadcaster nid
p <- widgetToPageContent $ repoListDisplay reposelector p <- widgetToPageContent $ repoListDisplay reposelector
giveUrlRenderer $ [hamlet|^{pageBody p}|] withUrlRenderer $ [hamlet|^{pageBody p}|]
mainRepoSelector :: RepoSelector mainRepoSelector :: RepoSelector
mainRepoSelector = RepoSelector mainRepoSelector = RepoSelector

View file

@ -73,7 +73,7 @@ getSideBarR nid = do
liftIO $ threadDelay 100000 liftIO $ threadDelay 100000
page <- widgetToPageContent sideBarDisplay page <- widgetToPageContent sideBarDisplay
giveUrlRenderer $ [hamlet|^{pageBody page}|] withUrlRenderer $ [hamlet|^{pageBody page}|]
{- Called by the client to close an alert. -} {- Called by the client to close an alert. -}
getCloseAlert :: AlertId -> Handler () getCloseAlert :: AlertId -> Handler ()

View file

@ -78,7 +78,7 @@ instance Yesod WebApp where
addScript $ StaticR js_jquery_full_js addScript $ StaticR js_jquery_full_js
addScript $ StaticR js_bootstrap_js addScript $ StaticR js_bootstrap_js
$(widgetFile "error") $(widgetFile "error")
giveUrlRenderer $(hamletFile $ hamletTemplate "bootstrap") withUrlRenderer $(hamletFile $ hamletTemplate "bootstrap")
instance RenderMessage WebApp FormMessage where instance RenderMessage WebApp FormMessage where
renderMessage _ _ = defaultFormMessage renderMessage _ _ = defaultFormMessage

View file

@ -1,9 +1,9 @@
{- Yesod stuff, that's typically found in the scaffolded site. {- Yesod stuff, that's typically found in the scaffolded site.
- -
- Also a bit of a compatability layer to make it easier to support yesod - Also a bit of a compatability layer to make it easier to support yesod
- 1.1 and 1.2 in the same code base. - 1.1-1.4 in the same code base.
- -
- Copyright 2012, 2013 Joey Hess <joey@kitenet.net> - Copyright 2012-2014 Joey Hess <joey@kitenet.net>
- -
- Licensed under the GNU GPL version 3 or higher. - Licensed under the GNU GPL version 3 or higher.
-} -}
@ -17,8 +17,10 @@ module Utility.Yesod
, widgetFile , widgetFile
, hamletTemplate , hamletTemplate
#endif #endif
#if ! MIN_VERSION_yesod(1,4,0)
, withUrlRenderer
#endif
#if ! MIN_VERSION_yesod(1,2,0) #if ! MIN_VERSION_yesod(1,2,0)
, giveUrlRenderer
, Html , Html
#endif #endif
) where ) where
@ -41,6 +43,11 @@ import Data.Default (def)
import Text.Hamlet hiding (Html) import Text.Hamlet hiding (Html)
#endif #endif
#endif #endif
#if ! MIN_VERSION_yesod(1,4,0)
#if MIN_VERSION_yesod(1,2,0)
import Data.Text (Text)
#endif
#endif
#ifndef __NO_TH__ #ifndef __NO_TH__
widgetFile :: String -> Q Exp widgetFile :: String -> Q Exp
@ -69,8 +76,13 @@ liftH = lift
{- Misc new names for stuff. -} {- Misc new names for stuff. -}
#if ! MIN_VERSION_yesod(1,2,0) #if ! MIN_VERSION_yesod(1,2,0)
giveUrlRenderer :: forall master sub. HtmlUrl (Route master) -> GHandler sub master RepHtml withUrlRenderer :: forall master sub. HtmlUrl (Route master) -> GHandler sub master RepHtml
giveUrlRenderer = hamletToRepHtml withUrlRenderer = hamletToRepHtml
type Html = RepHtml type Html = RepHtml
#else
#if ! MIN_VERSION_yesod(1,4,0)
withUrlRenderer :: MonadHandler m => ((Route (HandlerSite m) -> [(Text, Text)] -> Text) -> output) -> m output
withUrlRenderer = giveUrlRenderer
#endif
#endif #endif