parent
6689127d06
commit
d978b5fc3a
@ -1,5 +1,5 @@
|
||||
(executable
|
||||
(name txt)
|
||||
(public_name txt)
|
||||
(modules txt authors convert conversion file index last listing new topics html atom gemini pull)
|
||||
(modules txt authors convert conversion file index last listing new topics html atom gemini publish pull)
|
||||
(libraries text_parse.converter text_parse.parsers logarion msgpck curl str cmdliner))
|
||||
|
@ -0,0 +1,30 @@
|
||||
let targets () =
|
||||
let home =
|
||||
try Sys.getenv "txtpubdir" with Not_found ->
|
||||
try Sys.getenv "HOME" with Not_found -> ""
|
||||
in
|
||||
List.filter
|
||||
(fun x -> try Sys.is_directory (snd x) with Sys_error _ -> false)
|
||||
[
|
||||
"htm", home ^ "/public/html";
|
||||
"gmi", home ^ "/public/gemini";
|
||||
"", home ^ "/public/gopher";
|
||||
]
|
||||
|
||||
open Logarion
|
||||
let publish ids =
|
||||
let predicate t = List.mem t.Text.id ids in
|
||||
let targets = targets () in
|
||||
let pub_dirs = List.map (fun x -> snd x) targets in
|
||||
try File_store.iter ~predicate (fun (_t, p) -> File.file ((List.hd p)::pub_dirs))
|
||||
with Unix.Unix_error (Unix.EEXIST, _, _) -> ();
|
||||
List.iter (fun t ->
|
||||
Index.((load (snd t)) false None None None None);
|
||||
Convert.convert_dir (fst t) false (snd t))
|
||||
targets
|
||||
|
||||
open Cmdliner
|
||||
let term =
|
||||
let ids = Arg.(value & pos_all string [] & info [] ~docv:"text ids") in
|
||||
let doc = "convert texts into standart public dirs public_{html,gemini,gopher} if they exists" in
|
||||
Term.(const publish $ ids), Term.info "publish" ~doc ~man:[ `S "DESCRIPTION"; `P doc ]
|
Loading…
Reference in new issue