-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update digestive-functors-snap, cabal files
- Loading branch information
Showing
10 changed files
with
70 additions
and
281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
:set -isrc -i../digestive-functors/src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.