Common Lisp Package: HTML-SUGAR

README:

FUNCTION

Public

BUTTON (LABEL URL &KEY DESCRIPTION COLOUR IMAGE)

Create an HTML link to URL having the look of a button. If IMAGE is available use it, otherwise render LABEL as a rectangular button. IMAGE can be a string or a pathname.

COMPRESS-CSS (CSS)

Remove superfluous whitespace and comments from CSS, which is supposed to be a Cascading Style Sheet in the form of a string.

CRYPT (KEY SALT)

Encrypt KEY using SALT.

CURRENT-PAGE (REQUEST ENTITY)

Return the current page path excluding prefix, session ID (if present), and query variables.

ENCODE-URL (REQ ENT PAGE &OPTIONAL QUERY-VALUES-ALIST)

Encode an url using when appropriate the session id. QUERY-VALUES-ALIST is a list of pairs where the car of each pair is a string or a keyword and the cdr is its value.

HTML-RADIO (NAME CHOICES &KEY SELECTED VERTICAL)

Output HTML for a <RADIO> input item. NAME is the name to be given to the input item. CHOICES is a list of pairs: (id . description) The descriptions fill the selection box while the ids are passed to the web server. If SELECTED tells which item of the radio buttons groub should be selected by default. If VERTICAL is true lays the radio buttons vertically rather than horizontally.

HTML-SELECT (NAME CHOICES &KEY SELECTED MULTIPLE)

Output HTML for a <SELECT> input item. NAME is the name to be given to the input item. CHOICES is a list of pairs: (id . description) The descriptions fill the selection box while the ids are passed to the web server. If SELECTED tells which items of the selection should be selected by default. If MULTIPLE tell to make a multiple choice selection input item of that size in lines.

QUERY-VALUE (REQUEST VARIABLE-NAME &OPTIONAL MULTIPLE)

Similar to QUERY-VALUE-STRING, but interpret the string value as Lisp value.

QUERY-VALUE-STRING (REQUEST VARIABLE-NAME &OPTIONAL MULTIPLE)

Similar to REQUEST-QUERY-VALUE but case insensitive. If MULTIPLE is true, the returned value is a list of values; one for each occurrence of VARIABLE-NAME in the query REQUEST.

REQUEST-QUERY-VALUES (KEY REQ &KEY (POST T) (URI T) (TEST #'EQUAL) (EXTERNAL-FORMAT *DEFAULT-ASERVE-EXTERNAL-FORMAT*))

Just like REQUEST-QUERY-VALUE but KEY is expected to accur more than once in the query, so return all its values in a list.

WRITE-HTML-SEQUENCE (SEQUENCE &KEY (STREAM *HTML-STREAM*) (START 0) END)

Write a sequence to HTML stream. This is more general than WRITE-HTML-STRING and thus more appropriate to write arbitrary sequences.

Undocumented

COMPRESS-CSS-STREAM (IN OUT)

HTML-BOOKMARKS (REQ ENT SELECTOR BOOKMARKS)

HTML-CHECKBOX (NAME &KEY CHECKED LABEL (VALUE T))

SETFQUERY-VALUE (VALUE REQUEST VARIABLE-NAME &OPTIONAL MULTIPLE)

REDIRECT-TO (REQ ENT URL)

SESSION-VARIABLE (REQ NAME)

SETFSESSION-VARIABLE (VALUE REQ NAME)

Private

Undocumented

%CRYPT (KEY SALT)

MACRO

Public

DEFCLP (NAME SESSION-VARIABLES &BODY FORMS)

Define a Common Lisp Page function. This can be then referred in a CLP page in the usual way. This macro captures some variables which can be used by FORMS. These are: REQ, ENT, ARGS, BODY, WA, SESSION. See the AServe documentation for their meaning.

DEFPAGE (NAME (&KEY VARIABLES TITLE (LANGUAGE *DEFAULT-LANGUAGE*) OUTPUT-PAGE-HEAD BODY-ARGS TIMEOUT) &BODY BODY)

Define a web page. Header and footer are standard. BODY is supposed to output the dynamic part of the page.

DEFWA (NAME VARIABLES &BODY FORMS)

Define a web action (aka web page). A web action is supposed to return either :CONTINUE or a string of the name of the page to redirect the browser to. This macro captures some variables which can be used by FORMS. These are: REQ, ENT, WA, SESSION. See the AServe documentation for their meaning.

HTML-TABLE ((&REST ARGS) &BODY BODY)

Generate an HTML table with ARGS and run BODY with TR defined locally as a macro that outputs table's TR elements of class ODD or EVEN, according to their position within tha table.

URL (PAGE &REST QUERY-VALUES)

Encode an URL based on current status. This means that the URL may contain any additonal information required to keep the association to the webactions' session. This macro expect to find a couple of bindings in the current lexical environment: REQ and ENT. These are normally guaranted by DEFWA and DEFCLP macros.

WITH-HTML-FORM ((URL &KEY (CLASS *DEFAULT-FORM-CLASS*) SUBMIT RESET STYLE (METHOD post)) &REST FIELDS)

Creates an HTML form of CSS class CLASS. SUBMIT is the label on the OK button. If RESET is true add a reset button. If RESET is a string use that as the label on the reset button. Each field in FIELDS is a list of which the first element is a string (the field description) and the rest is HTML code to appear next to it. Local to this block the macro INPUT is defined. If the first element is the keyword :HIDDEN, the field won't have a table entry but it will be hidden from the user; in this case the other elements are the name and value of the field.

Undocumented

WITH-QUERY-VALUES ((REQUEST &REST VARIABLES) &BODY BODY)

WITH-REQUEST-VALUES ((REQUEST &REST VARIABLES) &BODY BODY)

WITH-SESSION-VARIABLES ((REQ &REST VARIABLES) &BODY BODY)

Private

WITH-WA ((ENT) &BODY BODY)

Create a local binding of WA to the current web action (taken from ENT).

GENERIC-FUNCTION

Public

AUTHORISER-GET-USER-PASSWORD (AUTHORISER USER-NAME)

Return the password associated with USER-NAME.

Undocumented

AUTHORISER-CHECK-PASSWORD (AUTH NAME PASSWORD)

AUTHORISER-DENY-PAGE (AUTH)

VARIABLE

Public

*BUTTON-STYLE*

Type of HTML rendering for button items. This can be :IMPLICIT-FORM or :FANCY-LINK. See the function BUTTON for further details. Both require support from the stylesheet, though a bit less for the implicit form. Something like this would do: form.button { display: inline; margin: .5em; } a.button { border: outset; display: inline; font-weight: bold; padding: .3em .8em .5em .8em; background-color: #BBB; margin: .3em .5em .3em .5em; color: #000; text-decoration: none; } a.button img { border: none; padding: 0; margin: 0; } a.button:hover { background-color: #DDD; } a.button:active { border: none; background-color: #DDD; }

*DEFAULT-FORM-CLASS*

The default CSS class of the form tables generated by WITH-HTML-FORM.

Undocumented

*DEFAULT-LANGUAGE*

Private

Undocumented

*CRYPT-LIBRARY-LOADED*

*CRYPT-LIBRARY-PATHNAME*

CLASS

Public

BETTER-PASSWORD-AUTHORISER

Convenience base class to diversify AUTHORIZE method (below).

CRYPT-PASSWORD-AUTHORISER

Access authoriser for Unix-like accounts. This class is similar to PASSWORD-AUTHORISER but passwords in ALLOWED are ancrypted with Unix crypt(3). User passwords are supposed to be taken from /etc/passwd (or /etc/master.passwd) or encrypted in the same way.