PiLLoW typesAuthor(s): Daniel Cabeza.
Here are defined the regular types used in the documentation of the predicates of the PiLLoW package.
Usage and interface
- Library usage:
Documentation on exports
canonic_html_item(comment(S)) :- string(S). canonic_html_item(declare(S)) :- string(S). canonic_html_item(env(Tag,Atts,Terms)) :- atm(Tag), list(Atts,tag_attrib), canonic_html_term(Terms). canonic_html_item($(Tag,Atts)) :- atm(Tag), list(Atts,tag_attrib). canonic_html_item(S) :- string(S).
tag_attrib(Att) :- atm(Att). tag_attrib(Att=Val) :- atm(Att), string(Val).Each structure represents one HTML construction:
- An HTML environment, with name tag, list of attributes attribs and contents terms.
- An HTML element of name tag and list of attributes attribs. ($)/2 is defined by the pillow package as an infix, binary operator.
- An HTML comment (translates to/from <!--string-->).
- An HTML declaration, they are used only in the header (translates to/from <!string>).
- Normal text is represented as a list of character codes.
For example, the term
env(a,[href="www.therainforestsite.com"], ["Visit ",img$[src="TRFS.gif"]])is output to (or parsed from):
<a href="www.therainforestsite.com">Visit <img src="TRFS.gif"></a>
HTMLTerm is a term representing HTML code in canonical form.
canonic_xml_item(Term) :- canonic_html_item(Term). canonic_xml_item(xmldecl(Atts)) :- list(Atts,tag_attrib). canonic_xml_item(env(Tag,Atts,Terms)) :- atm(Tag), list(Atts,tag_attrib), canonic_xml_term(Terms). canonic_xml_item(elem(Tag,Atts)) :- atm(Tag), list(Atts,tag_attrib).In addition to the structures defined by canonic_html_term/1 (the ($)/2 structure appears only in malformed XML code), the following structures can be used:
- Specifies an XML empty element of name tag and list of attributes atts. For example, the term
elem(arc,[weigh="3",begin="n1",end="n2"])is output to (or parsed from):
<arc weigh="3" begin="n1" end="n2"/>
- Specifies an XML declaration with attributes atts (translates to/from <?xml atts?>)
XMLTerm is a term representing XML code in canonical form.
- It translates to the start of an HTML environment of name tag and attributes atts. There exists also a begin(tag) structure. Useful, in conjunction with the next structure, when including in a document output generated by an existing piece of code (e.g. tag = pre). Its use is otherwise discouraged.
- Translates to the end of an HTML environment of name tag.
- Used at the beginning of a document (translates to <html>).
- 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>).
- Used to include an image of address (URL) address (equivalent to img$[src=address]).
- As above with the list of attributes atts.
- Produces a hypertext link, address is the URL of the referenced resource, text is the text of the reference (equivalent to a([href=address],text)).
- Labels text as a target destination with label name (equivalent to a([name=name],text)).
- Produces a heading of level n (between 1 and 6), text is the text to be used as heading. Useful when one wants a heading level relative to another heading (equivalent to hn(text)).
- Produces a list of bulleted items, items is a list of corresponding HTML terms (translates to a <ul> environment).
- Produces a list of numbered items, items is a list of corresponding HTML terms (translates to a <ol> environment).
- 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 a <dl> environment).
- Produces a list of bulleted items, using the image img as bullet. The predicate icon_address/2 provides a colored bullet.
- 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).
- Used to include text verbatim, special HTML characters (<,>,&," and space) are translated into its quoted HTML equivalent.
- Includes any prolog term term, represented in functional notation. Variables are output as _.
- Used to include a newline in the HTML source (just to improve human readability).
- Includes the entity of name name (ISO-8859-1 special character).
- Specifies the beginning of a form. addr is the address (URL) of the program that will handle the form, and atts other attributes of the form, as the method used to invoke it. If atts is not present (there is only one argument) the method defaults to POST.
- Specifies the beginning of a form without assigning address to the handler, so that the form handler will be the cgi-bin executable producing the form.
- Specifies the end of a form.
- Specifies an input of type checkbox with name name, state is on if the checkbox is initially checked.
- Specifies an input of type radio with name name (several radio buttons which are interlocked must share their name), value is the the value returned by the button, if selected=value the button is initially checked.
- Specifies an input of type type with a list of attributes atts. Possible values of type are text, hidden, submit, reset, ldots
- Specifies an input text area of name name. text provides the default text to be shown in the area, atts a list of attributes.
- Specifies a simple option selector of name name, options is the list of available options and val is the initial selected option (if val is not in options the first item is selected by default) (translates to a <select> environment).
- Specifies a menu of name name, list of attributes atts and list of options items. The elements of the list items are marked with the prefix operator $ to indicate that they are selected (translates to a <select> environment).
- This two are equivalent, they do not generate HTML, rather, the CGI protocol requires this content descriptor to be used at the beginning by CGI executables (including form handlers) when replying (translates to Content-type: text/html).
- 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.
- A term with functor name/1, different from the special functors defined herein, represents an HTML environment of name name and included text text. For example, the term
address('firstname.lastname@example.org')is translated into the HTML source
- A term with functor name/2, different from the special functors defined herein, represents an HTML environment of name name, attributes atts and included text text. For example, the term
a([href='http://www.clip.dia.fi.upm.es/'],"Clip home")represents the HTML source
<a href="http://www.clip.dia.fi.upm.es/">Clip home</a>
HTMLTerm is a term representing HTML code.
Dict is a dictionary of values of the attributes of a form. It is a list of form_assignment
Eq is an assignment of value of an attribute of a form. It is defined by:
form_assignment(A=V) :- atm(A), form_value(V).
form_value(A) :- atm(A). form_value(N) :- num(N). form_value(L) :- list(L,string).
V is a value of an attribute of a form.
Dict is a dictionary of values. It is a list of pairs atom=constant.
url_term(http(Host,Port,Document)) :- atm(Host), int(Port), string(Document).
URL specifies a URL.
- head: Specify that the document content is not wanted.
- timeout(T): T specifies the time in seconds to wait for the response. Default is 300 seconds.
- if_modified_since(Date): Get document only if newer than Date. Date has the format defined by http_date/1.
- user_agent(Agent): Provides a user-agent field, Agent is an atom. The string "PiLLoW/1.1" (or whatever version of PiLLoW is used) is appended.
- authorization(Scheme,Params): To provide credentials. See RFC 1945 for details.
- option(Value): Any unary term, being Value an atom, can be used to provide another valid option (e.g. from('user@machine')).
Request is a parameter of an HTTP request.
- content(String): String is the document content (list of bytes). If the head parameter of the HTTP request is used, an empty list is get here.
- status(Type,Code,Reason): Type is an atom denoting the response type, Code is the status code (an integer), and Reason is a string holding the reason phrase.
- message_date(Date): Date is the date of the response, with format defined by http_date/1.
- location(Loc): This parameter appears when the document has moved, Loc is an atom holding the new location.
- http_server(Server): Server is the server responding, as a string.
- authenticate(Params): Returned if document is protected, Params is a list of chagenges. See RFC 1945 for details.
- allow(Methods): Methods are the methods allowed by the server, as a list of atoms.
- content_encoding(Encoding): Encoding is an atom defining the encoding.
- content_length(Length): Length is the length of the document (an integer).
- content_type(Type,Subtype,Params): Specifies the document content type, Type and Subtype are atoms, Params a list of parameters (e.g. content_type(text,html,)).
- expires(Date): Date is the date after which the entity should be considered stale. Format defined by http_date/1.
- last_modified(Date): Date is the date at which the sender believes the resource was last modified. Format defined by http_date/1.
- pragma(String): Miscellaneous data.
- header(String): Any other functor header/1 is an extension header.
Response is a parameter of an HTTP response.
Date is a term defined as
http_date(date(WeekDay,Day,Month,Year,Time)) :- weekday(WeekDay), int(Day), month(Month), int(Year), hms_time(Time)..
Date is a term denoting a date.
WeekDay is a term denoting a weekday.
Month is a term denoting a month.
Time is an atom of the form hh:mm:ss