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