Changeset 19 in code for trunk/cli/convert.ml
- Timestamp:
- Oct 26, 2022, 7:36:02 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cli/convert.ml
r15 r19 10 10 List.fold_left 11 11 (fun a f -> 12 let dest = dest ^ f.Conversion.ext in 13 if is_older source dest then (File_store.file dest (f.Conversion.page r text); true) else false 14 || a) 12 match f.Conversion.page with None -> false || a 13 | Some page -> 14 let dest = dest ^ f.Conversion.ext in 15 (if is_older source dest then (File_store.file dest (page r text); true) else false) 16 || a) 15 17 false cs 16 18 | x -> Printf.eprintf "Can't convert Content-Type: %s file: %s" x text.Text.title; false 17 19 18 20 let converters types kv = 21 let n = String.split_on_char ',' types in 19 22 let t = [] in 20 let t = if ("htm" = types || "all" = types) then 21 (let htm = Html.init kv in 22 Conversion.{ ext = Html.ext; page = Html.page htm; indices = Html.indices htm })::t 23 else t in 24 let t = if ("gmi" = types || "all" = types) then 25 Conversion.{ ext = Gemini.ext; page = Gemini.page; indices = Gemini.indices}::t else t in 23 let t = if List.(mem "all" n || mem "htm" n) then (Html.converter kv)::t else t in 24 let t = if List.(mem "all" n || mem "atom" n) then (Atom.converter "text/html")::t else t in 25 let t = if List.(mem "all" n || mem "gmi" n) then (Gemini.converter)::t else t in 26 let t = if List.(mem "all" n || mem "gmi-atom" n) then (Atom.converter "text/gemini")::t else t in 26 27 t 27 28 … … 36 37 with Not_found -> Topic_set.roots topics in 37 38 let repo = Conversion.{ repo with topic_roots; topics; texts } in 38 if not noindex then List.iter (fun c -> c.Conversion.indicesrepo) converters;39 if not noindex then List.iter (fun c -> match c.Conversion.indices with None -> () | Some f -> f repo) converters; 39 40 Printf.printf "Converted: %d Indexed: %d\n" count (List.length texts) 40 41 … … 48 49 let kv = let f = Filename.concat dir ".convert.conf" in (* TODO: better place to store convert conf? *) 49 50 if Sys.file_exists f then File_store.of_kv_file f else Store.KV.empty in 50 let kv = if Store.KV.mem "Title" kv then kv 51 else Store.KV.add "Title" info.Header_pack.title kv in 51 let kv = if Store.KV.mem "Title" kv then kv else Store.KV.add "Title" info.Header_pack.title kv in 52 52 let kv = Store.KV.add "Locations" (String.concat ";\n" info.Header_pack.locations) kv in 53 53 let kv = Store.KV.add "Peers" (String.concat ";\n" Header_pack.(to_str_list peers)) kv in
Note:
See TracChangeset
for help on using the changeset viewer.