site.cd 18.4 KB
Newer Older
1
2
(* This CDuce script produces CDuce web site. *)

3
4
(** Command line **)

5
let (input,outdir) =
6
  match argv [] with
7
  | [ s ("-o" o | /(o := "www")) ] -> (s,o)
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
15
(** Input types **)

16
17
type Site = <site>[ <title>String Footer? Page ]
type Footer = <footer>[ Item* ]
18
type Page =  <page name=Latin1 url=?String new=?"" leftbar=?("true"|"false")>[ <title>String <banner>[InlineText*]? Item* ]
19
type External = <external href=String title=String name=String>[]
20
21

type Item = 
22
   <box ({title=String; link=String; short=?String} | {})>Content
23
24
 | <meta>Content
 | <left>Content
25
 | <footnotes>[]
26
 | Page
27
 | External
28

29
type Author = <author presenter=?("yes"|"no")>String
30
type Paper = 
31
  <paper file=?String old=?"">[ 
32
     <title>String Author+ <comment>[InlineText*] <abstract>Content ]
33
34

type Slides = 
35
  <slides file=String>[ <title>String Author+ <comment>[InlineText*] ]
36
37

type Link =
38
  <link url=String title=String>[ InlineText* ]
39
40

type Content =      
41
42
43
   [ ( <p style=?String>[InlineText*]
     | <ul>[<li>Content *]
     | <ol style=?String>[<li>Content *]
44
     | <section title=String>Content
45
     | <sample highlight=?"true"|"false">String
46
     | <xmlsample highlight=?"true"|"false">String
47
     | <sessionsample highlight=?"true"|"false">String
48
     | H.table
49
     | Paper | Slides | Link
50
51
     | <boxes-toc short=?"" sections=?"">[]
     | <pages-toc sections=?"">[]
52
53
     | <site-toc>[]
     | <local-links href=String>[]
54
     | <two-columns>[ <left>Content <right>Content ]
55
     | <note title=?String> Content
56
     | <footnotes>[]
57
     | <xhtml>H.Flow
58
     | <demo label=?String prefix=?String>String 
59
     | InlineText
60
     )* ]
61
62
63

type InlineText =
     Char
64
   | <(`b|`i|`tt|`em) style=?String>[InlineText*]
65
   | <code>String
66
   | <local href=String>String
67
   | <footnote nocount=?"true">[InlineText*]
68
   | H.a | H.img | H.br |H.script
69
70
71
72
73
   | <thumbnail href=String width=?IntStr height=?IntStr>[]
   | <thumbnails href=String width=?IntStr height=?IntStr>[ PCDATA ]

type IntStr = ['0'--'9'+]

74
75
76
77
(** Generic purpose functions **)

(* Recursive inclusion of XML files and verbatim text files *)

78
let load_include (Latin1 -> [Any*])
79
 name ->
80
(*   let _ = print [ 'Loading ' !name '... \n' ] in  *)
81
   xtransform [ (load_xml name) ] with 
82
83
   | <include file=(s & Latin1)>[] -> load_include s
   | <include-verbatim file=(s & Latin1)>[] -> load_file s 
84

85
86
87
88
(* Loading *)

let [<site>[ <title>site (<footer>footer | /(footer:=[])) main_page ] ] = 
 try (load_include input :? [ Site ])
89
 with err & Latin1 -> 
90
   print ['Invalid input document:\n' !err '\n']; 
91
92
   exit 2 

93
94


95
(* Highlighting text between {{...}} *)
96

97
let highlight (String -> [ (Char | H.strong | H.i)* ] )
98
99
 | [ '{{%%' h ::(Char *?) '%%}}' ; rest ] -> 
          [ <strong class="highlight">[<i>h]; highlight rest ]
100
 | [ '{{' h ::(Char *?) '}}' ; rest ] -> 
101
          [ <strong class="highlight">h; highlight rest ]
102
103
104
105
 | [ '$$%%' h ::(Char *?) '%%$$' ; rest ] -> 
          [ <strong class="ocaml">[<i>h]; highlight rest ]
 | [ '$$' h ::(Char *?) '$$' ; rest ] -> 
          [ <strong class="ocaml">h; highlight rest ]
106
 | [ '%%' h ::(Char *?) '%%' ; rest ] ->
107
          [ <i>h; highlight rest ] 
108
 | [ c; rest ] -> [ c; highlight rest ]
109
 | [] -> []
110

111
112
(* Split a comma-separated string *)

113
let split_comma (String -> [String*])
114
 | [ x::(Char*?) ',' ; rest ] -> (x, split_comma rest)
115
 | s -> [ s ]
116

117
118
119
120
121
122
123
124
type wschar = ' ' | '\n' | '\t' | '\r'

let split_thumbnails (String -> [(String,String)*])
 | [ wschar* x::(Char\wschar\':')+ ':' y::_*? '.'; rest ] -> 
        ((x,y), split_thumbnails rest)
 | [ wschar* x::(Char\wschar)+; rest ] -> 
        ((x,""), split_thumbnails rest)
 | [ wschar* ] -> []
125

126
(** Internal types **)
127

128
129
130
type Path = [ { url=String title=String }* ]
type Tree = { name=String url=String title=String
              children=[Tree*] boxes=[H.ul?] } 
131

132
let url_of_page (Page -> String)
133
134
 | <page url=u ..>_ -> u
 | <page name=n ..>_ -> n @ ".html"
135

136
137
138
139
let render(a : String)(p : {presenter=?"yes"|"no" ..}) : H.Flow =
 match p with
 | {presenter="yes" ..} -> [<strong class="ocaml">a] 
 | _ -> a
140

141
let authors ([Author+] -> H.Flow)
142
143
144
 | [ <author (p)>a ] -> render a p
 | [ <author (p1)>a1 <author (p2)>a2 ] -> (render a1 p1) @ ", and " @ (render a2 p2)
 | [ <author (p)>a; rem ] -> (render a p)@ ", " @ authors rem
145

146
let find_local_link (sitemap : [Tree*], l : String) : Tree =
147
148
match sitemap with
 | (h,t) ->
149
   if (h . name = l) then h
150
151
152
   else 
    (try find_local_link (t,l) with `Not_found -> 
         find_local_link (h . children,l))
153
 | [] -> raise `Not_found
154

155
let local_link (sitemap : Tree, l : String, txt : String) : [H.Inline?] =
156
157
158
 try 
  let h = find_local_link ([sitemap],l)  in
  let txt = if txt = "" then h . title else txt in
159
160
161
162
  [ <a href=(h . url)>txt ]
 with `Not_found -> 
  print [ 'Warning. Local link not found: ' !(string_of l) '\n' ];
  []
163
 
164
let compute_sitemap ((Page|External) -> Tree)
165
 | <page name=name ..>[ <title>title (c::(Page|External) | _)* ] & p ->
166
   let children = map c with p -> compute_sitemap p in
167
168
169
   { name url=(url_of_page p) title children boxes=(boxes_of p) }
 | <external name=name href=h title>[] ->
   { name url=h title children=[] boxes=[] }
170

171
let ul([H.li*] -> [H.ul?]) [] -> [] | l -> [ <ul>l ]
172

173
174
175
let ol(([H.li*],{style=?String}) -> [H.ol?]) 
 | ([],_) -> [] 
 | (l,s) -> [ <ol (s)>l ] 
176

177
let display_sitemap (h : Tree) :  H.li =
178
  let ch = map h . children with x -> display_sitemap x in
179
  <li>[ <a href=(h . url)>[ '[' !(h . title) ']' ] !(h . boxes); (ul ch) ]
180

181

182
183
let boxes_of (Page -> [H.ul?])
<page ..>[ (items::Item | _)*] & p ->
184
 let toc = transform items with 
185
 | <box title=t link=l ..>_ -> [ <li>[ <a href=[ !(url_of_page p) '#' !l ]>t ] ] 
186
187
188
 in
 ul toc

189
190
191
let link_to (<page (r)>[<title>t _* ] & p : Page) : H.a =
 let t = match r with
 | {new="" ..} -> t @ [ <img src="img/new.gif" alt="(new)" style="border:0">[]]
192
 | _ -> t in
193
 <a href=(url_of_page p)>t
194

195
let small_box (x : H.Flow) : H.Block =
196
 <table cellpadding="2" 
197
198
    style="font-size:11px ; font-family:arial,sans-serif;
           border: solid 2px black; background: #ffffff" width="100%">
199
200
   [ <tr> [<td>x] ]

201
let meta (x : H.Flow) : H.Block =
202
 <table cellpadding="2" 
203
    style="border: solid 1px #b0b0b0; background: #e0e0e0; font-size: 80%"  
204
205
206
    width="100%">
   [ <tr> [<td>x] ]

207
let box_title (x : H.Flow, a : String, t : String) : H.Block =
208
209
 <table cellpadding="5" 
    style="border: solid 2px black; background: #ffffff" width="100%">
210
211
212
213
   [ <tr>[ 
       <td style="background: #fff0f0; color: #0000ff; font: bold 100%
                  helvetica">[<a name=a>t] ] 
     <tr> [<td>x] ]
214

215
let box (x : H.Flow) : H.Block =
216
217
218
219
 <table cellpadding="5" 
    style="border: solid 2px black; background: #ffffff" width="100%">
   [ <tr> [<td>x] ]

220
221
222
223
224
225
let style = "
a:link:hover, a:visited:hover {
  text-decoration: none;
  background: #FFFFD0;
  color: #FF0000;
}
226
227
228
229
230
231
232
233
a.old, a.old:hover, a.old:visited:hover { text-decoration: line-through; }
p { text-align: justify; margin: 1ex 1em 0 1em; }
pre { margin: 1ex 1em 0 1em; }
strong.ocaml{ color: #333b8e; }
strong.highlight { color: #FF0000; }
img.icon { border: 0; }
div.code { background: #E0E0E0; margin: 0.5ex 0.5em 0 0.5em; padding: 0.2ex; }
div.xmlcode { background:#ebefa2; margin: 0.5ex 0.5em 0 0.5em; padding: 0.2ex;}
234

235
236
237
238
239
div.abstract { 
  margin: 1ex 1em 1ex 1em;
  padding: 1ex 1em 1ex 1em;
  background: #F0F0F0;
}
240
241

div.note { 
242
  text-align: justify;
243
244
245
246
247
  margin: 1ex 3em 1ex 3em;
  padding: 1ex 1em 1ex 1em;
  background: #D0E2D2;
}

248
249
250
251
252
div.session
 { 
  font: bold 80% helvetica;
  margin: 1ex 1em 1ex 1em;
  padding: 1ex 1em 1ex 1em;
253
  border: solid .5px gray;
254
255
}

256
div.abstract p { font-family: sans-serif; }
257
258
"

259
260
type PageO = Page | []

261

262
let button(title : String)(onclick : String) : H.Inline =
263
264
  <input type="submit" style="font-size:8px;" value=title onclick=onclick>[] 
let button_id(id : String)(title : String)(onclick : String)(style : String) 
265
: H.Inline =
266
267
268
  <input type="submit" id=id 
   style=("font-size:8px;"@style) value=title 
   onclick=onclick>[] 
269

270
let demo(no : Int)(name : String)(prefix : String)(txt : String) : H.Flow = 
271
272
 let n = [ 'a' !name '_' ] in
 let prefix = if prefix = "" then "" else [ 'a' !prefix '_' ] in
273
 [ !(if (no = 1) then [<script src="demo.js" type="text/javascript">" "]
274
275
276
277
     else [])
  <table style="width:100%">[
   <tr>[ 
    <td style="width:50%">[
278
     (button_id (n@"btn") "Edit" ("editable('"@n@"','');") "")
279
     (button "Evaluate" ("submit('"@n@"');"))
280
     (button "Default" ("defreq('"@n@"');"))
281
     (button_id (n@"btnclear") "Clear" ("clearreq('"@n@"');") "visibility:hidden;")
282
283
    ]
    <td style="width:50%">[
284
     <input id=(n@"def") type="hidden" value=txt>[]
285
     <input id=(n@"prefix") type="hidden" value=prefix>[]
286
     (button "Clear" ("clearres('"@n@"');"))
287
288
    ] ]
   <tr>[
289
    <td valign="top">[ 
290
291
292
     <div id=(n@"container")>[
      <pre id=(n@"req")>txt
      <textarea id=(n@"edit") cols="50" rows="25" style="display:none;border:1px solid #CCCCCC; background-color:#F0F0F0;">txt 
293
294
     ]
    ]
295
296
    <td valign="top">[ <div id=(n@"res")>[] ] ] ] 
  ]
297

298
299
(* Main transformation function *)

300
(* returns the last page of the descendance *)
301
302

let thumbnail(w : String, h : String)
303
 (url : String)(title : String) : H.Inlines =
304
305
306
 [ <a href=url>[ 
   <img src=url width=w height=h alt="Click to enlarge" title=title>[] ] ]

307
let thumbwh({ width=?IntStr height=?IntStr ..} -> 
308
   (String -> String ->H.Inlines))
309
310
311
312
313
314
315
  | { width = w; height = h } ->
      let w = int_of w in let h = int_of h in
      (match h with
       | 0 -> raise "Thumbnail height = 0"
       | h -> let w = string_of ((w * 200) div h) in thumbnail (w,"200"))
  | _ -> thumbnail ("266","200")

316
317
let gen_page (site : String,
              prev : PageO, page : Page, next : PageO, 
318
319
              path : Path, sitemap : Tree) : PageO = 
match page with 
320
<page name=name leftbar="false"&(leftbar:=`false) else (leftbar:=`true) ..>[ 
321
322
323
 (<title>title <banner>banner | <title>(title & banner)) 
 items::_* ] ->
 let items = items @ footer in
324

325
 let footnote_counter = ref Int 0 in 
326
 let footnotes = ref H.Flow [] in
327
 let demo_no = ref Int 0 in
328
 let last_demo = ref String "" in
329

330
 let text (t : [InlineText*]) : H.Inlines =
331
332
  transform t with
   | <code>x -> [ <b>[ <tt>(highlight x) ] ]
333
   | <local href=l>txt -> local_link (sitemap,l,txt)
334
   | <(tag & (`b|`i|`tt|`em)) (attr)>x -> [ <(tag) (attr)>(text x) ]
335
   | <footnote nocount="true">_ -> 
336
337
338
339
      let n = string_of !footnote_counter in
      [ <a name=[ 'bnote' !n ]>[]
        <a href=[ '#note' !n ]>[ '[' !n ']' ] ]

340
341
342
343
344
345
346
347
348
349
350
   | <footnote>c -> 
      footnote_counter := !footnote_counter + 1;
      let n = string_of !footnote_counter in
      let fn = !footnotes in
      footnotes := [];
      let c = <p>[ <a name=[ 'note' !n ]>[] 
                   <a href=[ '#bnote' !n ]>[ '[' !n ']' ]
		   ' ' ; text c ] in
      footnotes := fn @ [ c ] @ !footnotes;
      [ <a name=[ 'bnote' !n ]>[]
        <a href=[ '#note' !n ]>[ '[' !n ']' ] ]
351
   | <thumbnail ({href=url ..} & r)>[] ->
352
      thumbwh r url ""
353
   | <thumbnails ({href=url ..} & r)>l ->
354
355
356
357
358
359
360
      let l = split_thumbnails l in
      let f = thumbwh r in
      let c = ref Int 0 in
      (transform l with (x,y) -> 
          let t = f (url @ x) y in
          if (!c = 4) then (c := 1; [ <br>[] ] @ t)
          else (c := !c + 1; t))
361
   | z -> [ z ] 
362
 in
363

364
 let content (t : Content) : H.Flow =
365
  transform t with
366
   | <section title=title>c -> 
367
         [ <p>[ <b style="color: #008000">title ] !(content c) ]
368
   | <paper (r)>[ <title>tit aut::Author* <comment>com <abstract>ab  ] ->
369
         [ (match r with
370
           | { file = f; old = "" } -> <a class="old" href=f>tit
371
372
           | { file = f } -> <a href=f>tit
           | _ -> <b>tit) '. '
373
           !(authors aut) '. '
374
	   !(text com)
375
376
377
           <div class="abstract">[ 'Abstract:' !(content ab) ]
         ]
   | <slides file=f>[ <title>tit aut::Author* <comment>com ]  ->
378
        [ <a href=f>tit '. ' !(authors aut) '. ' !(text com) ]
379
380
   | <sample highlight="false">s ->
        [ <div class="code">[ <pre>s ] ]
381
   | <sample ..>s ->
382
        [ <div class="code">[ <pre>(highlight s) ] ]
383
384
   | <xmlsample highlight="false">s ->
        [ <div class="xmlcode">[ <pre>s ] ]
385
   | <xmlsample ..>s ->
386
        [ <div class="xmlcode">[ <pre>(highlight s) ] ]
387
388
   | <sessionsample highlight="false">s ->
        [ <div class="session">[ <pre>s ] ]
389
   | <sessionsample ..>s ->
390
        [ <div class="session">[ <pre>(highlight s) ] ]
391
   | <link url=url title=title>com -> 
392
        [ <ul>[ <li>[ <a href=url>title '. ' !(text com) ] ] ]
393
   | <ul>lis -> 
394
        ul (map lis with <li>x -> <li>(content x))
395
396
   | <ol (attr) >lis -> 
        ol ((map lis with <li>x -> <li>(content x) ),(attr))
397
   | H.table & x -> 
398
       [ <table width="100%">[<tr>[<td align="center">[x]]] ]
399
   | <p (attr)>x -> [ <p (attr)>(text x) ]
400
   | <pages-toc (a)>[] ->
401
402
      let toc = transform items with 
      | Page & p -> 
403
        let sects = match a with {sections=_ ..} -> boxes_of p | _ -> [] in
404
        [ <li>[ (link_to p) ; sects ] ]
405
      | <external href title=t ..>[] -> [ <li>[ <a href>t ] ] in
406
      ul toc
407
   | <boxes-toc (a)>[] ->
408
409
      let sections = match a with { sections=_ ..} -> `true | _ -> `false in
      let short = match a with { short=_ ..} -> `true | _ -> `false in
410
      let toc = transform items with 
411
      | <box ({title=t link=l ..} & ({short=s ..} | {title=s ..}))>b ->
412
413
414
        let t = if short then s else t in
        let sects = 
         if sections then
415
          (transform b with <section title=t>_ -> [<br>[] '-' !t])
416
         else [] in
417
418
        [ <li>[ <a href=('#',l)>t !sects ]] in
      ul toc
419
420
421
   | <site-toc>[] ->
        [ <ul>[ (display_sitemap sitemap) ] ]
   | <local-links href=s>[] ->
422
423
        ul (transform (split_comma s) with x -> 
             match local_link(sitemap,x,"") with [] -> [] | x -> [<li>x])
424
425
426
427
428
   | <two-columns>[ <left>x <right>y ] ->
	[ <table width="100%">[ 
            <tr>[ 
              <td valign="top">(content x) 
              <td valign="top">(content y) ] ] ]
429
   | <note title=t>c ->  [ <div class="note">[ <b>[!t ':  '] !(content c) ]]
430
431
432
433
434
   | <note>c ->  [ <div class="note">[ <b>"Note:  " !(content c) ]]
   | <footnotes>[] -> 
       (match !footnotes with 
        | [] -> [] 
        | n -> footnotes := []; [ <br>[] (meta n) ] )
435
   | <xhtml>i -> i
436
437
   | <demo (r)>s -> 
       demo_no := !demo_no + 1; 
438
       let name = match r with { label .. } -> label | _ -> string_of !demo_no in
439
       let prefix = 
440
441
           match r with { prefix = "last" .. } -> !last_demo 
                      | { prefix .. } -> prefix
442
443
444
                      | _ -> "" in
       last_demo := name;
       demo !demo_no name prefix s
445
446
   | t -> text [ t ]
 in
447

448
(* Preparing left panel *)
449

450
 let left = 
451
452
453
454
  if leftbar then
  let navig = transform items with <left>c -> [ c ] in
  let left = match navig with [] -> [ [<boxes-toc>[]] ] | n -> n in
  [
455
  
456
   <td valign="top" align="left">[
457
     <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;">"*"
458
     <table cellpadding="0" cellspacing="15" id="leftbar"
459
460
            width="200"
            style="font-size:80%; border: 1px dashed black;
461
                   background: #ffcd72">	(* altbg 9aa8ba *)
462
463
     (map left with x -> <tr>[ <td>[ (small_box (content x)) ] ]) ] ]
 else [] in
464

465
 let dpath : H.Inlines = transform path with 
466
  | { url = f title = t } -> [ <a href=f>t ': '] 
467
 in
468
 let npath = path @ [ { url = (url_of_page page); title = title } ] in
469
 let subpages = transform items with p & Page -> [ p ] in
470
 let (next,last) = gen_page_seq (site,page, subpages, next, npath, sitemap) in
471
 let next = match next with [] -> [] 
472
   | <page ..>[ <title>t; _ ] & p -> 
473
      [ <a href=(url_of_page p)>[ 
474
          <img width="16" height="16" class="icon" alt="Next page:"
475
               src="img/right.gif">[]
476
477
478
          ' ' !t
        ] ] in
 let prev = match prev with [] -> [] 
479
   | <page ..>[ <title>t; _ ] & p -> 
480
      [ <a href=(url_of_page p)>[ 
481
          <img width="16" height="16" class="icon"
482
               alt="Previous page:" src="img/left.gif">[]
483
484
          ' ' !t
        ] ] in
485
 let navig = 
486
   if prev = [] then [] else
487
   [ (small_box [
488
     <p>[ !dpath !title ]
489
490
491
492
     <p>[ !prev ' ' !next ] ]) ] in

(* Preparing main panel *)
 let main = transform items with
493
   | <box title=t link=l ..>c -> [ (box_title (content c, l, t)) ]
494
   | <box>c -> [ (box (content c)) ]
495
496
497
498
   | <footnotes>[] -> 
       (match !footnotes with 
        | [] -> [] 
        | n -> footnotes := []; [ (meta n) ] )
499
   | <meta>c -> [ (meta (content c)) ]
500
 in
501
502
503
504
 let notes = match !footnotes with
   | [] -> []
   | n -> [ (meta n) ] in
 let main = match (navig @ main @ notes @ navig) with
505
506
507
   | [] -> raise "Empty page !"
   | x -> x in

508
 let right : H.td =
509
510
511
512
513
514
515
516
517
518
  <td valign="top" align="left" style="width:100%">[
   <table width="100%">[
    <tr>[ <td valign="top" align="left"
              style="border: 2px solid black; background: #ffffff;
text-align:center; color: #aa0000; font: bold 200% helvetica" >
          (text banner)
        ]
 
    <tr>[
      <td valign="top" align="left"
519
          style="border: 1px solid black; background: #fccead">[ (* altbg c8ccd1 *)
520
       <table width="100%" cellpadding="0" cellspacing="17">
521
522
523
524
         (map main with x -> <tr>[ <td>[x] ])
      ] ]
  ] ] in

525
 let html : H.html =
526
527
 <html>[
  <head>[ 
528
   <title>[ !site ': ' !title ]
529
   <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">[]
530
   <style type="text/css">style
531
  ]
532
533
  <body style="margin: 0; padding : 0; background: #fcb333"
        onload="javascript:if (document.cookie.indexOf('leftbar=none')>=0) document.getElementById('leftbar').style.display='none';">[  (* altbg  4e6e99 *)
534
   <table cellspacing="10" cellpadding="0" width="100%" border="0">[
535
    <tr>[ !left right ]
536
   ]
537
  ]
538
539
 ]
 in
540
 let txt : Latin1 = 
541
   [ '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'
542
     '  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
543
     !(print_xml html) ] in
544
 let fn = outdir @ "/" @ name @ ".html" in
545
 dump_to_file fn txt;
546
 last
547
	
548

549
let gen_page_seq 
550
551
 (site : String,
  prev : PageO, pages : [Page*], next : PageO, 
552
  path : Path, sitemap : Tree) : (PageO, PageO) =
553
554
 match pages with
 | [ p1 p2 ; _ ] & [ _; rest ] -> 
555
556
     let last = gen_page (site,prev,p1,p2, path, sitemap) in
     let (_,last)  = gen_page_seq (site,last, rest, next, path, sitemap) in 
557
     (p1,last)
558
 | [ p ] ->
559
     let last = gen_page (site,prev,p,next, path, sitemap) in (p,last)
560
 | [] -> (next,prev)
561

562

563
;;
564

565
gen_page (site,[],main_page,[], [], compute_sitemap main_page)