Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge with ocaml.org styling and layout #113

Merged
merged 10 commits into from
Aug 24, 2014
10 changes: 9 additions & 1 deletion content/template.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
<meta name="description"
content="The homepage of OPAM, a package manager for OCaml" />
<meta name="author" content="OCamlPro" />
<link rel="icon" type="image/png" href="/ext/img/favicon.png" />
<link rel="stylesheet" href="/ext/css/bootstrap.css" />
<link rel="stylesheet" href="/ext/css/bootstrap-responsive.css" />
<link rel="stylesheet" href="/ext/css/docs.css" />
<link rel="stylesheet" href="/ext/js/google-code-prettify/prettify.css" />
<link rel="stylesheet" href="/ext/css/site.css" />
<t:insert name="head" />
<link href="/ext/css/opam2web.css" type="text/css" rel="stylesheet" />
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
Expand Down Expand Up @@ -53,6 +58,9 @@
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->

<script src="/ext/js/google-code-prettify/prettify.js"> </script>
<t:insert name="js" />
<script src="/ext/js/bootstrap.min.js"> </script>
</body>
</html>
11 changes: 0 additions & 11 deletions ext/css/opam2web.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
clear: both;
text-align: center;
padding-top:20px;
border-top: 10px #EBEBEB solid;
}

.footer .copyright {
Expand Down Expand Up @@ -104,13 +103,3 @@ tr.embedded-formula > td:last-child {
width: 100%;
text-align: right;
}


h2 {
border-bottom: 1px solid lightgrey;
padding-top: 5px;
}

h2, h3, h4 {
margin-top: 1ex;
}
13 changes: 13 additions & 0 deletions ext/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,16 @@ code {
html, body {
height: 100%;
}

.footer {
border-top: 10px #EBEBEB solid;
}

h2 {
border-bottom: 1px solid lightgrey;
padding-top: 5px;
}

h2, h3, h4 {
margin-top: 1ex;
}
6 changes: 2 additions & 4 deletions src/o2wBlog.ml
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,7 @@ let make_pages entries =
<:html<
<div class="row">
<div class="span3">
<span> </span>
<div class="bs-docs-menu hidden-phone" data-spy="affix"
data-offset-top="0" data-offset-bottom="140">
<div class="bs-docs-menu hidden-phone">
$nav_menu entry$
</div>
</div>
Expand All @@ -215,7 +213,7 @@ let make_menu entries =
| first_entry::entries, first_page::pages ->
let first =
[{ menu_source = first_entry.blog_source;
menu_link = link ~text:"Blog" first_entry;
menu_link = link ~text:"Platform Blog" first_entry;
menu_item = Internal (2, first_page) }] in
let others =
List.map2 (fun entry page ->
Expand Down
5 changes: 1 addition & 4 deletions src/o2wDocumentation.ml
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ let to_menu_aux ~content_dir ~subdir ?(header=Cow.Html.nil) ~menu_pages =
<:html<
<div class="row">
<div class="span3">
<span> </span>
<div class="bs-docs-menu hidden-phone"
data-spy="affix"
data-offset-top="0" data-offset-bottom="140">
<div class="bs-docs-menu hidden-phone">
$doc_menu$
$html_toc$
</div>
Expand Down
16 changes: 3 additions & 13 deletions src/o2wTemplate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,18 @@ let prepend_root (depth: int) (src: string): string =

let create ~title ~header ~body ~footer ~depth =
let title = <:html< $str:title$ >> in
let css_files = [
"ext/css/bootstrap.css";
"ext/css/bootstrap-responsive.css";
"ext/css/docs.css";
"ext/js/google-code-prettify/prettify.css";
"ext/css/site.css";
] in
let js_files = [
"ext/js/jquery.js";
"ext/js/google-code-prettify/prettify.js";
"ext/js/bootstrap.min.js";
"ext/js/site.js";
"ext/js/search.js";
] in
let prepend_root = prepend_root depth in
let css = "ext/css/opam2web.css" in
let head_html =
<:html<
<link href=$str: prepend_root css$ type="text/css" rel="stylesheet" />
<meta name="generator" content=$str: "opam2web " ^ Version.string$ />
<link rel="icon" type="image/png" href="/ext/img/favicon.png" />
>>@(List.flatten (List.map (fun f ->
<:html< <link href="$str: prepend_root f$" rel="stylesheet" /> >>
) css_files))
>>
in
let js_html =
<:html<
Expand Down
6 changes: 3 additions & 3 deletions src/opam2web.ml
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,19 @@ let make_website user_options universe =
~content_dir ~out_dir:user_options.out_dir
([
{ menu_source = content_dir;
menu_link = { text="Home"; href="." };
menu_link = { text="OPAM"; href="." };
menu_item = Internal (0, home_index) };

{ menu_source = content_dir;
menu_link = { text="Packages"; href=packages_prefix^"/" };
menu_link = { text="Repository"; href=packages_prefix^"/" };
menu_item = Internal (1, package_index) };

{ menu_source = content_dir^"/doc";
menu_link = { text="Documentation"; href="doc/" };
menu_item = Submenu doc_menu; };

{ menu_source = content_dir;
menu_link = { text="About"; href="about.html" };
menu_link = { text="About OPAM"; href="about.html" };
menu_item = Internal (0, Template.serialize about_page) };

]
Expand Down
28 changes: 27 additions & 1 deletion src/template.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ let serialize xml =
let default html = Default (serialize html)
let mandatory () = Mandatory

let html_void_elements = [
"img";
"input";
"link";
"meta";
"br";
"hr";
"source";
"wbr";
"param";
"embed";
"base";
"area";
"col";
"track";
"keygen";
]

(* TODO: cache template *)
let generate content_dir template parameters =
let tt = template.fields in
Expand All @@ -54,7 +72,15 @@ let generate content_dir template parameters =
prerr_endline (Xmlm.error_message e);
exit 1 in
let signals = ref [] in
let output signal = signals := signal :: !signals in
(* TODO: This assumes HTML *)
let output signal = match signal with
| `Data _ | `Dtd _ | `El_start _ -> signals := signal :: !signals
| `El_end -> match !signals with
| `El_start ((_,tag),_) :: _ when List.mem tag html_void_elements ->
signals := signal :: !signals
| [] | (`Data _ | `Dtd _ | `El_end)::_ -> signals := signal :: !signals
| `El_start _ :: _ -> signals := signal :: `Data "" :: !signals
in

let rsub s v = v - s in
let consumep = function 0::_ -> true | _ -> false in
Expand Down