site.cd 18.5 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
11


12
(** Output types **)
13

14
using H = "xhtml"
15

16
17
(** Input types **)

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

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

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

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

type Link =
40
  <link url=String title=String>[ InlineText* ]
41
42

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

type InlineText =
     Char
66
   | <(`b|`i|`tt|`em) {| style=?String |}>[InlineText*]
67
   | <code>String
68
   | <local href=String>String
69
   | <footnote>[InlineText*]
70
71
72
73
74
75
   | H:Xa | H:Ximg | H:Xbr
   | <thumbnail href=String width=?IntStr height=?IntStr>[]
   | <thumbnails href=String width=?IntStr height=?IntStr>[ PCDATA ]

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

76

77
78
79
80
(** Generic purpose functions **)

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

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

88
89
90
91
(* Loading *)

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

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

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

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

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

118
119
120
121
122
123
124
125
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* ] -> []
126

127
(** Internal types **)
128

129
type Path = [ { url = String; title = String }* ]
130
type Tree = { name = String; url = String; title = String; 
131
              children = [Tree*]; boxes = [H:Xul?] } 
132

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

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

let authors ([Author+] -> H:Flow)
 | [ <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
144

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

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

171
172
let ul([H:Xli*] -> [H:Xul?]) [] -> [] | l -> [ <ul>l ]

173
174
175
176
177
let ol(([H:Xli*],{|style=?String|}) -> [H:Xol?]) 
      ([],_) -> [] 
    | (l,s&{|style=?String|}) -> [ <ol (s)>l ] 


178

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

183

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

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

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

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

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

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

222
223
224
225
226
227
let style = "
a:link:hover, a:visited:hover {
  text-decoration: none;
  background: #FFFFD0;
  color: #FF0000;
}
228
229
230
231
232
233
234
235
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;}
236

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

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

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

258
div.abstract p { font-family: sans-serif; }
259
260
"

261
262
type PageO = Page | []

263

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

272
273
274
let demo(no : Int)(name : String)(prefix : String)(txt : String) : H:Flow = 
 let n = [ 'a' !name '_' ] in
 let prefix = if prefix = "" then "" else [ 'a' !prefix '_' ] in
275
 [ !(if (no = 1) then [<script src="demo.js" type="text/javascript">" "]
276
277
278
279
     else [])
  <table style="width:100%">[
   <tr>[ 
    <td style="width:50%">[
280
     (button_id (n@"btn") "Edit" ("editable('"@n@"','');") "")
281
     (button "Evaluate" ("submit('"@n@"');"))
282
     (button "Default" ("defreq('"@n@"');"))
283
     (button_id (n@"btnclear") "Clear" ("clearreq('"@n@"');") "visibility:hidden;")
284
285
    ]
    <td style="width:50%">[
286
     <input id=(n@"def") type="hidden" value=txt>[]
287
     <input id=(n@"prefix") type="hidden" value=prefix>[]
288
     (button "Clear" ("clearres('"@n@"');"))
289
290
    ] ]
   <tr>[
291
    <td valign="top">[ 
292
293
294
     <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 
295
296
     ]
    ]
297
298
    <td valign="top">[ <div id=(n@"res")>[] ] ] ] 
  ]
299

300
301
(* Main transformation function *)

302
(* returns the last page of the descendance *)
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317

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

let thumbwh({ width =? IntStr; height =? IntStr} -> 
   (String -> String ->H:Inlines))
  | { 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")

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

 let items = items @ footer in
327

328
 let footnote_counter = ref Int 0 in 
329
 let footnotes = ref H:Flow [] in
330
 let demo_no = ref Int 0 in
331
 let last_demo = ref String "" in
332

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

343
344
345
346
347
348
349
350
351
352
353
   | <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 ']' ] ]
354
355
356
357
358
359
360
361
362
363
   | <thumbnail ({href=url} & r)>[] ->
      thumbwh r url ""
   | <thumbnails ({href=url} & r)>l ->
      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))
364
   | z -> [ z ] 
365
 in
366

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

451
(* Preparing left panel *)
452

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

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

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

511
 let right : H:Xtd =
512
513
514
515
516
517
518
519
520
521
  <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"
522
          style="border: 1px solid black; background: #fccead">[ (* altbg c8ccd1 *)
523
       <table width="100%" cellpadding="0" cellspacing="17">
524
525
526
527
         (map main with x -> <tr>[ <td>[x] ])
      ] ]
  ] ] in

528
 let html : H:Xhtml =
529
530
 <html>[
  <head>[ 
531
   <title>[ !site ': ' !title ]
532
   <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">[]
533
   <style type="text/css">style
534
  ]
535
536
  <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 *)
537
   <table cellspacing="10" cellpadding="0" width="100%" border="0">[
538
    <tr>[ !left right ]
539
   ]
540
  ]
541
542
 ]
 in
543
 let txt : Latin1 = 
544
   [ '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'
545
     '  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
546
     !(print_xml html) ] in
547
 let fn = outdir @ "/" @ name @ ".html" in
548
 dump_to_file fn txt;
549
 last
550
	
551

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

565

566
;;
567

568
569

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