Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
2f9f4ecb
Commit
2f9f4ecb
authored
Oct 05, 2007
by
Pietro Abate
Browse files
[r2003-07-05 10:41:00 by cvscast] Getting rid of php
Original author: cvscast Date: 2003-07-05 10:41:00+00:00
parent
a5cf614d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
2f9f4ecb
...
...
@@ -26,14 +26,13 @@ profile:
# Site-specific installation
cedre_build
:
rsh cedre
". .env; cd IMPLEM/CDUCE; make webiface webpages
PHP=true
"
scp CHANGES web/www/
*
.
php
web/cduce.css cduce@iris:public_html/
rsh cedre
". .env; cd IMPLEM/CDUCE; make webiface webpages"
scp CHANGES web/www/
*
.
html
web/cduce.css cduce@iris:public_html/
scp webiface cduce@iris:cgi-bin/cduce
install_web_distant
:
make webpages
PHP
=
true
scp CHANGES web/www/
*
.php web/cduce.css cduce@iris:public_html/
scp webiface cduce@iris:cgi-bin/cduce
make webpages
scp CHANGES web/www/
*
.html web/cduce.css cduce@iris:public_html/
# Packaging
...
...
Makefile.conf
View file @
2f9f4ecb
...
...
@@ -10,9 +10,6 @@ PXP_WLEX = false
# include support for expat
EXPAT
=
false
# generates PHP code in web pages to match the browser
PHP
=
false
# Customize the following variables to match the settings
# of your local web server
WEB_PREFIX
= /
var
/
www
...
...
Makefile.distrib
View file @
2f9f4ecb
...
...
@@ -38,14 +38,6 @@ else
CAMLOPT_P
=
ocamlopt
-inline
25
endif
ifeq
($(PHP), true)
PHP_ARG
=
-php
WEB_EXT
=
.php
else
PHP_ARG
=
WEB_EXT
=
.html
endif
OPT
=
-warn-error
FPS
CAMLC
=
ocamlfind
$(CAMLC_P)
$(OPT)
-package
"
$(PACKAGES)
"
CAMLOPT
=
ocamlfind
$(CAMLOPT_P)
$(OPT)
-package
"
$(PACKAGES)
"
...
...
@@ -134,7 +126,7 @@ clean:
rm
-f
cduce ocamlprof.dump
rm
-f
dtd2cduce pool webiface validate
rm
-Rf
prepro package
rm
-f
web/www/
*
.php
web/www/
*
.html web/
*
~
rm
-f
web/www/
*
.html web/
*
~
.SUFFIXES
:
.ml .mli .cmo .cmi .cmx
...
...
@@ -159,12 +151,12 @@ driver/examples.ml: cduce web/examples/build.cd web/examples/examples.xml
(
cd
web/examples
;
../../cduce
--quiet
build.cd
--arg
examples.xml
)
webpages
:
cduce web/site.cd
(
cd
web
;
../cduce
--quiet
site.cd
--arg
$(PHP_ARG)
site.xml
)
(
cd
web
;
../cduce
--quiet
site.cd
--arg
site.xml
)
website
:
webpages webiface
install_web
:
website
cp
web/www/
*
$(WEB_EXT)
web/cduce.css
$(HTML_DIR)
/
cp
web/www/
*
.html
web/cduce.css
$(HTML_DIR)
/
cp
CHANGES
$(HTML_DIR)
/
cp
webiface
$(CGI_DIR)
/cduce
if
test
!
-d
"
$(HTML_DIR)
/img"
;
then
\
...
...
web/site.cd
View file @
2f9f4ecb
...
...
@@ -2,10 +2,9 @@
(** Command line **)
let
(
input
, php)
=
let input =
match argv with
| [ "-php" s ] -> (s, `true)
| [ s ] -> (s, `false)
| [ s ] -> s
| _ -> raise "Please specify an input file on the command line"
...
...
@@ -21,7 +20,7 @@ type Page = <page name=String>[ <title>String <banner>[InlineText*]? Item* ]
type External =
<external
{|
href=
String;
title=
String;
name=
String
|}
>
[]
type Item =
<box
title=
String
subtitle=
?String
link=
String
>
Content
<box
title=
String
link=
String
>
Content
|
<meta>
Content
|
<left>
Content
| Page
...
...
@@ -89,57 +88,6 @@ let split_comma (String -> [String*])
| s -> [ s ]
(** Ugly hack to introduce PHP code ...
The idea is to produce first an XML document with a distinguished element.
The function patch_css search for the textual representation of this
element and replace it with the PHP code. **)
let css : Latin1 =
['
<link
rel=
"stylesheet"
href=
"cduce.css"
type=
"text/css"
>
']
let protect_quote (s : Latin1) : Latin1 =
transform s with '"' -> [ '\\"' ] | c -> [c]
let php_css : Latin1 =
if php then
['
<?php
$browser = getenv("HTTP_USER_AGENT");
if (preg_match("/MSIE/i", "$browser")) {
$css = "<link rel=\\"stylesheet\\" href=\\"cduce.css\\"
type=\\"text/css\\">";
} elseif (preg_match("/Mozilla/i", "$browser")) {
$css = "<blink>For better presentation use a more recent version
of your browser, like Netscape 6</blink>";
} if (preg_match("/Mozilla\\/5.0/i", "$browser")) {
$css = "<link rel=\\"stylesheet\\" href=\\"cduce.css\\"
type=\\"text/css\\">";
} elseif (preg_match("/opera/i", "$browser")) {
$css = "<link rel=\\"stylesheet\\" href=\\"cduce.css\\"
type=\\"text/css\\">";
}
echo "$css";
?>
']
else css
(** It does not work with IE
if php then
['
<?php $browser = getenv("HTTP_USER_AGENT");
if (preg_match("/Mozilla/i", "$browser") && !preg_match("/Mozilla\\/5.0/i", "$browser"))
{
echo "<blink>For better presentation use a more recent version of
your browser, like Netscape 6</blink>";
}
else { echo "' !(protect_quote css) '"; }
?>
']
else css
**)
let patch_css (Latin1 -> Latin1)
| [ a::_*? '
<meta
content=
"css"
/>
'; rem ] -> a @ php_css @ rem
| s -> s
(** Internal types **)
type Path = [ { url = String; title = String }* ]
...
...
@@ -186,8 +134,61 @@ let display_sitemap (h : Tree) : Xli =
let link_to (Page -> Xa)
<page
name=
n
>
[
<title>
t ; _ ] ->
<a
href=
(url_of_name
n
)
>
t
let box (x : Flow) : Block =
<table
cellpadding=
"2"
style=
"border: solid 2px black; background: #ffffff"
width=
"100%"
>
[
<tr>
[
<td>
x] ]
let meta (x : Flow) : Block =
<table
cellpadding=
"2"
style=
"border: solid 1px #b0b0b0; background: #e0e0e0; font-size: 80%"
width=
"100%"
>
[
<tr>
[
<td>
x] ]
let box_title (x : Flow, t : String) : Block =
<table
cellpadding=
"5"
style=
"border: solid 2px black; background: #ffffff"
width=
"100%"
>
[
<tr>
[
<td
style=
"background: #fff0f0; color: #0000ff; font: bold
100% helvetica"
>
t ]
<tr>
[
<td>
x] ]
let style = "
a:link:hover, a:visited:hover {
text-decoration: none;
background: #FFFFD0;
color: #FF0000;
}
p {
text-align: justify;
margin: 1ex 1em 0 1em;
}
pre {
margin: 1ex 1em 0 1em;
}
var.highlight {
color: #FF0000;
}
img.icon {
border: 0;
}
div.code {
background: #E0E0E0;
margin: 0.5ex 0.5em 0 0.5em;
padding: 0.2ex;
}
div.abstract {
font: bold 80% helvetica;
margin: 1ex 1em 1ex 1em;
padding: 1ex 1em 1ex 1em;
background: #F0F0F0;
}
div.abstract p {
font: 100% sans-serif;
}
"
(* Main transformation function *)
(* returns the last page of the descendance *)
let gen_page (prev : Page|[], page : Page, next : Page|[],
path : Path, sitemap : Tree) : (Page|[]) =
...
...
@@ -207,7 +208,7 @@ match page with
let content (t : Content) : Flow =
transform t with
|
<section
title=
title
>
c ->
[
<
h4
>
title !(content c) ]
[
<
p>
[
<b
style=
"color: #008000"
>
title
]
!(content c) ]
|
<paper
(
r
)
>
[
<title>
tit aut::Author*
<comment>
com
<abstract>
ab ] ->
[ (match r with { file = f } ->
<a
href=
f
>
tit | _ ->
<b>
tit) '. '
!(authors aut) '. '
...
...
@@ -253,21 +254,16 @@ match page with
| t -> text [ t ]
in
let main : Flow = transform items with
|
<box
(
r
)
>
c ->
[
<div
class=
"box"
>
[
<h2>
(r . title)
!(match r with { subtitle = t } -> [
<b>
t] | _ -> [])
<a
name=
(r
.
link
)
>
[]
!(content c) ] ]
|
<meta>
c -> [
<div
class=
"meta"
>
(content c) ]
in
let navig : Flow = transform items with
|
<left>
c -> [
<div
class=
"box"
>
(content c)]
in
let left = match navig with
| [] -> [
<div
class=
"box"
>
(content [
<boxes-toc>
[]])]
| n -> n in
(* Preparing left panel *)
let navig = transform items with
<left>
c -> [ c ] in
let left = match navig with [] -> [ [
<boxes-toc>
[]] ] | n -> n in
let left =
<td
valign=
"top"
align=
"left"
>
[
<table
cellpadding=
"5"
cellspacing=
"2"
width=
"200"
style=
"font-size:80%; border: 1px dashed black; background: #ffcd72"
>
(map left with x ->
<tr>
[
<td>
[ (box (content x)) ] ]) ] in
let dpath : Inlines = transform path with
| { url = f; title = t } -> [
<a
href=
f
>
t ': ']
in
...
...
@@ -286,30 +282,61 @@ match page with
<img
width=
"16"
height=
"16"
class=
"icon"
alt=
"Previous page"
src=
"img/left.gif"
>
[]
' ' !t
] ] in
let navig
: [ Xdiv* ]
=
let navig =
if prev = [] then [] else
[
<div
class=
"
box
"
>
[
[
(
box
[
<p>
[ !dpath !title ]
<p>
[ !prev ' ' !next ] ] ] in
<p>
[ !prev ' ' !next ] ]) ] in
(* Preparing main panel *)
let main = transform items with
|
<box
(
r
)
>
c ->
let b = [
<a
name=
(r
.
link
)
>
[]
!(content c) ] in
[ (box_title (b,r . title)) ]
|
<meta>
c -> [ (meta (content c)) ]
in
let main = match (navig @ main @ navig) with
| [] -> raise "Empty page !"
| x -> x in
let right : Xtd =
<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"
style=
"border: 1px solid black; background: #fccead"
>
[
<table
width=
"100%"
cellpadding=
"15"
>
(map main with x ->
<tr>
[
<td>
[x] ])
] ]
] ] in
let html : Xhtml =
<html>
[
<head>
[
<title>
[ 'CDuce: ' !title ]
<meta
content=
"text/html; charset=iso-8859-1"
http-equiv=
"Content-Type"
>
[]
<
meta
content=
"css"
>
[] (* Placeholder for PHP code *)
<
style
type=
"text/css"
>style
]
<body>
[
<
div
class=
"title"
>
[
<h1>
(text banner) ]
<div
id=
"Sidelog"
>
left
<div
id=
"Content"
>
( navig @ main @ navig )
<
body
style
=
"margin: 0; padding : 0; background: #fcb333"
>[
<
table
cellspacing
=
"10"
cellpadding
=
"0"
width
=
"100%"
border
=
"0"
>[
<
tr
>[
left
right
]
]
]
]
in
let
txt
:
Latin1
=
[
'
<!
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 fn = "www/" @ name @
(if php then ".html.php" else
".html"
)
in
!(
print_xml
html
)
]
in
let
fn
=
"www/"
@
name
@
".html"
in
let
[]
=
dump_to_file
fn
txt
in
last
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment