happstack-helpers-0.52: Convenience functions for Happstack.

Happstack.Helpers.HtmlOutput.Common

Description

Simple stupid output of common types of html

Synopsis

Documentation

fullUrlLink :: FilePath -> StringSource

fullUrlLink "http:www.google.com" | for when you want a link that the anchor text is the full url. eg, for displaying a url for darcs get.

simpleLink :: (FilePath, String) -> StringSource

simpleLink ("http:www.google.com","google is a nice way to look for information")

simpleAttentionLink :: (String, String) -> StringSource

like simpleLink, but a link tag is class=attention

if class attention is defined via css you can get some useful behavior. I typically do something like the following, in a global css file:

a.attention:link {color: orange}

a.attention:active {color: orange}

a.attention:visited {color: orange}

a.attention:hover {color: orange}

simpleImage :: (FilePath, String) -> (String, String) -> StringSource

width and height args blank blank if you don't want to specify this

simpleImage (url, alttext) (width, height) = ...

paintVHtml :: [String] -> StringSource

format a list of text vertically by putting list items in paragraphs

paintTableSource

Arguments

:: Maybe [String]

optional header rows

-> [[String]]

table cells

-> Maybe Pagination

optional pagination

-> String 

paintTable mbHeaderCells datacells mbPagination = ...

mbHeaderCells: text for header cells, if you want them. Can use html formatting if desired.

pagination also optional

paintTable'Source

Arguments

:: (String -> String)

table tag function

-> ([String] -> String)

row tag function, input is table cell contents

-> (String, Bool)

(spacer row, more padding) (use ("",False) for no spacer rows) if more padding is true, prepend and append spacers

-> Maybe ([String], [String] -> String)

optional (header rows, header row tag function)

-> [[String]]

table cells

-> Maybe Pagination

optional pagination

-> String 

paintTable' tableF trF spacerRow mbHeaderStuff datacells mbPagination =

helper function for a table with pagination

see paintTable for an example of how this can be used

newlinesToHtmlLines :: String -> StringSource

substitute newlines with br

readcheckbox :: String -> RqData BoolSource

The checkbox form element has optional attribute checked.

If this attribute is present, readcheckbox returns true, otherwise false.

use in conjunction with checkStringIfTrue, when, eg, writing StringTemplate code that renders a from with a box that might or not be checked. Something like:

attrs = [ ... , (somethingIsChecked, checkedStringIfTrue $ someBoolVal ) ... ]

checkedStringIfTrue :: Bool -> StringSource

useful hack for dealing with checkboxes in HAppS. Maybe there's a better way?

checkedStringIfTrue p = if p then "checked" else ""

paintVUL :: [String] -> StringSource

Render a list of strings as an unordered list (ul.../ul)

paintVOL :: [String] -> StringSource

Render a list of strings as an ordered list (ol.../ol)

paintHBars :: [String] -> StringSource

render a list of strings horizontally, separated by " | "

newtype HtmlString Source

Constructors

HtmlString String 

newtype HtmlText Source

Constructors

HtmlText Text 

Instances