Removed deprecated methods from Yesod typeclass
This commit is contained in:
parent
ee81979430
commit
e0fda35a55
@ -47,7 +47,6 @@ import Yesod.Handler hiding (lift, getExpires)
|
|||||||
|
|
||||||
import Yesod.Routes.Class
|
import Yesod.Routes.Class
|
||||||
|
|
||||||
import Control.Applicative ((<$>))
|
|
||||||
import Control.Arrow ((***))
|
import Control.Arrow ((***))
|
||||||
import Control.Monad (forM)
|
import Control.Monad (forM)
|
||||||
import Yesod.Widget
|
import Yesod.Widget
|
||||||
@ -152,18 +151,6 @@ class RenderRoute a => Yesod a where
|
|||||||
approot :: Approot a
|
approot :: Approot a
|
||||||
approot = ApprootRelative
|
approot = ApprootRelative
|
||||||
|
|
||||||
-- | The encryption key to be used for encrypting client sessions.
|
|
||||||
-- Returning 'Nothing' disables sessions.
|
|
||||||
-- this method will be removed in Yesod 1.0, use makeSessionBackend instead
|
|
||||||
encryptKey :: a -> IO (Maybe CS.Key)
|
|
||||||
encryptKey _ = fmap Just $ CS.getKey CS.defaultKeyFile
|
|
||||||
|
|
||||||
-- | Number of minutes before a client session times out. Defaults to
|
|
||||||
-- 120 (2 hours).
|
|
||||||
-- this method will be removed in Yesod 1.0, use makeSessionBackend instead
|
|
||||||
clientSessionDuration :: a -> Int
|
|
||||||
clientSessionDuration = const 120
|
|
||||||
|
|
||||||
-- | Output error response pages.
|
-- | Output error response pages.
|
||||||
errorHandler :: ErrorResponse -> GHandler sub a ChooseRep
|
errorHandler :: ErrorResponse -> GHandler sub a ChooseRep
|
||||||
errorHandler = defaultErrorHandler
|
errorHandler = defaultErrorHandler
|
||||||
@ -313,29 +300,22 @@ class RenderRoute a => Yesod a where
|
|||||||
gzipSettings :: a -> GzipSettings
|
gzipSettings :: a -> GzipSettings
|
||||||
gzipSettings _ = def
|
gzipSettings _ = def
|
||||||
|
|
||||||
-- | Deprecated. Use 'jsloader'. To use yepnope: jsLoader = BottomOfHeadAsync (loadJsYepnope eyn)
|
-- | Where to Load sripts from. We recommend the default value,
|
||||||
-- Location of yepnope.js, if any. If one is provided, then all
|
-- 'BottomOfBody'. Alternatively use the built in async yepnope loader:
|
||||||
-- Javascript files will be loaded asynchronously.
|
|
||||||
yepnopeJs :: a -> Maybe (Either Text (Route a))
|
|
||||||
yepnopeJs _ = Nothing
|
|
||||||
|
|
||||||
-- | Where to Load sripts from. We recommend changing this to 'BottomOfBody'
|
|
||||||
-- Alternatively use the built in async yepnope loader:
|
|
||||||
--
|
--
|
||||||
-- > BottomOfHeadAsync $ loadJsYepnope $ Right $ StaticR js_modernizr_js
|
-- > BottomOfHeadAsync $ loadJsYepnope $ Right $ StaticR js_modernizr_js
|
||||||
--
|
--
|
||||||
-- Or write your own async js loader: see 'loadJsYepnope'
|
-- Or write your own async js loader: see 'loadJsYepnope'
|
||||||
jsLoader :: a -> ScriptLoadPosition a
|
jsLoader :: a -> ScriptLoadPosition a
|
||||||
jsLoader y = case yepnopeJs y of
|
jsLoader _ = BottomOfBody
|
||||||
Nothing -> BottomOfHeadBlocking
|
|
||||||
Just eyn -> BottomOfHeadAsync (loadJsYepnope eyn)
|
|
||||||
|
|
||||||
-- | Create a session backend. Returning `Nothing' disables sessions.
|
-- | Create a session backend. Returning `Nothing' disables sessions.
|
||||||
|
--
|
||||||
|
-- Default: Uses clientsession with a 2 hour timeout.
|
||||||
makeSessionBackend :: a -> IO (Maybe (SessionBackend a))
|
makeSessionBackend :: a -> IO (Maybe (SessionBackend a))
|
||||||
makeSessionBackend a = do
|
makeSessionBackend _ = do
|
||||||
key <- encryptKey a
|
key <- CS.getKey CS.defaultKeyFile
|
||||||
return $
|
return $ Just $ clientSessionBackend key 120
|
||||||
(\k -> clientSessionBackend k (clientSessionDuration a)) <$> key
|
|
||||||
|
|
||||||
type Session = [(Text, S8.ByteString)]
|
type Session = [(Text, S8.ByteString)]
|
||||||
|
|
||||||
|
|||||||
@ -16,13 +16,14 @@ data H = H
|
|||||||
mkYesod "H" [parseRoutes|
|
mkYesod "H" [parseRoutes|
|
||||||
/ HeadR GET
|
/ HeadR GET
|
||||||
|]
|
|]
|
||||||
instance Yesod H
|
instance Yesod H where
|
||||||
|
jsLoader _ = BottomOfHeadBlocking
|
||||||
|
|
||||||
getHeadR :: Handler RepHtml
|
getHeadR :: Handler RepHtml
|
||||||
getHeadR = defaultLayout $ addScriptRemote "load.js"
|
getHeadR = defaultLayout $ addScriptRemote "load.js"
|
||||||
|
|
||||||
specs :: [Spec]
|
specs :: [Spec]
|
||||||
specs = describe "Test.Links" [
|
specs = describe "Test.JsLoader" [
|
||||||
it "link from head" $ runner H $ do
|
it "link from head" $ runner H $ do
|
||||||
res <- request defaultRequest
|
res <- request defaultRequest
|
||||||
assertBody "<!DOCTYPE html>\n<html><head><title></title><script src=\"load.js\"></script></head><body></body></html>" res
|
assertBody "<!DOCTYPE html>\n<html><head><title></title><script src=\"load.js\"></script></head><body></body></html>" res
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user