Changeset 19 in code for trunk/cli/html.ml


Ignore:
Timestamp:
Oct 26, 2022, 7:36:02 PM (2 years ago)
Author:
fox
Message:

Accept comma separated converter names, separate Atom from Html and Gemini converters.

Note: atom must be called separately now because of the separation. Example

txt convert -t htm,atom xyz

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cli/html.ml

    r18 r19  
    1515        { templates = { header; footer} }
    1616
    17 let wrap c htm text_title body =
    18         let site_title = try Logarion.Store.KV.find "Title" c.Conversion.kv
     17let wrap conv htm text_title body =
     18        let site_title = try Logarion.Store.KV.find "Title" conv.Conversion.kv
    1919                with Not_found -> "" in
    2020        let replace x = let open Str in
     
    5858        let keywords = str_set "keywords" text in
    5959        let header =
    60                 let time x = {|<time datetime="|} ^ x ^ {|">|} ^ x ^ "</time>" in
     60                let time x = Printf.sprintf {|<time datetime="%s">%s</time>|}
     61                        (Date.rfc_string x) (Date.pretty_date x) in
    6162                let topic_links x =
    6263                        let to_linked t a =
     
    6768                ^ opt_kv "Title:" text.title
    6869                ^ opt_kv "Authors:" authors
    69                 ^ opt_kv "Date: " (time (Date.(pretty_date @@ listing text.date)))
     70                ^ opt_kv "Date: " (time (Date.listing text.date))
    7071                ^ opt_kv "Series: " (str_set "series" text)
    7172                ^ opt_kv "Topics: " (topic_links (set "topics" text))
     
    162163                ^ listing_index topic_map [topic_root] "" metas)
    163164
    164 open Logarion
    165165let indices htm c =
    166166        let file name = Logarion.File_store.file (Filename.concat c.Conversion.dir name) in
    167         let index_name = try Store.KV.find "HTM-index" c.Conversion.kv with Not_found -> "index.html" in
    168         let title = try Store.KV.find "Title" c.Conversion.kv with Not_found -> "" in
    169 
    170         if index_name <> "" then
    171                 file index_name (topic_main_index c htm c.topic_roots c.texts);
    172 
     167        let index_name = try Logarion.Store.KV.find "HTM-index" c.Conversion.kv with Not_found -> "index.html" in
     168        if index_name <> "" then file index_name (topic_main_index c htm c.topic_roots c.texts);
    173169        file "index.date.htm" (date_index c htm c.texts);
    174 
    175170        List.iter
    176171                (fun root -> file ("index." ^ root ^ ".htm") (topic_sub_index c htm c.topics root c.texts))
    177                 c.topic_roots;
     172                c.topic_roots
    178173
    179         let base_url = try
    180                 let locs = Store.KV.find "Locations" c.kv in
    181                 let _i = Str.(search_forward (regexp "https?://[^;]*") locs 0) in
    182                 Str.(matched_string locs)
    183                 with Not_found -> prerr_endline "Missing location for HTTP(S)"; "" in
    184         file "feed.atom" (Atom.feed title c.id base_url "text/html" c.texts)
     174let converter kv =
     175        let htm = init kv in
     176        Conversion.{ ext; page = Some (page htm); indices = Some (indices htm) }
Note: See TracChangeset for help on using the changeset viewer.