Changeset 21 in code for trunk/cli/publish.ml


Ignore:
Timestamp:
Nov 1, 2022, 5:11:09 PM (2 years ago)
Author:
fox
Message:

Moved conversion file, conf -> pack, fixes

Conversion:

  • Configuration sought in: txt.conf, ~/.config/txt/txt.conf
  • logarion.conf to produce index and target formats

Publication:

  • publish <ids>: copies txt with ID into Pubdir/public_{html,gemini,gopher} (Pubdir fromtxt.conf), if dirs exist, and runs convert <pubdir>

Fixes:

  • Feed <nav> regression
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cli/publish.ml

    r13 r21  
    11let targets () =
    2         let home =
    3                 try Sys.getenv "txtpubdir" with Not_found ->
    4                 try Sys.getenv "HOME" with Not_found -> ""
     2        let kv = Logarion.File_store.of_kv_file () in
     3        let pub_dir =
     4                try Logarion.Store.KV.find "Pubdir" kv with Not_found ->
     5                try Sys.getenv "txtpubdir" with Not_found -> ""
    56        in
    6         List.filter
    7                 (fun x -> try Sys.is_directory (snd x) with Sys_error _ -> false)
    8                 [
    9                         "htm", home ^ "/public_html/txt";
    10                         "gmi", home ^ "/public_gemini/txt";
    11                         "", home ^ "/public_gopher/txt";
    12                 ]
     7        let exists_dir dir = Sys.is_directory (Filename.concat pub_dir dir) in
     8        List.filter (fun x -> try exists_dir (snd x) with Sys_error _ -> false) [
     9                "htm,atom", "public_html/";
     10                "gmi,gmi-atom", "public_gemini/";
     11                "", "public_gopher/";
     12        ]
    1313
    1414open Logarion
     
    1717        let targets = targets () in
    1818        let pub_dirs = List.map (fun x -> snd x) targets in
    19         try File_store.iter ~predicate (fun (_t, p) -> File.file ((List.hd p)::pub_dirs))
    20         with Unix.Unix_error (Unix.EEXIST, _, _) -> ();
    21         List.iter (fun t ->
     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);
    2223                Index.((load (snd t)) false None None None None);
    23                 Convert.at_path (fst t) false (snd t))
     24                Convert.at_path (fst t) false (snd t);
     25                prerr_endline (snd t))
    2426                targets
    2527
Note: See TracChangeset for help on using the changeset viewer.