From 4dd9880389e3b61f976e44525ae97831ec578a17 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Thu, 9 Feb 2012 09:07:53 +0200 Subject: [PATCH 1/5] Approot --- yesod-core/Yesod/Core.hs | 2 + yesod-core/Yesod/Dispatch.hs | 2 +- yesod-core/Yesod/Internal/Core.hs | 44 +++++++++++++++---- yesod-core/test/YesodCoreTest/Cache.hs | 2 +- yesod-core/test/YesodCoreTest/CleanPath.hs | 2 +- .../test/YesodCoreTest/ErrorHandling.hs | 2 +- yesod-core/test/YesodCoreTest/Exceptions.hs | 2 +- yesod-core/test/YesodCoreTest/Links.hs | 3 +- yesod-core/test/YesodCoreTest/Media.hs | 1 - .../test/YesodCoreTest/NoOverloadedStrings.hs | 4 +- yesod-core/test/YesodCoreTest/Redirect.hs | 2 +- yesod-core/test/YesodCoreTest/Widget.hs | 2 +- yesod-core/test/YesodCoreTest/YesodTest.hs | 1 + yesod/scaffold/Foundation.hs.cg | 2 +- yesod/scaffold/tiny/Foundation.hs.cg | 2 +- 15 files changed, 50 insertions(+), 23 deletions(-) diff --git a/yesod-core/Yesod/Core.hs b/yesod-core/Yesod/Core.hs index 34500f40..740bb1dc 100644 --- a/yesod-core/Yesod/Core.hs +++ b/yesod-core/Yesod/Core.hs @@ -8,6 +8,8 @@ module Yesod.Core -- ** Breadcrumbs , YesodBreadcrumbs (..) , breadcrumbs + -- * Types + , Approot (..) -- * Utitlities , maybeAuthorized , widgetToPageContent diff --git a/yesod-core/Yesod/Dispatch.hs b/yesod-core/Yesod/Dispatch.hs index a7f33d79..38af2a16 100644 --- a/yesod-core/Yesod/Dispatch.hs +++ b/yesod-core/Yesod/Dispatch.hs @@ -182,7 +182,7 @@ sendRedirect y segments' env = , ("Location", Blaze.ByteString.Builder.toByteString dest') ] "Redirecting" where - dest = joinPath y (approot y) segments' [] + dest = joinPath y (resolveApproot y env) segments' [] dest' = if S.null (W.rawQueryString env) then dest diff --git a/yesod-core/Yesod/Internal/Core.hs b/yesod-core/Yesod/Internal/Core.hs index ce4e4e82..9f1d6403 100644 --- a/yesod-core/Yesod/Internal/Core.hs +++ b/yesod-core/Yesod/Internal/Core.hs @@ -28,6 +28,8 @@ module Yesod.Internal.Core -- * Misc , yesodVersion , yesodRender + , resolveApproot + , Approot (..) ) where import Yesod.Content @@ -121,20 +123,36 @@ class YesodDispatch sub master where -> W.Application yesodRunner = defaultYesodRunner --- | Define settings for a Yesod applications. The only required setting is --- 'approot'; other than that, there are intelligent defaults. +-- | How to determine the root of the application for constructing URLs. +-- +-- Note that future versions of Yesod may add new constructors without bumping +-- the major version number. As a result, you should /not/ pattern match on +-- @Approot@ values. +data Approot master = ApprootRelative -- ^ No application root. + | ApprootStatic Text + | ApprootMaster (master -> Text) + | ApprootRequest (master -> W.Request -> Text) + +type ResolvedApproot = Text + +-- | Define settings for a Yesod applications. All methods have intelligent +-- defaults, and therefore no implementation is required. class RenderRoute a => Yesod a where -- | An absolute URL to the root of the application. Do not include -- trailing slash. -- - -- If you want to be lazy, you can supply an empty string under the - -- following conditions: + -- Default value: 'ApprootRelative'. This is valid under the following + -- conditions: -- -- * Your application is served from the root of the domain. -- -- * You do not use any features that require absolute URLs, such as Atom -- feeds and XML sitemaps. - approot :: a -> Text + -- + -- If this is not true, you should override with a different + -- implementation. + approot :: Approot a + approot = ApprootRelative -- | The encryption key to be used for encrypting client sessions. -- Returning 'Nothing' disables sessions. @@ -395,7 +413,8 @@ defaultYesodRunner handler master sub murl toMasterRoute mkey req = do handler let sessionMap = Map.fromList $ filter (\(x, _) -> x /= nonceKey) session' - yar <- handlerToYAR master sub toMasterRoute (yesodRender master) errorHandler rr murl sessionMap h + let ra = resolveApproot master req + yar <- handlerToYAR master sub toMasterRoute (yesodRender master ra) errorHandler rr murl sessionMap h let mnonce = reqNonce rr -- FIXME should we be caching this IV value and reusing it for efficiency? iv <- {-# SCC "iv" #-} maybe (return $ error "Should not be used") (const $ liftIO CS.randomIV) mkey @@ -633,14 +652,23 @@ ynHelper render scripts jscript jsLoc = yesodRender :: Yesod y => y + -> ResolvedApproot -> Route y -> [(Text, Text)] -- ^ url query string -> Text -yesodRender y url params = +yesodRender y ar url params = TE.decodeUtf8 $ toByteString $ fromMaybe - (joinPath y (approot y) ps + (joinPath y ar ps $ params ++ params') (urlRenderOverride y url) where (ps, params') = renderRoute url + +resolveApproot :: Yesod master => master -> W.Request -> ResolvedApproot +resolveApproot master req = + case approot of + ApprootRelative -> "" + ApprootStatic t -> t + ApprootMaster f -> f master + ApprootRequest f -> f master req diff --git a/yesod-core/test/YesodCoreTest/Cache.hs b/yesod-core/test/YesodCoreTest/Cache.hs index c87118a7..30dcfaaa 100644 --- a/yesod-core/test/YesodCoreTest/Cache.hs +++ b/yesod-core/test/YesodCoreTest/Cache.hs @@ -21,7 +21,7 @@ key2 = $(mkCacheKey) mkYesod "C" [parseRoutes|/ RootR GET|] -instance Yesod C where approot _ = "" +instance Yesod C getRootR :: Handler () getRootR = do diff --git a/yesod-core/test/YesodCoreTest/CleanPath.hs b/yesod-core/test/YesodCoreTest/CleanPath.hs index 0428164e..ba3d7a00 100644 --- a/yesod-core/test/YesodCoreTest/CleanPath.hs +++ b/yesod-core/test/YesodCoreTest/CleanPath.hs @@ -41,7 +41,7 @@ mkYesod "Y" [parseRoutes| |] instance Yesod Y where - approot _ = "http://test" + approot = ApprootStatic "http://test" cleanPath _ s@("subsite":_) = Right s cleanPath _ ["bar", ""] = Right ["bar"] cleanPath _ ["bar"] = Left ["bar", ""] diff --git a/yesod-core/test/YesodCoreTest/ErrorHandling.hs b/yesod-core/test/YesodCoreTest/ErrorHandling.hs index 16118e46..b07d3753 100644 --- a/yesod-core/test/YesodCoreTest/ErrorHandling.hs +++ b/yesod-core/test/YesodCoreTest/ErrorHandling.hs @@ -21,7 +21,7 @@ mkYesod "App" [parseRoutes| /after_runRequestBody AfterRunRequestBodyR POST |] -instance Yesod App where approot _ = "" +instance Yesod App getHomeR :: Handler RepHtml getHomeR = defaultLayout $ toWidget [hamlet| diff --git a/yesod-core/test/YesodCoreTest/Exceptions.hs b/yesod-core/test/YesodCoreTest/Exceptions.hs index 2f0e25ef..93368b7a 100644 --- a/yesod-core/test/YesodCoreTest/Exceptions.hs +++ b/yesod-core/test/YesodCoreTest/Exceptions.hs @@ -18,7 +18,7 @@ mkYesod "Y" [parseRoutes| |] instance Yesod Y where - approot _ = "http://test" + approot = ApprootStatic "http://test" errorHandler (InternalError e) = return $ chooseRep $ RepPlain $ toContent e errorHandler x = defaultErrorHandler x diff --git a/yesod-core/test/YesodCoreTest/Links.hs b/yesod-core/test/YesodCoreTest/Links.hs index 6df9ab62..49ece3d1 100644 --- a/yesod-core/test/YesodCoreTest/Links.hs +++ b/yesod-core/test/YesodCoreTest/Links.hs @@ -15,8 +15,7 @@ mkYesod "Y" [parseRoutes| / RootR GET |] -instance Yesod Y where - approot _ = "" +instance Yesod Y getRootR :: Handler RepHtml getRootR = defaultLayout $ addHamlet [hamlet||] diff --git a/yesod-core/test/YesodCoreTest/Media.hs b/yesod-core/test/YesodCoreTest/Media.hs index 0b7e4190..fec2ffdb 100644 --- a/yesod-core/test/YesodCoreTest/Media.hs +++ b/yesod-core/test/YesodCoreTest/Media.hs @@ -15,7 +15,6 @@ import YesodCoreTest.MediaData mkYesodDispatch "Y" resourcesY instance Yesod Y where - approot _ = "" addStaticContent _ _ content = do tm <- getRouteToMaster route <- getCurrentRoute diff --git a/yesod-core/test/YesodCoreTest/NoOverloadedStrings.hs b/yesod-core/test/YesodCoreTest/NoOverloadedStrings.hs index 24f9d75f..b32e6d65 100644 --- a/yesod-core/test/YesodCoreTest/NoOverloadedStrings.hs +++ b/yesod-core/test/YesodCoreTest/NoOverloadedStrings.hs @@ -8,7 +8,6 @@ import Test.Hspec.HUnit () import Yesod.Core hiding (Request) import Network.Wai.Test import Data.Monoid (mempty) -import Data.String (fromString) data Subsite = Subsite @@ -29,8 +28,7 @@ mkYesod "Y" [parseRoutes| /subsite SubsiteR Subsite getSubsite |] -instance Yesod Y where - approot _ = fromString "" +instance Yesod Y getRootR :: Handler () getRootR = return () diff --git a/yesod-core/test/YesodCoreTest/Redirect.hs b/yesod-core/test/YesodCoreTest/Redirect.hs index 71b03db2..5019467a 100644 --- a/yesod-core/test/YesodCoreTest/Redirect.hs +++ b/yesod-core/test/YesodCoreTest/Redirect.hs @@ -13,7 +13,7 @@ mkYesod "Y" [parseRoutes| /r307 R307 GET /rregular RRegular GET |] -instance Yesod Y where approot _ = "http://test" +instance Yesod Y where approot = ApprootStatic "http://test" app :: Session () -> IO () app = yesod Y diff --git a/yesod-core/test/YesodCoreTest/Widget.hs b/yesod-core/test/YesodCoreTest/Widget.hs index ae1e4699..f102136e 100644 --- a/yesod-core/test/YesodCoreTest/Widget.hs +++ b/yesod-core/test/YesodCoreTest/Widget.hs @@ -28,7 +28,7 @@ mkYesod "Y" [parseRoutes| |] instance Yesod Y where - approot _ = "http://test" + approot = ApprootStatic "http://test" getRootR :: Handler RepHtml getRootR = defaultLayout $ toWidgetBody [julius||] diff --git a/yesod-core/test/YesodCoreTest/YesodTest.hs b/yesod-core/test/YesodCoreTest/YesodTest.hs index 9150f5ad..46040f84 100644 --- a/yesod-core/test/YesodCoreTest/YesodTest.hs +++ b/yesod-core/test/YesodCoreTest/YesodTest.hs @@ -3,6 +3,7 @@ module YesodCoreTest.YesodTest ( yesod , parseRoutes, mkYesod, yesodDispatch, renderRoute, Yesod(..) , redirect + , Approot (..) , module Network.Wai , module Network.Wai.Test , module Test.Hspec diff --git a/yesod/scaffold/Foundation.hs.cg b/yesod/scaffold/Foundation.hs.cg index f0f136ab..14e5b821 100644 --- a/yesod/scaffold/Foundation.hs.cg +++ b/yesod/scaffold/Foundation.hs.cg @@ -83,7 +83,7 @@ type Form x = Html -> MForm ~sitearg~ ~sitearg~ (FormResult x, Widget) -- Please see the documentation for the Yesod typeclass. There are a number -- of settings which can be configured by overriding methods here. instance Yesod ~sitearg~ where - approot = appRoot . settings + approot = ApprootMaster $ appRoot . settings -- Place the session key file in the config folder encryptKey _ = fmap Just $ getKey "config/client_session_key.aes" diff --git a/yesod/scaffold/tiny/Foundation.hs.cg b/yesod/scaffold/tiny/Foundation.hs.cg index c93df758..f67df47e 100644 --- a/yesod/scaffold/tiny/Foundation.hs.cg +++ b/yesod/scaffold/tiny/Foundation.hs.cg @@ -60,7 +60,7 @@ mkYesodData "~sitearg~" $(parseRoutesFile "config/routes") -- Please see the documentation for the Yesod typeclass. There are a number -- of settings which can be configured by overriding methods here. instance Yesod ~sitearg~ where - approot = appRoot . settings + approot = ApprootMaster $ appRoot . settings -- Place the session key file in the config folder encryptKey _ = fmap Just $ getKey "config/client_session_key.aes" From b26868cd28b558c7e8469a47c4bf2e9be8ed8da9 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Thu, 9 Feb 2012 15:20:15 +0200 Subject: [PATCH 2/5] Version bumps --- yesod-auth/yesod-auth.cabal | 10 +++++----- yesod-core/yesod-core.cabal | 4 ++-- yesod-default/yesod-default.cabal | 4 ++-- yesod-form/yesod-form.cabal | 6 +++--- yesod-json/yesod-json.cabal | 4 ++-- yesod-newsfeed/yesod-newsfeed.cabal | 4 ++-- yesod-persistent/yesod-persistent.cabal | 4 ++-- yesod-routes/yesod-routes.cabal | 2 +- yesod-static/yesod-static.cabal | 4 ++-- yesod/yesod.cabal | 12 ++++++------ 10 files changed, 27 insertions(+), 27 deletions(-) diff --git a/yesod-auth/yesod-auth.cabal b/yesod-auth/yesod-auth.cabal index 69900408..dfcd7d70 100644 --- a/yesod-auth/yesod-auth.cabal +++ b/yesod-auth/yesod-auth.cabal @@ -1,5 +1,5 @@ name: yesod-auth -version: 0.8.0 +version: 0.8.1 license: BSD3 license-file: LICENSE author: Michael Snoyman, Patrick Brisbin @@ -23,7 +23,7 @@ library build-depends: base >= 4 && < 4.3 build-depends: authenticate >= 1.0 && < 1.1 , bytestring >= 0.9.1.4 && < 0.10 - , yesod-core >= 0.10 && < 0.11 + , yesod-core >= 0.10.1 && < 0.11 , wai >= 1.1 && < 1.2 , template-haskell , pureMD5 >= 2.0 && < 2.2 @@ -31,13 +31,13 @@ library , text >= 0.7 && < 0.12 , mime-mail >= 0.3 && < 0.5 , blaze-html >= 0.4.1.3 && < 0.5 - , yesod-persistent >= 0.3 && < 0.4 + , yesod-persistent >= 0.3.1 && < 0.4 , hamlet >= 0.10 && < 0.11 , shakespeare-css >= 0.10 && < 0.11 - , yesod-json >= 0.3 && < 0.4 + , yesod-json >= 0.3.1 && < 0.4 , containers , unordered-containers - , yesod-form >= 0.4 && < 0.5 + , yesod-form >= 0.4.1 && < 0.5 , transformers >= 0.2.2 && < 0.3 , persistent >= 0.8 && < 0.9 , persistent-template >= 0.8 && < 0.9 diff --git a/yesod-core/yesod-core.cabal b/yesod-core/yesod-core.cabal index 005d1e21..315e3041 100644 --- a/yesod-core/yesod-core.cabal +++ b/yesod-core/yesod-core.cabal @@ -1,5 +1,5 @@ name: yesod-core -version: 0.10.0 +version: 0.10.1 license: BSD3 license-file: LICENSE author: Michael Snoyman @@ -47,7 +47,7 @@ library build-depends: wai-test build-depends: time >= 1.1.4 - , yesod-routes >= 0.0 && < 0.1 + , yesod-routes >= 0.0.1 && < 0.1 , wai >= 1.1 && < 1.2 , wai-extra >= 1.1 && < 1.2 , bytestring >= 0.9.1.4 && < 0.10 diff --git a/yesod-default/yesod-default.cabal b/yesod-default/yesod-default.cabal index 75326305..cc36a60e 100644 --- a/yesod-default/yesod-default.cabal +++ b/yesod-default/yesod-default.cabal @@ -1,5 +1,5 @@ name: yesod-default -version: 0.6.0 +version: 0.6.1 license: BSD3 license-file: LICENSE author: Patrick Brisbin @@ -18,7 +18,7 @@ library cpp-options: -DWINDOWS build-depends: base >= 4 && < 5 - , yesod-core >= 0.10 && < 0.11 + , yesod-core >= 0.10.1&& < 0.11 , warp >= 1.1 && < 1.2 , wai >= 1.1 && < 1.2 , wai-extra >= 1.1 && < 1.2 diff --git a/yesod-form/yesod-form.cabal b/yesod-form/yesod-form.cabal index 48f5b367..8b12cdf7 100644 --- a/yesod-form/yesod-form.cabal +++ b/yesod-form/yesod-form.cabal @@ -1,5 +1,5 @@ name: yesod-form -version: 0.4.0 +version: 0.4.1 license: BSD3 license-file: LICENSE author: Michael Snoyman @@ -14,8 +14,8 @@ description: Form handling support for Yesod Web Framework library build-depends: base >= 4 && < 5 - , yesod-core >= 0.10 && < 0.11 - , yesod-persistent >= 0.3 && < 0.4 + , yesod-core >= 0.10.1 && < 0.11 + , yesod-persistent >= 0.3.1 && < 0.4 , time >= 1.1.4 , hamlet >= 0.10 && < 0.11 , shakespeare-css >= 0.10 && < 0.11 diff --git a/yesod-json/yesod-json.cabal b/yesod-json/yesod-json.cabal index 1f8f98db..2d15b5bb 100644 --- a/yesod-json/yesod-json.cabal +++ b/yesod-json/yesod-json.cabal @@ -1,5 +1,5 @@ name: yesod-json -version: 0.3.0 +version: 0.3.1 license: BSD3 license-file: LICENSE author: Michael Snoyman @@ -14,7 +14,7 @@ description: Generate content for Yesod using the aeson package. library build-depends: base >= 4 && < 5 - , yesod-core >= 0.10 && < 0.11 + , yesod-core >= 0.10.1 && < 0.11 , yesod-routes < 0.1 , aeson >= 0.5 , text >= 0.8 && < 1.0 diff --git a/yesod-newsfeed/yesod-newsfeed.cabal b/yesod-newsfeed/yesod-newsfeed.cabal index c46c3faa..8eeb66db 100644 --- a/yesod-newsfeed/yesod-newsfeed.cabal +++ b/yesod-newsfeed/yesod-newsfeed.cabal @@ -1,5 +1,5 @@ name: yesod-newsfeed -version: 0.4.0 +version: 0.4.1 license: BSD3 license-file: LICENSE author: Michael Snoyman, Patrick Brisbin @@ -14,7 +14,7 @@ description: Helper functions and data types for producing News feeds. library build-depends: base >= 4 && < 5 - , yesod-core >= 0.10 && < 0.11 + , yesod-core >= 0.10.1 && < 0.11 , time >= 1.1.4 , hamlet >= 0.10 && < 0.11 , bytestring >= 0.9.1.4 && < 0.10 diff --git a/yesod-persistent/yesod-persistent.cabal b/yesod-persistent/yesod-persistent.cabal index 242112c6..12216793 100644 --- a/yesod-persistent/yesod-persistent.cabal +++ b/yesod-persistent/yesod-persistent.cabal @@ -1,5 +1,5 @@ name: yesod-persistent -version: 0.3.0 +version: 0.3.1 license: BSD3 license-file: LICENSE author: Michael Snoyman @@ -14,7 +14,7 @@ description: Some helpers for using Persistent from Yesod. library build-depends: base >= 4 && < 5 - , yesod-core >= 0.10 && < 0.11 + , yesod-core >= 0.10.1 && < 0.11 , persistent >= 0.8 && < 0.9 , persistent-template >= 0.8 && < 0.9 , transformers >= 0.2.2 && < 0.3 diff --git a/yesod-routes/yesod-routes.cabal b/yesod-routes/yesod-routes.cabal index 1a6426fe..d17de50d 100644 --- a/yesod-routes/yesod-routes.cabal +++ b/yesod-routes/yesod-routes.cabal @@ -1,5 +1,5 @@ name: yesod-routes -version: 0.0.0 +version: 0.0.1 license: BSD3 license-file: LICENSE author: Michael Snoyman diff --git a/yesod-static/yesod-static.cabal b/yesod-static/yesod-static.cabal index 08a2a47e..c751dbcf 100644 --- a/yesod-static/yesod-static.cabal +++ b/yesod-static/yesod-static.cabal @@ -1,5 +1,5 @@ name: yesod-static -version: 0.10.0 +version: 0.10.1 license: BSD3 license-file: LICENSE author: Michael Snoyman @@ -19,7 +19,7 @@ library build-depends: base >= 4 && < 5 , containers >= 0.2 && < 0.5 , old-time >= 1.0 - , yesod-core >= 0.10 && < 0.11 + , yesod-core >= 0.10.1 && < 0.11 , base64-bytestring >= 0.1.0.1 && < 0.2 , cereal >= 0.3 && < 0.4 , bytestring >= 0.9.1.4 && < 0.10 diff --git a/yesod/yesod.cabal b/yesod/yesod.cabal index 3e00a5e7..057b5051 100644 --- a/yesod/yesod.cabal +++ b/yesod/yesod.cabal @@ -1,5 +1,5 @@ name: yesod -version: 0.10.0 +version: 0.10.1 license: BSD3 license-file: LICENSE author: Michael Snoyman @@ -73,11 +73,11 @@ library cpp-options: -DGHC7 else build-depends: base >= 4 && < 4.3 - build-depends: yesod-core >= 0.10 && < 0.11 - , yesod-auth >= 0.8 && < 0.9 - , yesod-json >= 0.3 && < 0.4 - , yesod-persistent >= 0.3 && < 0.4 - , yesod-form >= 0.4 && < 0.5 + build-depends: yesod-core >= 0.10.1 && < 0.11 + , yesod-auth >= 0.8.1 && < 0.9 + , yesod-json >= 0.3.1 && < 0.4 + , yesod-persistent >= 0.3.1 && < 0.4 + , yesod-form >= 0.4.1 && < 0.5 , monad-control >= 0.3 && < 0.4 , transformers >= 0.2.2 && < 0.3 , wai >= 1.1 && < 1.2 From 458d7c50b1f3d47d64c278b794b1b10262936ad9 Mon Sep 17 00:00:00 2001 From: jonnadal Date: Thu, 9 Feb 2012 13:30:21 -0500 Subject: [PATCH 3/5] fixed a typo --- yesod-routes/Yesod/Routes/Dispatch.lhs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yesod-routes/Yesod/Routes/Dispatch.lhs b/yesod-routes/Yesod/Routes/Dispatch.lhs index b29955b7..181906a4 100644 --- a/yesod-routes/Yesod/Routes/Dispatch.lhs +++ b/yesod-routes/Yesod/Routes/Dispatch.lhs @@ -61,7 +61,7 @@ So each route is specified by: > , rhDispatch :: Dispatch res > } -Your application needs to provide this moudle with a list of routes, and then +Your application needs to provide this module with a list of routes, and then this module will give you back a new dispatch function. In other words: > toDispatch :: [Route res] -> Dispatch res From 566a5d2502ce1b983a3f75216a78159d83e864be Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Thu, 9 Feb 2012 23:44:26 +0200 Subject: [PATCH 4/5] niceditor works with yepnope --- yesod-form/Yesod/Form/Nic.hs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/yesod-form/Yesod/Form/Nic.hs b/yesod-form/Yesod/Form/Nic.hs index 299008ea..17361481 100644 --- a/yesod-form/Yesod/Form/Nic.hs +++ b/yesod-form/Yesod/Form/Nic.hs @@ -11,7 +11,7 @@ module Yesod.Form.Nic ) where import Yesod.Handler -import Yesod.Core (Route) +import Yesod.Core (Route, yepnopeJs, Yesod) import Yesod.Form import Yesod.Widget import Text.HTML.SanitizeXSS (sanitizeBalance) @@ -23,7 +23,7 @@ import Data.Text (Text, pack) import qualified Data.Text as T import Data.Maybe (listToMaybe) -class YesodNic a where +class Yesod a => YesodNic a where -- | NIC Editor Javascript file. urlNicEdit :: a -> Either (Route a) Text urlNicEdit _ = Right "http://js.nicedit.com/nicEdit-latest.js" @@ -41,13 +41,24 @@ nicHtmlField = Field