Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== Outdated egg! This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for [[/eggref/5/html-utils|the CHICKEN 5 version of this egg]], if it exists. If it does not exist, there may be equivalent functionality provided by another egg; have a look at the [[https://wiki.call-cc.org/chicken-projects/egg-index-5.html|egg index]]. Otherwise, please consider porting this egg to the current version of CHICKEN. == html-utils [[toc:]] === Introduction {{html-utils}} is an extension which provides procedures to ease the generation of some frequently used [SX]HTML structures. {{html-utils}} is based on [[/egg/html-tags|html-tags]], so it can generate strings or SXML code. The html-tags' {{generate-sxml?}} parameter (yields a boolean) specifies whether html-utils should generate strings or SXML code. Example: $ csi -n #;1> (use html-tags html-utils) #;2> (generate-sxml?) #f #;3> (itemize '(1 2 3)) "<ul><li>1</li><li>2</li><li>3</li></ul>" #;4> (generate-sxml? #t) #t #;5> (itemize '(1 2 3)) (ul (li 1) (li 2) (li 3)) === Author [[/users/mario-domenech-goulart|Mario Domenech Goulart]] === Procedures ==== {{itemize}} <procedure>(itemize items #!key list-id list-class quote-procedure)</procedure> Generates an HTML unordered list of {{items}}. The following attributes may be used: * {{list-id}}: the value for the HTML {{id}} attribute for the list. * {{list-class}}: the value for the HTML {{class}} attribute for the list. * {{quote-procedure}}: an one-argument procedure to specify the quoting of attributes' values for tags. Examples: <enscript highlight=scheme> (itemize '(apple watermelon strawberry)) </enscript> Produces: "<ul><li>apple</li><li>watermelon</li><li>strawberry</li></ul>" <enscript highlight=scheme> (itemize '(apple watermelon strawberry) list-id: "my-list" list-class: "lists") </enscript> Produces: "<ul id='my-list' class='lists'><li>apple</li><li>watermelon</li><li>strawberry</li></ul>" ==== {{enumerate}} <procedure>(enumerate items #!key list-id list-class quote-procedure)</procedure> Generates an HTML ordered list of {{items}}. See {{itemize}}. ==== {{html-page}} <procedure>(html-page contents #!key css title (doctype "") (headers "") charset content-type literal-style? html-attribs body-attribs)</procedure> Generates an HTML page containing {{contents}} (a string). If contents starts with {{"<body"}} (case insensitive), {{html-page}} won't use the {{<body>}} tag to enclose {{contents}}. The following keywords arguments may be used to customize the page: * {{headers}}: a string (when not in SXML mode) or an SXML form (when in SXML mode) containing additional headers to be inserted in the section delimited by the {{<head>}} tag. Default = {{""}}. * {{title}}: the title for the page (to be used in the {{<title>}} tag). Default = {{""}}. * {{css}}: may be either a path to a Cascading Style Sheet file, to be linked from the generated page (the default value is {{#f}}, so no CSS is used) or a list of paths to CSS files. If a list of paths is used, the elements which are also lists are read and inlined into the generated page. Example: {{css: '("css1.css" ("css2.css"))}}. In the example, {{css1.css}} would be linked from the generated page (using the link tag) and {{css2.css}} would be inlined into the generated page (e.g., {{html-page}} would read the {{css2.css}} file and inline its contents in the HTML code). * {{doctype}}: specifies the document type of the generated page. The default value is {{doctype:html-4.01-strict}}. The possible values are the ones available from the [[doctype]] egg. * {{charset}}: specifies the default charset to be used in the corresponding meta tag of the document. The default value is {{"UTF-8"}} (only when {{content-type}} is provided). * {{literal-style?}} (introduced in version 0.9): if {{#f}}, convert special characters in style code (CSS) to theyr equivalent HTML entities. If non-{{#f}}, insert them verbatim. * {{content-type}} (introduced in version 0.9) and {{charset}} work together: if {{content-type}} is provided and {{charset}} is not provided, {{charset}} is assumed to be {{"UTF-8"}}; if {{charset}} is provided and {{content-type}} is not provided, {{content-type}} is assumed to be {{"text/html"}} (if [[/egg/html-tags|html-tags]]' {{generate-sxml?}} is {{#f}}) or {{"application/xhtml+xml"}} (if {{generate-sxml?}} is non-{{#f}}). * {{html-attribs}} (introduced in version 0.10): attributes to the {{html}} tag. The format is a list of lists {{(<attribute> <value>)}} ({{<attribute>}} is a symbol). Example: {{(html-page "foo" html-attribs: '((lang "us")))}}. * {{body-attribs}} (introduced in version 0.10): attributes to the {{body}} tag. The format is a list of lists {{(<attribute> <value>)}} ({{<attribute>}} is a symbol). Example: {{(html-page "foo" body-attribs: '((bgcolor "red")))}}. Examples: <enscript highlight=scheme> (html-page "hello") </enscript> Produces: "<html><head></head><body>hello</body></html>" <enscript highlight=scheme> (html-page "hello" title: "hello") </enscript> Produces: "<html><head><title>hello</title></head><body>hello</body></html>" <enscript highlight=scheme> (use doctype) (html-page "hello" title: "hello" doctype: xhtml-1.0-strict) </enscript> Produces: "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html><head><title>hello</title></head><body>hello</body></html>" <enscript highlight=scheme> (html-page "hello" headers: (<script> type: "text/javascript" src: "my-script.js")) </enscript> Produces: "<html><head><script type='text/javascript' src='my-script.js'></script></head><body>hello</body></html>" <enscript highlight=scheme> (use html-tags html-utils) (parameterize ((generate-sxml? #t)) (html-page "hello" headers: (<script> type: "text/javascript" src: "my-script.js"))) </enscript> Produces: (html (head (script (@ (type "text/javascript") (src "my-script.js")))) (body "hello")) ==== {{combo-box}} <procedure>(combo-box name options #!key default id first-empty onchange onkeyup disabled length multiple selectedindex size tabindex type class)</procedure> Generates an HTML combo box using {{<select>}} and {{<option>}} tags. The keyword parameters {{id}}, {{onchange}}, {{onkeyup}}, {{disabled}}, {{length}}, {{multiple}}, {{selectedindex}}, {{size}}, {{tabindex}}, {{type}} and {{class}} are passed to the {{<select>}} procedure (from [[/egg/html-tags|html-tags]]). {{default}} is the value from the list of options to be selected. If {{first-empty}} is {{#t}}, the first option of the combo box will be empty. Example: <enscript highlight=scheme> (combo-box "test" '(#(1 1) #(2 2) #(3 3)) first-empty: #t default: 2) </enscript> Produces: "<select name='test' id='test'><option></option><option value='1'>1</option><option value='2' selected>2</option><option value='3'>3</option></select>" ==== {{hidden-input}} <procedure>(hidden-input name/list #!optional value id)</procedure> Generates an HTML hidden input field. {{name/list}} can be either a string representing the name attribute of the HTML input tag or an alist mapping names to values to be used by the corresponding input tags. When {{name/list}} is a string, so representing the name of the input tag, the optional values VALUE and ID can be used to be represent the values of their corresponding HTML attributes. Examples: <enscript highlight=scheme> (hidden-input 'secret-var "secret-val") </enscript> Produces: "<input type='hidden' name='secret-var' id='secret-var' value='secret-val'>" <enscript highlight=scheme> (hidden-input '((secret-var1 . "secret-val1") (secret-var2 . "secret-val2"))) </enscript> Produces: "<input type='hidden' id='secret-var1' name='secret-var1' value='secret-val1'><input type='hidden' id='secret-var2' name='secret-var2' value='secret-val2'>" ==== {{text-input}} <procedure>(text-input name . args)</procedure> Generates an input text box. {{args}} are keyword arguments to be passed to {{<input>}} (from [[/egg/html-tags|html-tags]]). Examples: <enscript highlight=scheme> (text-input "foo" value: "bar") </enscript> Produces: "<input type='text' name='foo' id='foo' value='bar'>" ==== {{password-input}} <procedure>(password-input name . args)</procedure> The same as {{text-input}}, but for password inputs. ==== {{submit-input}} <procedure>(submit-input . args)</procedure> Generates a submit widget. {{args}} are keyword arguments to be passed to {{<input>}} (from [[/egg/html-tags|html-tags]]). <enscript highlight=scheme> (submit-input value: "Send!") </enscript> Produces: "<input type='submit' value='Send!'>" ==== {{tabularize}} <procedure>(tabularize items #!key table-id table-class quote-procedure even-row-class odd-row-class header)</procedure> Generates an HTML table from {{items}} (a list of lists). The following keyword parameters may be used: * {{table-id}}: the value for the HTML {{id}} attribute for the table. * {{table-class}}: the value for the HTML {{class}} attribute for the table. * {{quote-procedure}}: an one-argument procedure to specify the quoting of attributes' values for tags. * {{even-row-class}}: the value for the HTML {{class}} attribute for even rows of the the table. * {{odd-row-class}}: the value for the HTML {{class}} attribute for odd rows of the the table. * {{header}}: a list of column names to be used as the table header (enclosed by the {{th}} tag). * {{thead/tbody}}: if {{#t}}, generates the table with {{<thead>}} and {{<tbody>}} tags. Examples: <enscript highlight=scheme> (tabularize '((1 2 3) (4 5 6))) </enscript> Produces: <nowiki> <pre> "<table><tr><td>1</td><td>2</td><td>3</td></tr><tr><td>4</td><td>5</td><td>6</td></tr></table>" </pre> </nowiki> <enscript highlight=scheme> (tabularize '((1 2 3) (4 5 6)) table-id: "test" even-row-class: "yellow" odd-row-class: "blue") </enscript> Produces: <nowiki> <pre> "<table id='test'><tr class='yellow'><td>1</td><td>2</td><td>3</td></tr><tr class='blue'><td>4</td><td>5</td><td>6</td></tr></table>" </pre> </nowiki> === License BSD === Requirements [[/egg/html-tags|html-tags]] === Version history ==== Version 0.10 * New keyword parameters for {{html-page}}: {{html-attribs}} and {{body-attribs}}. ==== Version 0.9 * Added {{literal-style?}} and {{content-type}} keyword parameters for {{html-page}} * '''Warning''': the default behavior for inlined CSS ({{css}} keyword parameter for {{html-page}}) has changed. Now the special HTML characters are converted to their corresponding entities in non-SXML mode (i.e., when [[/egg/html-tags|html-tags]]' {{generate-sxml?}} is {{#f}} -- the default value). This may break your page styles if you inline CSS via {{html-page}}'s {{css}} keyword parameter. To get the old behavior, use {{literal-style?: #t}} for {{html-page}}. ==== Version 0.8 * Fixed order of elements in {{<head>}}: {{<meta http-equiv...>}} should be before {{<title>}} (reported by Sandra Snan) ==== Version 0.7 * Bugfix: {{password-input}} was not being exported ==== Version 0.6 * Added {{thead/tbody}} keyword parameter for {{tabularize}} ==== Version 0.5 * Added the {{password-input}} procedure and the {{header}} keyword parameter for {{tabularize}} ==== Version 0.5 * Added {{text-input}} and {{submit-input}} ==== Version 0.1 * Initial release
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you multiply 0 by 7?