Skip to content

Commit

Permalink
Update digestive-functors-snap, cabal files
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspervdj committed Mar 20, 2012
1 parent d379085 commit 896f0f8
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 281 deletions.
19 changes: 8 additions & 11 deletions digestive-functors-blaze/digestive-functors-blaze.cabal
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Name: digestive-functors-blaze
Version: 0.3.0.0
Synopsis: Blaze frontend for the digestive-functors library
Description: This is a blaze frontend for the digestive-functors library.

Description: Blaze frontend for the digestive-functors library
Homepage: http://github.com/jaspervdj/digestive-functors
License: BSD3
License-file: LICENSE
Expand All @@ -13,14 +12,12 @@ Build-type: Simple
Cabal-version: >= 1.6

Library
Hs-source-dirs: src
GHC-options: -Wall -fwarn-tabs

Exposed-modules:
Text.Digestive.Blaze.Html5
Hs-source-dirs: src
GHC-options: -Wall -fwarn-tabs
Exposed-modules: Text.Digestive.Blaze.Html5

Build-depends:
base >= 4 && < 5,
digestive-functors >= 0.3 && < 0.4,
blaze-html >= 0.4 && < 0.6,
text >= 0.11 && < 0.12
base >= 4 && < 5,
digestive-functors >= 0.3 && < 0.4,
blaze-html >= 0.4 && < 0.6,
text >= 0.11 && < 0.12
1 change: 1 addition & 0 deletions digestive-functors-happstack/.ghci
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:set -isrc -i../digestive-functors/src
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
Name: digestive-functors-happstack
Version: 0.3.0.0
Synopsis: Happstack backend for the digestive-functors library
Description: This is a happstack backend for the digestive-functors
library.

Description: Happstack backend for the digestive-functors library
Homepage: http://github.com/jaspervdj/digestive-functors
License: BSD3
License-file: LICENSE
Expand All @@ -16,6 +14,7 @@ Cabal-version: >= 1.6

Library
Hs-source-dirs: src
GHC-options: -Wall -fwarn-tabs
Exposed-modules: Text.Digestive.Happstack

Build-depends:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ runForm :: (Happstack.HasRqData m, Monad m, Happstack.ServerMonad m)
-> m (View v, Maybe a) -- ^ Result
runForm name form = Happstack.askRq >>= \rq ->
case Happstack.rqMethod rq of
Happstack.GET -> return $ (getForm name form, Nothing)
Happstack.GET -> return (getForm name form, Nothing)
_ -> postForm name form happstackEnv
42 changes: 21 additions & 21 deletions digestive-functors-snap/digestive-functors-snap.cabal
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
Name: digestive-functors-snap
Version: 0.1.2.0
Synopsis: Snap backend for the digestive-functors library
Description: This is a snap backend for the digestive-functors library.

Homepage: http://github.com/jaspervdj/digestive-functors
License: BSD3
License-file: LICENSE
Author: Jasper Van der Jeugt
Maintainer: jaspervdj@gmail.com
Category: Web
Build-type: Simple
Cabal-version: >=1.6

Name: digestive-functors-snap
Version: 0.3.0.0
Synopsis: Snap backend for the digestive-functors library
Description: Snap backend for the digestive-functors library
Homepage: http://github.com/jaspervdj/digestive-functors
License: BSD3
License-file: LICENSE
Author: Jasper Van der Jeugt <m@jaspervdj.be>
Maintainer: Jasper Van der Jeugt <m@jaspervdj.be>
Category: Web
Build-type: Simple
Cabal-version: >= 1.6

Library
Hs-source-dirs: src
Exposed-modules: Text.Digestive.Forms.Snap
Hs-source-dirs: src
GHC-options: -Wall -fwarn-tabs
Exposed-modules: Text.Digestive.Snap

Build-depends:
base >= 4 && < 5,
bytestring >= 0.9 && < 0.10,
digestive-functors >= 0.1 && < 0.3,
snap-core >= 0.5 && < 0.8,
utf8-string >= 0.3 && < 0.4
base >= 4 && < 5,
containers >= 0.3 && < 0.5,
digestive-functors >= 0.3 && < 0.4,
snap-core >= 0.7 && < 0.9,
text >= 0.11 && < 0.12
23 changes: 0 additions & 23 deletions digestive-functors-snap/src/Text/Digestive/Forms/Snap.hs

This file was deleted.

36 changes: 36 additions & 0 deletions digestive-functors-snap/src/Text/Digestive/Snap.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
-- | Module providing a Snap backend for the digestive-functors library
module Text.Digestive.Snap
( runForm
) where

import Control.Applicative ((<$>))
import Data.Maybe (fromMaybe)
import qualified Data.Map as M

import Data.Text (Text)
import qualified Data.Text.Encoding as T
import qualified Snap.Core as Snap

import Text.Digestive.Form
import Text.Digestive.Types
import Text.Digestive.View

snapEnv :: Snap.MonadSnap m => Env m
snapEnv path =
map (TextInput . T.decodeUtf8) . findParams <$> Snap.getPostParams
where
findParams = fromMaybe [] . M.lookup name
name = T.encodeUtf8 $ fromPath path

-- | Runs a form with the HTTP input provided by Happstack.
--
-- Automatically picks between 'getForm' and 'postForm' based on the request
-- method.
runForm :: Snap.MonadSnap m
=> Text -- ^ Name for the form
-> Form v m a -- ^ Form to run
-> m (View v, Maybe a) -- ^ Result
runForm name form = Snap.getRequest >>= \rq ->
case Snap.rqMethod rq of
Snap.GET -> return (getForm name form, Nothing)
_ -> postForm name form snapEnv
2 changes: 1 addition & 1 deletion digestive-functors/digestive-functors.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Cabal-version: >= 1.6

Library
Hs-source-dirs: src
Ghc-options: -Wall
Ghc-options: -Wall -fwarn-tabs

Exposed-modules:
Text.Digestive,
Expand Down
42 changes: 0 additions & 42 deletions examples/Cli.lhs

This file was deleted.

179 changes: 0 additions & 179 deletions examples/Snap.lhs

This file was deleted.

0 comments on commit 896f0f8

Please sign in to comment.