adamc@1151
|
1 (* Copyright (c) 2008-2010, Adam Chlipala
|
adamc@380
|
2 * All rights reserved.
|
adamc@380
|
3 *
|
adamc@380
|
4 * Redistribution and use in source and binary forms, with or without
|
adamc@380
|
5 * modification, are permitted provided that the following conditions are met:
|
adamc@380
|
6 *
|
adamc@380
|
7 * - Redistributions of source code must retain the above copyright notice,
|
adamc@380
|
8 * this list of conditions and the following disclaimer.
|
adamc@380
|
9 * - Redistributions in binary form must reproduce the above copyright notice,
|
adamc@380
|
10 * this list of conditions and the following disclaimer in the documentation
|
adamc@380
|
11 * and/or other materials provided with the distribution.
|
adamc@380
|
12 * - The names of contributors may not be used to endorse or promote products
|
adamc@380
|
13 * derived from this software without specific prior written permission.
|
adamc@380
|
14 *
|
adamc@380
|
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
adamc@380
|
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
adamc@380
|
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
adamc@380
|
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
adamc@380
|
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
adamc@380
|
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
adamc@380
|
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
adamc@380
|
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
adamc@380
|
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
adamc@380
|
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
adamc@380
|
25 * POSSIBILITY OF SUCH DAMAGE.
|
adamc@380
|
26 *)
|
adamc@380
|
27
|
adamc@380
|
28 structure Demo :> DEMO = struct
|
adamc@380
|
29
|
adamc@1079
|
30 fun make' {prefix, dirname, guided} =
|
adamc@380
|
31 let
|
adamc@380
|
32 val prose = OS.Path.joinDirFile {dir = dirname,
|
adamc@380
|
33 file = "prose"}
|
adamc@380
|
34 val inf = TextIO.openIn prose
|
adamc@380
|
35
|
adamc@380
|
36 val outDir = OS.Path.concat (dirname, "out")
|
adamc@380
|
37
|
adamc@380
|
38 val () = if OS.FileSys.access (outDir, []) then
|
adamc@380
|
39 ()
|
adamc@380
|
40 else
|
adamc@380
|
41 OS.FileSys.mkDir outDir
|
adamc@380
|
42
|
adamc@380
|
43 val fname = OS.Path.joinDirFile {dir = outDir,
|
adamc@380
|
44 file = "index.html"}
|
adamc@380
|
45
|
adamc@380
|
46 val out = TextIO.openOut fname
|
adamc@773
|
47 val () = (TextIO.output (out, "<frameset cols=\"15%,85%\">\n");
|
adamc@380
|
48 TextIO.output (out, "<frame src=\"demos.html\">\n");
|
adamc@380
|
49 TextIO.output (out, "<frame src=\"intro.html\" name=\"staging\">\n");
|
adamc@380
|
50 TextIO.output (out, "</frameset>\n");
|
adamc@380
|
51 TextIO.closeOut out)
|
adamc@380
|
52
|
adamc@380
|
53 val fname = OS.Path.joinDirFile {dir = outDir,
|
adamc@380
|
54 file = "demos.html"}
|
adamc@380
|
55
|
adamc@380
|
56 val demosOut = TextIO.openOut fname
|
adamc@381
|
57 val () = (TextIO.output (demosOut, "<html><body>\n\n");
|
adamc@380
|
58 TextIO.output (demosOut, "<li> <a target=\"staging\" href=\"intro.html\">Intro</a></li>\n\n"))
|
adamc@380
|
59
|
adamc@384
|
60 val fname = OS.Path.joinDirFile {dir = dirname,
|
adamc@384
|
61 file = "demo.urs"}
|
adamc@384
|
62 val ursOut = TextIO.openOut fname
|
adamc@384
|
63 val () = (TextIO.output (ursOut, "val main : unit -> transaction page\n");
|
adamc@384
|
64 TextIO.closeOut ursOut)
|
adamc@384
|
65
|
adamc@384
|
66 val fname = OS.Path.joinDirFile {dir = dirname,
|
adamc@384
|
67 file = "demo.ur"}
|
adamc@384
|
68 val urOut = TextIO.openOut fname
|
adamc@384
|
69 val () = TextIO.output (urOut, "fun main () = return <xml><body>\n")
|
adamc@384
|
70
|
adamc@380
|
71 fun mergeWith f (o1, o2) =
|
adamc@380
|
72 case (o1, o2) of
|
adamc@380
|
73 (NONE, _) => o2
|
adamc@380
|
74 | (_, NONE) => o1
|
adamc@380
|
75 | (SOME v1, SOME v2) => SOME (f (v1, v2))
|
adamc@380
|
76
|
adamc@380
|
77 fun combiner (combined : Compiler.job, urp : Compiler.job) = {
|
adamc@385
|
78 prefix = prefix,
|
adamc@380
|
79 database = mergeWith (fn (v1, v2) =>
|
adamc@380
|
80 if v1 = v2 then
|
adamc@380
|
81 v1
|
adamc@380
|
82 else
|
adamc@380
|
83 raise Fail "Different demos want to use different database strings")
|
adamc@380
|
84 (#database combined, #database urp),
|
adamc@380
|
85 sources = foldl (fn (file, files) =>
|
adamc@380
|
86 if List.exists (fn x => x = file) files then
|
adamc@380
|
87 files
|
adamc@380
|
88 else
|
adamc@380
|
89 files @ [file])
|
adamc@380
|
90 (#sources combined) (#sources urp),
|
adamc@891
|
91 exe = case Settings.getExe () of
|
adamc@891
|
92 NONE => OS.Path.joinDirFile {dir = dirname,
|
adamc@891
|
93 file = "demo.exe"}
|
adamc@891
|
94 | SOME s => s,
|
adamc@891
|
95 sql = SOME (case Settings.getSql () of
|
adamc@891
|
96 NONE => OS.Path.joinDirFile {dir = dirname,
|
adamc@891
|
97 file = "demo.sql"}
|
adamc@891
|
98 | SOME s => s),
|
adamc@863
|
99 debug = Settings.getDebug (),
|
adamc@673
|
100 timeout = Int.max (#timeout combined, #timeout urp),
|
adamc@764
|
101 profile = false,
|
adamc@764
|
102 ffi = [],
|
adamc@764
|
103 link = [],
|
adamc@765
|
104 headers = [],
|
adamc@766
|
105 scripts = [],
|
adamc@765
|
106 clientToServer = [],
|
adamc@765
|
107 effectful = [],
|
adamc@1171
|
108 benignEffectful = [],
|
adamc@765
|
109 clientOnly = [],
|
adamc@765
|
110 serverOnly = [],
|
adamc@768
|
111 jsFuncs = [],
|
adamc@774
|
112 rewrites = #rewrites combined @ #rewrites urp,
|
adamc@769
|
113 filterUrl = #filterUrl combined @ #filterUrl urp,
|
adamc@866
|
114 filterMime = #filterMime combined @ #filterMime urp,
|
adamc@866
|
115 protocol = mergeWith #2 (#protocol combined, #protocol urp),
|
adamc@1164
|
116 dbms = mergeWith #2 (#dbms combined, #dbms urp),
|
adamc@1183
|
117 sigFile = mergeWith #2 (#sigFile combined, #sigFile urp),
|
adam@1294
|
118 safeGets = [],
|
adam@1294
|
119 onError = NONE
|
adamc@380
|
120 }
|
adamc@380
|
121
|
adamc@380
|
122 val parse = Compiler.run (Compiler.transform Compiler.parseUrp "Demo parseUrp")
|
adamc@380
|
123
|
adamc@380
|
124 fun capitalize "" = ""
|
adamc@380
|
125 | capitalize s = str (Char.toUpper (String.sub (s, 0)))
|
adamc@380
|
126 ^ String.extract (s, 1, NONE)
|
adamc@380
|
127
|
adamc@380
|
128 fun startUrp urp =
|
adamc@380
|
129 let
|
adamc@380
|
130 val base = OS.Path.base urp
|
adamc@380
|
131 val name = capitalize base
|
adamc@380
|
132
|
adamc@380
|
133 val () = (TextIO.output (demosOut, "<li> <a target=\"staging\" href=\"");
|
adamc@380
|
134 TextIO.output (demosOut, base);
|
adamc@380
|
135 TextIO.output (demosOut, ".html\">");
|
adamc@380
|
136 TextIO.output (demosOut, name);
|
adamc@380
|
137 TextIO.output (demosOut, "</a></li>\n"))
|
adamc@380
|
138
|
adamc@384
|
139 val () = (TextIO.output (urOut, " <li> <a link={");
|
adamc@384
|
140 TextIO.output (urOut, name);
|
adamc@384
|
141 TextIO.output (urOut, ".main ()}>");
|
adamc@384
|
142 TextIO.output (urOut, name);
|
adamc@384
|
143 TextIO.output (urOut, "</a></li>\n"))
|
adamc@384
|
144
|
adamc@380
|
145 val urp_file = OS.Path.joinDirFile {dir = dirname,
|
adamc@380
|
146 file = urp}
|
adamc@380
|
147
|
adamc@380
|
148 val out = OS.Path.joinBaseExt {base = base,
|
adamc@380
|
149 ext = SOME "html"}
|
adamc@380
|
150 val out = OS.Path.joinDirFile {dir = outDir,
|
adamc@380
|
151 file = out}
|
adamc@380
|
152 val out = TextIO.openOut out
|
adamc@380
|
153
|
adamc@501
|
154 val () = (TextIO.output (out, "<frameset rows=\"");
|
adamc@501
|
155 TextIO.output (out, if guided then
|
adamc@501
|
156 "*,100"
|
adamc@501
|
157 else
|
adamc@501
|
158 "50%,*");
|
adamc@501
|
159 TextIO.output (out, "\">\n");
|
adamc@380
|
160 TextIO.output (out, "<frame src=\"");
|
adamc@380
|
161 TextIO.output (out, prefix);
|
adamc@380
|
162 TextIO.output (out, "/");
|
adamc@380
|
163 TextIO.output (out, name);
|
adamc@380
|
164 TextIO.output (out, "/main\" name=\"showcase\">\n");
|
adamc@380
|
165 TextIO.output (out, "<frame src=\"");
|
adamc@380
|
166 TextIO.output (out, base);
|
adamc@380
|
167 TextIO.output (out, ".desc.html\">\n");
|
adamc@380
|
168 TextIO.output (out, "</frameset>\n");
|
adamc@380
|
169 TextIO.closeOut out)
|
adamc@380
|
170 val () = TextIO.closeOut out
|
adamc@380
|
171
|
adamc@380
|
172 val out = OS.Path.joinBaseExt {base = base,
|
adamc@380
|
173 ext = SOME "desc"}
|
adamc@380
|
174 val out = OS.Path.joinBaseExt {base = out,
|
adamc@380
|
175 ext = SOME "html"}
|
adamc@380
|
176 val out = TextIO.openOut (OS.Path.joinDirFile {dir = outDir,
|
adamc@380
|
177 file = out})
|
adamc@380
|
178 in
|
adamc@380
|
179 case parse (OS.Path.base urp_file) of
|
adamc@380
|
180 NONE => raise Fail ("Can't parse " ^ urp_file)
|
adamc@380
|
181 | SOME urpData =>
|
adamc@380
|
182 (TextIO.output (out, "<html><head>\n<title>");
|
adamc@380
|
183 TextIO.output (out, name);
|
adamc@380
|
184 TextIO.output (out, "</title>\n</head><body>\n\n<h1>");
|
adamc@380
|
185 TextIO.output (out, name);
|
adamc@380
|
186 TextIO.output (out, "</h1>\n\n<center>[ <a target=\"showcase\" href=\"");
|
adamc@382
|
187 TextIO.output (out, prefix);
|
adamc@382
|
188 TextIO.output (out, "/");
|
adamc@382
|
189 TextIO.output (out, name);
|
adamc@382
|
190 TextIO.output (out, "/main\">Application</a>");
|
adamc@382
|
191 TextIO.output (out, " | <a target=\"showcase\" href=\"");
|
adamc@380
|
192 TextIO.output (out, urp);
|
adamc@380
|
193 TextIO.output (out, ".html\"><tt>");
|
adamc@380
|
194 TextIO.output (out, urp);
|
adamc@380
|
195 TextIO.output (out, "</tt></a>");
|
adamc@380
|
196 app (fn file =>
|
adamc@380
|
197 let
|
adamc@380
|
198 fun ifEx s =
|
adamc@380
|
199 let
|
adamc@380
|
200 val src = OS.Path.joinBaseExt {base = file,
|
adamc@380
|
201 ext = SOME s}
|
adamc@380
|
202 val src' = OS.Path.file src
|
adamc@380
|
203 in
|
adamc@1151
|
204 if String.isPrefix (OS.Path.mkAbsolute {path = dirname,
|
adamc@1151
|
205 relativeTo = OS.FileSys.getDir ()}) src
|
adamc@943
|
206 andalso OS.FileSys.access (src, []) then
|
adamc@380
|
207 (TextIO.output (out, " | <a target=\"showcase\" href=\"");
|
adamc@380
|
208 TextIO.output (out, src');
|
adamc@380
|
209 TextIO.output (out, ".html\"><tt>");
|
adamc@380
|
210 TextIO.output (out, src');
|
adamc@380
|
211 TextIO.output (out, "</tt></a>"))
|
adamc@380
|
212 else
|
adamc@1156
|
213 ()
|
adamc@380
|
214 end
|
adamc@380
|
215 in
|
adamc@380
|
216 ifEx "urs";
|
adamc@380
|
217 ifEx "ur"
|
adamc@380
|
218 end) (#sources urpData);
|
adamc@380
|
219 TextIO.output (out, " ]</center>\n\n");
|
adamc@380
|
220
|
adamc@380
|
221 (urpData, out))
|
adamc@380
|
222 end
|
adamc@380
|
223
|
adamc@380
|
224 fun endUrp out =
|
adamc@380
|
225 (TextIO.output (out, "\n</body></html>\n");
|
adamc@380
|
226 TextIO.closeOut out)
|
adamc@380
|
227
|
adamc@380
|
228 fun readUrp (combined, out) =
|
adamc@380
|
229 let
|
adamc@380
|
230 fun finished () = endUrp out
|
adamc@380
|
231
|
adamc@380
|
232 fun readUrp' () =
|
adamc@380
|
233 case TextIO.inputLine inf of
|
adamc@384
|
234 NONE => (finished ();
|
adamc@384
|
235 combined)
|
adamc@380
|
236 | SOME line =>
|
adamc@380
|
237 if String.isSuffix ".urp\n" line then
|
adamc@380
|
238 let
|
adamc@380
|
239 val urp = String.substring (line, 0, size line - 1)
|
adamc@380
|
240 val (urpData, out) = startUrp urp
|
adamc@380
|
241 in
|
adamc@380
|
242 finished ();
|
adamc@380
|
243
|
adamc@380
|
244 readUrp (combiner (combined, urpData),
|
adamc@380
|
245 out)
|
adamc@380
|
246 end
|
adamc@380
|
247 else
|
adamc@380
|
248 (TextIO.output (out, line);
|
adamc@380
|
249 readUrp' ())
|
adamc@380
|
250 in
|
adamc@380
|
251 readUrp' ()
|
adamc@380
|
252 end
|
adamc@380
|
253
|
adamc@380
|
254 val indexFile = OS.Path.joinDirFile {dir = outDir,
|
adamc@380
|
255 file = "intro.html"}
|
adamc@380
|
256
|
adamc@380
|
257 val out = TextIO.openOut indexFile
|
adamc@380
|
258 val () = TextIO.output (out, "<html><head>\n<title>Ur/Web Demo</title>\n</head><body>\n\n")
|
adamc@380
|
259
|
adamc@380
|
260 fun readIndex () =
|
adamc@380
|
261 let
|
adamc@380
|
262 fun finished () = (TextIO.output (out, "\n</body></html>\n");
|
adamc@380
|
263 TextIO.closeOut out)
|
adamc@380
|
264 in
|
adamc@380
|
265 case TextIO.inputLine inf of
|
adamc@384
|
266 NONE => (finished ();
|
adamc@384
|
267 NONE)
|
adamc@380
|
268 | SOME line =>
|
adamc@380
|
269 if String.isSuffix ".urp\n" line then
|
adamc@380
|
270 let
|
adamc@380
|
271 val urp = String.substring (line, 0, size line - 1)
|
adamc@380
|
272 val (urpData, out) = startUrp urp
|
adamc@380
|
273 in
|
adamc@380
|
274 finished ();
|
adamc@380
|
275
|
adamc@384
|
276 SOME (readUrp (urpData,
|
adamc@384
|
277 out))
|
adamc@380
|
278 end
|
adamc@380
|
279 else
|
adamc@380
|
280 (TextIO.output (out, line);
|
adamc@380
|
281 readIndex ())
|
adamc@380
|
282 end
|
adamc@381
|
283
|
adamc@381
|
284 fun prettyPrint () =
|
adamc@381
|
285 let
|
adamc@381
|
286 val dir = Posix.FileSys.opendir dirname
|
adamc@381
|
287
|
adamc@381
|
288 fun loop () =
|
adamc@381
|
289 case Posix.FileSys.readdir dir of
|
adamc@381
|
290 NONE => Posix.FileSys.closedir dir
|
adamc@381
|
291 | SOME file =>
|
adamc@381
|
292 let
|
adamc@381
|
293 fun doit f =
|
adamc@381
|
294 f (OS.Path.joinDirFile {dir = dirname,
|
adamc@381
|
295 file = file},
|
adamc@382
|
296 OS.Path.mkAbsolute
|
adamc@382
|
297 {relativeTo = OS.FileSys.getDir (),
|
adamc@382
|
298 path = OS.Path.joinDirFile {dir = outDir,
|
adamc@382
|
299 file = OS.Path.joinBaseExt {base = file,
|
adamc@382
|
300 ext = SOME "html"}}})
|
adamc@382
|
301
|
adamc@382
|
302 fun highlight () =
|
adamc@382
|
303 doit (fn (src, html) =>
|
adamc@382
|
304 let
|
adamc@410
|
305 val dirty =
|
adamc@410
|
306 let
|
adamc@410
|
307 val srcSt = Posix.FileSys.stat src
|
adamc@410
|
308 val htmlSt = Posix.FileSys.stat html
|
adamc@410
|
309 in
|
adamc@410
|
310 Time.> (Posix.FileSys.ST.mtime srcSt,
|
adamc@410
|
311 Posix.FileSys.ST.mtime htmlSt)
|
adamc@410
|
312 end handle OS.SysErr _ => true
|
adamc@410
|
313
|
adamc@382
|
314 val cmd = "emacs --eval \"(progn "
|
adamc@382
|
315 ^ "(global-font-lock-mode t) "
|
adamc@382
|
316 ^ "(add-to-list 'load-path \\\""
|
adamc@382
|
317 ^ Config.sitelisp
|
adamc@382
|
318 ^ "/\\\") "
|
adamc@382
|
319 ^ "(load \\\"urweb-mode-startup\\\") "
|
adamc@382
|
320 ^ "(urweb-mode) "
|
adamc@382
|
321 ^ "(find-file \\\""
|
adamc@382
|
322 ^ src
|
adamc@382
|
323 ^ "\\\") "
|
adamc@382
|
324 ^ "(switch-to-buffer (htmlize-buffer)) "
|
adamc@382
|
325 ^ "(write-file \\\""
|
adamc@382
|
326 ^ html
|
adamc@382
|
327 ^ "\\\") "
|
adamc@382
|
328 ^ "(kill-emacs))\""
|
adamc@382
|
329 in
|
adamc@410
|
330 if dirty then
|
adamc@410
|
331 (print (">>> " ^ cmd ^ "\n");
|
adamc@410
|
332 ignore (OS.Process.system cmd))
|
adamc@410
|
333 else
|
adamc@410
|
334 ()
|
adamc@382
|
335 end)
|
adamc@381
|
336 in
|
adamc@384
|
337 if OS.Path.base file = "demo" then
|
adamc@384
|
338 ()
|
adamc@384
|
339 else case OS.Path.ext file of
|
adamc@384
|
340 SOME "urp" =>
|
adamc@384
|
341 doit (fn (src, html) =>
|
adamc@384
|
342 let
|
adamc@384
|
343 val inf = TextIO.openIn src
|
adamc@384
|
344 val out = TextIO.openOut html
|
adamc@381
|
345
|
adamc@384
|
346 fun loop () =
|
adamc@384
|
347 case TextIO.inputLine inf of
|
adamc@384
|
348 NONE => ()
|
adamc@384
|
349 | SOME line => (TextIO.output (out, line);
|
adamc@384
|
350 loop ())
|
adamc@384
|
351 in
|
adamc@384
|
352 TextIO.output (out, "<html><body>\n\n<pre>");
|
adamc@384
|
353 loop ();
|
adamc@384
|
354 TextIO.output (out, "</pre>\n\n</body></html>");
|
adamc@381
|
355
|
adamc@384
|
356 TextIO.closeIn inf;
|
adamc@384
|
357 TextIO.closeOut out
|
adamc@384
|
358 end)
|
adamc@384
|
359 | SOME "urs" => highlight ()
|
adamc@384
|
360 | SOME "ur" => highlight ()
|
adamc@384
|
361 | _ => ();
|
adamc@381
|
362 loop ()
|
adamc@381
|
363 end
|
adamc@381
|
364 in
|
adamc@381
|
365 loop ()
|
adamc@381
|
366 end
|
adamc@380
|
367 in
|
adamc@384
|
368 case readIndex () of
|
adamc@384
|
369 NONE => raise Fail "No demo applications!"
|
adamc@384
|
370 | SOME combined =>
|
adamc@384
|
371 let
|
adamc@384
|
372 val () = (TextIO.output (urOut, "</body></xml>\n");
|
adamc@384
|
373 TextIO.closeOut urOut)
|
adamc@384
|
374
|
adamc@384
|
375 val fname = OS.Path.joinDirFile {dir = dirname,
|
adamc@384
|
376 file = "demo.urp"}
|
adamc@384
|
377 val outf = TextIO.openOut fname
|
adamc@776
|
378
|
adamc@776
|
379 fun filters kind =
|
adamc@776
|
380 app (fn rule : Settings.rule =>
|
adamc@776
|
381 (TextIO.output (outf, case #action rule of
|
adamc@776
|
382 Settings.Allow => "allow"
|
adamc@776
|
383 | Settings.Deny => "deny");
|
adamc@776
|
384 TextIO.output (outf, " ");
|
adamc@776
|
385 TextIO.output (outf, kind);
|
adamc@776
|
386 TextIO.output (outf, " ");
|
adamc@776
|
387 TextIO.output (outf, #pattern rule);
|
adamc@776
|
388 case #kind rule of
|
adamc@776
|
389 Settings.Exact => ()
|
adamc@776
|
390 | Settings.Prefix => TextIO.output (outf, "*");
|
adamc@776
|
391 TextIO.output (outf, "\n")))
|
adamc@384
|
392 in
|
adamc@384
|
393 Option.app (fn db => (TextIO.output (outf, "database ");
|
adamc@384
|
394 TextIO.output (outf, db);
|
adamc@384
|
395 TextIO.output (outf, "\n")))
|
adamc@384
|
396 (#database combined);
|
adamc@384
|
397 TextIO.output (outf, "sql demo.sql\n");
|
adamc@385
|
398 TextIO.output (outf, "prefix ");
|
adamc@385
|
399 TextIO.output (outf, prefix);
|
adamc@385
|
400 TextIO.output (outf, "\n");
|
adamc@774
|
401 app (fn rule =>
|
adamc@774
|
402 (TextIO.output (outf, "rewrite ");
|
adamc@774
|
403 TextIO.output (outf, case #pkind rule of
|
adamc@774
|
404 Settings.Any => "any"
|
adamc@774
|
405 | Settings.Url => "url"
|
adamc@774
|
406 | Settings.Table => "table"
|
adamc@774
|
407 | Settings.Sequence => "sequence"
|
adamc@774
|
408 | Settings.View => "view"
|
adamc@774
|
409 | Settings.Relation => "relation"
|
adamc@774
|
410 | Settings.Cookie => "cookie"
|
adamc@774
|
411 | Settings.Style => "style");
|
adamc@774
|
412 TextIO.output (outf, " ");
|
adamc@774
|
413 TextIO.output (outf, #from rule);
|
adamc@774
|
414 case #kind rule of
|
adamc@774
|
415 Settings.Exact => ()
|
adamc@774
|
416 | Settings.Prefix => TextIO.output (outf, "*");
|
adamc@774
|
417 TextIO.output (outf, " ");
|
adamc@774
|
418 TextIO.output (outf, #to rule);
|
adamc@774
|
419 TextIO.output (outf, "\n"))) (#rewrites combined);
|
adamc@776
|
420 filters "url" (#filterUrl combined);
|
adamc@776
|
421 filters "mime" (#filterMime combined);
|
adamc@384
|
422 TextIO.output (outf, "\n");
|
adamc@384
|
423
|
adamc@384
|
424 app (fn s =>
|
adamc@384
|
425 let
|
adamc@384
|
426 val s = OS.Path.mkAbsolute {relativeTo = OS.FileSys.getDir (),
|
adamc@384
|
427 path = s}
|
adamc@384
|
428 in
|
adamc@384
|
429 TextIO.output (outf, s);
|
adamc@384
|
430 TextIO.output (outf, "\n")
|
adamc@384
|
431 end)
|
adamc@384
|
432 (#sources combined);
|
adamc@384
|
433 TextIO.output (outf, "\n");
|
adamc@384
|
434 TextIO.output (outf, "demo\n");
|
adamc@384
|
435
|
adamc@384
|
436 TextIO.closeOut outf;
|
adamc@384
|
437
|
adamc@1079
|
438 let
|
adamc@1079
|
439 val b = Compiler.compile (OS.Path.base fname)
|
adamc@1079
|
440 in
|
adamc@1079
|
441 TextIO.output (demosOut, "\n</body></html>\n");
|
adamc@1079
|
442 TextIO.closeOut demosOut;
|
adamc@1079
|
443 if b then
|
adamc@1079
|
444 prettyPrint ()
|
adamc@1079
|
445 else
|
adamc@1079
|
446 ();
|
adamc@1079
|
447 b
|
adamc@1079
|
448 end
|
adamc@1079
|
449 end
|
adamc@380
|
450 end
|
adamc@380
|
451
|
adamc@1079
|
452 fun make args = if make' args then
|
adamc@1079
|
453 ()
|
adamc@1079
|
454 else
|
adamc@1079
|
455 OS.Process.exit OS.Process.failure
|
adamc@1079
|
456
|
adamc@380
|
457 end
|