Last change
on this file since 22 was 22, checked in by fox, 2 years ago |
Use txt.conf to generate index.pck meta; fix double load while indexing
|
File size:
1.2 KB
|
Rev | Line | |
---|
[22] | 1 | let targets kv =
|
---|
[21] | 2 | let pub_dir =
|
---|
| 3 | try Logarion.Store.KV.find "Pubdir" kv with Not_found ->
|
---|
| 4 | try Sys.getenv "txtpubdir" with Not_found -> ""
|
---|
[6] | 5 | in
|
---|
[21] | 6 | let exists_dir dir = Sys.is_directory (Filename.concat pub_dir dir) in
|
---|
| 7 | List.filter (fun x -> try exists_dir (snd x) with Sys_error _ -> false) [
|
---|
| 8 | "htm,atom", "public_html/";
|
---|
| 9 | "gmi,gmi-atom", "public_gemini/";
|
---|
| 10 | "", "public_gopher/";
|
---|
| 11 | ]
|
---|
[6] | 12 |
|
---|
| 13 | open Logarion
|
---|
| 14 | let publish ids =
|
---|
[22] | 15 | let kv = Logarion.File_store.of_kv_file () in
|
---|
[6] | 16 | let predicate t = List.mem t.Text.id ids in
|
---|
[22] | 17 | let targets = targets kv in
|
---|
[6] | 18 | let pub_dirs = List.map (fun x -> snd x) targets in
|
---|
[21] | 19 | File_store.iter ~predicate (fun (_t, p) ->
|
---|
| 20 | try File.file ((List.hd p)::pub_dirs)
|
---|
| 21 | with Unix.Unix_error (Unix.EEXIST, _, _) -> ());
|
---|
| 22 | List.iter (fun t -> Printf.eprintf "%s %s\n" (fst t) (snd t);
|
---|
[6] | 23 | Index.((load (snd t)) false None None None None);
|
---|
[21] | 24 | Convert.at_path (fst t) false (snd t);
|
---|
| 25 | prerr_endline (snd t))
|
---|
[6] | 26 | targets
|
---|
| 27 |
|
---|
| 28 | open Cmdliner
|
---|
| 29 | let term =
|
---|
| 30 | let ids = Arg.(value & pos_all string [] & info [] ~docv:"text ids") in
|
---|
[10] | 31 | let doc = "convert texts into standard public dirs public_{html,gemini,gopher} if they exist" in
|
---|
[6] | 32 | Term.(const publish $ ids), Term.info "publish" ~doc ~man:[ `S "DESCRIPTION"; `P doc ]
|
---|
Note:
See
TracBrowser
for help on using the repository browser.