| 1 |
|
(* This CDuce script produces CDuce web site. *) |
| 2 |
|
|
| 3 |
|
|
| 4 |
include "xhtml-strict.cd";; (* XHTML 1 Strict DTD *) |
include "xhtml-strict.cd";; (* XHTML 1 Strict DTD *) |
| 5 |
include "xhtml-categ.cd";; (* Categories (Inline, ...) from this DTD *) |
include "xhtml-categ.cd";; (* Categories (Inline, ...) from this DTD *) |
| 6 |
|
|
| 43 |
|
|
| 44 |
type InlineText = |
type InlineText = |
| 45 |
Char |
Char |
| 46 |
| <(`b|`i) {||}>[InlineText*] |
| <(`b|`i|`tt) {||}>[InlineText*] |
| 47 |
| <duce>[InlineText*] |
| <duce>[InlineText*] |
| 48 |
| Xa |
| Xa |
| 49 |
| Ximg | Xbr ;; |
| Ximg | Xbr ;; |
| 59 |
|
|
| 60 |
let fun text (t : [InlineText*]) : Inlines = |
let fun text (t : [InlineText*]) : Inlines = |
| 61 |
map t with |
map t with |
| 62 |
<duce>x -> <b>[ <tt>(text x) ] |
| <duce>x -> <b>[ <tt>(text x) ] |
| 63 |
| <b>x -> <b>(text x) |
| <(tag & (`b|`i|`tt))>x -> <(tag)>(text x) |
|
| <i>x -> <i>(text x) |
|
| 64 |
| z -> z;; |
| z -> z;; |
| 65 |
|
|
| 66 |
let fun content (t : Content) : Flow = |
let fun content (t : Content) : Flow = |
| 67 |
transform t with |
transform t with |
| 68 |
| <section title=title>c -> [ <h4>title !(content c) ] |
| <section title=title>c -> |
| 69 |
|
[ <h4>title !(content c) ] |
| 70 |
| <paper (r)>[ <title>tit aut::Author* <comment>com <abstract>ab ] -> |
| <paper (r)>[ <title>tit aut::Author* <comment>com <abstract>ab ] -> |
| 71 |
[ |
[ (match r with { file = f } -> <a href=f>tit | _ -> <b>tit) '. ' |
|
(match r with |
|
|
| { file = f } -> <a href=f>tit |
|
|
| _ -> <b>tit |
|
|
) '. ' |
|
| 72 |
!(authors aut) '. ' |
!(authors aut) '. ' |
| 73 |
!(text com) |
!(text com) |
| 74 |
<div class="abstract">[ 'Abstract:' !(content ab) ] |
<div class="abstract">[ 'Abstract:' !(content ab) ] |
| 76 |
| <slides file=f>[ <title>tit aut::Author* <comment>com ] -> |
| <slides file=f>[ <title>tit aut::Author* <comment>com ] -> |
| 77 |
[ <a href=f>tit '. ' !(authors aut) '. ' !(text com) ] |
[ <a href=f>tit '. ' !(authors aut) '. ' !(text com) ] |
| 78 |
| <include-verbatim file=f>[] -> |
| <include-verbatim file=f>[] -> |
| 79 |
let code = load_file f in |
[ <div class="code">[ <pre>(load_file f) ] ] |
| 80 |
let code = transform code with |
| <link url=url; title=title>com -> |
| 81 |
(* | c & ('a'--'z') -> [ <b>[c] ] *) |
[ <a href=url>title '. ' !(text com) ] |
| 82 |
(* | ' ' -> "\160" *) |
| <ul>lis -> |
| 83 |
| c -> [c] in |
[ <ul>(map lis with <li>x -> <li>(content x)) ] |
| 84 |
[ |
| Xtable & x -> |
| 85 |
<div class="code">[ <pre>code ] |
[ x ] |
|
] |
|
|
| <link url=url; title=title>com -> [ <a href=url>title '. ' !(text com) ] |
|
|
| <ul>lis -> [ <ul>(map lis with <li>x -> <li>(content x)) ] |
|
|
| Xtable & x -> [ x ] |
|
| 86 |
| <p>x -> [ <p>(text x) ] |
| <p>x -> [ <p>(text x) ] |
|
| <ul>x -> [ <ul>(text x) ] |
|
| 87 |
| x -> text [ x ];; |
| x -> text [ x ];; |
| 88 |
|
|
| 89 |
let fun main2html (Box -> Flow) |
let fun main2html (Box -> Flow) |
| 96 |
| <meta>c -> [ <div class="meta">(content c) ];; |
| <meta>c -> [ <div class="meta">(content c) ];; |
| 97 |
|
|
| 98 |
|
|
| 99 |
|
(* Ugly hack to introduce PHP code ... |
| 100 |
|
The idea is to produce first an XML document with a distinguished element. |
| 101 |
|
The function patch_css search for the textual representation of this |
| 102 |
|
element and replace it with the PHP code. *) |
| 103 |
|
|
| 104 |
let php_css : String = |
let php_css : String = |
| 105 |
[' <?php |
[' <?php |
| 106 |
$browser = getenv("HTTP_USER_AGENT"); |
$browser = getenv("HTTP_USER_AGENT"); |
| 138 |
<head>[ |
<head>[ |
| 139 |
<title>title |
<title>title |
| 140 |
<meta content="text/html; charset=iso-8859-1"; http-equiv="Content-Type">[] |
<meta content="text/html; charset=iso-8859-1"; http-equiv="Content-Type">[] |
| 141 |
<meta content="css">[] |
<meta content="css">[] (* Placeholder for PHP code *) |
| 142 |
] |
] |
| 143 |
<body>[ |
<body>[ |
| 144 |
<div class="title">[ <h1>(text banner) ] |
<div class="title">[ <h1>(text banner) ] |
| 148 |
];; |
];; |
| 149 |
|
|
| 150 |
type P = (String,<title>String);; |
type P = (String,<title>String);; |
| 151 |
|
|
| 152 |
let fun make_plan (l : [ P+ ]) : Page = |
let fun make_plan (l : [ P+ ]) : Page = |
| 153 |
<page>[ <title>"CDuce site" |
<page>[ |
| 154 |
|
<title>"CDuce site" |
| 155 |
<banner>"CDuce site" |
<banner>"CDuce site" |
| 156 |
<navig>[ <box>[ <a href="/">"Home" ] ] |
<navig>[ <box>[ <a href="/">"Home" ] ] |
| 157 |
<main>[ |
<main>[ |
| 158 |
<box title="Pages"; link="pages">[ |
<box title="Pages"; link="pages">[ |
| 159 |
<ul>(map l with (file,<title>t) -> <li>[<a href=file>t]) ] |
<ul>(map l with (file,<title>t) -> <li>[<a href=file>t]) |
|
<meta>[ |
|
|
'This page was automatically generated by a CDuce program.' |
|
| 160 |
] |
] |
| 161 |
|
<meta>[ 'This page was automatically generated by a CDuce program.' ] |
| 162 |
] |
] |
| 163 |
];; |
];; |
| 164 |
|
|