diff --git a/src/generate.ml b/src/generate.ml index 7b23433cc70c4acbaf8307327dda3d0566f2239f..30212fc611359b6c2995ae8c46cab774b85fa21c 100644 --- a/src/generate.ml +++ b/src/generate.ml @@ -1,8 +1,26 @@ open Html5.M +open Menu -let page ~title:t b = +let internal_link ?(a=[]) p text = + Html5.M.a ~a:(a_href (p.filename^".html")::a_title p.long_title::a) + [pcdata text] + +let page p b = + let header = + div ~a:[a_id "Header"] + [internal_link ~a:[a_style "font-size: large;"] main "SOPRANO"; + pcdata (": "^p.long_title)] in + let menu = + (List.map (fun p -> internal_link p p.menu_title)) menu + in + let menu = div ~a:[a_id "Menu"] menu in + let content = div ~a:[a_id "Content"] b in let html = html - (head (title (pcdata t)) [meta ~a:[a_charset "utf-8"] ()]) - (body b) in + (head (title (pcdata ("SOPRANO: "^p.long_title))) + [ + meta ~a:[a_charset "utf-8"] (); + link ~rel:[`Stylesheet] ~href:"css/main.css" () + ]) + (body ([header;content;menu])) in Html5.P.print ~output:print_string html diff --git a/src/index.page.ml b/src/index.page.ml index 7122e0d1dbb9273b46e169c0877cf89e125178cf..554d380dd7f7974ac379efcee0041199dabc0bd3 100644 --- a/src/index.page.ml +++ b/src/index.page.ml @@ -1,7 +1,8 @@ open Html5.M open Generate +open Menu -let () = Generate.page ~title:"Toto" [ +let () = Generate.page main [ p [pcdata "C'est ça!"] ] diff --git a/src/menu.ml b/src/menu.ml new file mode 100644 index 0000000000000000000000000000000000000000..cef58d481cbfb1a87c5e0e748befa64aeed98b89 --- /dev/null +++ b/src/menu.ml @@ -0,0 +1,14 @@ +open Html5.M + +type page = { + long_title: string; + menu_title: string; + filename: string; (** If this field is foo the page must + be defined in "foo.page.ml" *) +} + +let main = { long_title="Home"; menu_title = "Home"; filename = "index" } + +let menu = [ + main; +] diff --git a/src/utils.mllib b/src/utils.mllib index 2615ec9650e68e01d970c8a51cb751fe7ab94336..297a509a0976be329e17c2cc6b7f968f39eff48f 100644 --- a/src/utils.mllib +++ b/src/utils.mllib @@ -1 +1,2 @@ +Menu Generate \ No newline at end of file diff --git a/www/css/main.css b/www/css/main.css new file mode 100644 index 0000000000000000000000000000000000000000..872027cfaecfc5411f8b4a7330d045e13717cd9d --- /dev/null +++ b/www/css/main.css @@ -0,0 +1,87 @@ + +/* From bluerobot layout1 */ + +body { + margin:0px; + padding:0px; + font-family:verdana, arial, helvetica, sans-serif; + color:#333; + background-color:white; + } +h1 { + margin:0px 0px 15px 0px; + padding:0px; + font-size:28px; + line-height:28px; + font-weight:900; + color:#ccc; + } +p { + font:11px/20px verdana, arial, helvetica, sans-serif; + margin:0px 0px 16px 0px; + padding:0px; + } +#Content>p {margin:0px;} +#Content>p+p {text-indent:30px;} + +a { + color:#09c; + font-size:11px; + text-decoration:none; + font-weight:600; + font-family:verdana, arial, helvetica, sans-serif; + } +a:link {color:#09c;} +a:visited {color:#07a;} +a:hover {background-color:#eee;} + +#Header { + margin:50px 0px 10px 0px; + padding:17px 0px 0px 20px; + /* For IE5/Win's benefit height = [correct height] + [top padding] + [top and bottom border widths] */ + height:33px; /* 14px + 17px + 2px = 33px */ + border-style:solid; + border-color:black; + border-width:1px 0px; /* top and bottom borders: 1px; left and right borders: 0px */ + line-height:11px; + background-color:#eee; + +/* Here is the ugly brilliant hack that protects IE5/Win from its own stupidity. +Thanks to Tantek Celik for the hack and to Eric Costello for publicizing it. +IE5/Win incorrectly parses the "\"}"" value, prematurely closing the style +declaration. The incorrect IE5/Win value is above, while the correct value is +below. See http://glish.com/css/hacks.asp for details. */ + voice-family: "\"}\""; + voice-family:inherit; + height:14px; /* the correct height */ + } +/* I've heard this called the "be nice to Opera 5" rule. Basically, it feeds correct +length values to user agents that exhibit the parsing error exploited above yet get +the CSS box model right and understand the CSS2 parent-child selector. ALWAYS include +a "be nice to Opera 5" rule every time you use the Tantek Celik hack (above). */ +body>#Header {height:14px;} + +#Content { + margin:0px 50px 50px 200px; + padding:10px; + } + +#Menu { + position:absolute; + top:100px; + left:20px; + width:172px; + padding:10px; + background-color:#eee; + border:1px dashed #999; + line-height:17px; +/* Again, the ugly brilliant hack. */ + voice-family: "\"}\""; + voice-family:inherit; + width:150px; + } +/* Again, "be nice to Opera 5". */ +body>#Menu {width:150px;} + + + diff --git a/www/index.html b/www/index.html index a9ef376e1405add976f333b34d46f5a672fedec8..f9c7da040526c5e0c2571f023d8c900f37ede080 100644 --- a/www/index.html +++ b/www/index.html @@ -1,2 +1,2 @@ -Toto

C'est ça!

\ No newline at end of file +SOPRANO: Home

C'est ça!

\ No newline at end of file