WashNGo-2.12.0.1: WASH is a family of EDSLs for programming Web applications in Haskell.

WASH.CGI.CGIInternals

Synopsis

Documentation

makeRefSource

Arguments

:: (CGIMonad cgi, Monad m) 
=> String

internal name of entity

-> WithHTML x m ()

body of the reference

-> cgi (WithHTML y m ()) 

Create a hyperlink to internal entity.

makePopupRefSource

Arguments

:: CGIMonad cgi 
=> String

name of popup window

-> String

internal name of entity

-> HTMLCons x y cgi () 

Create a popup hyperlink to internal entity.

makeA :: CGIMonad cgi => String -> String -> HTMLField cgi x y ()Source

Create hyperlink to internal entity /path?name.

data VALID Source

Constructors

VALID 

data INVALID Source

Constructors

INVALID 

concatFields :: (Reason c, Read c) => InputField c INVALID -> InputField Text INVALID -> InputField c INVALIDSource

create a virtual input field from the concatenation of two input fields

concatFieldsWith :: (Reason c, Read c) => (String -> [String] -> String) -> InputField c INVALID -> [InputField Text INVALID] -> InputField c INVALIDSource

Create a virtual input field from the result of applying a function to two input fields. Parsing is applied to the result of the function call.

feither :: (a -> b) -> (c -> d) -> Either a c -> Either b dSource

Combine the values of separately parsed fields

propagate :: Either [err] a -> Either [err] b -> Either [err] (a, b)Source

type HTMLField cgi x y a = WithHTML x cgi () -> WithHTML y cgi aSource

Every input widget maps the content generator for the widget (which may produce HTML elements or attributes) to the content generator of the widget.

resetField :: CGIMonad cgi => HTMLField cgi x y (InputField () INVALID)Source

Creates a reset button that clears all fields of a form.

submitField :: CGIMonad cgi => cgi () -> HTMLField cgi x y ()Source

Creates a submit button. Unsafe. Internal use only.

activeInputFieldSource

Arguments

:: (CGIMonad cgi, Reason a, Read a) 
=> (a -> cgi ())

Function that maps input data to a CGI action.

-> HTMLField cgi x y () 

Creates an input field that submits the field to the browser when data is entered into this field.

activateI :: CGIMonad cgi => (a -> cgi ()) -> HTMLField cgi x y (InputField a INVALID) -> HTMLField cgi x y ()Source

Attach a CGI action to the value returned by the input field. Activation means that data is submitted as soon as it is entered.

inputField :: (CGIMonad cgi, Reason a, Read a) => HTMLField cgi x y (InputField a INVALID)Source

Create a textual input field. Return type can be *anything* in class Reason and Read.

textInputField :: CGIMonad cgi => HTMLField cgi x y (InputField String INVALID)Source

Create a textual input field that returns the string entered. (Avoids having to put quotes around a string.)

checkedTextInputField :: CGIMonad cgi => (Maybe String -> Maybe String) -> HTMLField cgi x y (InputField String INVALID)Source

Creates a textual input field that takes a custom validation function.

passwordInputField :: (CGIMonad cgi, Reason a, Read a) => HTMLField cgi x y (InputField a INVALID)Source

Like inputField but the characters are not echoed on the screen.

checkboxInputField :: CGIMonad cgi => HTMLField cgi x y (InputField Bool INVALID)Source

Creates a checkbox. Returns True if box was checked.

fileInputField :: CGIMonad cgi => HTMLField cgi x y (InputField FileReference INVALID)Source

Creates a file input field. Returns a temporary FileReference. The fileReferenceName of the result is *not* guaranteed to be persistent. The application is responsible for filing it away at a safe place.

checkedFileInputField :: CGIMonad cgi => (Maybe FileReference -> Maybe FileReference) -> HTMLField cgi x y (InputField FileReference INVALID)Source

Creates a file input field. Like fileInputField but has an additional parameter for additional validation of the input.

internalSubmitLink :: CGIMonad cgi => Bool -> Either [ValidationError] (cgi ()) -> HTMLCons x y cgi ()Source

generates a hyperlink that submits the current form.

imageField :: CGIMonad cgi => Image -> HTMLField cgi x y (InputField (Int, Int) INVALID)Source

Create an input field from an image. Returns (x,y) position clicked in the image.

radioGroup :: (CGIMonad cgi, Read a) => WithHTML x cgi (RadioGroup a INVALID)Source

Create a handle for a new radio group. This handle is invisible on the screen!

radioButton :: (Show a, Monad cgi) => RadioGroup a INVALID -> a -> HTMLField cgi x y ()Source

Create a new radio button and attach it to an existing RadioGroup.

radioError :: CGIMonad cgi => RadioGroup a INVALID -> WithHTML x cgi ()Source

Create and place the error indicator for an existing RadioGroup. Becomes visible only if no button of a radio group is pressed.

makeButton :: CGIMonad cgi => HTMLField cgi x y (InputField Bool INVALID)Source

Create a single button.

makeForm :: CGIMonad cgi => WithHTML x cgi a -> WithHTML y cgi ()Source

Wraps an HTML form around its arguments. All standard attributes are computed and need not be supplied explicitly.

makeTextarea :: CGIMonad cgi => String -> HTMLField cgi x y (InputField String INVALID)Source

Create a text area with a preset string.

selectMultipleSource

Arguments

:: (CGIMonad cgi, Eq a) 
=> (a -> String)

function to display values of type a

-> [a]

list of preselected entries

-> [a]

list of all possible entries

-> (Int, Int)

(min, max) number of fields that must be selected

-> HTMLField cgi x y (InputField [a] INVALID) 

Create a selection box where multiple entries can be selected.

selectSingleSource

Arguments

:: (CGIMonad cgi, Eq a) 
=> (a -> String)

function to display values of type a

-> Maybe a

optional preselected value

-> [a]

list of all possible values

-> HTMLField cgi x y (InputField a INVALID) 

Create a selection box where exactly one entry can be selected.

selectBounded :: (CGIMonad cgi, Enum a, Bounded a, Read a, Show a, Eq a) => Maybe a -> HTMLField cgi x y (InputField a INVALID)Source

Selection box for elements of a Bounded type. Argument is the optional preselected value.

fieldSIZE :: Monad m => Int -> WithHTML x m ()Source

Create a SIZE attribute from an Int.

fieldMAXLENGTH :: Monad m => Int -> WithHTML x m ()Source

Create a MAXLENGTH attribute from an Int.

fieldVALUE :: (Monad m, Show a) => a -> WithHTML x m ()Source

Create a VALUE attribute from any Showable.

data Image Source

Constructors

Image 

Fields

imageSRC :: URL
 
imageALT :: String
 

internalImageSource

Arguments

:: CGIMonad cgi 
=> FreeForm

the raw image

-> String

alternative text

-> WithHTML x cgi Image 

Reference to internal image.

dataImageSource

Arguments

:: CGIMonad cgi 
=> FreeForm

the raw image

-> String

alternative text

-> WithHTML x cgi Image 

Reference to internal image via data URL (small images, only).

jsImageSource

Arguments

:: CGIMonad cgi 
=> FreeForm

the raw image

-> String

alternative text

-> WithHTML x cgi Image 

Reference to internal image via javascript URL (does not seem to work).

externalImageSource

Arguments

:: CGIMonad cgi 
=> URL

URL of image

-> String

alternative text

-> WithHTML x cgi Image 

Reference to image by URL.

makeImg :: Monad cgi => Image -> HTMLField cgi x y ()Source

Create an inline image.

popuplink :: Monad m => String -> URL -> HTMLCons x y m ()Source

Hyperlink that creates a named popup window from an URL string.

restart :: CGIMonad cgi => cgi ()Source

restart application.

standardQuery :: CGIMonad cgi => String -> WithHTML x cgi a -> cgi ()Source

Convenient workhorse. Takes the title of a page and a monadic HTML value for the contents of the page. Wraps the contents in a form so that input fields and buttons may be used inside.