refactored html head

This commit is contained in:
Stavros Polymenis 2016-09-20 22:12:56 +01:00
parent 166c7bc343
commit fddd910fc7

View File

@ -1,16 +1,16 @@
open Tyxml.Html
let logarion_head ?(style="/style.css") t =
head (title (pcdata t)) [link ~rel:[`Stylesheet] ~href:"/style.css" ()]
let html_of ymd = let html_of ymd =
let ymd_title = Logarion.(ymd.meta.title) in let ymd_title = Logarion.(ymd.meta.title) in
let ymd_date = match Logarion.(ymd.meta.date.published) with let ymd_date = match Logarion.(ymd.meta.date.published) with
| Some t -> Some t | Some t -> Some t
| None -> Logarion.(ymd.meta.date.edited) in | None -> Logarion.(ymd.meta.date.edited) in
let ymd_body = Omd.to_html (Omd.of_string Logarion.(ymd.body)) in let ymd_body = Omd.to_html (Omd.of_string Logarion.(ymd.body)) in
let open Tyxml.Html in
let tyhtml = let tyhtml =
html html (logarion_head ymd_title)
(head
(title (Unsafe.data ymd_title))
[link ~rel:[`Stylesheet] ~href:"/style.css" ();]
)
(body [ (body [
header [ header [
h1 [Unsafe.data ymd_title]; h1 [Unsafe.data ymd_title];
@ -25,14 +25,9 @@ let html_of ymd =
Format.asprintf "%a" (Tyxml.Html.pp ()) tyhtml Format.asprintf "%a" (Tyxml.Html.pp ()) tyhtml
let html_of_titles titles = let html_of_titles titles =
let open Tyxml.Html in
let link_item x = li [a ~a:[a_href ("/" ^ x)] [Unsafe.data x]] in let link_item x = li [a ~a:[a_href ("/" ^ x)] [Unsafe.data x]] in
let tyhtml = let tyhtml =
html html (logarion_head "Homepage")
(head
(title (pcdata "Homepage"))
[link ~rel:[`Stylesheet] ~href:"/style.css" ();]
)
(body [ (body [
header [ header [
h1 [pcdata "Homepage"]; h1 [pcdata "Homepage"];
@ -46,13 +41,8 @@ let html_of_titles titles =
Format.asprintf "%a" (Tyxml.Html.pp ()) tyhtml Format.asprintf "%a" (Tyxml.Html.pp ()) tyhtml
let html_of_form ymd = let html_of_form ymd =
let open Tyxml.Html in
let tyhtml = let tyhtml =
html html (logarion_head "Compose")
(head
(title (pcdata "Write post"))
[link ~rel:[`Stylesheet] ~href:"/style.css" ();]
)
(body [ (body [
header [ header [
h1 [pcdata "Create new article"]; h1 [pcdata "Create new article"];