Changeset 15 in code


Ignore:
Timestamp:
Sep 24, 2022, 8:01:37 PM (3 years ago)
Author:
fox
Message:

List peers (from index.pck) in exported htm and gmi index

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/cli/convert.ml

    r13 r15  
    4545                (match Header_pack.of_string @@ File_store.to_string fname with
    4646                | Error s -> prerr_endline s
    47                 | Ok { info; _ } ->
     47                | Ok { info; peers; _ } ->
    4848                        let kv = let f = Filename.concat dir ".convert.conf" in (* TODO: better place to store convert conf? *)
    4949                                if Sys.file_exists f then File_store.of_kv_file f else Store.KV.empty in
     
    5151                                else Store.KV.add "Title" info.Header_pack.title kv in
    5252                        let kv = Store.KV.add "Locations" (String.concat ";\n" info.Header_pack.locations) kv in
     53                        let kv = Store.KV.add "Peers" (String.concat ";\n" Header_pack.(to_str_list peers)) kv in
    5354                        let cs = converters types kv in
    5455                        directory cs noindex dir info.Header_pack.id kv)
  • trunk/cli/gemini.ml

    r3 r15  
    7272  List.fold_left (fun a x -> a ^ list_item x x) "" (List.rev topic_roots)
    7373
    74 let topic_main_index title topic_roots metas =
    75         "# " ^ title ^ "\n\n"
     74let topic_main_index r title topic_roots metas =
     75  "# " ^ title ^ "\n\n"
    7676  ^ (if topic_roots <> [] then ("## Main topics\n\n" ^ fold_topic_roots topic_roots) else "")
    7777  ^ "\n## Latest\n\n" ^ to_dated_links ~limit:10 metas
    78   ^ "\n=> index.date.gmi More by date\n"
     78  ^ "\n=> index.date.gmi More by date\n\n"
     79  ^ let peers = Logarion.Store.KV.find "Peers" r.Conversion.kv in
     80    if peers = "" then "" else
     81    List.fold_left (fun a s -> Printf.sprintf "%s=> %s\n" a s) "## Peers\n\n"
     82      (Str.split (Str.regexp ";\n") peers)
    7983
    8084let topic_sub_index title topic_map topic_root metas =
     
    8993
    9094        if index_name <> "" then
    91                 file index_name (topic_main_index title r.topic_roots r.texts);
     95                file index_name (topic_main_index r title r.topic_roots r.texts);
    9296
    9397        file "index.date.gmi" (date_index title r.texts);
  • trunk/cli/html.ml

    r5 r15  
    3737let topic_link root topic =
    3838  let replaced_space = String.map (function ' '->'+' | x->x) in
    39   "<a href='index." ^ replaced_space root ^ ".htm#" ^ replaced_space topic ^ "'>"
     39  "<a href='index." ^ root ^ ".htm#" ^ replaced_space topic ^ "'>"
    4040  ^ String.capitalize_ascii topic ^ "</a>"
    4141
     
    148148    (fold_topic_roots topic_roots
    149149     ^ "<nav><h1>Latest</h1><ul>" ^ to_dated_links ~limit:8 metas
    150      ^ {|</ul><a href="index.date.htm">More by date</a></nav>|} )
     150     ^ {|</ul><a href="index.date.htm">More by date</a>|}
     151     ^ let peers = Logarion.Store.KV.find "Peers" conv.kv in
     152       (if peers = "" then "" else
     153        List.fold_left (fun a s -> Printf.sprintf {|%s<li><a href="%s">%s</a>|} a s s) "<h1>Peers</h1><ul>"
     154        (Str.split (Str.regexp ";\n") (Logarion.Store.KV.find "Peers" conv.kv))
     155        ^ "</ul>"))
    151156
    152157let topic_sub_index conv htm topic_map topic_root metas =
     
    172177
    173178        let base_url = try
    174                 let _i = Str.(search_forward (regexp "https?://[^;]*") (Store.KV.find "Locations" c.kv) 0) in
    175                 Str.(matched_string (Store.KV.find "Locations" c.kv))
     179                let locs = Store.KV.find "Locations" c.kv in
     180                let _i = Str.(search_forward (regexp "https?://[^;]*") locs 0) in
     181                Str.(matched_string locs)
    176182                with Not_found -> prerr_endline "Missing location for HTTP(S)"; "" in
    177183        file "feed.atom" (Atom.feed title c.id base_url "text/html" c.texts)
  • trunk/install

    r14 r15  
    33Requirements are ocaml (the compiler) and opam (the package manager). Then run:
    44
    5         opam pin add text_parse git://orbitalfox.eu/text-parse-ml
    6         opam pin add logarion git://orbitalfox.eu/logarion
     5        opam pin add text_parse https://git.disroot.org/orbifx/text-parse-ml.git
     6        opam pin add logarion https://git.disroot.org/orbifx/logarion.git
    77        opam install logarion
  • trunk/readme

    r14 r15  
    66
    77Source: <http://git.disroot.org/orbifx/logarion>
    8 EUPL licence: <http://joinup.ec.europa.eu/software/page/eupl>
     8Licence: EUPL <http://joinup.ec.europa.eu/software/page/eupl>
    99
    1010IRC: <irc://tilde.chat/#logarion>
Note: See TracChangeset for help on using the changeset viewer.