refactoring in preparation for better article editing

This commit is contained in:
Stavros Polymenis 2016-11-01 21:12:51 +00:00
parent cf0fddadaf
commit ca64375439

View File

@ -34,13 +34,6 @@ let of_file s =
else
{ blank_ymd with body = "Error parsing file" }
let to_file ymd =
let open Lwt.Infix in
let path = "ymd/" ^ (Ymd.filename ymd) ^ ".ymd" in
Lwt_io.with_file ~mode:Lwt_io.output path (fun out ->
Lwt_io.write out (Ymd.to_string ymd)
)
let file_meta_pairs () =
let files = Array.to_list @@ Sys.readdir "ymd/" in
let ymd_list a e = if BatString.ends_with e ".ymd" then List.cons e a else a in
@ -48,6 +41,11 @@ let file_meta_pairs () =
let t y = (y, (of_file ("ymd/" ^ y)).Ymd.meta) in
List.map t ymds
let to_file ymd =
let path = "ymd/" ^ (Ymd.filename ymd) ^ ".ymd" in
let write_ymd out = Lwt_io.write out (Ymd.to_string ymd) in
Lwt_io.with_file ~mode:Lwt_io.output path write_ymd
let latest_file_meta_pair fragment =
let open Ymd in
let latest p (path', meta') =