snaplet-recaptcha 1.0 → 1.0.1
raw patch · 3 files changed
+16/−14 lines, 3 filesnew-uploaderPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- snaplet-recaptcha.cabal +1/−1
- src/Snap/Snaplet/ReCaptcha.hs +1/−3
- src/Snap/Snaplet/ReCaptcha/Example.hs +14/−10
snaplet-recaptcha.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: snaplet-recaptcha-version: 1.0+version: 1.0.1 synopsis: A ReCAPTCHA verification snaplet with Heist integration and connection sharing. -- description: homepage: http://github.com/mikeplus64/snaplet-recaptcha
src/Snap/Snaplet/ReCaptcha.hs view
@@ -1,7 +1,5 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} -- |@@ -19,7 +17,7 @@ -- `http-conduit` and keeps connections alive (a maximum of 10). This is an -- important point in order to avoid denial of service attacks. ----- See 'Snap.Snaplet.ReCaptcha.Example' and the docs provided here for example+-- See "Snap.Snaplet.ReCaptcha.Example" and the docs provided here for example -- usage. --
src/Snap/Snaplet/ReCaptcha/Example.hs view
@@ -1,8 +1,8 @@-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TemplateHaskell #-}++-- | Provides example usage for "Snap.Snaplet.ReCaptcha". module Snap.Snaplet.ReCaptcha.Example ( -- * Main main@@ -12,6 +12,7 @@ -- * Implementation , initBlog ) where+ import qualified Blaze.ByteString.Builder as Blaze import Heist import Heist.Compiled@@ -48,10 +49,13 @@ instance HasHeist Sample where heistLens = subSnaplet heist --- | A "blog" snaplet which reads hypothetical "posts" by their 'id', routing--- GET on \/posts\/:id to display a post, and POST on \/posts\/:id to add a--- comment to them. For loose, useless definitions of "post" and "comment" ---- this snaplet is only for demonstration purposes.+-- | A "blog" snaplet which reads hypothetical "posts" by their id, and+-- displays a comment form there.+--+-- @GET@ on @posts/:id@ → a comment form+--+-- @POST@ on @posts/:id@ → the comment poster which verifies that the user+-- correctly responded to the captcha. initBlog :: forall b. (HasReCaptcha b, HasHeist b) => Snaplet (Heist b) -> SnapletInit b Blog initBlog heist = makeSnaplet "blog" "simple blog" Nothing $ do@@ -83,7 +87,6 @@ commentOnPost :: Handler b Blog () commentOnPost = do Just postId <- getParam "id"- Just captcha <- getPostParam "g-recaptcha-response" checkCaptcha <|> fail "Bad captcha response." -- if we reach here, the captcha was OK Just name <- getPostParam "name"@@ -130,10 +133,11 @@ \ </body>\ \</html>" --- | Requires 'snaplets/heist/templates/sample.tpl' - a suggested version of which--- is available in this module as 'sampleTemplate'.+-- | Requires 'snaplets/heist/templates/sample.tpl' - a suggested version of+-- which is available in this module as 'sampleTemplate'. ----- This simple asks for your site and private key through stdin.+-- This reads the ReCaptcha configuration as an ordinary snaplet config on the+-- filesystem as per 'initReCaptcha' (@snaplets/recaptcha/devel.cfg@). initSample :: SnapletInit Sample Sample initSample = makeSnaplet "sample" "" Nothing $ do h <- nestSnaplet "heist" heist (heistInit "templates")