Add style path parameter to Html.of_note and use custom style path for html exports

This commit is contained in:
Stavros Polymenis 2017-11-20 21:34:22 +00:00
parent 6bfb636d8e
commit 52d2ee9f93
2 changed files with 8 additions and 5 deletions

View File

@ -3,7 +3,7 @@ open Logarion
let to_string tyxml = Format.asprintf "%a" (Tyxml.Html.pp ()) tyxml let to_string tyxml = Format.asprintf "%a" (Tyxml.Html.pp ()) tyxml
let head ?(style="/static/main.css") t = let head ~style t =
head (title (pcdata t)) [ head (title (pcdata t)) [
link ~rel:[`Stylesheet] ~href:style (); link ~rel:[`Stylesheet] ~href:style ();
link ~rel:[`Alternate] ~href:"/feed.atom" ~a:[a_mime_type "application/atom+xml"] (); link ~rel:[`Alternate] ~href:"/feed.atom" ~a:[a_mime_type "application/atom+xml"] ();
@ -15,8 +15,10 @@ let logarion_header ?(header_tpl=None) blog_url title =
| Some (Template.Header s) -> Unsafe.data Template.(fold_header blog_url title s) | Some (Template.Header s) -> Unsafe.data Template.(fold_header blog_url title s)
| None -> header [ h1 [ pcdata title] ] | None -> header [ h1 [ pcdata title] ]
let logarion_page ?(header_tpl=None) blog_url head_title header_title main = let default_style = "/static/main.css"
html (head head_title) (body [ logarion_header ~header_tpl blog_url header_title; main ])
let logarion_page ?(style=default_style) ?(header_tpl=None) blog_url head_title header_title main =
html (head ~style head_title) (body [ logarion_header ~header_tpl blog_url header_title; main ])
let logarion_note ?(note_tpl=None) ymd = let logarion_note ?(note_tpl=None) ymd =
match note_tpl with match note_tpl with
@ -32,8 +34,9 @@ let logarion_note ?(note_tpl=None) ymd =
Unsafe.data ymd_body; Unsafe.data ymd_body;
] ]
let of_note ?(header_tpl=None) ?(note_tpl=None) blog_url lgrn ymd = let of_note ?(style=default_style) ?(header_tpl=None) ?(note_tpl=None) blog_url lgrn ymd =
logarion_page logarion_page
~style
~header_tpl ~header_tpl
blog_url blog_url
(Note.title ymd ^ " by " ^ ymd.Note.meta.Meta.author.Meta.Author.name) (Note.title ymd ^ " by " ^ ymd.Note.meta.Meta.author.Meta.Author.name)

View File

@ -122,7 +122,7 @@ let convert directory =
let archive = L.{ config; store } in let archive = L.{ config; store } in
let notes = File.to_list L.note_lens archive.store in let notes = File.to_list L.note_lens archive.store in
let page_of_note = Converters.Html.of_note "locahost" config in let page_of_note = Converters.Html.of_note ~style:"static/main.css" "localhost" config in
let path_of_note note = directory ^ "/" ^ Meta.string_alias Note.(note.meta.Meta.title) ^ ".html" in let path_of_note note = directory ^ "/" ^ Meta.string_alias Note.(note.meta.Meta.title) ^ ".html" in
let file_creation note = let file_creation note =
let out = open_out @@ path_of_note note in let out = open_out @@ path_of_note note in