Next: Specific Structures for Forms
Up: Handling HTML as Prolog
Previous: General Structures
In this section we will list the special structures for
HTML which PiLLoW understands.
A predicate html_expansion/2 is provided to define new
structures.
- start Used at the beginning of a document (translates to
<html>
). - end Used at the end of a document (translates to
</html>
). - -- Produces a horizontal rule (translates to
<hr>
). -
\\
Produces a line break (translates to <br>
). - $ Produces a paragraph break (translates to
<p>
). - comment(Comment) Used to insert an HTML comment
(translates to <!- Comment ->).
- declare(Decl) Used to insert an HTML declaration
- seldom used (translates to <!Decl>).
- image(Addr) Used to include an image of address (URL)
Addr (translates to an
<img>
element). - image(Addr,Atts) As above with the list of
attributes Atts.
- ref(Addr,Text) Produces a hypertext link, Addr
is the URL of the referenced resource, Text is the text of the
reference (translates to
<a href="
Addr">
Text</a>
). - label(Label,Text) Labels Text as a target
destination with label Label (translates to
<a name="
Label">
Text</a>
). - heading(N,Text) Produces a heading of level
N (1 <= N <= 6), Text is the text to be used as
heading - useful when one wants a heading level relative to
another heading (translates to a
<h
N>
environment). - itemize(Items) Produces a list of bulleted items,
Items is a list of corresponding HTML terms (translates to a
<ul>
environment). - enumerate(Items) Produces a list of numbered items,
Items is a list of corresponding HTML terms (translates to an
<ol>
environment). - description(Defs) Produces a list of defined items,
Defs is a list whose elements are definitions, each of them
being a Prolog sequence (composed by ','/2 operators). The last
element of the sequence is the definition, the other (if any) are the
defined terms (translates to an
<dl>
environment). - nice_itemize(Img,Items) Produces a list of
bulleted items, using the image Img as bullet. The predicate
icon_address/2 provides a colored bullet.
- preformatted(Text) Used to include preformatted text,
Text is a list of HTML terms, each element of the list being a
line of the resulting document (translates to a
<pre>
environment). - entity(Name) Includes the entity of name
Name (ISO-8859-1 special character).
- verbatim(Text) Used to include text verbatim, special
HTML characters (<,>,&,") are translated into its quoted HTML
equivalent.
- nl Used to include a newline in the HTML source (just to
improve human readability).
- cgi_reply This is not HTML, rather, the CGI protocol
requires this content descriptor to be used by CGI executables
(including form handlers) when replying (translates to ``
Content-type: text/html'').
- pr Includes in the page a graphical logo with the
message ``Developed using the PiLLoW Web programming library'', which
points to the manual and library source.
With these additional structures, we can rewrite the previous example as
follows (note that in this particular example the
use of heading/2 or h2/1 is equally suitable):
#!/usr/local/bin/lpshell
:- use_module('/usr/local/src/pillow/pillow.pl').
main(_) :-
get_form_input(Input),
get_form_value(Input,person_name,Name),
response(Name,Response),
output_html([
cgi_reply,
start,
title('Telephone database'),
image('phone.gif'),
heading(2,'Telephone database'),
--,
Response,
end]).
response(Name, Response) :-
form_empty_value(Name) ->
Response = 'You have to provide a name.'
; phone(Name, Phone) ->
Response = ['Telephone number of ',b(Name),': ',Phone]
; Response = ['No telephone number available for ',b(Name),'.'].
phone(daniel, '336-7448').
phone(manuel, '336-7435').
phone(sacha, '543-5316').
We have not included above the specific structures for creating forms,
they are included and explained in the following section.
Next: Specific Structures for Forms
Up: Handling HTML as Prolog
Previous: General Structures
Daniel Cabeza Gras
Fri Oct 4 18:56:02 MET DST 1996