Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Indent next-line --^ comments

  • Loading branch information...
commit bc66dcccbc7a8897607641ff1aa529cdf1fb2ce5 1 parent e55a60f
@mightybyte mightybyte authored
View
6 src/Snap/Snaplet/Auth/Backends/JsonFile.hs
@@ -38,12 +38,12 @@ import Snap.Snaplet.Session
------------------------------------------------------------------------------
-- | Initialize a JSON file backed 'AuthManager'
initJsonFileAuthManager :: AuthSettings
- -- ^ Authentication settings for your app
+ -- ^ Authentication settings for your app
-> Lens b (Snaplet SessionManager)
- -- ^ Lens into a 'SessionManager' auth snaplet will
+ -- ^ Lens into a 'SessionManager' auth snaplet will
-- use
-> FilePath
- -- ^ Where to store user data as JSON
+ -- ^ Where to store user data as JSON
-> SnapletInit b (AuthManager b)
initJsonFileAuthManager s l db = do
makeSnaplet
View
18 src/Snap/Snaplet/Auth/Handlers.hs
@@ -383,7 +383,7 @@ authenticatePassword u pw = auth
--
cacheOrLookup
:: Handler b (AuthManager b) (Maybe AuthUser)
- -- ^ Lookup action to perform if request local cache is empty
+ -- ^ Lookup action to perform if request local cache is empty
-> Handler b (AuthManager b) (Maybe AuthUser)
cacheOrLookup f = do
au <- gets activeUser
@@ -417,15 +417,15 @@ registerUser lf pf = do
--
loginUser
:: ByteString
- -- ^ Username field
+ -- ^ Username field
-> ByteString
- -- ^ Password field
+ -- ^ Password field
-> Maybe ByteString
- -- ^ Remember field; Nothing if you want no remember function.
+ -- ^ Remember field; Nothing if you want no remember function.
-> (AuthFailure -> Handler b (AuthManager b) ())
- -- ^ Upon failure
+ -- ^ Upon failure
-> Handler b (AuthManager b) ()
- -- ^ Upon success
+ -- ^ Upon success
-> Handler b (AuthManager b) ()
loginUser unf pwdf remf loginFail loginSucc =
runErrorT go >>= either loginFail (const loginSucc)
@@ -461,11 +461,11 @@ logoutUser target = logout >> target
-- in the current session.
--
requireUser :: Lens b (Snaplet (AuthManager b))
- -- ^ Lens reference to an "AuthManager"
+ -- ^ Lens reference to an "AuthManager"
-> Handler b v a
- -- ^ Do this if no authenticated user is present.
+ -- ^ Do this if no authenticated user is present.
-> Handler b v a
- -- ^ Do this if an authenticated user is present.
+ -- ^ Do this if an authenticated user is present.
-> Handler b v a
requireUser auth bad good = do
loggedIn <- withTop auth isLoggedIn
View
2  src/Snap/Snaplet/Auth/SpliceHelpers.hs
@@ -48,7 +48,7 @@ import Snap.Snaplet.Heist
addAuthSplices
:: HasHeist b
=> Lens b (Snaplet (AuthManager b))
- -- ^ A lens reference to 'AuthManager'
+ -- ^ A lens reference to 'AuthManager'
-> Initializer b v ()
addAuthSplices auth = addSplices
[ ("ifLoggedIn", ifLoggedIn auth)
View
10 src/Snap/Snaplet/Auth/Types.hs
@@ -166,20 +166,20 @@ setPassword au pass = do
-- | Authetication settings defined at initialization time
data AuthSettings = AuthSettings {
asMinPasswdLen :: Int
- -- ^ Currently not used/checked
+ -- ^ Currently not used/checked
, asRememberCookieName :: ByteString
- -- ^ Name of the desired remember cookie
+ -- ^ Name of the desired remember cookie
, asRememberPeriod :: Maybe Int
- -- ^ How long to remember when the option is used in rest of the API.
+ -- ^ How long to remember when the option is used in rest of the API.
-- 'Nothing' means remember until end of session.
, asLockout :: Maybe (Int, NominalDiffTime)
- -- ^ Lockout strategy: ([MaxAttempts], [LockoutDuration])
+ -- ^ Lockout strategy: ([MaxAttempts], [LockoutDuration])
, asSiteKey :: FilePath
- -- ^ Location of app's encryption key
+ -- ^ Location of app's encryption key
}
View
40 src/Snap/Snaplet/Heist.hs
@@ -93,7 +93,7 @@ class HasHeist b where
addTemplates :: HasHeist b
=> Snaplet (Heist b)
-> ByteString
- -- ^ The url prefix for the template routes
+ -- ^ The url prefix for the template routes
-> Initializer b v ()
addTemplates h pfx = withTop' heistLens (Unclassed.addTemplates h pfx)
@@ -108,9 +108,9 @@ addTemplates h pfx = withTop' heistLens (Unclassed.addTemplates h pfx)
addTemplatesAt :: HasHeist b
=> Snaplet (Heist b)
-> ByteString
- -- ^ URL prefix for template routes
+ -- ^ URL prefix for template routes
-> FilePath
- -- ^ Path to templates
+ -- ^ Path to templates
-> Initializer b v ()
addTemplatesAt h pfx p =
withTop' heistLens (Unclassed.addTemplatesAt h pfx p)
@@ -124,7 +124,7 @@ addTemplatesAt h pfx p =
-- use the addConfig function to add compiled splices or load time splices.
addSplices :: (HasHeist b)
=> [(Text, Unclassed.SnapletISplice b)]
- -- ^ Splices to bind
+ -- ^ Splices to bind
-> Initializer b v ()
addSplices = Unclassed.addSplices' heistLens
@@ -133,7 +133,7 @@ addSplices = Unclassed.addSplices' heistLens
-- | More general function allowing arbitrary HeistState modification.
modifyHeistState :: (HasHeist b)
=> (HeistState (Handler b b) -> HeistState (Handler b b))
- -- ^ HeistState modifying function
+ -- ^ HeistState modifying function
-> Initializer b v ()
modifyHeistState = Unclassed.modifyHeistState' heistLens
@@ -142,7 +142,7 @@ modifyHeistState = Unclassed.modifyHeistState' heistLens
-- | Runs a function on with the Heist snaplet's 'HeistState'.
withHeistState :: (HasHeist b)
=> (HeistState (Handler b b) -> a)
- -- ^ HeistState function to run
+ -- ^ HeistState function to run
-> Handler b v a
withHeistState = Unclassed.withHeistState' heistLens
@@ -160,7 +160,7 @@ withHeistState = Unclassed.withHeistState' heistLens
-- this returns 'empty'.
render :: HasHeist b
=> ByteString
- -- ^ Template name
+ -- ^ Template name
-> Handler b v ()
render t = withTop' heistLens (Unclassed.render t)
@@ -170,9 +170,9 @@ render t = withTop' heistLens (Unclassed.render t)
-- is not found, this returns 'empty'.
renderAs :: HasHeist b
=> ByteString
- -- ^ Content type to render with
+ -- ^ Content type to render with
-> ByteString
- -- ^ Template name
+ -- ^ Template name
-> Handler b v ()
renderAs ct t = withTop' heistLens (Unclassed.renderAs ct t)
@@ -182,7 +182,7 @@ renderAs ct t = withTop' heistLens (Unclassed.renderAs ct t)
-- found, this returns 'empty'.
cRender :: HasHeist b
=> ByteString
- -- ^ Template name
+ -- ^ Template name
-> Handler b v ()
cRender t = withTop' heistLens (Unclassed.cRender t)
@@ -192,9 +192,9 @@ cRender t = withTop' heistLens (Unclassed.cRender t)
-- template is not found, this returns 'empty'.
cRenderAs :: HasHeist b
=> ByteString
- -- ^ Content type to render with
+ -- ^ Content type to render with
-> ByteString
- -- ^ Template name
+ -- ^ Template name
-> Handler b v ()
cRenderAs ct t = withTop' heistLens (Unclassed.cRenderAs ct t)
@@ -215,7 +215,7 @@ heistServe = withTop' heistLens Unclassed.heistServe
-- this throws an error.
heistServeSingle :: HasHeist b
=> ByteString
- -- ^ Template name
+ -- ^ Template name
-> Handler b v ()
heistServeSingle t = withTop' heistLens (Unclassed.heistServeSingle t)
@@ -231,7 +231,7 @@ cHeistServe = withTop' heistLens Unclassed.cHeistServe
-- this throws an error.
cHeistServeSingle :: HasHeist b
=> ByteString
- -- ^ Template name
+ -- ^ Template name
-> Handler b v ()
cHeistServeSingle t = withTop' heistLens (Unclassed.cHeistServeSingle t)
@@ -241,9 +241,9 @@ cHeistServeSingle t = withTop' heistLens (Unclassed.cHeistServeSingle t)
-- a common combination of heistLocal, bindSplices, and render.
renderWithSplices :: HasHeist b
=> ByteString
- -- ^ Template name
+ -- ^ Template name
-> [(Text, Unclassed.SnapletISplice b)]
- -- ^ Splices to bind
+ -- ^ Splices to bind
-> Handler b v ()
renderWithSplices = Unclassed.renderWithSplices' heistLens
@@ -253,9 +253,9 @@ renderWithSplices = Unclassed.renderWithSplices' heistLens
-- 'HeistState'.
withSplices :: HasHeist b
=> [(Text, Unclassed.SnapletISplice b)]
- -- ^ Splices to bind
+ -- ^ Splices to bind
-> Handler b v a
- -- ^ Handler to run
+ -- ^ Handler to run
-> Handler b v a
withSplices = Unclassed.withSplices' heistLens
@@ -268,9 +268,9 @@ withSplices = Unclassed.withSplices' heistLens
-- > heistLocal (bindSplices mySplices) handlerThatNeedsSplices
heistLocal :: HasHeist b
=> (HeistState (Handler b b) -> HeistState (Handler b b))
- -- ^ HeistState modifying function
+ -- ^ HeistState modifying function
-> Handler b v a
- -- ^ Handler to run
+ -- ^ Handler to run
-> Handler b v a
heistLocal = Unclassed.heistLocal' heistLens
View
25 src/Snap/Snaplet/HeistNoClass.hs
@@ -138,7 +138,8 @@ type SnapletISplice b = SnapletHeist b (Handler b b) Template
-- | The 'Initializer' for 'Heist'. This function is a convenience wrapper
-- around `heistInit'` that uses defaultHeistState and sets up routes for all
-- the templates.
-heistInit :: FilePath -- ^ Path to templates
+heistInit :: FilePath
+ -- ^ Path to templates
-> SnapletInit b (Heist b)
heistInit templateDir = do
makeSnaplet "heist" "" Nothing $ do
@@ -154,9 +155,9 @@ heistInit templateDir = do
-- to specify the initial HeistConfig. It also does not add any routes for
-- templates, allowing you complete control over which templates get routed.
heistInit' :: FilePath
- -- ^ Path to templates
+ -- ^ Path to templates
-> HeistConfig (Handler b b)
- -- ^ Initial HeistConfig
+ -- ^ Initial HeistConfig
-> SnapletInit b (Heist b)
heistInit' templateDir initialConfig =
makeSnaplet "heist" "" Nothing $ heistInitWorker templateDir initialConfig
@@ -204,7 +205,7 @@ finalLoadHook (Running _ _) = left "finalLoadHook called while running"
-- read from the templates directory in the current snaplet's filesystem root.
addTemplates :: Snaplet (Heist b)
-> ByteString
- -- ^ The url prefix for the template routes
+ -- ^ The url prefix for the template routes
-> Initializer b (Heist b) ()
addTemplates h urlPrefix = do
snapletPath <- getSnapletFilePath
@@ -220,9 +221,9 @@ addTemplates h urlPrefix = do
-- normal directory structure.
addTemplatesAt :: Snaplet (Heist b)
-> ByteString
- -- ^ URL prefix for template routes
+ -- ^ URL prefix for template routes
-> FilePath
- -- ^ Path to templates
+ -- ^ Path to templates
-> Initializer b (Heist b) ()
addTemplatesAt h urlPrefix templateDir = do
rootUrl <- getSnapletRootURL
@@ -338,32 +339,32 @@ cRenderHelper c t = do
------------------------------------------------------------------------------
render :: ByteString
- -- ^ Name of the template
+ -- ^ Name of the template
-> Handler b (Heist b) ()
render t = iRenderHelper Nothing t
------------------------------------------------------------------------------
renderAs :: ByteString
- -- ^ Content type
+ -- ^ Content type
-> ByteString
- -- ^ Name of the template
+ -- ^ Name of the template
-> Handler b (Heist b) ()
renderAs ct t = iRenderHelper (Just ct) t
------------------------------------------------------------------------------
cRender :: ByteString
- -- ^ Name of the template
+ -- ^ Name of the template
-> Handler b (Heist b) ()
cRender t = cRenderHelper Nothing t
------------------------------------------------------------------------------
cRenderAs :: ByteString
- -- ^ Content type
+ -- ^ Content type
-> ByteString
- -- ^ Name of the template
+ -- ^ Name of the template
-> Handler b (Heist b) ()
cRenderAs ct t = cRenderHelper (Just ct) t
View
87 src/Snap/Snaplet/Internal/Initializer.hs
@@ -139,11 +139,11 @@ modifyCfg f = iModify $ modL curConfig $ \c -> f c
-- | If a snaplet has a filesystem presence, this function creates and copies
-- the files if they dont' already exist.
setupFilesystem :: Maybe (IO FilePath)
- -- ^ The directory where the snaplet's reference files are
- -- stored. Nothing if the snaplet doesn't come with any files
- -- that need to be installed.
+ -- ^ The directory where the snaplet's reference files are
+ -- stored. Nothing if the snaplet doesn't come with any
+ -- files that need to be installed.
-> FilePath
- -- ^ Directory where the files should be copied.
+ -- ^ Directory where the files should be copied.
-> Initializer b v ()
setupFilesystem Nothing _ = return ()
setupFilesystem (Just getSnapletDataDir) targetDir = do
@@ -180,21 +180,23 @@ setupFilesystem (Just getSnapletDataDir) targetDir = do
-- and makeSnaplet converts it into an opaque SnapletInit type. This allows
-- us to use the type system to ensure that the API is used correctly.
makeSnaplet :: Text
- -- ^ A default id for this snaplet. This is only used when the
- -- end-user has not already set an id using the nameSnaplet function.
- -> Text
- -- ^ A human readable description of this snaplet.
- -> Maybe (IO FilePath)
- -- ^ The path to the directory holding the snaplet's reference
- -- filesystem content. This will almost always be the directory
- -- returned by Cabal's getDataDir command, but it has to be passed in
- -- because it is defined in a package-specific import. Setting this
- -- value to Nothing doesn't preclude the snaplet from having files in
- -- in the filesystem, it just means that they won't be copied there
- -- automatically.
- -> Initializer b v v
- -- ^ Snaplet initializer.
- -> SnapletInit b v
+ -- ^ A default id for this snaplet. This is only used when
+ -- the end-user has not already set an id using the
+ -- nameSnaplet function.
+ -> Text
+ -- ^ A human readable description of this snaplet.
+ -> Maybe (IO FilePath)
+ -- ^ The path to the directory holding the snaplet's reference
+ -- filesystem content. This will almost always be the
+ -- directory returned by Cabal's getDataDir command, but it
+ -- has to be passed in because it is defined in a
+ -- package-specific import. Setting this value to Nothing
+ -- doesn't preclude the snaplet from having files in in the
+ -- filesystem, it just means that they won't be copied there
+ -- automatically.
+ -> Initializer b v v
+ -- ^ Snaplet initializer.
+ -> SnapletInit b v
makeSnaplet snapletId desc getSnapletDataDir m = SnapletInit $ do
modifyCfg $ \c -> if isNothing $ _scId c
then setL scId (Just snapletId) c else c
@@ -264,12 +266,13 @@ setupSnapletCall rte = do
-- possible for the child snaplet to make use of functionality provided by
-- sibling snaplets.
nestSnaplet :: ByteString
- -- ^ The root url for all the snaplet's routes. An empty string
- -- gives the routes the same root as the parent snaplet's routes.
+ -- ^ The root url for all the snaplet's routes. An empty
+ -- string gives the routes the same root as the parent
+ -- snaplet's routes.
-> (Lens v (Snaplet v1))
- -- ^ Lens identifying the snaplet
+ -- ^ Lens identifying the snaplet
-> SnapletInit b v1
- -- ^ The initializer function for the subsnaplet.
+ -- ^ The initializer function for the subsnaplet.
-> Initializer b v (Snaplet v1)
nestSnaplet rte l (SnapletInit snaplet) = with l $ bracketInit $ do
setupSnapletCall rte
@@ -286,16 +289,17 @@ nestSnaplet rte l (SnapletInit snaplet) = with l $ bracketInit $ do
-- type variable. The embedded snaplet can still get functionality from other
-- snaplets, but only if it nests or embeds the snaplet itself.
embedSnaplet :: ByteString
- -- ^ The root url for all the snaplet's routes. An empty string
- -- gives the routes the same root as the parent snaplet's routes.
- --
- -- NOTE: Because of the stronger isolation provided by
- -- embedSnaplet, you should be more careful about using an empty
- -- string here.
+ -- ^ The root url for all the snaplet's routes. An empty
+ -- string gives the routes the same root as the parent
+ -- snaplet's routes.
+ --
+ -- NOTE: Because of the stronger isolation provided by
+ -- embedSnaplet, you should be more careful about using an
+ -- empty string here.
-> (Lens v (Snaplet v1))
- -- ^ Lens identifying the snaplet
+ -- ^ Lens identifying the snaplet
-> SnapletInit v1 v1
- -- ^ The initializer function for the subsnaplet.
+ -- ^ The initializer function for the subsnaplet.
-> Initializer b v (Snaplet v1)
embedSnaplet rte l (SnapletInit snaplet) = bracketInit $ do
curLens <- getLens
@@ -343,9 +347,9 @@ chrootHandler l (Handler h) = Handler $ do
--
-- @fooState <- nestSnaplet \"fooA\" $ nameSnaplet \"myFoo\" $ fooInit@
nameSnaplet :: Text
- -- ^ The snaplet name
+ -- ^ The snaplet name
-> SnapletInit b v
- -- ^ The snaplet initializer function
+ -- ^ The snaplet initializer function
-> SnapletInit b v
nameSnaplet nm (SnapletInit m) = SnapletInit $
modifyCfg (setL scId (Just nm)) >> m
@@ -380,7 +384,7 @@ addRoutes rs = do
-- > wrapSite (\site -> ensureAdminUser >> site)
--
wrapSite :: (Handler b v () -> Handler b v ())
- -- ^ Handler modifier function
+ -- ^ Handler modifier function
-> Initializer b v ()
wrapSite f0 = do
f <- mungeFilter f0
@@ -388,14 +392,6 @@ wrapSite f0 = do
------------------------------------------------------------------------------
--- | This function has been renamed to 'wrapSite' and is deprecated. It will
--- be removed in the next major Snap release. Fix your code now!
-wrapHandlers :: (Handler b v () -> Handler b v ()) -> Initializer b v ()
-wrapHandlers = wrapSite
-{-# DEPRECATED wrapHandlers "wrapHandlers was renamed to wrapSite" #-}
-
-
-------------------------------------------------------------------------------
mungeFilter :: (Handler b v () -> Handler b v ())
-> Initializer b v (Handler b b () -> Handler b b ())
mungeFilter f = do
@@ -553,10 +549,11 @@ combineConfig config handler = do
-- runs the given Snaplet initializer, and starts an HTTP server running the
-- Snaplet's toplevel 'Handler'.
serveSnaplet :: Config Snap AppConfig
- -- ^ The configuration of the server - you can usually pass a
- -- default 'Config' via 'Snap.Http.Server.Config.defaultConfig'.
+ -- ^ The configuration of the server - you can usually pass a
+ -- default 'Config' via
+ -- 'Snap.Http.Server.Config.defaultConfig'.
-> SnapletInit b b
- -- ^ The snaplet initializer function.
+ -- ^ The snaplet initializer function.
-> IO ()
serveSnaplet startConfig initializer = do
config <- commandLineAppConfig startConfig
View
21 src/Snap/Snaplet/Internal/Types.hs
@@ -49,8 +49,9 @@ data SnapletConfig = SnapletConfig
, _scUserConfig :: Config
, _scRouteContext :: [ByteString]
, _scRoutePattern :: Maybe ByteString
- -- ^ Holds the actual route pattern passed to addRoutes for the current
- -- handler. Nothing during initialization and before route dispatech.
+ -- ^ Holds the actual route pattern passed to addRoutes for the
+ -- current handler. Nothing during initialization and before route
+ -- dispatech.
, _reloader :: IO (Either Text Text) -- might change
}
@@ -134,9 +135,9 @@ class MonadSnaplet m where
-- supplied to this snaplet must be a relative path. In other words, the
-- lens's base state must be the same as the current snaplet.
with :: (Lens v (Snaplet v'))
- -- ^ A relative lens identifying a snaplet
+ -- ^ A relative lens identifying a snaplet
-> m b v' a
- -- ^ Action from the lense's snaplet
+ -- ^ Action from the lense's snaplet
-> m b v a
with = with' . subSnaplet
@@ -145,9 +146,9 @@ class MonadSnaplet m where
-- metaphor again, the lens for this function must be an absolute
-- path--it's base must be the same as the current base.
withTop :: (Lens b (Snaplet v'))
- -- ^ An \"absolute\" lens identifying a snaplet
+ -- ^ An \"absolute\" lens identifying a snaplet
-> m b v' a
- -- ^ Action from the lense's snaplet
+ -- ^ Action from the lense's snaplet
-> m b v a
withTop l = withTop' (subSnaplet l)
@@ -350,12 +351,12 @@ data InitializerState b = InitializerState
{ _isTopLevel :: Bool
, _cleanup :: IORef (IO ())
, _handlers :: [(ByteString, Handler b b ())]
- -- ^ Handler routes built up and passed to route.
+ -- ^ Handler routes built up and passed to route.
, _hFilter :: Handler b b () -> Handler b b ()
- -- ^ Generic filtering of handlers
+ -- ^ Generic filtering of handlers
, _curConfig :: SnapletConfig
- -- ^ This snaplet config is the incrementally built config for whatever
- -- snaplet is currently being constructed.
+ -- ^ This snaplet config is the incrementally built config for
+ -- whatever snaplet is currently being constructed.
, _initMessages :: IORef Text
, _environment :: String
}
View
2  src/Snap/Snaplet/Session/Helpers.hs
@@ -80,7 +80,7 @@ hiddenCSRFTag = do
-- match. The exact name of the parameter is defined by
-- 'authAuthenticityTokenParam'.
checkCSRF :: MonadSession m => m ()
- -- ^ Do this if CSRF token does not match.
+ -- ^ Do this if CSRF token does not match.
-> m ()
checkCSRF failAct = method POST doCheck <|> return ()
where
Please sign in to comment.
Something went wrong with that request. Please try again.