Commit 46bfb65b authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-05-14 22:30:05 by cvscast] Empty log message

Original author: cvscast
Date: 2003-05-14 22:30:06+00:00
parent 7e9108de
......@@ -151,9 +151,13 @@ let fun display_sitemap (h : Tree) : Xli =
let ch = match ch with [] -> [] | l -> [ <ul>l ] in
<li>[ <a href=(h . url)>(h . title); ch ];;
let fun link_to (Page -> Xa)
<page name=n>[<title>t ; _ ] -> <a href=(url_of_name n)>t;;
(* Main transformation function *)
let fun gen_page (page : Page, path : Path, sitemap : Tree) : [] =
let fun gen_page (prev : Page|[], page : Page, next : Page|[],
path : Path, sitemap : Tree) : [] =
match page with
<page name=name>[ <title>title <banner>banner ; items ] ->
......@@ -192,7 +196,7 @@ match page with
| <pages-toc>[] ->
let toc =
transform items with
| <page name=l>[<title>t;_] -> [ <li>[ <a href=(url_of_name l)>t ] ]
| Page & p -> [ <li>[ (link_to p) ] ]
| <external href=l; title=t>[] -> [ <li>[ <a href=l>t ] ] in
(match toc with [] -> [] | lis -> [ <ul>lis ])
| <boxes-toc>[] ->
......@@ -225,6 +229,11 @@ match page with
let dpath : Inlines = transform path with
| { url = f; title = t } -> [ <a href=f>t ' :: ']
in
let npath = path @ [ { url = url_of_name name; title = title } ] in
let subpages = transform items with p & Page -> [ p ] in
let next = gen_page_seq (page, subpages, next, npath, sitemap) in
let next = match next with [] -> [] | p -> [' Next : ' (link_to p)] in
let prev = match prev with [] -> [] | p -> [' Prev : ' (link_to p)] in
let html : Xhtml =
<html>[
<head>[
......@@ -233,27 +242,37 @@ match page with
<meta content="css">[] (* Placeholder for PHP code *)
]
<body>[
<div class="title">[ <h1>(text banner)
<p>[ <b>"You're here: " !dpath !title ] ]
<div class="title">[
<h1>(text banner)
<p>[ <b>"You're here: " !dpath !title ]
<p>[ !prev !next ]
]
<div id="Sidelog">navig
<div id="Content">main
]
]
in
let txt : String =
[ (* '<?xml version="1.0" encoding="iso-8859-1"?>' *)
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'
[ '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'
' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
!(patch_css (print_xml html)) ] in
let [] = dump_to_file (name @ ".html.php") txt in
let url = url_of_name name in
let path = path @ [ { url = url; title = title } ] in
transform items with p & Page -> gen_page (p,path,sitemap);;
dump_to_file (name @ ".html.php") txt;;
let fun gen_page_seq
(prev : Page|[], pages : [Page*], next : Page|[],
path : Path, sitemap : Tree) : Page|[] =
match pages with
| [ p1 p2 ; _ ] & [ _; rest ] ->
let [] = gen_page (prev,p1,p2, path, sitemap) in
let _ = gen_page_seq (p1, rest, next, path, sitemap) in p1
| [ p ] ->
let [] = gen_page (prev,p,next, path, sitemap) in p
| [] -> next;;
(* Entry point *)
match load_include "site.xml" with
| [ Page & p ] -> gen_page (p,[], compute_sitemap p)
| [ Page & p ] -> gen_page ([],p,[], [], compute_sitemap p)
| _ -> raise "Invalid site.xml";;
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<page name="tutorial2">
<title>CDuce tutorial</title>
<banner> CDuce tutorial </banner>
<title>First functions</title>
<banner>First functions</banner>
<left>
<boxes-toc/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment