Started static conversion indexer

This commit is contained in:
Stavros Polymenis 2017-11-20 22:31:17 +00:00
parent 52d2ee9f93
commit bbc329ef61
2 changed files with 10 additions and 5 deletions

View File

@ -53,9 +53,10 @@ let article_link meta =
in in
li [ a ~a:[ a_href (uri_of_string u) ] [ d ] ] li [ a ~a:[ a_href (uri_of_string u) ] [ d ] ]
let of_entries ?(header_tpl=None) ?(list_tpl=None) ?(item_tpl=None) ?(from=0) ?(n=0) blog_url lgrn notes = let of_entries ?(style=default_style) ?(header_tpl=None) ?(list_tpl=None) ?(item_tpl=None) ?(from=0) ?(n=0) blog_url lgrn notes =
let title = Logarion.(lgrn.Archive.Configuration.title) in let title = Logarion.(lgrn.Archive.Configuration.title) in
logarion_page logarion_page
~style
~header_tpl ~header_tpl
blog_url blog_url
title title

View File

@ -121,18 +121,22 @@ let convert directory =
let store = File.store config.repository in let store = File.store config.repository in
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 metas = File.to_list L.meta_lens archive.store in
let page_of_note = Converters.Html.of_note ~style:"static/main.css" "localhost" config in let page_of_note = Converters.Html.of_note ~style:"static/main.css" "localhost" config in
let page_of_note_listing = Converters.Html.of_entries ~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 path content =
let out = open_out @@ path_of_note note in let out = open_out path in
output_string out @@ page_of_note note; output_string out content;
close_out out close_out out
in in
match create_dir directory |> create_dir_msg ~descr:"export" directory with match create_dir directory |> create_dir_msg ~descr:"export" directory with
| Ok _ -> | Ok _ ->
(match copy ~recursive:true ".logarion/static" (directory) with (match copy ~recursive:true ".logarion/static" (directory) with
| Ok _ -> List.iter file_creation notes | Ok _ ->
List.iter (fun note -> file_creation (path_of_note note) (page_of_note note)) notes;
file_creation (directory ^ "/index.html") (page_of_note_listing metas);
| Error (`Msg m) -> prerr_endline m) | Error (`Msg m) -> prerr_endline m)
| Error _ -> () | Error _ -> ()