aboutsummaryrefslogtreecommitdiffstats
path: root/htmlform.txi
blob: 77704ffbe62a1e1a998e84e4d32eb856500e84cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
@code{(require 'html-form)}
@ftindex html-form


@defun html:atval txt
Returns a string with character substitutions appropriate to
send @var{txt} as an @dfn{attribute-value}.
@cindex attribute-value
@end defun


@defun html:plain txt
Returns a string with character substitutions appropriate to
send @var{txt} as an @dfn{plain-text}.
@cindex plain-text
@end defun


@defun html:meta name content
Returns a tag of meta-information suitable for passing as the
third argument to @code{html:head}.  The tag produced is @samp{<META
NAME="@var{name}" CONTENT="@var{content}">}.  The string or symbol @var{name} can be
@samp{author}, @samp{copyright}, @samp{keywords}, @samp{description},
@samp{date}, @samp{robots}, @dots{}.
@end defun


@defun html:http-equiv name content
Returns a tag of HTTP information suitable for passing as the
third argument to @code{html:head}.  The tag produced is @samp{<META
HTTP-EQUIV="@var{name}" CONTENT="@var{content}">}.  The string or symbol @var{name} can be
@samp{Expires}, @samp{PICS-Label}, @samp{Content-Type},
@samp{Refresh}, @dots{}.
@end defun


@defun html:meta-refresh delay uri


@defunx html:meta-refresh delay

Returns a tag suitable for passing as the third argument to
@code{html:head}.  If @var{uri} argument is supplied, then @var{delay} seconds after
displaying the page with this tag, Netscape or IE browsers will fetch
and display @var{uri}.  Otherwise, @var{delay} seconds after displaying the page with
this tag, Netscape or IE browsers will fetch and redisplay this page.
@end defun


@defun html:head title backlink tags @dots{}


@defunx html:head title backlink

@defunx html:head title

Returns header string for an HTML page named @var{title}.  If @var{backlink} is a string,
it is used verbatim between the @samp{H1} tags; otherwise @var{title} is
used.  If string arguments @var{tags} ... are supplied, then they are
included verbatim within the @t{<HEAD>} section.
@end defun


@defun html:body body @dots{}
Returns HTML string to end a page.
@end defun


@defun html:pre line1 line @dots{}
Returns the strings @var{line1}, @var{lines} as @dfn{PRE}formmated plain text
@cindex PRE
(rendered in fixed-width font).  Newlines are inserted between @var{line1},
@var{lines}.  HTML tags (@samp{<tag>}) within @var{lines} will be visible verbatim.
@end defun


@defun html:comment line1 line @dots{}
Returns the strings @var{line1} as HTML comments.
@end defun

@section HTML Forms


@defun html:form method action body @dots{}
The symbol @var{method} is either @code{get}, @code{head}, @code{post},
@code{put}, or @code{delete}.  The strings @var{body} form the body of the
form.  @code{html:form} returns the HTML @dfn{form}.
@cindex form
@end defun


@defun html:hidden name value
Returns HTML string which will cause @var{name}=@var{value} in form.
@end defun


@defun html:checkbox pname default
Returns HTML string for check box.
@end defun


@defun html:text pname default size @dots{}
Returns HTML string for one-line text box.
@end defun


@defun html:text-area pname default-list
Returns HTML string for multi-line text box.
@end defun


@defun html:select pname arity default-list foreign-values
Returns HTML string for pull-down menu selector.
@end defun


@defun html:buttons pname arity default-list foreign-values
Returns HTML string for any-of selector.
@end defun


@defun form:submit submit-label command


@defunx form:submit submit-label

The string or symbol @var{submit-label} appears on the button which submits the form.
If the optional second argument @var{command} is given, then @code{*command*=@var{command}}
and @code{*button*=@var{submit-label}} are set in the query.  Otherwise,
@code{*command*=@var{submit-label}} is set in the query.
@end defun


@defun form:image submit-label image-src
The @var{image-src} appears on the button which submits the form.
@end defun


@defun form:reset
Returns a string which generates a @dfn{reset} button.
@cindex reset
@end defun


@defun form:element pname arity default-list foreign-values
Returns a string which generates an INPUT element for the field
named @var{pname}.  The element appears in the created form with its
representation determined by its @var{arity} and domain.  For domains which
are foreign-keys:

@table @code
@item single
select menu
@item optional
select menu
@item nary
check boxes
@item nary1
check boxes
@end table

If the foreign-key table has a field named @samp{visible-name}, then
the contents of that field are the names visible to the user for
those choices.  Otherwise, the foreign-key itself is visible.

For other types of domains:

@table @code
@item single
text area
@item optional
text area
@item boolean
check box
@item nary
text area
@item nary1
text area
@end table
@end defun


@defun form:delimited pname doc aliat arity default-list foreign-values


Returns a HTML string for a form element embedded in a line of a
delimited list.  Apply map @code{form:delimited} to the list returned by
@code{command->p-specs}.
@end defun


@defun html:delimited-list row @dots{}
Wraps its arguments with delimited-list (@samp{DL} command.
@end defun


@defun get-foreign-choices tab
Returns a list of the @samp{visible-name} or first fields of
table @var{tab}.
@end defun


@defun command->p-specs rdb command-table command


The symbol @var{command-table} names a command table in the @var{rdb} relational database.
The symbol @var{command} names a key in @var{command-table}.

@code{command->p-specs} returns a list of lists of @var{pname}, @var{doc}, @var{aliat},
@var{arity}, @var{default-list}, and @var{foreign-values}.  The
returned list has one element for each parameter of command @var{command}.

This example demonstrates how to create a HTML-form for the @samp{build}
command.

@example
(require (in-vicinity (implementation-vicinity) "build.scm"))
(call-with-output-file "buildscm.html"
  (lambda (port)
    (display
     (string-append
      (html:head 'commands)
      (html:body
       (sprintf #f "<H2>%s:</H2><BLOCKQUOTE>%s</BLOCKQUOTE>\\n"
                (html:plain 'build)
                (html:plain ((comtab 'get 'documentation) 'build)))
       (html:form
        'post
        (or "http://localhost:8081/buildscm" "/cgi-bin/build.cgi")
        (apply html:delimited-list
               (apply map form:delimited
                      (command->p-specs build '*commands* 'build)))
        (form:submit 'build)
        (form:reset))))
     port)))
@end example
@end defun