/[svn]/web/site.cd
ViewVC logotype

Contents of /web/site.cd

Parent Directory Parent Directory | Revision Log Revision Log


Revision 254 - (show annotations)
Tue Jul 10 17:19:36 2007 UTC (5 years, 10 months ago) by abate
File size: 3994 byte(s)
[r2003-03-16 18:43:57 by cvscast] Empty log message

Original author: cvscast
Date: 2003-03-16 18:43:58+00:00
1 include "xhtml-strict.cd";;
2 include "xhtml-categ.cd";;
3
4 type Site = <site>[ <page {|input=String; output=String|}>[]* ];;
5
6 type Page = <page>[
7 <title>String
8 <banner>[InlineText*]
9 <navig>[ NavigBox* ] <main>[ Box* ] ];;
10
11 type Author = <author>String;;
12 type Paper =
13 <paper file=?String>[
14 <title>String
15 Author+
16 <comment>[InlineText*]
17 <abstract>Content ];;
18 type Slides =
19 <slides file=String>[
20 <title>String
21 Author+
22 <comment>[InlineText*]
23 ];;
24
25 type Link =
26 <link url=String; title=String>[InlineText*];;
27
28
29 type Content =
30 [ ( <p {||}>[InlineText*]
31 | <ul {||}>[<li {||}>Content +]
32 | <section title=String>Content
33 | Paper | Slides | Link | InlineText )* ];;
34
35 type InlineText =
36 Char
37 | <(`b|`i) {||}>[InlineText*]
38 | <duce>[InlineText*]
39 | Xa
40 | Ximg | Xbr
41 ;;
42
43 type Box = <box title=String; subtitle=?String; link=String>Content
44 | <meta>Content;;
45 type NavigBox = <box>Content | <toc>[];;
46
47 let fun authors ([Author+] -> String)
48 | [ <author>a ] -> a
49 | [ <author>a1 <author>a2 ] -> a1 @ ", and " @ a2
50 | [ <author>a; rem ] -> a @ ", " @ authors rem;;
51
52 let fun text (t : [InlineText*]) : Inlines =
53 map t with
54 <duce>x -> <b>[ <tt>(text x) ]
55 | <b>x -> <b>(text x)
56 | <i>x -> <i>(text x)
57 | z -> z;;
58
59 let fun content (t : Content) : Flow =
60 transform t with
61 | <section title=title>c -> [ <h4>title !(content c) ]
62 | <paper (r)>[ <title>tit aut::Author* <comment>com <abstract>ab ] ->
63 [
64 (match r with
65 | { file = f } -> <a href=f>tit
66 | _ -> <b>tit
67 ) '. '
68 !(authors aut) '. '
69 !(text com)
70 <div class="abstract">[ 'Abstract:' !(content ab) ]
71 ]
72 | <slides file=f>[ <title>tit aut::Author* <comment>com ] ->
73 [ <a href=f>tit '. ' !(authors aut) '. ' !(text com) ]
74 | <link url=url; title=title>com ->
75 [ <a href=url>title '. ' !(text com) ]
76 | <ul>lis -> [ <ul>(map lis with <li>x -> <li>(content x)) ]
77 | <p>x -> [ <p>(text x) ]
78 | <ul>x -> [ <ul>(text x) ]
79 | x -> text [ x ];;
80
81 let fun main2html (Box -> Flow)
82 <box (r)>c ->
83 [ <div class="box">[
84 <h2>(r.title)
85 !(match r with { subtitle = t } -> [<b>t] | _ -> [])
86 <a name=r.link>[]
87 !(content c) ] ]
88 | <meta>c -> [ <div class="meta">(content c) ];;
89
90
91 let fun page2html (Page -> Xhtml)
92 <page>[ <title>title <banner>banner <navig>navig <main>main ] ->
93 let toc =
94 transform main with <box title=t; link=l>_ -> [ <li>[ <a href=('#',l)>t ] ] in
95 let toc = match toc with [] -> [] | lis -> [ <ul>lis ] in
96 let navig : Flow = transform navig with
97 | <box>c -> [ <div class="box">(content c) ]
98 | <toc>[] -> [ <div class="box">toc ]
99 in
100 <html>[
101 <head>[
102 <title>title
103 <meta content="text/html; charset=iso-8859-1"; http-equiv="Content-Type">[]
104 <link rel="stylesheet"; href="cduce.css"; type="text/css"> []
105 ]
106 <body>[
107 <div class="title">[ <h1>(text banner) ]
108 <div id="Sidelog">navig
109 <div id="Content">(transform main with b -> main2html b)
110 ]
111 ];;
112
113 let fun do_page((String,String) -> [])
114 (inf,outf) ->
115 let _ = print [ 'Loading ' !inf '... ' ] in
116 let page = match load_xml inf with
117 | Page & p -> p
118 | _ -> raise ("Invalid input document: " @ inf) in
119 let _ = print [ 'Generating html ... ' ] in
120 let html : String =
121 [ '<?xml version="1.0" encoding="iso-8859-1"?>'
122 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'
123 ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
124 !(print_xml (page2html page)) ] in
125 let _ = print [ 'Saving to ' !outf '...\n' ] in
126 dump_to_file outf html;;
127
128
129 let site =
130 let _ = print [ 'Loading site.xml ...\n' ] in
131 match load_xml "site.xml" with
132 | Site & <site>s ->
133 (transform s with <page input=inf; output=outf>[] ->
134 do_page(inf,outf))
135 | _ -> raise "Invalid site.xml";;

CVS Admin">CVS Admin
ViewVC Help
Powered by ViewVC 1.1.5