]> matita.cs.unibo.it Git - helm.git/blob - helm/uwobo/uwobo_common.ml
moved uwobo sources to the root uwobo directory
[helm.git] / helm / uwobo / uwobo_common.ml
1 (*
2  * Copyright (C) 2003:
3  *    Stefano Zacchiroli <zack@cs.unibo.it>
4  *    for the HELM Team http://helm.cs.unibo.it/
5  *
6  *  This file is part of HELM, an Hypertextual, Electronic
7  *  Library of Mathematics, developed at the Computer Science
8  *  Department, University of Bologna, Italy.
9  *
10  *  HELM is free software; you can redistribute it and/or
11  *  modify it under the terms of the GNU General Public License
12  *  as published by the Free Software Foundation; either version 2
13  *  of the License, or (at your option) any later version.
14  *
15  *  HELM is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with HELM; if not, write to the Free Software
22  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston,
23  *  MA  02111-1307, USA.
24  *
25  *  For details, see the HELM World-Wide-Web page,
26  *  http://helm.cs.unibo.it/
27  *)
28
29 open Printf;;
30
31 exception Uwobo_failure of string;;
32
33 let supported_properties = [
34   "cdata-section-elements";
35   "doctype-public";
36   "doctype-system";
37   "encoding";
38   "indent";
39   "media-type";
40   "method";
41   "omit-xml-declaration";
42   "standalone";
43   "version"
44 ]
45
46 let is_supported_property name = List.mem name supported_properties
47
48 let usage_string =
49   sprintf
50 "
51 <html>
52   <head>
53     <title>UWOBO's help message</title>
54   </head>
55   <body>
56     <p>
57     Usage: <kbd>http://hostname:uwoboport/</kbd><em>command</em>
58     </p>
59     <p>
60     Available commands:
61     </p>
62     <p>
63       <b><kbd>help</kbd></b><br />
64       display this help message
65     </p>
66     <p>
67       <b><kbd>add?bind=key,uri[&bind=key,uri[&...]]</kbd></b><br />
68       load a new stylesheet, specified by <em>uri</em>, and bind it to key
69           <em>key</em>
70     </p>
71     <p>
72       <b><kbd>remove[?keys=key1,key2,...]</kbd></b><br />
73       unload stylesheets specified by <em>key1, key2, ...</em> or all
74           stylesheets if no key was given
75     </p>
76     <p>
77       <b><kbd>reload[?keys=key1,key2,...]</kbd></b><br />
78       reload stylesheets specified by <em>key1, key2, ...</em> or all
79           stylesheets if no key was given
80     </p>
81     <p>
82       <b><kbd>list</kbd></b><br />
83       return a list of loaded stylesheets
84     </p>
85     <p>
86       <b><kbd>apply?xmluri=uri&keys=key1,key2,...[&param.name=value[&param.name=value[&...]]][&param.key.name=value[&param.key.name=value[&...]]][&prop.name[=value][&prop.name[=value][&...]]]</kbd></b><br />
87       apply a chain of stylesheets, specified by <em>key1, key2, ...</em>, to an
88       input document, specified by <em>uri</em>.<br />
89       Additional parameters can be set for each stylesheet application: global
90       parameters (i.e. parameters passed to all stylesheets) are set using
91       <em>param.name=value</em> syntax, per stylesheet parameters are set using
92       <em>param.key.name=value</em> where <em>key</em> is the key of a loaded
93       stylesheet.<br />
94       Properties of the final chain output can be set too: valueless properties
95       can be set using <em>prop.name</em> syntax, others can be set using
96       <em>prop.name=value</em> syntax.<br />
97       Current supported properties are: %s.
98     </p>
99   </body>
100 </html>
101 "
102   (String.concat ", " supported_properties);;
103
104 let pp_error = sprintf "<html><body><h1>Error: %s</h1></body></html>";;
105 let return_error msg outchan =
106   Http_daemon.respond ~body:(pp_error msg) outchan;;
107 let bad_request body outchan =
108   Http_daemon.respond_error ~code:400 ~body outchan
109 ;;
110
111