packages feed

yesod-recaptcha2 0.1.0.1 → 0.2.0

raw patch · 3 files changed

+25/−9 lines, 3 filesdep +text

Dependencies added: text

Files

README.md view
@@ -1,17 +1,24 @@ # yesod-recaptcha2  ~~~hs-import Import.ReCaptcha2+import Yesod.ReCaptcha2 ~~~  ~~~hs instance YesodReCaptcha App where-    reCaptchaSiteKey = return "foo"-    reCaptchaSecretKey = return "bar"+    reCaptchaSiteKey = pure "foo"+    reCaptchaSecretKey = pure "bar"+    reCaptchaLanguage = pure Nothing++    -- with specific language from https://developers.google.com/recaptcha/docs/language+    -- reCaptchaLanguage = pure (Just "ru") ~~~ +## Append to applicative form  ~~~hs-<* reCaptcha+buildForm :: Form MyForm+buildForm = renderDivs $ MyForm+  <$> areq textField "foo" Nothing+  <* reCaptcha ~~~-
src/Yesod/ReCaptcha2.hs view
@@ -7,15 +7,18 @@ module Yesod.ReCaptcha2 (YesodReCaptcha(..), reCaptcha, mReCaptcha) where  import           ClassyPrelude.Yesod+import           Data.Text           (append) import           Network.HTTP.Simple import           Yesod.Auth  -- | default key is testing. you should impl reCaptchaSiteKey and reCaptchaSecretKey class YesodAuth site => YesodReCaptcha site where     reCaptchaSiteKey :: HandlerT site IO Text-    reCaptchaSiteKey = return "6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"+    reCaptchaSiteKey = pure "6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"     reCaptchaSecretKey :: HandlerT site IO Text-    reCaptchaSecretKey = return "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe"+    reCaptchaSecretKey = pure "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe"+    reCaptchaLanguage :: HandlerT site IO (Maybe Text)+    reCaptchaLanguage = pure Nothing  data SiteverifyResponse = SiteverifyResponse { success :: Bool }     deriving (Eq, Ord, Read, Show, Generic, FromJSON, ToJSON)@@ -49,7 +52,12 @@             , fvTooltip = Nothing             , fvId = ""             , fvInput = do-                    addScriptRemote "https://www.google.com/recaptcha/api.js"+                    language <- handlerToWidget reCaptchaLanguage+                    case language of+                      Nothing ->+                        addScriptRemote "https://www.google.com/recaptcha/api.js"+                      Just language ->+                        addScriptRemote $ append "https://www.google.com/recaptcha/api.js?hl=" language                     siteKey <- handlerToWidget reCaptchaSiteKey                     [whamlet|<div .g-recaptcha data-sitekey=#{siteKey}>|]             , fvErrors = Nothing
yesod-recaptcha2.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack  name:           yesod-recaptcha2-version:        0.1.0.1+version:        0.2.0 synopsis:       yesod recaptcha2 description:    recaptcha2 for yesod-form category:       Web@@ -32,6 +32,7 @@     , classy-prelude-yesod     , http-conduit     , yesod-auth+    , text   exposed-modules:       Yesod.ReCaptcha2   default-language: Haskell2010