snaplet-mandrill (empty) → 0.1.0.1
raw patch · 7 files changed
+315/−0 lines, 7 filesdep +basedep +configuratordep +mandrillsetup-changed
Dependencies added: base, configurator, mandrill, mtl, network, snap, transformers
Files
- DEPENDENCY-LICENSES.md +145/−0
- LICENSE +28/−0
- README.org +34/−0
- Setup.hs +2/−0
- resources/mandrill/devel.cfg +1/−0
- snaplet-mandrill.cabal +57/−0
- src/Snap/Snaplet/Mandrill.hs +48/−0
+ DEPENDENCY-LICENSES.md view
@@ -0,0 +1,145 @@+# BSD3++- HUnit+- MonadCatchIO-transformers+- QuickCheck+- aeson+- array+- asn1-encoding+- asn1-parse+- asn1-types+- attoparsec+- base+- base64-bytestring+- bifunctors+- binary+- blaze-builder+- blaze-builder-enumerator+- blaze-html+- blaze-markup+- byteable+- bytestring+- bytestring-mmap+- case-insensitive+- cereal+- cipher-aes+- cipher-des+- cipher-rc4+- clientsession+- comonad+- configurator+- connection+- containers+- contravariant+- cookie+- cprng-aes+- crypto-api+- crypto-cipher-types+- crypto-numbers+- crypto-pubkey+- crypto-pubkey-types+- crypto-random+- cryptohash+- data-default+- data-default-class+- data-default-instances-base+- data-default-instances-containers+- data-default-instances-dlist+- data-default-instances-old-locale+- deepseq+- directory+- directory-tree+- distributive+- dlist+- either+- email-validate+- entropy+- errors+- exceptions+- extensible-exceptions+- filepath+- free+- ghc-prim+- hashable+- heist+- http-types+- integer-gmp+- lens+- lens-aeson+- logict+- monad-control+- monads-tf+- mtl+- mwc-random+- nats+- network+- network-uri+- old-locale+- parallel+- parsec+- pem+- prelude-extras+- pretty+- primitive+- process+- profunctors+- publicsuffixlist+- pwstore-fast+- random+- reflection+- regex-base+- regex-posix+- rts+- safe+- scientific+- securemem+- semigroupoids+- semigroups+- skein+- snap+- snap-core+- snap-server+- socks+- split+- stm+- syb+- tagged+- template-haskell+- text+- tf-random+- time+- tls+- transformers+- transformers-base+- transformers-compat+- unix+- unix-compat+- unordered-containers+- utf8-string+- vector+- vector-algorithms+- void+- wreq+- x509+- x509-store+- x509-system+- x509-validation+- xmlhtml+- zlib+- zlib-bindings++# OtherLicense++- MonadRandom++# MIT++- attoparsec-enumerator+- enumerator+- http-client+- http-client-tls+- mandrill+- mime-types+- streaming-commons+- zlib-enum+
+ LICENSE view
@@ -0,0 +1,28 @@+Copyright (c) 2014, Parnell Springmeyer+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++* Redistributions of source code must retain the above copyright notice, this+ list of conditions and the following disclaimer.++* Redistributions in binary form must reproduce the above copyright notice,+ this list of conditions and the following disclaimer in the documentation+ and/or other materials provided with the distribution.++* Neither the name of the {organization} nor the names of its+ contributors may be used to endorse or promote products derived from+ this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.+
+ README.org view
@@ -0,0 +1,34 @@+* Welcome!+ =snaplet-amqp= provides a convenience interface to the Haskell AMQP+ package.++ #+BEGIN_SRC+ import Control.Lens+ import Snap+ import Snap.Snaplet+ import Snap.Snaplet.Mandrill+ import Network.API.Mandrill hiding (runMandrill)++ data App = App+ { _mandrill :: Snaplet Mandrill }++ makeLenses ''App++ instance HasMandrill (Handler b App) where+ getMandrill = with mandrill getMandrill++ app :: SnapletInit App App+ app = makeSnaplet "app" "An snaplet example application." Nothing $ do+ a <- nestSnaplet "mandrill" mandrill initMandrill+ addRoutes appRoutes -- Your routes, I haven't defined any here+ return $ App a++ handler = do+ runMandrill $ do+ let msg = "<p>My Html</p>"+ res <- sendEmail (newTextMessage addr [addr] "Hello" msg)+ case res of+ MandrillSuccess k -> liftIO (print k)+ MandrillFailure f -> liftIO (print f)++ #+END_SRC
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ resources/mandrill/devel.cfg view
@@ -0,0 +1,1 @@+token = "mandrilltokenhere"
+ snaplet-mandrill.cabal view
@@ -0,0 +1,57 @@+Name: snaplet-mandrill+Version: 0.1.0.1+Synopsis: Snap framework snaplet for the Mandrill API library.+Homepage: https://github.com/ixmatus/snaplet-mandrill+License: BSD3+License-file: LICENSE+Author: Parnell Springmeyer+Maintainer: parnell@digitalmentat.com+Copyright: (c) 2014 Parnell Springmeyer+Category: Web+Build-type: Simple+Stability: stable+Bug-reports: https://github.com/ixmatus/snaplet-mandrill/issues+Package-url: http://hackage.haskell.org/package/snaplet-mandrill+Tested-with: GHC == 7.6.3+Cabal-version: >=1.14.0++description:+ `snaplet-mandrill` is a snaplet for the Snap web framework providing+ convenience functions and state management for the Haskell Mandrill+ package.+ .+ Please refer to the README for an example - Cabal descriptions don't+ make it easy to do so.++Extra-source-files:+ LICENSE+ DEPENDENCY-LICENSES.md+ README.org++Data-files:+ resources/mandrill/devel.cfg++Library+ Default-Language: Haskell2010+ HS-Source-Dirs: src+ Ghc-options: -Wall -fwarn-tabs -funbox-strict-fields+ -fno-warn-orphans -fno-warn-unused-do-bind++ Exposed-Modules:+ Snap.Snaplet.Mandrill++ Other-Modules:+ Paths_snaplet_mandrill++ Build-Depends:+ base >= 4.4 && < 5,+ snap >= 0.13 && < 0.14,+ mandrill >= 0.1 && < 0.2,+ transformers >= 0.4 && < 0.5,+ configurator >= 0.3 && < 0.4,+ network >= 2.5 && < 2.7,+ mtl >= 2 && < 3++Source-Repository head+ Type: git+ Location: https://github.com/ixmatus/snaplet-mandrill
+ src/Snap/Snaplet/Mandrill.hs view
@@ -0,0 +1,48 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE OverloadedStrings #-}+++module Snap.Snaplet.Mandrill+ ( initMandrill+ , runMandrill+ , MandrillState (..)+ , HasMandrill (..)+ ) where++import Control.Applicative+import Control.Monad.State+import Control.Monad.Trans.Reader+import Data.Configurator+import qualified Network.API.Mandrill as M+import Paths_snaplet_mandrill+import Snap.Snaplet++-------------------------------------------------------------------------------+newtype MandrillState = MandrillState { token :: M.MandrillKey }++-------------------------------------------------------------------------------+class MonadIO m => HasMandrill m where+ getMandrill :: m M.MandrillKey++instance HasMandrill (Handler b MandrillState) where+ getMandrill = gets token++instance MonadIO m => HasMandrill (ReaderT M.MandrillKey m) where+ getMandrill = ask++-- | Initialize the Mandrill Snaplet.+initMandrill :: SnapletInit b MandrillState+initMandrill = makeSnaplet "mandrill" description datadir $ do+ conf <- getSnapletUserConfig+ return =<< MandrillState <$> (liftIO $ require conf "token")++ where+ description = "Snaplet for Mandrill library"+ datadir = Just $ liftM (++"/resources/mandrill") getDataDir++-------------------------------------------------------------------------------+-- | Runs an Mandrill action in any monad with a HasAmqpConn instance.+runMandrill :: (HasMandrill m) => M.MandrillT m a -> m (m a)+runMandrill action = do+ tk <- getMandrill+ return $ M.runMandrill tk action