{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE RankNTypes #-} -- | The basic typeclass for a Yesod application. module Yesod.Yesod ( -- * Type classes Yesod (..) , YesodSite (..) -- * Convenience functions , applyLayout , applyLayoutJson -- * Defaults , defaultErrorHandler ) where import Yesod.Content import Yesod.Request import Yesod.Hamlet import Yesod.Handler import Data.Convertible.Text import Control.Arrow ((***)) import Network.Wai.Middleware.ClientSession import qualified Network.Wai as W import Yesod.Definitions import Yesod.Json import Yesod.Internal import Web.Routes.Quasi (QuasiSite (..)) -- | This class is automatically instantiated when you use the template haskell -- mkYesod function. class YesodSite y where getSite :: QuasiSite YesodApp y y -- | Define settings for a Yesod applications. The only required setting is -- 'approot'; other than that, there are intelligent defaults. class YesodSite a => Yesod a where -- | An absolute URL to the root of the application. Do not include -- trailing slash. approot :: a -> Approot -- | The encryption key to be used for encrypting client sessions. encryptKey :: a -> IO Word256 encryptKey _ = getKey defaultKeyFile -- | Number of minutes before a client session times out. Defaults to -- 120 (2 hours). clientSessionDuration :: a -> Int clientSessionDuration = const 120 -- | Output error response pages. errorHandler :: Yesod y => a -> ErrorResponse -> Handler y ChooseRep errorHandler _ = defaultErrorHandler -- | Applies some form of layout to