Changeset 3 in code for trunk/cli/gemini.ml


Ignore:
Timestamp:
Apr 15, 2022, 1:17:01 PM (3 years ago)
Author:
fox
Message:
  • Removed 'txt init'

Format

  • New B32 ID

Index

  • New option: txt index --print
  • Move scheme to peers
  • Replace peer.*.conf files with index packed locations Instead of adding a URL to peers.*.conf, run txt pull <url>

Conversion

  • Rewritten converters
  • txt-convert looks for a .convert.conf containing key: value lines.
  • Specifiable topic-roots from .convert.conf.
  • Added Topics: key, with comma seperated topics.

If set only those topics will appear in the main index and used as topic roots.
Other topics will have sub-indices generated, but won't be listed in the main index.

  • HTML converter header & footer options
  • HTML-index renamed to HTM-index

Internal

  • Change types: uuid:Uuid -> id:string
  • File_store merges identical texts
  • Use peer ID for store path, store peers' texts in .local/share/texts
  • Simple URN resolution for converter

Continue to next feed if parsing one fails

  • Phasing-out Archive, replaced by improved packs
  • Eliminate Bos, Cohttp, lwt, uri, tls, Re, Ptime, dependencies
  • Lock version for Cmdliner, fix dune-project
  • Optional resursive store
  • Improve header_pack
  • Fix recursive mkdir
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cli/gemini.ml

    r2 r3  
    1 let page _archive_title text =
     1let ext = ".gmi"
     2
     3module GeminiConverter = struct
     4        include Converter.Gemini
     5        let angled_uri u a = if String.sub u 0 10 <> "urn:txtid:" then
     6                angled_uri u a else angled_uri (String.(sub u 10 (length u - 10)) ^ ext) a
     7end
     8
     9let page _conversion text =
    210  let open Logarion.Text in
    311  "# " ^ text.title
    412  ^ "\nAuthors: " ^ Logarion.Person.Set.to_string text.authors
    513  ^ "\nDate: " ^ Logarion.Date.(pretty_date @@ listing text.date)
    6   ^ let module T = Parsers.Plain_text.Make (Converter.Gemini) in
     14  ^ let module T = Parsers.Plain_text.Make (GeminiConverter) in
    715  "\n" ^ T.of_string text.body ""
    816
     
    3139    "" meta_list
    3240
    33 let topic_link root topic =
    34  "=> index." ^ root ^ ".gmi " ^ String.capitalize_ascii topic ^ "\n"
     41let topic_link root topic =
     42  let replaced_space = String.map (function ' '->'+' | x->x) in
     43         "=> index." ^ replaced_space  root ^ ".gmi " ^ String.capitalize_ascii topic ^ "\n"
    3544
    3645let text_item path meta =
     
    7281  "# " ^ title ^ "\n\n"
    7382  ^ listing_index topic_map [topic_root] "" metas
     83
     84let indices r =
     85        let open Logarion in
     86        let file name = File_store.file (Filename.concat r.Conversion.dir name) in
     87        let index_name = try Store.KV.find "Gemini-index" r.kv with Not_found -> "index.gmi" in
     88        let title = try Store.KV.find "Title" r.Conversion.kv with Not_found -> "" in
     89
     90        if index_name <> "" then
     91                file index_name (topic_main_index title r.topic_roots r.texts);
     92
     93        file "index.date.gmi" (date_index title r.texts);
     94
     95        List.iter
     96                (fun topic -> file ("index." ^ topic ^ ".gmi")
     97                 (topic_sub_index title r.topics topic r.texts))
     98                r.topic_roots;
     99
     100        let base_url = try
     101                let _i = Str.(search_forward (regexp "gemini?://[^;]*") (Store.KV.find "Locations" r.kv) 0) in
     102                Str.(matched_string (Store.KV.find "Locations" r.kv))
     103                with Not_found -> prerr_endline "Missing location for Gemini"; "" in
     104        file "gmi.atom" (Atom.feed title r.id base_url "text/gemini" r.texts)
Note: See TracChangeset for help on using the changeset viewer.