diff --git a/Makefile b/Makefile index 0e962c4..f803e11 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ dist: @dune build @cp _build/default/cli/txt.exe txt.exe @strip txt.exe - @tar czvf "logarion-${OS}-${MACHINE}-${DATE}-${COMMIT}" txt.exe readme.txt + @tar czvf "kosuzu-${OS}-${MACHINE}-${DATE}-${COMMIT}" txt.exe readme.txt @rm txt.exe install: @dune install --prefix ${PREFIX} diff --git a/cli/authors.ml b/cli/authors.ml index 32adcf4..aee5f5d 100644 --- a/cli/authors.ml +++ b/cli/authors.ml @@ -6,7 +6,7 @@ let authors r topics_opt = let s = File_store.fold ~r ~predicate author_union Person.Set.empty in Person.Set.iter (fun x -> print_endline (Person.to_string x)) s -open Cmdliner +open Ocmd let term = let recurse = Arg.(value & flag & info ["R"] ~doc:"include texts in subdirectories too") in diff --git a/cli/convert.ml b/cli/convert.ml index 0189e06..fca8584 100644 --- a/cli/convert.ml +++ b/cli/convert.ml @@ -76,7 +76,7 @@ let at_path types noindex path = match path with ) | path -> Printf.eprintf "Path doesn't exist: %s" path -open Cmdliner +open Ocmd let term = let path = Arg.(value & pos 0 string "" & info [] ~docv:"path" ~doc:"Text file or directory to convert. If directory is provided, it must contain an index.pck (see: txt index)") in diff --git a/cli/edit.ml b/cli/edit.ml index c504e36..68c9650 100644 --- a/cli/edit.ml +++ b/cli/edit.ml @@ -1,4 +1,4 @@ -open Cmdliner +open Ocmd let term = let id = Arg.(value & pos 0 string "" & info [] ~docv:"text ID") in let recurse = Arg.(value & flag & info ["R"] ~doc:"recurse, include subdirs") in diff --git a/cli/file.ml b/cli/file.ml index ab2ba0c..cab75e0 100644 --- a/cli/file.ml +++ b/cli/file.ml @@ -14,7 +14,7 @@ let unfile files = with Unix.(Unix_error(ENOENT,_,_))-> () in List.iter (fun d -> List.iter (unlink d) files) dirs -open Cmdliner +open Ocmd let term = let files = Arg.(value & pos_all string [] & info [] ~docv:"text filenames and subdirectories") in diff --git a/cli/index.ml b/cli/index.ml index 803d008..3348d27 100644 --- a/cli/index.ml +++ b/cli/index.ml @@ -67,7 +67,7 @@ let load dir = let index_path = Filename.concat dir "index.pck" in index { dir; index_path; pck = Header_pack.of_kv kv } -open Cmdliner +open Ocmd let term = let print= Arg.(value & flag & info ["print"] ~doc:"print info") in let title= Arg.(value & opt ~vopt:(Some "") (some string) None & info ["t"; "title"] diff --git a/cli/last.ml b/cli/last.ml index e766589..700df24 100644 --- a/cli/last.ml +++ b/cli/last.ml @@ -20,7 +20,7 @@ let last search_mine = | None -> () | Some (_, f) -> List.iter print_endline f -open Cmdliner +open Ocmd let term = let mine = Arg.(value & flag & info ["mine"] ~doc:"last text authored by me") in Term.(const last $ mine), diff --git a/cli/listing.ml b/cli/listing.ml index 066b109..321c175 100644 --- a/cli/listing.ml +++ b/cli/listing.ml @@ -19,7 +19,7 @@ let listing r order_opt reverse_opt number_opt paths_opt authors_opt topics_opt | Some number -> FS.iter ~r ~dir ~predicate ~order ~number list_text | None -> FS.iter ~r ~dir ~predicate ~order list_text -open Cmdliner +open Ocmd let term = let recurse = Arg.(value & flag & info ["R"] ~doc:"recurse, include subdirs") in let reverse = Arg.(value & flag & info ["r"] ~doc:"reverse order") in diff --git a/cli/new.ml b/cli/new.ml index aeccba6..8a20ac9 100644 --- a/cli/new.ml +++ b/cli/new.ml @@ -1,5 +1,5 @@ open Logarion -open Cmdliner +open Ocmd let new_txt title topics_opt interactive = let kv = Logarion.File_store.of_kv_file () in diff --git a/cli/peers.ml b/cli/peers.ml index 7a18212..4e30dcf 100644 --- a/cli/peers.ml +++ b/cli/peers.ml @@ -28,7 +28,7 @@ let peers = function Printf.printf "Peers in %s\n" Logarion.Peers.text_dir; Logarion.Peers.fold print_peer () -open Cmdliner +open Ocmd let term = let remove = Arg.(value & opt (some string) None & info ["remove"] ~docv:"repository ID" ~doc:"remove repository texts & from future pulling") in diff --git a/cli/pull.ml b/cli/pull.ml index 44c0ddf..a49e958 100644 --- a/cli/pull.ml +++ b/cli/pull.ml @@ -138,7 +138,7 @@ let pull_list auths topics = let pull url auths topics = match url with | "" -> pull_list auths topics | x -> ignore (pull_index x auths topics) -open Cmdliner +open Ocmd let term = let authors = Arg.(value & opt (some string) None & info ["a"; "authors"] ~docv:"comma-separated names" ~doc:"filter by authors") in diff --git a/cli/read.ml b/cli/read.ml index 7f5d5b7..def70f9 100644 --- a/cli/read.ml +++ b/cli/read.ml @@ -1,6 +1,6 @@ open Logarion -open Cmdliner +open Ocmd let term = let id = Arg.(value & pos 0 string "" & info [] ~docv:"text ID") in let recurse = Arg.(value & flag & info ["R"] ~doc:"recurse, include subdirs") in diff --git a/cli/recent.ml b/cli/recent.ml index a59767d..effb0a7 100644 --- a/cli/recent.ml +++ b/cli/recent.ml @@ -2,7 +2,7 @@ open Logarion module FS = File_store module A = Archive -open Cmdliner +open Ocmd let term = let recurse = Arg.(value & flag & info ["R"] ~doc:"recurse, include subdirs") in let reverse = Arg.(value & flag & info ["r"] ~doc:"reverse order") in diff --git a/cli/topics.ml b/cli/topics.ml index 44af03b..d8caf9d 100644 --- a/cli/topics.ml +++ b/cli/topics.ml @@ -6,7 +6,7 @@ let topics r authors_opt = let s = File_store.fold ~r ~predicate topic_union String_set.empty in print_endline @@ String_set.to_string s -open Cmdliner +open Ocmd let term = let recurse = Arg.(value & flag & info ["R"] ~doc:"include texts in subdirectories") in diff --git a/cli/txt.ml b/cli/txt.ml index d4f74ba..01c7341 100644 --- a/cli/txt.ml +++ b/cli/txt.ml @@ -1,10 +1,8 @@ -let version = "1.3.2" - -open Cmdliner +open Ocmd let default_cmd = let doc = "Discover, collect & exchange texts" in let man = [ `S "CONTACT"; `P "" ] in - Term.(ret (const (`Help (`Pager, None)))), Term.info "txt" ~version ~doc ~man + Term.(ret (const (`Help (`Pager, None)))), Term.info "txt" ~version:"%%VERSION%%" ~doc ~man let () = match Term.eval_choice default_cmd [ Authors.term; diff --git a/doc/3sqd84.txt b/doc/3sqd84.txt new file mode 100644 index 0000000..a68472f --- /dev/null +++ b/doc/3sqd84.txt @@ -0,0 +1,11 @@ +ID: 3sqd84 +Date: 2022-11-06T13:01:19Z +Title: Exploring & pulling texts from Logarion repositories +Authors: orbifx +Topics: Logarion + +Logarion repositories are collections of text files, accompanied by a special index file. These collections can exist on any server and accessed by any transport protocol. Logarion's client currently supports a plethora of protocols, HTTP, FTP, Gopher to name a few examples. + +A remote repository can be registered and texts copied locally. To add a new remote run: `txt pull `, where is the address of the remote repository. The program will connect to the server, copy the `index.pck` file and use it to download each text file. It will not redownload previous texts, unless their Date or Date-Edited dates are newer than the previous ones. + +The text files are by default downloaded to `.local/share/texts/peers/`. A new directory is created for each peer's unique id and the index & texts are stored in it. Running `txt pull` with no URL, will refetch indices from all previously pulled repositories, and new text files will be downloaded automatically. diff --git a/doc/9egbae.txt b/doc/9egbae.txt new file mode 100644 index 0000000..f38edab --- /dev/null +++ b/doc/9egbae.txt @@ -0,0 +1,15 @@ +ID: 9egbae +Date: 2023-06-17T23:27:44Z +Title: Building from source +Authors: Izuru Yakumo +Topics: Logarion + +Requirements: +* git +* ocaml (>=4.13) + +1. git clone git://git.chaotic.ninja/yakumo_izuru/logarion +2. cd logarion +3. git submodule update --init +4. make deps +5. make tgz diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..82069d7 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,23 @@ +all: clean build + +build: index generate + +clean: + find htm -type f -name "*.html" -print -delete + find htm -type f -name "*.htm" -print -delete + find . -type f -name "*.atom" -print -delete +copy-index: index + cp index.pck htm +generate: relink copy-index + txt convert --type=htm htm +index: + txt index . +link: + txt file *.txt htm +delink: + rm htm/*.txt +serve: + darkhttpd htm +upload: + rsync -acv --del htm/ webdev@chaotic.ninja:/var/www/logarion +relink: delink link diff --git a/doc/d41e68.txt b/doc/d41e68.txt new file mode 100644 index 0000000..e1dfb75 --- /dev/null +++ b/doc/d41e68.txt @@ -0,0 +1,26 @@ +ID: d41e68 +Date: 2023-10-18T18:45:33+00:00 +Title: Header format +Authors: orbifx +Topics: Logarion + +ID: Unique identifier +Date: ISO8601 date of creation +Topics: Comma seperated list of topic names & phrases +Title: A title for the text, ideally less than 70 characters +Authors: List of name with optional set of
+Date-edited: ISO8601, use only when text edited +References: list of text ID links + +A blank line must follow the last header field. + + +Example + +ID: 11bcd +Title: A Logarion exemplar header +Authors: John Doe +Date: 1970-11-06T12:29:50-00:00 +Topic: Logarion, examples + +Hello world! diff --git a/doc/footer.html b/doc/footer.html new file mode 100644 index 0000000..0024d39 --- /dev/null +++ b/doc/footer.html @@ -0,0 +1,4 @@ +
+

+Source code +

diff --git a/doc/h1a9tg.txt b/doc/h1a9tg.txt new file mode 100644 index 0000000..cd830fc --- /dev/null +++ b/doc/h1a9tg.txt @@ -0,0 +1,17 @@ +ID: h1a9tg +Date: 2022-11-20T13:28:57Z +Authors: orbifx +Title: Txt uniform resource names +Topics: Logarion + +Logarion texts are transport agnostic. URIs should therefore avoid using URLs and use URNs instead. Some definitions of Uniform Resource: +- Locator (URL) +- Identifier (URI) +- Name (URN) + + +Links enclosed in angled brackets <> of the format: + + urn:txtid:abcdef + +where `abcdef` is the id of the text are understood by `txt` and handled accordingly. For example when converting to HTML or Gemini, the URNs are converted to relative URLs which browsers can understand. diff --git a/doc/header.html b/doc/header.html new file mode 100644 index 0000000..74e4f15 --- /dev/null +++ b/doc/header.html @@ -0,0 +1,2 @@ +

Logarion

+

discover, collect & exchange plain text files

diff --git a/doc/htm/index.pck b/doc/htm/index.pck new file mode 100644 index 0000000..48d3683 Binary files /dev/null and b/doc/htm/index.pck differ diff --git a/doc/htm/main.css b/doc/htm/main.css new file mode 100644 index 0000000..b1ccb62 --- /dev/null +++ b/doc/htm/main.css @@ -0,0 +1,8 @@ +body{color:#111;background:#faeed6;margin:auto;padding:1ch;max-width:80ch} +@media(min-resolution:130dpi){body{font-size:1.5em}} +article>header{margin:auto;padding:1ch} +dt{float:left;text-align:right;padding-right:1ch;min-width:8ch;opacity:0.4;clear:left} +:target::before{content:"☞"} +body>h1{font-family:cursive} +h1,h2{color:#ff6600} +h3,h4{color:#333} diff --git a/doc/hvhhwf.txt b/doc/hvhhwf.txt new file mode 100644 index 0000000..a91da61 --- /dev/null +++ b/doc/hvhhwf.txt @@ -0,0 +1,77 @@ +ID: hvhhwf +Date: 2022-11-06T13:19:57Z +Title: Creating texts & publishing on the net +Authors: orbifx +Topics: Logarion + +# New + +To create new text files, use "txt new". For example: + txt new "Hello world" +It's important to enclose the title with quotation marks if it contains spaces. The command will return the filename of the new text. The filename starts with a part of the ID and the title of the text. Use the file name to open it with your text editor. + +Alternatively add the -i flag to have the text editor launched to edit the newly created file: + txt new -i "Some title" + +Text files will be stored in either: +1. The directory pointed at by txtdir if defined +2. $HOME/.local/share/texts, if directory exists +3. The current working directory, if all else fails + +The simplest approach is to put all texts in the local-share directory and override that on occasion with +$txtdir. For example: + txtdir=. txt new "Hello world" + + +# Publish + +Texts created with "new" are treated as personal until published. To publish a text, use `txt publish [id]` where [id] is the text of the text to publish. Publication requires a `txt.conf` file which must exist in either: +1. The current working directory +2. $HOME/.config/txt/txt.conf + +With the above in place, `txt publish [id]` will add the text file with [id] in the publication-directory and reproduce the `index.pck` in that directory. If Pubdir is not defined in `txt.conf` then the environmental variable `txtpubdir` is used. If that is also undefined, the current working directory is used as a publication directory. + +Logarion is protocol agnostic, so publish looks for the existence of directories to copy the files, ready for publication. At the time of writing the three directories are `public_html`, `public_gemini` and `public_gopher`. For each of these directories, `txt publish [id]` will copy the text file, revise the `index.pck` and also convert produce converted files, such .htm for public_html. + +## txt.conf keys + +Id: + A random, unique, alphanumeric string for distinguishing the repository (atleast 6 characters of Crockford's Base32 recommended) + +Title: + a human-friendly title + +Authors: + comma seperated list of names and, optionally, addresses + +Topics: + topics the repository aims to cover + +Locations: + list of URIs the repositories can be accessed + +Peers: + list of peer URIs + +Pubdir: + (optional) the directory that contains publication subdirectories + + +## HTML + +There are some special settings for HTML publication: + +HTM-style: + path to a CSS style. It will be inserted in every .htm file. To link to a single CSS consider using `@import` + +HTM-header: + path to a file, inserted in every .htm file, right after the body tag + +HTM-footer: + path to a file, inserted in every .htm file, right before the body tag + +HTM-index: + if defined, determines the filename for the index files. Left undefined, defaults to `index.html` + +HTM-feed: + if defined, this will overrite the feed URI used in HTML files. If left undefined the default `feed.atom` is used diff --git a/doc/index.pck b/doc/index.pck new file mode 100644 index 0000000..48d3683 Binary files /dev/null and b/doc/index.pck differ diff --git a/doc/main.css b/doc/main.css new file mode 100644 index 0000000..b1ccb62 --- /dev/null +++ b/doc/main.css @@ -0,0 +1,8 @@ +body{color:#111;background:#faeed6;margin:auto;padding:1ch;max-width:80ch} +@media(min-resolution:130dpi){body{font-size:1.5em}} +article>header{margin:auto;padding:1ch} +dt{float:left;text-align:right;padding-right:1ch;min-width:8ch;opacity:0.4;clear:left} +:target::before{content:"☞"} +body>h1{font-family:cursive} +h1,h2{color:#ff6600} +h3,h4{color:#333} diff --git a/doc/txt.conf b/doc/txt.conf new file mode 100644 index 0000000..3f6f5ef --- /dev/null +++ b/doc/txt.conf @@ -0,0 +1,8 @@ +Id: 17f4e3 +Title: Logarion +Authors: orbifx , Izuru Yakumo +HTM-style: main.css +HTM-header: header.html +HTM-footer: footer.html +HTM-feed: +Topics: Logarion diff --git a/dune-project b/dune-project index 454b338..fa51771 100644 --- a/dune-project +++ b/dune-project @@ -1,6 +1,6 @@ (lang dune 2.0) (name logarion) -(version 1.3.2) +(version 1.4.0) (license EUPL-1.2) (authors "orbifx ") (bug_reports "mailto:logarion-dev@chaotic.ninja") @@ -13,4 +13,4 @@ (package (name logarion) (synopsis "Texts archival and exchange") - (depends (cmdliner (<= 1.0.4)) msgpck ocurl)) + (depends ocaml dune ocurl msgpck cmdliner)) diff --git a/logarion.opam b/logarion.opam index 4b84423..1590a0c 100644 --- a/logarion.opam +++ b/logarion.opam @@ -7,12 +7,7 @@ authors: ["orbifx "] license: "EUPL-1.2" homepage: "https://suzunaan.chaotic.ninja/logarion/" bug-reports: "mailto:logarion-dev@chaotic.ninja" -depends: [ - "dune" {>= "2.0"} - "cmdliner" {<= "1.0.4"} - "msgpck" - "ocurl" -] +depends: ["ocaml" "dune" "ocurl" "msgpck" "ocmd"] build: [ ["dune" "subst"] {pinned} [