happstack-helpers-0.51: Convenience functions for Happstack.Source codeContentsIndex
Happstack.Helpers.HtmlOutput.Common
Description
Simple stupid output of common types of html
Synopsis
fullUrlLink :: FilePath -> String
simpleLink :: (FilePath, String) -> String
simpleAttentionLink :: (String, String) -> String
simpleImage :: (FilePath, String) -> (String, String) -> String
paintVHtml :: [String] -> String
paintTable :: Maybe [String] -> [[String]] -> Maybe Pagination -> String
paintTable' :: (String -> String) -> ([String] -> String) -> (String, Bool) -> Maybe ([String], [String] -> String) -> [[String]] -> Maybe Pagination -> String
data Pagination = Pagination {
currentbar :: Int
resultsPerBar :: Int
currentpage :: Int
resultsPerPage :: Int
baselink :: String
paginationtitle :: String
}
paintPaginationBar :: [[String]] -> Pagination -> String
getPaginatedCells :: [[String]] -> Pagination -> [[String]]
newlinesToHtmlLines :: String -> String
readcheckbox :: String -> RqData Bool
checkedStringIfTrue :: Bool -> String
paintVUL :: [String] -> String
paintVOL :: [String] -> String
paintHBars :: [String] -> String
newtype HtmlString = HtmlString String
newtype HtmlText = HtmlText Text
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
:: Maybe [String]optional header rows
-> [[String]]table cells
-> Maybe Paginationoptional 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
:: String -> Stringtable tag function
-> [String] -> Stringrow tag function, input is table cell contents
-> (String, Bool)
-> Maybe ([String], [String] -> String)optional (header rows, header row tag function)
-> [[String]]table cells
-> Maybe Paginationoptional 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

data Pagination Source
Constructors
Pagination
currentbar :: Int
resultsPerBar :: Int
currentpage :: Int
resultsPerPage :: Int
baselink :: String
paginationtitle :: String
paintPaginationBar :: [[String]] -> Pagination -> StringSource
getPaginatedCells :: [[String]] -> Pagination -> [[String]]Source
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
show/hide Instances
newtype HtmlText Source
Constructors
HtmlText Text
show/hide Instances
Produced by Haddock version 2.6.1