fixed article renamed when title changes

This commit is contained in:
Stavros Polymenis 2016-11-01 23:27:12 +00:00
parent bafec4a287
commit 152f1695d2
2 changed files with 9 additions and 1 deletions

View File

@ -62,6 +62,7 @@ let form ?(header_tpl=None) blog_url lgrn ymd =
let auth_name = either ymd.meta.author.Author.name Logarion.Configuration.(lgrn.owner) in
let auth_addr = either ymd.meta.author.Author.email Logarion.Configuration.(lgrn.email) in
[
input ~a:[a_name "uuid"; a_value (Id.to_string ymd.meta.uuid); a_hidden ()] ();
input_set
"Title"
(input ~a:[a_name "title"; a_value ymd.meta.title; a_required ()] ());

View File

@ -42,8 +42,15 @@ let file_meta_pairs () =
List.map t ymds
let to_file ymd =
let path = "ymd/" ^ (Ymd.filename ymd) ^ ".ymd" in
let fmp = file_meta_pairs () in
let path = ("ymd/" ^ (Ymd.filename ymd) ^ ".ymd") in
let write_ymd out = Lwt_io.write out (Ymd.to_string ymd) in
let open Ymd in
(try
let (file, m) = List.find (fun (_, meta) -> meta.uuid = ymd.meta.uuid) fmp in
let fp = "ymd/" ^ file in
Unix.rename fp path;
with Not_found -> ());
Lwt_io.with_file ~mode:Lwt_io.output path write_ymd
let latest_file_meta_pair fragment =