yesod-form-1.4.6/0000755000000000000000000000000012630110214011762 5ustar0000000000000000yesod-form-1.4.6/ChangeLog.md0000644000000000000000000000076012630110214014136 0ustar0000000000000000## 1.4.6 * Functor instances for Option/OptionList ## 1.4.5 * Foldable/Traversable instances for FormResult [#1089](https://github.com/yesodweb/yesod/pull/1089) ## 1.4.4.1 * runFormPost has wrong behavior for empty forms [#950](https://github.com/yesodweb/yesod/issues/950) ## 1.4.4 * Add a `Semigroup` instance ## 1.4.3 Added `jqueryDatePickerDayField`. ## 1.4.2.1 Documentation updates ## 1.4.2 Added `timeFieldTypeTime` and `timeFieldTypeText`, and deprecated `timeField` itself. yesod-form-1.4.6/LICENSE0000644000000000000000000000207512630110214012773 0ustar0000000000000000Copyright (c) 2012 Michael Snoyman, http://www.yesodweb.com/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. yesod-form-1.4.6/README.md0000644000000000000000000000022612630110214013241 0ustar0000000000000000## yesod-form Form handling for Yesod, in the same style as formlets. See [the forms chapter](http://www.yesodweb.com/book/forms) of the Yesod book. yesod-form-1.4.6/Setup.lhs0000644000000000000000000000016212630110214013571 0ustar0000000000000000#!/usr/bin/env runhaskell > module Main where > import Distribution.Simple > main :: IO () > main = defaultMain yesod-form-1.4.6/yesod-form.cabal0000644000000000000000000000603512630110214015036 0ustar0000000000000000name: yesod-form version: 1.4.6 license: MIT license-file: LICENSE author: Michael Snoyman maintainer: Michael Snoyman synopsis: Form handling support for Yesod Web Framework category: Web, Yesod stability: Stable cabal-version: >= 1.8 build-type: Simple homepage: http://www.yesodweb.com/ description: API docs and the README are available at extra-source-files: ChangeLog.md README.md flag network-uri description: Get Network.URI from the network-uri package default: True library build-depends: base >= 4 && < 5 , yesod-core >= 1.4 && < 1.5 , yesod-persistent >= 1.4 && < 1.5 , time >= 1.1.4 , shakespeare >= 2.0 , persistent , template-haskell , transformers >= 0.2.2 , data-default , xss-sanitize >= 0.3.0.1 , blaze-builder >= 0.2.1.4 , email-validate >= 1.0 , bytestring >= 0.9.1.4 , text >= 0.9 , wai >= 1.3 , containers >= 0.2 , blaze-html >= 0.5 , blaze-markup >= 0.5.1 , attoparsec >= 0.10 , byteable , aeson , resourcet , semigroups if flag(network-uri) build-depends: network-uri >= 2.6 else build-depends: network < 2.6 exposed-modules: Yesod.Form Yesod.Form.Types Yesod.Form.Functions Yesod.Form.Bootstrap3 Yesod.Form.Input Yesod.Form.Fields Yesod.Form.Jquery Yesod.Form.Nic Yesod.Form.MassInput Yesod.Form.I18n.English Yesod.Form.I18n.Portuguese Yesod.Form.I18n.Swedish Yesod.Form.I18n.German Yesod.Form.I18n.French Yesod.Form.I18n.Norwegian Yesod.Form.I18n.Japanese Yesod.Form.I18n.Czech Yesod.Form.I18n.Russian Yesod.Form.I18n.Dutch -- FIXME Yesod.Helpers.Crud ghc-options: -Wall test-suite test type: exitcode-stdio-1.0 main-is: main.hs hs-source-dirs: test build-depends: base , yesod-form , time , hspec , text source-repository head type: git location: https://github.com/yesodweb/yesod yesod-form-1.4.6/test/0000755000000000000000000000000012630110214012741 5ustar0000000000000000yesod-form-1.4.6/test/main.hs0000644000000000000000000000316312630110214014224 0ustar0000000000000000{-# LANGUAGE OverloadedStrings #-} import Test.Hspec import Data.Time (TimeOfDay (TimeOfDay)) import Data.Text (pack) import Yesod.Form.Fields (parseTime) import Yesod.Form.Types main :: IO () main = hspec $ describe "parseTime" $ mapM_ (\(s, e) -> it s $ parseTime (pack s) `shouldBe` e) [ ("01:00:00", Right $ TimeOfDay 1 0 0) , ("1:00", Right $ TimeOfDay 1 0 0) , ("1:00 AM", Right $ TimeOfDay 1 0 0) , ("1:00 am", Right $ TimeOfDay 1 0 0) , ("1:00AM", Right $ TimeOfDay 1 0 0) , ("1:00am", Right $ TimeOfDay 1 0 0) , ("01:00:00am", Right $ TimeOfDay 1 0 0) , ("01:00:00 am", Right $ TimeOfDay 1 0 0) , ("01:00:00AM", Right $ TimeOfDay 1 0 0) , ("01:00:00 AM", Right $ TimeOfDay 1 0 0) , ("1:00:01", Right $ TimeOfDay 1 0 1) , ("1:00:02 AM", Right $ TimeOfDay 1 0 2) , ("1:00:04 am", Right $ TimeOfDay 1 0 4) , ("1:00:05 am", Right $ read "01:00:05") , ("1:00:64 am", Left $ MsgInvalidSecond "64") , ("1:00:4 am", Left $ MsgInvalidSecond "4") , ("0:00", Right $ TimeOfDay 0 0 0) , ("12:00am", Right $ TimeOfDay 0 0 0) , ("12:59:59am", Right $ TimeOfDay 0 59 59) , ("12:59:60am", Left $ MsgInvalidSecond "60") , ("12:60:59am", Left $ MsgInvalidMinute "60") , ("12:00pm", Right $ TimeOfDay 12 0 0) , ("12:59:59pm", Right $ TimeOfDay 12 59 59) , ("12:59:60pm", Left $ MsgInvalidSecond "60") , ("12:60:59pm", Left $ MsgInvalidMinute "60") , ("12:7pm", Left $ MsgInvalidMinute "7") , ("23:47", Right $ TimeOfDay 23 47 0) ] yesod-form-1.4.6/Yesod/0000755000000000000000000000000012630110214013045 5ustar0000000000000000yesod-form-1.4.6/Yesod/Form.hs0000644000000000000000000000050112630110214014300 0ustar0000000000000000-- | Parse forms (and query strings). module Yesod.Form ( module Yesod.Form.Types , module Yesod.Form.Functions , module Yesod.Form.Fields , module Yesod.Form.Input ) where import Yesod.Form.Types import Yesod.Form.Functions import Yesod.Form.Fields hiding (FormMessage (..)) import Yesod.Form.Input yesod-form-1.4.6/Yesod/Form/0000755000000000000000000000000012630110214013750 5ustar0000000000000000yesod-form-1.4.6/Yesod/Form/Bootstrap3.hs0000644000000000000000000003034512630110214016351 0ustar0000000000000000{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE OverloadedStrings #-} -- | Helper functions for creating forms when using . -- module Yesod.Form.Bootstrap3 ( -- * Example: Rendering a basic form -- $example -- * Example: Rendering a horizontal form -- $example2 -- * Rendering forms renderBootstrap3 , BootstrapFormLayout(..) , BootstrapGridOptions(..) -- * Field settings -- $fieldSettings , bfs , withPlaceholder , withAutofocus , withLargeInput , withSmallInput -- * Submit button , bootstrapSubmit , mbootstrapSubmit , BootstrapSubmit(..) ) where import Control.Arrow (second) import Control.Monad (liftM) import Data.Text (Text) import Data.String (IsString(..)) import Yesod.Core import qualified Data.Text as T import Yesod.Form.Types import Yesod.Form.Functions -- | Create a new 'FieldSettings' with the @form-control@ class that is -- required by Bootstrap v3. -- -- Since: yesod-form 1.3.8 bfs :: RenderMessage site msg => msg -> FieldSettings site bfs msg = FieldSettings (SomeMessage msg) Nothing Nothing Nothing [("class", "form-control")] -- | Add a placeholder attribute to a field. If you need i18n -- for the placeholder, currently you\'ll need to do a hack and -- use 'getMessageRender' manually. -- -- Since: yesod-form 1.3.8 withPlaceholder :: Text -> FieldSettings site -> FieldSettings site withPlaceholder placeholder fs = fs { fsAttrs = newAttrs } where newAttrs = ("placeholder", placeholder) : fsAttrs fs -- | Add an autofocus attribute to a field. -- -- Since: yesod-form 1.3.8 withAutofocus :: FieldSettings site -> FieldSettings site withAutofocus fs = fs { fsAttrs = newAttrs } where newAttrs = ("autofocus", "autofocus") : fsAttrs fs -- | Add the @input-lg@ CSS class to a field. -- -- Since: yesod-form 1.3.8 withLargeInput :: FieldSettings site -> FieldSettings site withLargeInput fs = fs { fsAttrs = newAttrs } where newAttrs = addClass "input-lg" (fsAttrs fs) -- | Add the @input-sm@ CSS class to a field. -- -- Since: yesod-form 1.3.8 withSmallInput :: FieldSettings site -> FieldSettings site withSmallInput fs = fs { fsAttrs = newAttrs } where newAttrs = addClass "input-sm" (fsAttrs fs) addClass :: Text -> [(Text, Text)] -> [(Text, Text)] addClass klass [] = [("class", klass)] addClass klass (("class", old):rest) = ("class", T.concat [old, " ", klass]) : rest addClass klass (other :rest) = other : addClass klass rest -- | How many bootstrap grid columns should be taken (see -- 'BootstrapFormLayout'). -- -- Since: yesod-form 1.3.8 data BootstrapGridOptions = ColXs !Int | ColSm !Int | ColMd !Int | ColLg !Int deriving (Eq, Ord, Show) toColumn :: BootstrapGridOptions -> String toColumn (ColXs 0) = "" toColumn (ColSm 0) = "" toColumn (ColMd 0) = "" toColumn (ColLg 0) = "" toColumn (ColXs columns) = "col-xs-" ++ show columns toColumn (ColSm columns) = "col-sm-" ++ show columns toColumn (ColMd columns) = "col-md-" ++ show columns toColumn (ColLg columns) = "col-lg-" ++ show columns toOffset :: BootstrapGridOptions -> String toOffset (ColXs 0) = "" toOffset (ColSm 0) = "" toOffset (ColMd 0) = "" toOffset (ColLg 0) = "" toOffset (ColXs columns) = "col-xs-offset-" ++ show columns toOffset (ColSm columns) = "col-sm-offset-" ++ show columns toOffset (ColMd columns) = "col-md-offset-" ++ show columns toOffset (ColLg columns) = "col-lg-offset-" ++ show columns addGO :: BootstrapGridOptions -> BootstrapGridOptions -> BootstrapGridOptions addGO (ColXs a) (ColXs b) = ColXs (a+b) addGO (ColSm a) (ColSm b) = ColSm (a+b) addGO (ColMd a) (ColMd b) = ColMd (a+b) addGO (ColLg a) (ColLg b) = ColLg (a+b) addGO a b | a > b = addGO b a addGO (ColXs a) other = addGO (ColSm a) other addGO (ColSm a) other = addGO (ColMd a) other addGO (ColMd a) other = addGO (ColLg a) other addGO (ColLg _) _ = error "Yesod.Form.Bootstrap.addGO: never here" -- | The layout used for the bootstrap form. -- -- Since: yesod-form 1.3.8 data BootstrapFormLayout = BootstrapBasicForm -- ^ A form with labels and inputs listed vertically. See | BootstrapInlineForm -- ^ A form whose @\@ are laid out horizontally (displayed as @inline-block@). For this layout, @\