Next: , Previous: HTML, Up: Textual Conversion Packages


4.7 HTML Tables

(require 'db->html)

— Function: html:table options row ...
— Function: html:caption caption align
— Function: html:caption caption

align can be ‘top’ or ‘bottom’.

— Function: html:heading columns

Outputs a heading row for the currently-started table.

— Function: html:href-heading columns uris

Outputs a heading row with column-names columns linked to URIs uris.

— Function: html:linked-row-converter k foreigns

The positive integer k is the primary-key-limit (number of primary-keys) of the table. foreigns is a list of the filenames of foreign-key field pages and #f for non foreign-key fields.

html:linked-row-converter returns a procedure taking a row for its single argument. This returned procedure returns the html string for that table row.

— Function: table-name->filename table-name

Returns the symbol table-name converted to a filename.

— Function: table->linked-html caption db table-name match-key1 ...

Returns HTML string for db table table-name chopped into 50-row HTML tables. Every foreign-key value is linked to the page (of the table) defining that key.

The optional match-key1 ... arguments restrict actions to a subset of the table. See match-key.

— Function: table->linked-page db table-name index-filename arg ...

Returns a complete HTML page. The string index-filename names the page which refers to this one.

The optional args ... arguments restrict actions to a subset of the table. See match-key.

— Function: catalog->html db caption arg ...

Returns HTML string for the catalog table of db.

4.7.1 HTML editing tables

A client can modify one row of an editable table at a time. For any change submitted, these routines check if that row has been modified during the time the user has been editing the form. If so, an error page results.

The behavior of edited rows is:

After any change to the table, a sync-database of the database is performed.

— Function: command:modify-table table-name null-keys update delete retrieve
— Function: command:modify-table table-name null-keys update delete
— Function: command:modify-table table-name null-keys update
— Function: command:modify-table table-name null-keys

Returns procedure (of db) which returns procedure to modify row of table-name. null-keys is the list of null keys indicating the row is to be deleted when any matches its corresponding primary key. Optional arguments update, delete, and retrieve default to the row:update, row:delete, and row:retrieve of table-name in db.

— Function: command:make-editable-table rdb table-name arg ...

Given table-name in rdb, creates parameter and *command* tables for editing one row of table-name at a time. command:make-editable-table returns a procedure taking a row argument which returns the HTML string for editing that row.

Optional args are expressions (lists) added to the call to command:modify-table.

The domain name of a column determines the expected arity of the data stored in that column. Domain names ending in:

*
have arity ‘nary’;
+
have arity ‘nary1’.

— Function: html:editable-row-converter k names edit-point edit-converter

The positive integer k is the primary-key-limit (number of primary-keys) of the table. names is a list of the field-names. edit-point is the list of primary-keys denoting the row to edit (or #f). edit-converter is the procedure called with k, names, and the row to edit.

html:editable-row-converter returns a procedure taking a row for its single argument. This returned procedure returns the html string for that table row.

Each HTML table constructed using html:editable-row-converter has first k fields (typically the primary key fields) of each row linked to a text encoding of these fields (the result of calling row->anchor). The page so referenced typically allows the user to edit fields of that row.

4.7.2 HTML databases

— Function: db->html-files db dir index-filename caption

db must be a relational database. dir must be #f or a non-empty string naming an existing sub-directory of the current directory.

db->html-files creates an html page for each table in the database db in the sub-directory named dir, or the current directory if dir is #f. The top level page with the catalog of tables (captioned caption) is written to a file named index-filename.

— Function: db->html-directory db dir index-filename
— Function: db->html-directory db dir

db must be a relational database. dir must be a non-empty string naming an existing sub-directory of the current directory or one to be created. The optional string index-filename names the filename of the top page, which defaults to index.html.

db->html-directory creates sub-directory dir if neccessary, and calls (db->html-files db dir index-filename dir). The ‘file:’ URI of index-filename is returned.

— Function: db->netscape db dir index-filename
— Function: db->netscape db dir

db->netscape is just like db->html-directory, but calls browse-url with the uri for the top page after the pages are created.