reform-blaze-0.2.0/0000755000000000000000000000000012171027321012260 5ustar0000000000000000reform-blaze-0.2.0/LICENSE0000644000000000000000000000275712171027321013300 0ustar0000000000000000Copyright (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-blaze-0.2.0/Setup.hs0000644000000000000000000000005612171027321013715 0ustar0000000000000000import Distribution.Simple main = defaultMain reform-blaze-0.2.0/reform-blaze.cabal0000644000000000000000000000211612171027321015631 0ustar0000000000000000Name: reform-blaze Version: 0.2.0 Synopsis: Add support for using blaze-html with Reform Description: Reform is a library for building and validating forms using applicative functors. This package add support for using reform with blaze-html. Homepage: http://www.happstack.com/ License: BSD3 License-file: LICENSE Author: Jeremy Shaw Maintainer: jeremy@n-heptane.com Copyright: 2012 Jeremy Shaw, SeeReason Partners LLC Category: Web Build-type: Simple Cabal-version: >=1.6 source-repository head type: darcs subdir: reform-blaze location: http://hub.darcs.net/stepcut/reform Library Exposed-modules: Text.Reform.Blaze.Common Text.Reform.Blaze.String Text.Reform.Blaze.Text Build-depends: base >4 && <5, blaze-markup == 0.5.*, blaze-html >= 0.5 && < 0.7, reform == 0.2.*, text == 0.11.* reform-blaze-0.2.0/Text/0000755000000000000000000000000012171027321013204 5ustar0000000000000000reform-blaze-0.2.0/Text/Reform/0000755000000000000000000000000012171027321014436 5ustar0000000000000000reform-blaze-0.2.0/Text/Reform/Blaze/0000755000000000000000000000000012171027321015473 5ustar0000000000000000reform-blaze-0.2.0/Text/Reform/Blaze/Common.hs0000644000000000000000000003274012171027321017265 0ustar0000000000000000{-# LANGUAGE OverloadedStrings, ScopedTypeVariables, TypeFamilies #-} module Text.Reform.Blaze.Common where import Data.Monoid (mconcat, mempty, (<>)) import Data.Text.Lazy (Text) import Text.Reform.Backend import Text.Reform.Core import Text.Reform.Generalized as G import Text.Reform.Result (FormId, Result(Ok), unitRange) import Text.Blaze.Html (Html, (!), toValue) import qualified Text.Blaze.Html5 as H import Text.Blaze.Html5.Attributes (type_, name, value) import qualified Text.Blaze.Html5.Attributes as A instance H.ToValue FormId where toValue fid = toValue (show fid) inputText :: (Monad m, FormError error, H.ToValue text) => (input -> Either error text) -> text -> Form m input error Html () text inputText getInput initialValue = G.input getInput inputField initialValue where inputField i a = H.input ! type_ "text" ! A.id (toValue i) ! name (toValue i) ! value (toValue a) inputPassword :: (Monad m, FormError error, H.ToValue text) => (input -> Either error text) -> text -> Form m input error Html () text inputPassword getInput initialValue = G.input getInput inputField initialValue where inputField i a = H.input ! type_ "password" ! A.id (toValue i) ! name (toValue i) ! value (toValue a) inputSubmit :: (Monad m, FormError error, H.ToValue text) => (input -> Either error text) -> text -> Form m input error Html () (Maybe text) inputSubmit getInput initialValue = G.inputMaybe getInput inputField initialValue where inputField i a = H.input ! type_ "submit" ! A.id (toValue i) ! name (toValue i) ! value (toValue a) inputReset :: (Monad m, FormError error, H.ToValue text) => text -> Form m input error Html () () inputReset lbl = G.inputNoData inputField lbl where inputField i a = H.input ! type_ "submit" ! A.id (toValue i) ! name (toValue i) ! value (toValue a) inputHidden :: (Monad m, FormError error, H.ToValue text) => (input -> Either error text) -> text -> Form m input error Html () text inputHidden getInput initialValue = G.input getInput inputField initialValue where inputField i a = H.input ! type_ "hidden" ! A.id (toValue i) ! name (toValue i) ! value (toValue a) inputButton :: (Monad m, FormError error, H.ToValue text) => text -> Form m input error Html () () inputButton label = G.inputNoData inputField label where inputField i a = H.input ! type_ "button" ! A.id (toValue i) ! name (toValue i) ! value (toValue a) textarea :: (Monad m, FormError error, H.ToMarkup text) => (input -> Either error text) -> Int -- ^ cols -> Int -- ^ rows -> text -- ^ initial text -> Form m input error Html () text textarea getInput cols rows initialValue = G.input getInput textareaView initialValue where textareaView i txt = H.textarea ! A.rows (toValue rows) ! A.cols (toValue cols) ! A.id (toValue i) ! A.name (toValue i) $ H.toHtml txt -- | Create an @\@ element -- -- This control may succeed even if the user does not actually select a file to upload. In that case the uploaded name will likely be \"\" and the file contents will be empty as well. inputFile :: (Monad m, FormError error, FormInput input, ErrorInputType error ~ input) => Form m input error Html () (FileType input) inputFile = G.inputFile fileView where fileView i = H.input ! type_ "file" ! A.id (toValue i) ! name (toValue i) -- | Create a @\