| 1 |
(* This CDuce script produces CDuce web site. *)
|
| 2 |
|
| 3 |
(** Command line **)
|
| 4 |
|
| 5 |
let input =
|
| 6 |
match argv [] with
|
| 7 |
| [ s ] -> s
|
| 8 |
| _ -> raise "Please use --arg to specify an input file on the command line"
|
| 9 |
|
| 10 |
(** Output types **)
|
| 11 |
|
| 12 |
using H = "xhtml"
|
| 13 |
|
| 14 |
(** Input types **)
|
| 15 |
|
| 16 |
type Site = <site>[ <title>String Page ]
|
| 17 |
type Page = <page name=Latin1 url=?String new=?"" leftbar=?("true"|"false")>[ <title>String <banner>[InlineText*]? Item* ]
|
| 18 |
type External = <external {|href=String; title=String; name=String |}>[]
|
| 19 |
|
| 20 |
type Item =
|
| 21 |
<box ({| title=String; link=String; short=?String |} | {| |})>Content
|
| 22 |
| <meta>Content
|
| 23 |
| <left>Content
|
| 24 |
| <footnotes>[]
|
| 25 |
| Page
|
| 26 |
| External
|
| 27 |
|
| 28 |
type Author = <author presenter=?("yes"|"no")>String
|
| 29 |
type Paper =
|
| 30 |
<paper file=?String old=?"">[
|
| 31 |
<title>String Author+ <comment>[InlineText*] <abstract>Content ]
|
| 32 |
|
| 33 |
type Slides =
|
| 34 |
<slides file=String>[ <title>String Author+ <comment>[InlineText*] ]
|
| 35 |
|
| 36 |
type Link =
|
| 37 |
<link url=String title=String>[ InlineText* ]
|
| 38 |
|
| 39 |
type Content =
|
| 40 |
[ ( <p {|style=?String|}>[InlineText*]
|
| 41 |
| <ul {||}>[<li {||}>Content *]
|
| 42 |
| <ol {|style=?String|}>[<li {||}>Content *]
|
| 43 |
| <section title=String>Content
|
| 44 |
| <sample highlight=?"true"|"false">String
|
| 45 |
| <xmlsample highlight=?"true"|"false">String
|
| 46 |
| <sessionsample highlight=?"true"|"false">String
|
| 47 |
| H:Xtable
|
| 48 |
| Paper | Slides | Link
|
| 49 |
| <boxes-toc short=?"" sections=?"">[]
|
| 50 |
| <pages-toc sections=?"">[]
|
| 51 |
| <site-toc>[]
|
| 52 |
| <local-links href=String>[]
|
| 53 |
| <two-columns>[ <left>Content <right>Content ]
|
| 54 |
| <note title=?String> Content
|
| 55 |
| <footnotes>[]
|
| 56 |
| <xhtml>H:Flow
|
| 57 |
| <demo label=?String prefix=?String>String
|
| 58 |
| InlineText
|
| 59 |
)* ]
|
| 60 |
|
| 61 |
type InlineText =
|
| 62 |
Char
|
| 63 |
| <(`b|`i|`tt|`em) {| style=?String |}>[InlineText*]
|
| 64 |
| <code>String
|
| 65 |
| <local href=String>String
|
| 66 |
| <footnote>[InlineText*]
|
| 67 |
| H:Xa | H:Ximg | H:Xbr
|
| 68 |
| <thumbnail href=String width=?IntStr height=?IntStr>[]
|
| 69 |
| <thumbnails href=String width=?IntStr height=?IntStr>[ PCDATA ]
|
| 70 |
|
| 71 |
type IntStr = ['0'--'9'+]
|
| 72 |
|
| 73 |
|
| 74 |
(** Generic purpose functions **)
|
| 75 |
|
| 76 |
(* Recursive inclusion of XML files and verbatim text files *)
|
| 77 |
|
| 78 |
let load_include (Latin1 -> [Any*])
|
| 79 |
name ->
|
| 80 |
(* let _ = print [ 'Loading ' !name '... \n' ] in *)
|
| 81 |
xtransform [ (load_xml name) ] with
|
| 82 |
| <include file=(s & Latin1)>[] -> load_include s
|
| 83 |
| <include-verbatim file=(s & Latin1)>[] -> load_file s
|
| 84 |
|
| 85 |
(* Highlighting text between {{...}} *)
|
| 86 |
|
| 87 |
let highlight (String -> [ (Char | H:Xstrong | H:Xi)* ] )
|
| 88 |
| [ '{{%%' h ::(Char *?) '%%}}' ; rest ] ->
|
| 89 |
[ <strong class="highlight">[<i>h]; highlight rest ]
|
| 90 |
| [ '{{' h ::(Char *?) '}}' ; rest ] ->
|
| 91 |
[ <strong class="highlight">h; highlight rest ]
|
| 92 |
| [ '$$%%' h ::(Char *?) '%%$$' ; rest ] ->
|
| 93 |
[ <strong class="ocaml">[<i>h]; highlight rest ]
|
| 94 |
| [ '$$' h ::(Char *?) '$$' ; rest ] ->
|
| 95 |
[ <strong class="ocaml">h; highlight rest ]
|
| 96 |
| [ '%%' h ::(Char *?) '%%' ; rest ] ->
|
| 97 |
[ <i>h; highlight rest ]
|
| 98 |
| [ c; rest ] -> [ c; highlight rest ]
|
| 99 |
| [] -> []
|
| 100 |
|
| 101 |
(* Split a comma-separated string *)
|
| 102 |
|
| 103 |
let split_comma (String -> [String*])
|
| 104 |
| [ x::(Char*?) ',' ; rest ] -> (x, split_comma rest)
|
| 105 |
| s -> [ s ]
|
| 106 |
|
| 107 |
type wschar = ' ' | '\n' | '\t' | '\r'
|
| 108 |
|
| 109 |
let split_thumbnails (String -> [(String,String)*])
|
| 110 |
| [ wschar* x::(Char\wschar\':')+ ':' y::_*? '.'; rest ] ->
|
| 111 |
((x,y), split_thumbnails rest)
|
| 112 |
| [ wschar* x::(Char\wschar)+; rest ] ->
|
| 113 |
((x,""), split_thumbnails rest)
|
| 114 |
| [ wschar* ] -> []
|
| 115 |
|
| 116 |
(** Internal types **)
|
| 117 |
|
| 118 |
type Path = [ { url = String; title = String }* ]
|
| 119 |
type Tree = { name = String; url = String; title = String;
|
| 120 |
children = [Tree*]; boxes = [H:Xul?] }
|
| 121 |
|
| 122 |
let url_of_page (Page -> String)
|
| 123 |
| <page url=u>_ -> u
|
| 124 |
| <page name=n>_ -> n @ ".html"
|
| 125 |
|
| 126 |
let render(a : String)(p : {presenter=?"yes"|"no"}) : H:Flow =
|
| 127 |
(match p with {presenter="yes"} -> [<strong class="ocaml">a] | _ -> a)
|
| 128 |
|
| 129 |
let authors ([Author+] -> H:Flow)
|
| 130 |
| [ <author (p)>a ] -> render a p
|
| 131 |
| [ <author (p1)>a1 <author (p2)>a2 ] -> (render a1 p1) @ ", and " @ (render a2 p2)
|
| 132 |
| [ <author (p)>a; rem ] -> (render a p)@ ", " @ authors rem
|
| 133 |
|
| 134 |
let find_local_link (sitemap : [Tree*], l : String) : Tree =
|
| 135 |
match sitemap with
|
| 136 |
| (h,t) ->
|
| 137 |
if (h . name = l) then h
|
| 138 |
else
|
| 139 |
(try find_local_link (t,l) with `Not_found ->
|
| 140 |
find_local_link (h . children,l))
|
| 141 |
| [] -> raise `Not_found
|
| 142 |
|
| 143 |
let local_link (sitemap : Tree, l : String, txt : String) : H:Inline =
|
| 144 |
try
|
| 145 |
let h = find_local_link ([sitemap],l) in
|
| 146 |
let txt = if txt = "" then h . title else txt in
|
| 147 |
<a href=(h . url)>txt
|
| 148 |
with `Not_found -> raise [ 'Local link not found: ' !l ]
|
| 149 |
|
| 150 |
let compute_sitemap ((Page|External) -> Tree)
|
| 151 |
| <page name=name>[ <title>title (c::(Page|External) | _)* ] & p ->
|
| 152 |
let children = map c with p -> compute_sitemap p in
|
| 153 |
{ name = name; url = (url_of_page p); title = title;
|
| 154 |
children = children; boxes = (boxes_of p) }
|
| 155 |
| <external name=name href=h title=t>[] ->
|
| 156 |
{ name = name; url = h; title = t; children = []; boxes = [] }
|
| 157 |
|
| 158 |
let ul([H:Xli*] -> [H:Xul?]) [] -> [] | l -> [ <ul>l ]
|
| 159 |
|
| 160 |
let ol(([H:Xli*],{|style=?String|}) -> [H:Xol?])
|
| 161 |
([],_) -> []
|
| 162 |
| (l,s&{|style=?String|}) -> [ <ol (s)>l ]
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
let display_sitemap (h : Tree) : H:Xli =
|
| 167 |
let ch = map h . children with x -> display_sitemap x in
|
| 168 |
<li>[ <a href=(h . url)>[ '[' !(h . title) ']' ] !(h . boxes); (ul ch) ]
|
| 169 |
|
| 170 |
|
| 171 |
let boxes_of (Page -> [H:Xul?])
|
| 172 |
<page>[ (items::Item | _)*] & p ->
|
| 173 |
let toc = transform items with
|
| 174 |
| <box title=t link=l>_ -> [ <li>[ <a href=[ !(url_of_page p) '#' !l ]>t ] ]
|
| 175 |
in
|
| 176 |
ul toc
|
| 177 |
|
| 178 |
let link_to (<page>[<title>t ; _ ] & p : Page) : H:Xa =
|
| 179 |
let t = match p with
|
| 180 |
| <_ new="">_ -> t @ [ <img src="img/new.gif" alt="(new)" style="border:0">[]]
|
| 181 |
| _ -> t in
|
| 182 |
<a href=(url_of_page p)>t
|
| 183 |
|
| 184 |
let small_box (x : H:Flow) : H:Block =
|
| 185 |
<table cellpadding="2"
|
| 186 |
style="font-size:11px ; font-family:arial,sans-serif;
|
| 187 |
border: solid 2px black; background: #ffffff" width="100%">
|
| 188 |
[ <tr> [<td>x] ]
|
| 189 |
|
| 190 |
let meta (x : H:Flow) : H:Block =
|
| 191 |
<table cellpadding="2"
|
| 192 |
style="border: solid 1px #b0b0b0; background: #e0e0e0; font-size: 80%"
|
| 193 |
width="100%">
|
| 194 |
[ <tr> [<td>x] ]
|
| 195 |
|
| 196 |
let box_title (x : H:Flow, a : String, t : String) : H:Block =
|
| 197 |
<table cellpadding="5"
|
| 198 |
style="border: solid 2px black; background: #ffffff" width="100%">
|
| 199 |
[ <tr>[
|
| 200 |
<td style="background: #fff0f0; color: #0000ff; font: bold 100%
|
| 201 |
helvetica">[<a name=a>t] ]
|
| 202 |
<tr> [<td>x] ]
|
| 203 |
|
| 204 |
let box (x : H:Flow) : H:Block =
|
| 205 |
<table cellpadding="5"
|
| 206 |
style="border: solid 2px black; background: #ffffff" width="100%">
|
| 207 |
[ <tr> [<td>x] ]
|
| 208 |
|
| 209 |
let style = "
|
| 210 |
a:link:hover, a:visited:hover {
|
| 211 |
text-decoration: none;
|
| 212 |
background: #FFFFD0;
|
| 213 |
color: #FF0000;
|
| 214 |
}
|
| 215 |
a.old, a.old:hover, a.old:visited:hover { text-decoration: line-through; }
|
| 216 |
p { text-align: justify; margin: 1ex 1em 0 1em; }
|
| 217 |
pre { margin: 1ex 1em 0 1em; }
|
| 218 |
strong.ocaml{ color: #333b8e; }
|
| 219 |
strong.highlight { color: #FF0000; }
|
| 220 |
img.icon { border: 0; }
|
| 221 |
div.code { background: #E0E0E0; margin: 0.5ex 0.5em 0 0.5em; padding: 0.2ex; }
|
| 222 |
div.xmlcode { background:#ebefa2; margin: 0.5ex 0.5em 0 0.5em; padding: 0.2ex;}
|
| 223 |
|
| 224 |
div.abstract {
|
| 225 |
font: bold helvetica;
|
| 226 |
margin: 1ex 1em 1ex 1em;
|
| 227 |
padding: 1ex 1em 1ex 1em;
|
| 228 |
background: #F0F0F0;
|
| 229 |
}
|
| 230 |
|
| 231 |
div.note {
|
| 232 |
text-align: justify;
|
| 233 |
font: bold helvetica;
|
| 234 |
margin: 1ex 3em 1ex 3em;
|
| 235 |
padding: 1ex 1em 1ex 1em;
|
| 236 |
background: #D0E2D2;
|
| 237 |
}
|
| 238 |
|
| 239 |
div.session
|
| 240 |
{
|
| 241 |
font: bold 80% helvetica;
|
| 242 |
margin: 1ex 1em 1ex 1em;
|
| 243 |
padding: 1ex 1em 1ex 1em;
|
| 244 |
border: solid .5px grey;
|
| 245 |
}
|
| 246 |
|
| 247 |
div.abstract p { font: sans-serif; }
|
| 248 |
"
|
| 249 |
|
| 250 |
type PageO = Page | []
|
| 251 |
|
| 252 |
|
| 253 |
let button(title : String)(onclick : String) : H:Xinput =
|
| 254 |
<input type="submit" value=title onclick=onclick>[]
|
| 255 |
|
| 256 |
let demo(no : Int)(name : String)(prefix : String)(txt : String) : H:Flow =
|
| 257 |
let n = [ 'a' !name '_' ] in
|
| 258 |
let prefix = if prefix = "" then "" else [ 'a' !prefix '_' ] in
|
| 259 |
[ !(if (no = 1) then [<script src="demo.js" type="text/javascript">" "]
|
| 260 |
else [])
|
| 261 |
<table style="width:100%">[
|
| 262 |
<tr>[
|
| 263 |
<td style="width:50%">[
|
| 264 |
<input type="button" id=(n@"btn") value="Edit" onclick=("editable('"@n@"','');")>[]
|
| 265 |
(button "Evaluate" ("submit('"@n@"');"))
|
| 266 |
(button "Default" ("defreq('"@n@"');"))
|
| 267 |
<input type="button" id=(n@"btnclear") value="Clear" onclick=("clearreq('"@n@"');") style="visibility:hidden;">[]
|
| 268 |
]
|
| 269 |
<td style="width:50%">[
|
| 270 |
<input id=(n@"def") type="hidden" value=txt>[]
|
| 271 |
<input id=(n@"prefix") type="hidden" value=prefix>[]
|
| 272 |
(button "Clear" ("clearres('"@n@"');"))
|
| 273 |
] ]
|
| 274 |
<tr>[
|
| 275 |
<td valign="top">[
|
| 276 |
<div style="position:relative;" id=(n@"container")>[
|
| 277 |
<pre style="z-level:1;" id=(n@"req")>txt
|
| 278 |
<textarea id=(n@"edit") cols="60" rows="25" style="position:absolute; top:0px; visibility: hidden; display:block;border:1px solid #CCCCCC; z-level:2; background-color:#EDEDED;">txt
|
| 279 |
]
|
| 280 |
]
|
| 281 |
<td valign="top">[ <div id=(n@"res")>[] ] ] ]
|
| 282 |
]
|
| 283 |
|
| 284 |
(* Main transformation function *)
|
| 285 |
|
| 286 |
(* returns the last page of the descendance *)
|
| 287 |
|
| 288 |
let thumbnail(w : String, h : String)
|
| 289 |
(url : String)(title : String) : H:Inlines =
|
| 290 |
[ <a href=url>[
|
| 291 |
<img src=url width=w height=h alt="Click to enlarge" title=title>[] ] ]
|
| 292 |
|
| 293 |
let thumbwh({ width =? IntStr; height =? IntStr} ->
|
| 294 |
(String -> String ->H:Inlines))
|
| 295 |
| { width = w; height = h } ->
|
| 296 |
let w = int_of w in let h = int_of h in
|
| 297 |
(match h with
|
| 298 |
| 0 -> raise "Thumbnail height = 0"
|
| 299 |
| h -> let w = string_of ((w * 200) div h) in thumbnail (w,"200"))
|
| 300 |
| _ -> thumbnail ("266","200")
|
| 301 |
|
| 302 |
let gen_page (site : String,
|
| 303 |
prev : PageO, page : Page, next : PageO,
|
| 304 |
path : Path, sitemap : Tree) : PageO =
|
| 305 |
match page with
|
| 306 |
<page name=name leftbar="false"&(leftbar:=`false) else (leftbar:=`true)>[
|
| 307 |
<title>title <banner>banner | <title>(title & banner); items ] ->
|
| 308 |
|
| 309 |
let footnote_counter = ref Int 0 in
|
| 310 |
let footnotes = ref H:Flow [] in
|
| 311 |
let demo_no = ref Int 0 in
|
| 312 |
let last_demo = ref String "" in
|
| 313 |
|
| 314 |
let text (t : [InlineText*]) : H:Inlines =
|
| 315 |
transform t with
|
| 316 |
| <code>x -> [ <b>[ <tt>(highlight x) ] ]
|
| 317 |
| <local href=l>txt ->
|
| 318 |
[ (local_link (sitemap,l,txt)) ]
|
| 319 |
| <(tag & (`b|`i|`tt|`em)) (attr)>x -> [ <(tag) (attr)>(text x) ]
|
| 320 |
| <footnote nocount=_>_ ->
|
| 321 |
let n = string_of !footnote_counter in
|
| 322 |
[ <a name=[ 'bnote' !n ]>[]
|
| 323 |
<a href=[ '#note' !n ]>[ '[' !n ']' ] ]
|
| 324 |
|
| 325 |
| <footnote>c ->
|
| 326 |
footnote_counter := !footnote_counter + 1;
|
| 327 |
let n = string_of !footnote_counter in
|
| 328 |
let fn = !footnotes in
|
| 329 |
footnotes := [];
|
| 330 |
let c = <p>[ <a name=[ 'note' !n ]>[]
|
| 331 |
<a href=[ '#bnote' !n ]>[ '[' !n ']' ]
|
| 332 |
' ' ; text c ] in
|
| 333 |
footnotes := fn @ [ c ] @ !footnotes;
|
| 334 |
[ <a name=[ 'bnote' !n ]>[]
|
| 335 |
<a href=[ '#note' !n ]>[ '[' !n ']' ] ]
|
| 336 |
| <thumbnail ({href=url} & r)>[] ->
|
| 337 |
thumbwh r url ""
|
| 338 |
| <thumbnails ({href=url} & r)>l ->
|
| 339 |
let l = split_thumbnails l in
|
| 340 |
let f = thumbwh r in
|
| 341 |
let c = ref Int 0 in
|
| 342 |
(transform l with (x,y) ->
|
| 343 |
let t = f (url @ x) y in
|
| 344 |
if (!c = 4) then (c := 1; [ <br>[] ] @ t)
|
| 345 |
else (c := !c + 1; t))
|
| 346 |
| z -> [ z ]
|
| 347 |
in
|
| 348 |
|
| 349 |
let content (t : Content) : H:Flow =
|
| 350 |
transform t with
|
| 351 |
| <section title=title>c ->
|
| 352 |
[ <p>[ <b style="color: #008000">title ] !(content c) ]
|
| 353 |
| <paper (r)>[ <title>tit aut::Author* <comment>com <abstract>ab ] ->
|
| 354 |
[ (match r with
|
| 355 |
| { file = f; old = "" } -> <a class="old" href=f>tit
|
| 356 |
| { file = f } -> <a href=f>tit
|
| 357 |
| _ -> <b>tit) '. '
|
| 358 |
!(authors aut) '. '
|
| 359 |
!(text com)
|
| 360 |
<div class="abstract">[ 'Abstract:' !(content ab) ]
|
| 361 |
]
|
| 362 |
| <slides file=f>[ <title>tit aut::Author* <comment>com ] ->
|
| 363 |
[ <a href=f>tit '. ' !(authors aut) '. ' !(text com) ]
|
| 364 |
| <sample highlight="false">s ->
|
| 365 |
[ <div class="code">[ <pre>s ] ]
|
| 366 |
| <sample>s ->
|
| 367 |
[ <div class="code">[ <pre>(highlight s) ] ]
|
| 368 |
| <xmlsample highlight="false">s ->
|
| 369 |
[ <div class="xmlcode">[ <pre>s ] ]
|
| 370 |
| <xmlsample>s ->
|
| 371 |
[ <div class="xmlcode">[ <pre>(highlight s) ] ]
|
| 372 |
| <sessionsample highlight="false">s ->
|
| 373 |
[ <div class="session">[ <pre>s ] ]
|
| 374 |
| <sessionsample>s ->
|
| 375 |
[ <div class="session">[ <pre>(highlight s) ] ]
|
| 376 |
| <link url=url title=title>com ->
|
| 377 |
[ <ul>[ <li>[ <a href=url>title '. ' !(text com) ] ] ]
|
| 378 |
| <ul>lis ->
|
| 379 |
ul (map lis with <li>x -> <li>(content x))
|
| 380 |
| <ol (attr) >lis ->
|
| 381 |
ol ((map lis with <li>x -> <li>(content x) ),(attr))
|
| 382 |
| H:Xtable & x ->
|
| 383 |
[ <table width="100%">[<tr>[<td align="center">[x]]] ]
|
| 384 |
| <p (attr)>x -> [ <p (attr)>(text x) ]
|
| 385 |
| <pages-toc (a)>[] ->
|
| 386 |
let toc = transform items with
|
| 387 |
| Page & p ->
|
| 388 |
let sects = match a with {|sections=_|} -> boxes_of p | _ -> [] in
|
| 389 |
[ <li>[ (link_to p) ; sects ] ]
|
| 390 |
| <external href=l title=t>[] -> [ <li>[ <a href=l>t ] ] in
|
| 391 |
ul toc
|
| 392 |
| <boxes-toc (a)>[] ->
|
| 393 |
let sections = match a with { section=_ } -> `true | _ -> `false in
|
| 394 |
let short = match a with { short=_ } -> `true | _ -> `false in
|
| 395 |
let toc = transform items with
|
| 396 |
| <box ({title=t; link=l} & ({short=s} | {title=s}))>b ->
|
| 397 |
let t = if short then s else t in
|
| 398 |
let sects =
|
| 399 |
if sections then
|
| 400 |
(transform b with <section title=t>_ -> [<br>[] '-' !t])
|
| 401 |
else [] in
|
| 402 |
[ <li>[ <a href=('#',l)>t !sects ]] in
|
| 403 |
ul toc
|
| 404 |
| <site-toc>[] ->
|
| 405 |
[ <ul>[ (display_sitemap sitemap) ] ]
|
| 406 |
| <local-links href=s>[] ->
|
| 407 |
ul (map (split_comma s) with x -> <li>[ (local_link(sitemap,x,"")) ])
|
| 408 |
| <two-columns>[ <left>x <right>y ] ->
|
| 409 |
[ <table width="100%">[
|
| 410 |
<tr>[
|
| 411 |
<td valign="top">(content x)
|
| 412 |
<td valign="top">(content y) ] ] ]
|
| 413 |
| <note title=t>c -> [ <div class="note">[ <b>[!t ': '] !(content c) ]]
|
| 414 |
| <note>c -> [ <div class="note">[ <b>"Note: " !(content c) ]]
|
| 415 |
| <footnotes>[] ->
|
| 416 |
(match !footnotes with
|
| 417 |
| [] -> []
|
| 418 |
| n -> footnotes := []; [ <br>[] (meta n) ] )
|
| 419 |
| <xhtml>i -> i
|
| 420 |
| <demo (r)>s ->
|
| 421 |
demo_no := !demo_no + 1;
|
| 422 |
let name = match r with { label } -> label | _ -> string_of !demo_no in
|
| 423 |
let prefix =
|
| 424 |
match r with { prefix = "last" } -> !last_demo
|
| 425 |
| { prefix } -> prefix
|
| 426 |
| _ -> "" in
|
| 427 |
last_demo := name;
|
| 428 |
demo !demo_no name prefix s
|
| 429 |
| t -> text [ t ]
|
| 430 |
in
|
| 431 |
|
| 432 |
(* Preparing left panel *)
|
| 433 |
|
| 434 |
let left =
|
| 435 |
if leftbar then
|
| 436 |
let navig = transform items with <left>c -> [ c ] in
|
| 437 |
let left = match navig with [] -> [ [<boxes-toc>[]] ] | n -> n in
|
| 438 |
[
|
| 439 |
|
| 440 |
<td valign="top" align="left">[
|
| 441 |
<span style="background:#ffffff;border: solid 2px black; cursor:e-resize;" onclick="javascript:var s=document.getElementById('leftbar').style; s.display=(s.display=='none'?'block':'none');">"*"
|
| 442 |
<table cellpadding="0" cellspacing="15" id="leftbar"
|
| 443 |
width="200"
|
| 444 |
style="font-size:80%; border: 1px dashed black;
|
| 445 |
background: #ffcd72"> (* altbg 9aa8ba *)
|
| 446 |
(map left with x -> <tr>[ <td>[ (small_box (content x)) ] ]) ] ]
|
| 447 |
else [] in
|
| 448 |
|
| 449 |
let dpath : H:Inlines = transform path with
|
| 450 |
| { url = f; title = t } -> [ <a href=f>t ': ']
|
| 451 |
in
|
| 452 |
let npath = path @ [ { url = (url_of_page page); title = title } ] in
|
| 453 |
let subpages = transform items with p & Page -> [ p ] in
|
| 454 |
let (next,last) = gen_page_seq (site,page, subpages, next, npath, sitemap) in
|
| 455 |
let next = match next with [] -> []
|
| 456 |
| <page>[ <title>t; _ ] & p ->
|
| 457 |
[ <a href=(url_of_page p)>[
|
| 458 |
<img width="16" height="16" class="icon" alt="Next page:"
|
| 459 |
src="img/right.gif">[]
|
| 460 |
' ' !t
|
| 461 |
] ] in
|
| 462 |
let prev = match prev with [] -> []
|
| 463 |
| <page>[ <title>t; _ ] & p ->
|
| 464 |
[ <a href=(url_of_page p)>[
|
| 465 |
<img width="16" height="16" class="icon"
|
| 466 |
alt="Previous page:" src="img/left.gif">[]
|
| 467 |
' ' !t
|
| 468 |
] ] in
|
| 469 |
let navig =
|
| 470 |
if prev = [] then [] else
|
| 471 |
[ (small_box [
|
| 472 |
<p>[ !dpath !title ]
|
| 473 |
<p>[ !prev ' ' !next ] ]) ] in
|
| 474 |
|
| 475 |
(* Preparing main panel *)
|
| 476 |
let main = transform items with
|
| 477 |
| <box title=t link=l>c -> [ (box_title (content c, l, t)) ]
|
| 478 |
| <box>c -> [ (box (content c)) ]
|
| 479 |
| <footnotes>[] ->
|
| 480 |
(match !footnotes with
|
| 481 |
| [] -> []
|
| 482 |
| n -> footnotes := []; [ (meta n) ] )
|
| 483 |
| <meta>c -> [ (meta (content c)) ]
|
| 484 |
in
|
| 485 |
let notes = match !footnotes with
|
| 486 |
| [] -> []
|
| 487 |
| n -> [ (meta n) ] in
|
| 488 |
let main = match (navig @ main @ notes @ navig) with
|
| 489 |
| [] -> raise "Empty page !"
|
| 490 |
| x -> x in
|
| 491 |
|
| 492 |
let right : H:Xtd =
|
| 493 |
<td valign="top" align="left" style="width:100%">[
|
| 494 |
<table width="100%">[
|
| 495 |
<tr>[ <td valign="top" align="left"
|
| 496 |
style="border: 2px solid black; background: #ffffff;
|
| 497 |
text-align:center; color: #aa0000; font: bold 200% helvetica" >
|
| 498 |
(text banner)
|
| 499 |
]
|
| 500 |
|
| 501 |
<tr>[
|
| 502 |
<td valign="top" align="left"
|
| 503 |
style="border: 1px solid black; background: #fccead">[ (* altbg c8ccd1 *)
|
| 504 |
<table width="100%" cellpadding="0" cellspacing="17">
|
| 505 |
(map main with x -> <tr>[ <td>[x] ])
|
| 506 |
] ]
|
| 507 |
] ] in
|
| 508 |
|
| 509 |
let html : H:Xhtml =
|
| 510 |
<html>[
|
| 511 |
<head>[
|
| 512 |
<title>[ !site ': ' !title ]
|
| 513 |
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">[]
|
| 514 |
<style type="text/css">style
|
| 515 |
]
|
| 516 |
<body style="margin: 0; padding : 0; background: #fcb333">[ (* altbg 4e6e99 *)
|
| 517 |
<table cellspacing="10" cellpadding="0" width="100%" border="0">[
|
| 518 |
<tr>[ !left right ]
|
| 519 |
]
|
| 520 |
]
|
| 521 |
]
|
| 522 |
in
|
| 523 |
let txt : Latin1 =
|
| 524 |
[ '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'
|
| 525 |
' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
|
| 526 |
!(print_xml html) ] in
|
| 527 |
let fn = "www/" @ name @ ".html" in
|
| 528 |
dump_to_file fn txt;
|
| 529 |
last
|
| 530 |
|
| 531 |
|
| 532 |
let gen_page_seq
|
| 533 |
(site : String,
|
| 534 |
prev : PageO, pages : [Page*], next : PageO,
|
| 535 |
path : Path, sitemap : Tree) : (PageO, PageO) =
|
| 536 |
match pages with
|
| 537 |
| [ p1 p2 ; _ ] & [ _; rest ] ->
|
| 538 |
let last = gen_page (site,prev,p1,p2, path, sitemap) in
|
| 539 |
let (_,last) = gen_page_seq (site,last, rest, next, path, sitemap) in
|
| 540 |
(p1,last)
|
| 541 |
| [ p ] ->
|
| 542 |
let last = gen_page (site,prev,p,next, path, sitemap) in (p,last)
|
| 543 |
| [] -> (next,prev)
|
| 544 |
|
| 545 |
|
| 546 |
;;
|
| 547 |
|
| 548 |
let [<site>[ <title>site p ] ] =
|
| 549 |
try (load_include input :? [ Site ])
|
| 550 |
with (err & Latin1) ->
|
| 551 |
print ['Invalid input document\n' !err '\n'];
|
| 552 |
exit 2
|
| 553 |
in
|
| 554 |
let _ = gen_page (site,[],p,[], [], compute_sitemap p) in []
|