Changed the stash format

This commit is contained in:
Luxferre
2023-03-31 14:35:35 +03:00
parent 429a9ab40c
commit ec0972fd73
2 changed files with 10 additions and 5 deletions
+4 -2
View File
@@ -13,7 +13,7 @@ Improvements over the original Bopher from that post:
- mouse support (where possible)
- smoother rendering and scrolling
- better edge-case stability (e.g. on macOS where using file descriptor 3 actually crashes everything)
- better Gophermap processing according to the RFC
- better Gophermap processing according to the RFC1436
- multi-level navigation history (although you can only go back)
- status bar with currently opened resource name
- ability to accept `gopher://` URLs from the command line
@@ -27,6 +27,8 @@ Improvements over the original Bopher from that post:
- `stty` (to fetch current terminal size in rows and columns)
- `date` (to shape entry timestamps when stashing links)
This Bopher-NG repo also contains a set of useful tools (also written in pure Bash) to ease authoring and publishing your own Gopher content. See the [Bopher Tools README](tools/README-tools.md) for more information.
## Which Bash versions are supported?
Bopher-NG was only tested on Bash 5.1, but should support any version from 4.2 and up.
@@ -75,7 +77,7 @@ No. Besides the ambiguity problem, it will also introduce huge external dependen
## What is the link stash?
Link stash is a viable and interoperable alternative to both bookmarks and clipboard that can be implemented with pure Bash. Essentially, it's an append-only text file at a fixed location (`~/.bopher-links.txt` by default) where the user can instruct Bopher-NG to save the link to the currently viewed resource. For your convenience, links are stashed with a UTC-based timestamp and in the `gopher://` format, so they can be copied from the file later and used in other browsers.
Link stash is a viable and interoperable alternative to both bookmarks and clipboard that can be implemented with pure Bash. Essentially, it's an append-only text file at a fixed location (`~/.bopher-links.txt` by default) where the user can instruct Bopher-NG to save the link to the currently viewed resource. For your convenience, links are stashed with a UTC-based timestamp and in the `gopher://` format, so they can be copied from the file later and used in other browsers. As of now, every stash file line is a valid Gophermap line, so can easily share your findings on the Gopherspace if you need to.
You can override the `BOPHER_LINKSTASH` environment variable to change the location and name of this file if you need to.
+6 -3
View File
@@ -7,7 +7,7 @@
# - mouse support
# - smoother rendering and scrolling
# - better edge-case stability
# - better Gophermap processing according to the RFC
# - better Gophermap processing according to the RFC1436
# - multi-level navigation history (although you can only go back)
# - status bar with currently opened resource name
# - ability to accept gopher:// URLs from the command line
@@ -269,8 +269,11 @@ goback() { # remove the last AM line from history and go there
stashlink() { # stash the link to the currently viewed resource
local gopherlink="$(amtogopher "$CURRENTAM")"
printf '[%s] %s\n' "$(date -u '+%F %T')" "$gopherlink" >> $BOPHER_LINKSTASH
printf 'Stashed %s%s' "$gopherlink" "$ERESET${ESC}[$TERMROWS;0H" # just reset the cursor to the last line
readarray -d $'\t' -t fields < <(printf '%s' "$CURRENTAM") # extract individual fields
local desc="${fields[1]}"
[[ -z "$desc" ]] && desc='Unnamed'
printf '%s [%s] %s - %s\t%s\t%s\t%s\r\n' "${fields[5]}" "$(date -u '+%F %T')" "$desc" "$gopherlink" "${fields[4]}" "${fields[2]}" "${fields[3]}" >> $BOPHER_LINKSTASH
printf 'Stashed %s - %s%s' "$desc" "$gopherlink" "$ERESET${ESC}[$TERMROWS;0H" # just reset the cursor to the last line
}
# Focus and click a link on a Gophermap