Changeset 3 in code for trunk/cli/gemini.ml
- Timestamp:
- Apr 15, 2022, 1:17:01 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cli/gemini.ml
r2 r3 1 let page _archive_title text = 1 let ext = ".gmi" 2 3 module 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 7 end 8 9 let page _conversion text = 2 10 let open Logarion.Text in 3 11 "# " ^ text.title 4 12 ^ "\nAuthors: " ^ Logarion.Person.Set.to_string text.authors 5 13 ^ "\nDate: " ^ Logarion.Date.(pretty_date @@ listing text.date) 6 ^ let module T = Parsers.Plain_text.Make ( Converter.Gemini) in14 ^ let module T = Parsers.Plain_text.Make (GeminiConverter) in 7 15 "\n" ^ T.of_string text.body "" 8 16 … … 31 39 "" meta_list 32 40 33 let topic_link root topic = 34 "=> index." ^ root ^ ".gmi " ^ String.capitalize_ascii topic ^ "\n" 41 let 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" 35 44 36 45 let text_item path meta = … … 72 81 "# " ^ title ^ "\n\n" 73 82 ^ listing_index topic_map [topic_root] "" metas 83 84 let 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.