- 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
2022-04-01 17:35:56 +02:00
|
|
|
let version = 0
|
|
|
|
type info_t = { version: int; id: string; title: string; people: string list; locations: string list }
|
|
|
|
type t = { info: info_t; fields: Msgpck.t; texts: Msgpck.t; peers: Msgpck.t }
|
2021-03-13 19:40:07 +01:00
|
|
|
|
- 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
2022-04-01 17:35:56 +02:00
|
|
|
let of_id id = Msgpck.of_string id
|
|
|
|
let to_id = Msgpck.to_string
|
2021-03-13 19:40:07 +01:00
|
|
|
|
|
|
|
let person p = Msgpck.String (Person.to_string p)
|
- 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
2022-04-01 17:35:56 +02:00
|
|
|
let persons ps = Msgpck.of_list @@ List.rev @@ Person.Set.fold (fun p a -> person p :: a) ps []
|
|
|
|
|
|
|
|
let str = Msgpck.of_string
|
|
|
|
let str_list ls = Msgpck.of_list @@ List.map str ls
|
|
|
|
let to_str_list x = List.map Msgpck.to_string (Msgpck.to_list x)
|
2021-03-13 19:40:07 +01:00
|
|
|
|
|
|
|
let of_set field t =
|
|
|
|
List.rev @@ String_set.fold (fun s a -> Msgpck.String s :: a) (Text.set field t) []
|
|
|
|
|
- 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
2022-04-01 17:35:56 +02:00
|
|
|
let date = function "" -> Int32.zero | date -> Int32.of_int (Date.to_secs date)
|
2021-03-13 19:40:07 +01:00
|
|
|
|
- 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
2022-04-01 17:35:56 +02:00
|
|
|
let to_sec = function Msgpck.Int i -> Int32.of_int i | Msgpck.Uint32 i -> i | x -> Msgpck.to_uint32 x
|
2021-03-13 19:40:07 +01:00
|
|
|
|
|
|
|
let fields = Msgpck.(List [String "id"; String "time"; String "title"; String "authors"; String "topics"])
|
|
|
|
let to_fields fieldpack = List.map Msgpck.to_string (Msgpck.to_list fieldpack)
|
|
|
|
|
- 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
2022-04-01 17:35:56 +02:00
|
|
|
let to_info = function
|
|
|
|
| Msgpck.List (v::id::n::a::ls::[]) ->
|
|
|
|
let people = to_str_list a in
|
|
|
|
let locations = to_str_list ls in
|
|
|
|
Msgpck.({version = to_int v; id = to_string id; title = to_string n; people; locations})
|
|
|
|
| _ -> invalid_arg "Pack header"
|
|
|
|
|
|
|
|
let of_info i = let open Msgpck in
|
|
|
|
List [Int i.version; String i.id; String i.title; str_list i.people; str_list i.locations]
|
|
|
|
|
|
|
|
let of_text a t =
|
2021-03-13 19:40:07 +01:00
|
|
|
let open Text in
|
|
|
|
Msgpck.(List [
|
- 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
2022-04-01 17:35:56 +02:00
|
|
|
of_id t.id; of_uint32 (date (Date.listing t.date));
|
|
|
|
String t.title; persons t.authors; List (of_set "topics" t)
|
2021-03-13 19:40:07 +01:00
|
|
|
]) :: a
|
|
|
|
|
- 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
2022-04-01 17:35:56 +02:00
|
|
|
let of_text_list l = Msgpck.List l
|
2021-03-13 19:40:07 +01:00
|
|
|
|
- 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
2022-04-01 17:35:56 +02:00
|
|
|
let pack p = Msgpck.List [of_info p.info; p.fields; p.texts; p.peers]
|
|
|
|
let string p = Bytes.to_string @@ Msgpck.Bytes.to_string @@ pack p
|
2021-03-13 19:40:07 +01:00
|
|
|
|
|
|
|
let unpack = function
|
- 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
2022-04-01 17:35:56 +02:00
|
|
|
| Msgpck.List (i::fields::texts::[]) ->
|
|
|
|
Ok { info = to_info i; fields; texts; peers = Msgpck.List [] }
|
|
|
|
| Msgpck.List (i::fields::texts::peers::[]) ->
|
|
|
|
Ok { info = to_info i; fields; texts; peers }
|
|
|
|
| _ -> Error "format mismatch"
|
|
|
|
|
|
|
|
let of_string s = unpack @@ snd @@ Msgpck.StringBuf.read s
|
2021-03-13 19:40:07 +01:00
|
|
|
|
|
|
|
let list filename = try
|
|
|
|
let texts_list = function
|
|
|
|
| Msgpck.List (_info :: _fields :: [texts]) -> Msgpck.to_list texts
|
|
|
|
| _ -> prerr_endline "malformed feed"; [] in
|
|
|
|
let _pos, data = Msgpck.StringBuf.read @@ File_store.to_string filename in
|
|
|
|
Ok (texts_list data)
|
|
|
|
with Not_found -> Error "unspecified export dir"
|
|
|
|
|
|
|
|
let contains text = function
|
|
|
|
| Msgpck.List (id::_time::title::_authors::_topics::[]) ->
|
- 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
2022-04-01 17:35:56 +02:00
|
|
|
(match to_id id with
|
|
|
|
| "" -> prerr_endline ("Invalid id for " ^ Msgpck.to_string title); false
|
|
|
|
| id -> text.Text.id = id)
|
2021-03-13 19:40:07 +01:00
|
|
|
| _ -> prerr_endline ("Invalid record pattern"); false
|
|
|
|
|
2022-06-18 01:47:52 +02:00
|
|
|
let numof_texts pack = List.length (Msgpck.to_list pack.texts)
|
|
|
|
|
|
|
|
let iteri fn pack =
|
|
|
|
let of_pck i = function Msgpck.List (id::time::title::authors::topics::[]) ->
|
|
|
|
let t = match time with Msgpck.Int i -> Int32.of_int i | Msgpck.Uint32 i -> i
|
|
|
|
| x -> Msgpck.to_uint32 x in
|
|
|
|
let id = to_id id in
|
|
|
|
let title = Msgpck.to_string title in
|
|
|
|
let topics = to_str_list topics in
|
|
|
|
let authors = to_str_list authors in
|
|
|
|
fn i id t title authors topics
|
|
|
|
| _ -> prerr_endline ("\n\nInvalid record structure\n\n")
|
|
|
|
in List.iteri of_pck (Msgpck.to_list pack.texts);
|
- 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
2022-04-01 17:35:56 +02:00
|
|
|
|
|
|
|
(*let pack_filename ?(filename="index.pck") archive =*)
|
|
|
|
(* let dir = Store.KV.find "Export-Dir" archive.File_store.kv in (*raises Not_found*)*)
|
|
|
|
(* dir ^ "/" ^ filename*)
|
|
|
|
|
|
|
|
(*let add archive records =*)
|
|
|
|
(* let fname = pack_filename archive in*)
|
|
|
|
(* let append published (t, _f) = if List.exists (contains t) published then published else to_pack published t in*)
|
|
|
|
(* match list fname with Error e -> prerr_endline e | Ok published_list ->*)
|
|
|
|
(* let header_pack = List.fold_left append published_list records in*)
|
|
|
|
(* let archive = Msgpck.(List [*)
|
|
|
|
(* Int 0; String archive.File_store.name; persons archive.people]) in*)
|
|
|
|
(* File_store.file fname @@ Bytes.to_string*)
|
|
|
|
(* @@ Msgpck.Bytes.to_string (List [archive; fields; Msgpck.List header_pack])*)
|