source: code/trunk/lib/id.ml@ 27

Last change on this file since 27 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: 957 bytes
Line 
1let random_state = Random.State.make_self_init
2
3(*module UUID = struct*)
4(*type t = Uuidm.t*)
5(*let compare = Uuidm.compare*)
6(*let to_string = Uuidm.to_string*)
7(*let of_string = Uuidm.of_string*)
8(*let to_bytes = Uuidm.to_bytes*)
9(*let of_bytes = Uuidm.of_bytes*)
10(*let generate ?(random_state=random_state ()) = Uuidm.v4_gen random_state*)
11(*let nil = Uuidm.nil*)
12(*end*)
13
14type t = string
15let compare = String.compare
16let nil = ""
17
18let short ?(len) id =
19 let id_len = String.length id in
20 let l = match len with Some l -> l | None -> if id_len = 36 then 8 else 6 in
21 String.sub id 0 (min l id_len)
22
23let generate ?(len=6) ?(seed=random_state ()) () =
24 let b32 i = char_of_int @@
25 if i < 10 then i+48 else
26 if i < 18 then i+87 else
27 if i < 20 then i+88 else
28 if i < 22 then i+89 else
29 if i < 27 then i+90 else
30 if i < 32 then i+91 else
31 (invalid_arg ("id.char" ^ string_of_int i)) in
32 let c _ = b32 (Random.State.int seed 31) in
33 String.init len c
Note: See TracBrowser for help on using the repository browser.