diff --git a/src/app/dbw.ml b/src/app/dbw.ml index c15c186..0569275 100644 --- a/src/app/dbw.ml +++ b/src/app/dbw.ml @@ -5,7 +5,12 @@ open Dibrawi_std let output_buffers html_name html_buffer err_buffer = ( ignore (Unix.system ("mkdir -p " ^ (Filename.dirname html_name))); File.with_file_out html_name (fun o -> - Buffer.output_buffer o html_buffer + let html_content = + Dibrawi.Templating.html_default + ~toc:"TOC TOC TOC" + ~menu:"MENU MENU MENU" + ~title:html_name (Buffer.contents html_buffer) in + output_string o html_content ); let s = Buffer.contents err_buffer in if s <> "" then (eprintf p"Errors for %s:\n%s\n" html_name s;); diff --git a/src/lib/dibrawi.ml b/src/lib/dibrawi.ml index 0e7e628..4a9ed85 100644 --- a/src/lib/dibrawi.ml +++ b/src/lib/dibrawi.ml @@ -1,6 +1,8 @@ open Dibrawi_std +module Templating = Dibrawi_templating + module Info = struct let version = 0 let version_string = sprintf p"The Dibrawi library, v %d" version @@ -332,6 +334,7 @@ module Bibliography = struct let bibtex = Sebib.BibTeX.str end + module Brtx_transform = struct (* TODO handle errors better *) @@ -345,8 +348,7 @@ module Brtx_transform = struct let url_hook = Special_paths.rewrite_url ~from in Bracetax.Transform.brtx_to_html - ~writer ~doc:true ?title - ?filename ~img_hook:url_hook ~url_hook ~input_char (); + ~writer ?filename ~img_hook:url_hook ~url_hook ~input_char (); (html_buffer, err_buffer) ) diff --git a/src/lib/dibrawi_templating.ml b/src/lib/dibrawi_templating.ml new file mode 100644 index 0000000..7e5a200 --- /dev/null +++ b/src/lib/dibrawi_templating.ml @@ -0,0 +1,163 @@ +open Dibrawi_std + +type html_template = + ?menu:string -> ?toc:string -> ?title:string -> ?footer:string -> string -> string + +let html_default +?(menu="") ?(toc="") ?(title="") ?(footer="") content = ( + let css = + " + +div.sidepane { + position:fixed; + font-size: 80%; + /* float_on_right */ + float: right; + width: 30%; + margin-left: 65%; + padding: 1em; +} +div.content { + margin-left: 5%; + border-right: 1px solid gray; + padding: 1em; + width: 55%; +} + + + body { + background-color:#ffffff; + color: black; + font-family: sans-serif; + min-width: 80em; + text-align: justify; + font-size: 80%; + } + + div.p { + padding-bottom: 0em; + /* The debug border: */ + /* border: thin silver solid; */ + } + div.p + div.p { padding-top: 0.5em; } + + div.header { + text-align: center; + /* border: #3E0C0C solid; */ + padding-top: 2.1em; + padding-bottom: 2.05em; + margin-bottom: 3em; + } + h1 { font-size: 300%; font-variant: small-caps; } + div.authors { font-size: 150%; line-height: 200%; } + div.subtitle { font-size: 140%; font-style: italic; } + h2 { font-size: 180%; } + h3 { font-size: 150%; padding-top: 0.1em;padding-bottom: 0.05em;} + h4 { font-size: 130%; padding-top: 0.1em;padding-bottom: 0.05em;} + h5 { font-size: 105%; padding-top: 0.1em;padding-bottom: 0.05em;} + + a { + text-decoration:none; + } + /* http://www.vision.to/add-a-small-icon-to-your-links-css-only.php */ + a[href$='']:hover {text-decoration: underline;} + a[href$='.pdf']:hover {text-decoration: underline;} + a[href$=''] { color: #831825;} + a[href$='.pdf'] { color: #831825;} + + tt { + font-family: monospace; + font-size: 120%; + color: #003300; + } + + code, pre { + font-family: monospace; + /* letter-spacing: 1px; */ + color: #003300; + } + pre { + /* border: dashed; + border-width: thin; + border-color: #dddddd;*/ + position: relative; + /*background-color: #eeeeee;*/ + left: 5%; + width: 70%; + clear: left; + /*padding-bottom: 1em;*/ + } + + ul, ol { + padding-top: 0em; + padding-bottom: 0em; + margin-top: 0em; + margin-bottom: 0em; + /* The debug border: */ + /* border: thin silver solid; */ + } + +/*********** Tables ***********/ +table.tablefigure { + margin-right:auto; + margin-left: auto; + border-collapse: collapse; + min-width: 80%; + margin-bottom: 1em; +} +caption.tablefigure { + /* margin-left:1em; */ + /* min-width: 30%; */ + caption-side:bottom; +} +/*caption.tablefigure:after { content: \" [\" attr(id) \"]\"; color: figid_color; }*/ +div.tablefigure { + text-align: center; + font-size:90%; + border: thin #959595 solid; + margin: 0.5em; + padding: 0.5em; + /*float: right; + width: 50%; + margin-right: 0em; + padding: 0.5em;*/ +} + " + in + + sprintf p"\n\ +\n\ + \n\ + \n\ + \n\ + \n\ + %s\n\ + \n\ + \n\ + \n\ +
\n\ + %s
\n\ + %s\n\ +
\n\ + %s\n\ +
\n\ + %s\n\ +
\n\ +
\n\ + %s\n\ +
\n\ +\n\ +" +title css title menu toc footer content +) + +(* Generates a BIG closure !! *) +let load str = ( + failwith "Templating.load not implemented" +) + + diff --git a/src/lib/libdibrawi.mllib b/src/lib/libdibrawi.mllib index dd60db2..426c75c 100644 --- a/src/lib/libdibrawi.mllib +++ b/src/lib/libdibrawi.mllib @@ -1,2 +1,3 @@ Dibrawi_std +Dibrawi_templating Dibrawi