reform-hamlet-0.0/ 0000755 0000000 0000000 00000000000 12174562470 012311 5 ustar 00 0000000 0000000 reform-hamlet-0.0/reform-hamlet.cabal 0000644 0000000 0000000 00000002132 12174562470 016035 0 ustar 00 0000000 0000000 Name: reform-hamlet
Version: 0.0
Synopsis: Add support for using Hamlet with Reform
Description: Reform is a library for building and validating forms using applicative functors. This package add support for using reform with Hamlet.
Homepage: http://www.happstack.com/
License: BSD3
License-file: LICENSE
Author: Jeremy Shaw
Maintainer: jeremy@n-heptane.com
Copyright: 2012 Jeremy Shaw, Jasper Van der Jeugt, SeeReason Partners LLC
Category: Web
Build-type: Simple
Cabal-version: >=1.6
source-repository head
type: darcs
subdir: reform-hamlet
location: http://hub.darcs.net/stepcut/reform
Library
Exposed-modules: Text.Reform.Hamlet.Common
Text.Reform.Hamlet.String
Text.Reform.Hamlet.Text
Build-depends: base > 4 && <5,
blaze-markup > 0.5 && < 0.6,
hamlet > 1.0 && < 1.2,
reform == 0.2.*,
text == 0.11.*
reform-hamlet-0.0/LICENSE 0000644 0000000 0000000 00000002757 12174562470 013331 0 ustar 00 0000000 0000000 Copyright (c)2012, Jeremy Shaw
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 Jeremy Shaw nor the names of other
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
OWNER 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.
reform-hamlet-0.0/Setup.hs 0000644 0000000 0000000 00000000056 12174562470 013746 0 ustar 00 0000000 0000000 import Distribution.Simple
main = defaultMain
reform-hamlet-0.0/Text/ 0000755 0000000 0000000 00000000000 12174562470 013235 5 ustar 00 0000000 0000000 reform-hamlet-0.0/Text/Reform/ 0000755 0000000 0000000 00000000000 12174562470 014467 5 ustar 00 0000000 0000000 reform-hamlet-0.0/Text/Reform/Hamlet/ 0000755 0000000 0000000 00000000000 12174562470 015701 5 ustar 00 0000000 0000000 reform-hamlet-0.0/Text/Reform/Hamlet/Common.hs 0000644 0000000 0000000 00000023742 12174562470 017475 0 ustar 00 0000000 0000000 {-# LANGUAGE QuasiQuotes, ScopedTypeVariables, TypeFamilies #-}
module Text.Reform.Hamlet.Common where
import Data.Text.Lazy (Text, pack)
import qualified Data.Text as T
import Text.Blaze (ToMarkup(..))
import Text.Reform.Backend
import Text.Reform.Core
import Text.Reform.Generalized as G
import Text.Reform.Result (FormId, Result(Ok), unitRange)
import Text.Hamlet (hamlet, HtmlUrl)
instance ToMarkup FormId where
toMarkup fid = toMarkup (show fid)
inputText :: (FormError error, Monad m, ToMarkup text) => (input -> Either error text) -> text -> Form m input error (HtmlUrl url) () text
inputText getInput initialValue = G.input getInput inputField initialValue
where
inputField i a = [hamlet||]
inputPassword :: (Monad m, FormError error, ToMarkup text) =>
(input -> Either error text)
-> text
-> Form m input error (HtmlUrl url) () text
inputPassword getInput initialValue = G.input getInput inputField initialValue
where
inputField i a = [hamlet||]
inputSubmit :: (Monad m, FormError error, ToMarkup text) =>
(input -> Either error text)
-> text
-> Form m input error (HtmlUrl url) () (Maybe text)
inputSubmit getInput initialValue = G.inputMaybe getInput inputField initialValue
where
inputField i a = [hamlet||]
inputReset :: (Monad m, FormError error, ToMarkup text) =>
text
-> Form m input error (HtmlUrl url) () ()
inputReset lbl = G.inputNoData inputField lbl
where
inputField i a = [hamlet||]
inputHidden :: (Monad m, FormError error, ToMarkup text) =>
(input -> Either error text)
-> text
-> Form m input error (HtmlUrl url) () text
inputHidden getInput initialValue = G.input getInput inputField initialValue
where
inputField i a = [hamlet||]
inputButton :: (Monad m, FormError error, ToMarkup text) =>
text
-> Form m input error (HtmlUrl url) () ()
inputButton label = G.inputNoData inputField label
where
inputField i a = [hamlet||]
textarea :: (Monad m, FormError error, ToMarkup text) =>
(input -> Either error text)
-> Int -- ^ cols
-> Int -- ^ rows
-> text -- ^ initial text
-> Form m input error (HtmlUrl url) () text
textarea getInput cols rows initialValue = G.input getInput textareaView initialValue
where
textareaView i txt = [hamlet|