source: code/trunk/cli/index.ml@ 3

Last change on this file since 3 was 3, checked in by fox, 3 years ago
  • 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 size: 2.5 KB
Line 
1open Logarion
2
3let index print title authors locations peers dir =
4 let fname = Filename.concat dir "index.pck" in
5 let pck = match Header_pack.of_string @@ File_store.to_string fname with
6 | Error s -> failwith s
7 | Ok pck -> let info = Header_pack.{ pck.info with
8 title = if title <> "" then title else pck.info.title;
9 people = if authors <> ""
10 then (String_set.list_of_csv authors) else pck.info.people;
11 locations = if locations <> ""
12 then (String_set.list_of_csv locations) else pck.info.locations;
13 } in
14 Header_pack.{ info; fields;
15 texts = of_text_list @@ File_store.fold ~dir
16 (fun a (t,_) -> of_text a t) [];
17 peers = if peers <> ""
18 then (str_list @@ String_set.list_of_csv peers) else pck.peers;
19 }
20 | exception (Sys_error _) -> Header_pack.{
21 info = {
22 version = version; id = Id.generate (); title;
23 people = String_set.list_of_csv authors;
24 locations = String_set.list_of_csv locations };
25 fields;
26 texts = of_text_list @@ File_store.fold ~dir
27 (fun a (t,_) -> of_text a t) [];
28 peers = str_list @@ String_set.list_of_csv peers;
29 } in
30 File_store.file fname (Header_pack.string pck);
31 let open Header_pack in
32 let s ss = String.concat "\n\t" ss in
33 if print then
34 Printf.printf "Title: %s\nAuthors: %s\nLocations:\n\t%s\nPeers:\n\t%s\n"
35 pck.info.title (String.concat "," pck.info.people)
36 (s pck.info.locations) (s (to_str_list pck.peers))
37
38open Cmdliner
39let term =
40 let print = Arg.(value & flag & info ["print"] ~doc:"print info") in
41 let title= Arg.(value & opt string "" & info ["t"; "title"]
42 ~docv:"string" ~doc:"Title for index") in
43 let auth = Arg.(value & opt string "" & info ["a"; "authors"]
44 ~docv:"comma-separated names" ~doc:"Index authors") in
45 let locs = Arg.(value & opt string "" & info ["l"; "locations"]
46 ~docv:"comma-separated URLs" ~doc:"repository URLs") in
47 let peers= Arg.(value & opt string "" & info ["p"; "peers"]
48 ~docv:"comma-separated URLs" ~doc:"URLs to other known text repositories") in
49 let dir = Arg.(value & pos 0 string "." & info []
50 ~docv:"directory to index") in
51 let doc = "Generate an index.pck for texts in a directory" in
52 Term.(const index $ print $ title $ auth $ locs $ peers $ dir),
53 Term.info "index" ~doc
54 ~man:[ `S "DESCRIPTION"; `Pre "An index contains:\n
55* an info section with: title for the index, the authors, locations (URLs) the texts can be access\n
56* listing of texts with: ID, date, title, authors, topics\n
57* list of other text repositories (peers)\n\n
58MessagePack format. <msgpack.org>" ]
59
Note: See TracBrowser for help on using the repository browser.