-- Leo's gemini proxy
-- Connecting to git.thebackupbox.net:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
repo: blog action: commit revision: path_from: revision_from: 3026759157ff44592258ff89a7df587f60ed0a09: path_to: revision_to:
commit 3026759157ff44592258ff89a7df587f60ed0a09 Author: epoch <epoch@thebackupbox.net> Date: Tue Feb 22 00:08:41 2022 +0000 oh, that's a long thing diff --git a/uri-plumbing b/uri-plumbing new file mode 100644 index 0000000000000000000000000000000000000000..1687d156923e943cfba60850c7c5693fdbf65393 --- /dev/null +++ b/uri-plumbing @@ -0,0 +1,113 @@ +# the uri plumbing mess + +alt+u is set to run: +## urilaunch +=> https://git.thebackupbox.net/uritools/blob/refs/heads/master:/urilaunch `urilaunch` +which will collect URIs from a handful of places +(uristart history, clipboard, xwindow-uri, hosted bookmarks) +(TODO: this script may be turned into just: `urilist | choose` and do the same thing) +which gets piped into: +## choose +=> https://git.thebackupbox.net/uritools/blob/refs/heads/master:/choose `choose` +choose will use either: +=> https://github.com/sgtpep/pmenu `pmenu` +or: +=> https://tools.suckless.org/dmenu/ `dmenu` +to let the user select which line of stdin (a uri and optional comments after first whitespace) to use. +the output of choose gets used as the arguments of: +## copy_start_nevermind.sh +=> https://git.thebackupbox.net/uritools/blob/refs/heads/master:/copy_start_nevermind.sh `copy_start_nevermind.sh` +(TODO: copy_start_nevermind.sh may be deprecated, as I added in multiple-choice selection to uristart) +copy_start_nevermind.sh uses `choose` again, to let the user choose one of a handful of things to do with the URI. +things like: +uristart, copy, shorten, unshorten, +urititle, QR-image, QR, +run copy_start_nevermind.sh with this URI on a remote computer, and +copy only portions of the URI +I add more things as I think of them. +the remote copy_start_nevermind option currenly uses ssh URIs that do a dumb thing of putting a command in the ssh URI path. +I use this to launch like, VNC on my laptop that is being used as a second screen and is connected to my desktop with: +=> https://github.com/debauchee/barrier `barrier` + +## uristart +=> https://git.thebackupbox.net/uritools/blob/refs/heads/master:/uristart `uristart` +uristart was originally meant to be a replacement for xdg-open, but on my system I have xdg-open replaced with copy_start_nevermind.sh +uristart's first order of business is to call out to: +=> https://git.thebackupbox.net/uritools/blob/refs/heads/master:/urigetline.c `urigetline.c` +with the uri as an argument and a config file on stdin. +This was originally a shell-script, but the format got a bit wonky because of extra matching options that don't require values +this program parses all of the config file lines and outputs either one or all of the matches. +in uristart's case, urigetline is ran with stdin set to the output of another script: +=> https://git.thebackupbox.net/uritools/blob/refs/heads/master:/uristart.conf `uristart.conf` +uristart.conf will cat some files from a few different places, usually ~/.config/uristart.conf +uristart calls out twice to urigetline, once to get only the first matching config line, +and the second time with -a to get all matching config lines. +if those don't match it will (later) let the user pick which line to use for launching the URI. +uristart second order of business is to get SRV records using: +=> https://git.thebackupbox.net/uritools/blob/refs/heads/master:/getsrv `getsrv` +and rewrite the URI using those. +if the SRV records don't provide a port, and a port wasn't explicitly in the URL, it'll set one based on /etc/services and the URI scheme. +if it got this far, it writes the URI to a log file and then starts the next layer of magic +the uri gets piped (with the line as first arugment, and the output of that is eval'd) into: + +## uriprintf +=> https://git.thebackupbox.net/uritools/blob/refs/heads/master:/uriprintf `uriprintf` +this is a small script that will, read a URI from stdin, and output the first argument, but with these replacements: +``` +%s for scheme +%u for username +%k for password +%d for domain +%P for port +%p for path +%q for query_string +%f for fragment_id +%U for the whole URI +``` +it does this using sed, xargs, and: + +## uricut +=> https://git.thebackupbox.net/uritools/blob/refs/heads/master:/uricut.c `uricut` +the first C program I've linked to so far and this is the first program in this repo. +I originally wrote the URI parsing into this file directly, then decided it'd make more sense +to put it into a header file and include it, so the parsing could be used in other C programs easier. +that header is: + +## uri.h +=> https://git.thebackupbox.net/uritools/blob/refs/heads/master:/uri.h uri.h +I waned to do the URI parsing without regular expressions, but it is probably +not a good implementation of a URI parser because it doesn't ever return an error. +that might be another function to write later... a URI validator instead of just a parser. + +## ANYWAY +that got kind of low level. we left off at... uristart evaluating a config line that was uriprintf'd with an input URI. +the format for uristart config lines is like: +=> https://git.thebackupbox.net/uritools/blob/refs/heads/master:/uristart.conf.example `uristart.conf.example` +I'm not going to go through all of the config lines I actually have in my real uristart.conf files because... that'd take kind of forever. +so, I guess for feed URIs because that uses a handful of neat things. + +# TODO: finish putting links into here: + +none of it is in my git repos atm, so I'm just going to spill shit and link to it later. +``` +s feed: curl -si '%U' | message_http +``` + +=> todo:put-a-link-to-message_http +curl -si outputs a whole HTTP response, which, itself is content type of: +=> https://www.iana.org/assignments/media-types/message/http "message/http" +message_http will read the "HTTP/1.1 200 Ok"-like first line into three env vars, +then it calls out to: +=> https://git.thebackupbox.net/shell-daemons/blob/refs/heads/master:/read_headers.c `read_headers` +which was originally meant to parse HTTP request headers server-side, but comes in handy for parsing them client-side too. +it dumps them into the environment and then executes another program that is named in read_header's arguments. +in the case of message_http, the program is message_http itself, but with an argument "stage2" +running message_http with an argument of "stage2" causes message_http to run: +=> https://git.thebackupbox.net/geminiclient/blob/refs/heads/master:/run_stdio_handler_by_mime_type `run_stdio_handler_by_mime_type` +with $HTTP_CONTENT_TYPE as its first argument. +this script is a switch that contains different things to run... on stdio.. based on mime-type... +the script name is kind of descriptive. *blinks* +for application/atom+xml, it runs atom2uri-list that has a single call to xmlstarlet that rewrite the feed into a uri-list +and then it pipes the output of that script to run_stdio_handler_by_mime_type with text/uri-list as the first argument. +and text/uri-list data is handled by piping the list into `choose` and then using the choice as an argument for: +`copy_start_nevermind.sh`
-----END OF PAGE-----
-- Response ended
-- Page fetched on Sun Jun 2 09:27:25 2024