Refactor writer & convert modified
This commit is contained in:
parent
6c29171c6c
commit
47cf59efc6
|
@ -8,23 +8,21 @@ topics: (String_set.t * String_set.t) Topic_set.Map.t;
|
|||
texts: Text.t list
|
||||
}
|
||||
|
||||
let convert_modified source dest fn title text =
|
||||
if (try Unix.((stat dest).st_mtime < (stat source).st_mtime) with _-> true)
|
||||
let is_older source dest = try
|
||||
Unix.((stat dest).st_mtime < (stat source).st_mtime) with _-> true
|
||||
|
||||
let convert_modified t types source dest fn title text =
|
||||
let dest = (dest ^ "." ^ t) in
|
||||
if (t = types || "all" = types) && is_older source dest
|
||||
then (File_store.file dest (fn title text); true) else false
|
||||
|
||||
let word_fname dir text = Filename.concat dir (Text.alias text)
|
||||
let id_fname dir text = Filename.concat dir (Text.short_id text)
|
||||
|
||||
let writer htm_opts types dir name (text,store_items) = (* todo: single_parser -> [files] *)
|
||||
(* convert_modified store_item idfilename (fun _title -> Text.to_string) text.title text;*)
|
||||
let h = if "htm" = types || "all" = types then
|
||||
convert_modified (List.hd store_items) (id_fname dir text ^ ".htm")
|
||||
Html.(page htm_opts) name text
|
||||
else false in
|
||||
let g = if "gmi" = types || "all" = types then
|
||||
convert_modified (List.hd store_items) (id_fname dir text ^ ".gmi")
|
||||
Gemini.page name text
|
||||
else false in
|
||||
let writer htm_opts types dir name (text,store_items) =
|
||||
let source = List.hd store_items in
|
||||
let fname = id_fname dir text in
|
||||
let h = convert_modified "htm" types source fname Html.(page htm_opts) name text in
|
||||
let g = convert_modified "gmi" types source fname Gemini.page name text in
|
||||
h || g
|
||||
|
||||
let index_writer_htm dir r htm_opts =
|
||||
|
|
Loading…
Reference in New Issue