diff options
author | Case Duckworth | 2020-06-03 23:22:55 -0500 |
---|---|---|
committer | Case Duckworth | 2020-06-03 23:22:55 -0500 |
commit | b73e5bf3e08885a0c2c5c2d0daa5d489800fd112 (patch) | |
tree | 70b7dc48fc5316864ddda46e2a08beb29cc31996 | |
parent | Update docs (diff) | |
download | bollux-b73e5bf3e08885a0c2c5c2d0daa5d489800fd112.tar.gz bollux-b73e5bf3e08885a0c2c5c2d0daa5d489800fd112.zip |
Version bump
-rw-r--r-- | README.md | 2 | ||||
-rwxr-xr-x | bollux | 58 | ||||
-rw-r--r-- | bollux.1 | 2 | ||||
-rw-r--r-- | bollux.conf.5 | 2 |
4 files changed, 29 insertions, 35 deletions
diff --git a/README.md b/README.md index 07b4252..03131b3 100644 --- a/README.md +++ b/README.md | |||
@@ -49,7 +49,7 @@ $ cd bollux | |||
49 | ## Alternative | 49 | ## Alternative |
50 | 50 | ||
51 | ``` | 51 | ``` |
52 | $ curl -fLo bollux https://git.sr.ht/~acdw/bollux/blob/0.2.2/bollux | 52 | $ curl -fLo bollux https://git.sr.ht/~acdw/bollux/blob/0.3.0/bollux |
53 | $ chmod +x bollux | 53 | $ chmod +x bollux |
54 | $ ./bollux | 54 | $ ./bollux |
55 | ``` | 55 | ``` |
diff --git a/bollux b/bollux index b6fb2a5..c8a6175 100755 --- a/bollux +++ b/bollux | |||
@@ -2,11 +2,11 @@ | |||
2 | # bollux: a bash gemini client | 2 | # bollux: a bash gemini client |
3 | # Author: Case Duckworth | 3 | # Author: Case Duckworth |
4 | # License: MIT | 4 | # License: MIT |
5 | # Version: 0.2.2 | 5 | # Version: 0.3 |
6 | 6 | ||
7 | # Program information | 7 | # Program information |
8 | PRGN="${0##*/}" | 8 | PRGN="${0##*/}" |
9 | VRSN=0.2.2 | 9 | VRSN=0.3 |
10 | # State | 10 | # State |
11 | REDIRECTS=0 | 11 | REDIRECTS=0 |
12 | set -f | 12 | set -f |
@@ -49,11 +49,11 @@ trim() { | |||
49 | log() { | 49 | log() { |
50 | [[ "$BOLLUX_LOGLEVEL" == QUIET ]] && return | 50 | [[ "$BOLLUX_LOGLEVEL" == QUIET ]] && return |
51 | case "$1" in | 51 | case "$1" in |
52 | d* | D*) # debug | 52 | [dD]*) # debug |
53 | [[ "$BOLLUX_LOGLEVEL" == DEBUG ]] || return | 53 | [[ "$BOLLUX_LOGLEVEL" == DEBUG ]] || return |
54 | fmt=34 | 54 | fmt=34 |
55 | ;; | 55 | ;; |
56 | e* | E*) # error | 56 | [eE]*) # error |
57 | fmt=31 | 57 | fmt=31 |
58 | ;; | 58 | ;; |
59 | *) fmt=1 ;; | 59 | *) fmt=1 ;; |
@@ -68,7 +68,7 @@ bollux() { | |||
68 | run bollux_args "$@" | 68 | run bollux_args "$@" |
69 | run history_init | 69 | run history_init |
70 | 70 | ||
71 | if [[ ! "${BOLLUX_URL:+isset}" ]]; then | 71 | if [[ ! "${BOLLUX_URL:+x}" ]]; then |
72 | run prompt GO BOLLUX_URL | 72 | run prompt GO BOLLUX_URL |
73 | fi | 73 | fi |
74 | 74 | ||
@@ -173,6 +173,7 @@ blastoff() { # load a url | |||
173 | log d "URL='$URL' server='$server'" | 173 | log d "URL='$URL' server='$server'" |
174 | 174 | ||
175 | run request_url "$server" "$BOLLUX_PORT" "$URL" | | 175 | run request_url "$server" "$BOLLUX_PORT" "$URL" | |
176 | run normalize_crlf | | ||
176 | run handle_response "$URL" | 177 | run handle_response "$URL" |
177 | } | 178 | } |
178 | 179 | ||
@@ -318,29 +319,22 @@ request_url() { | |||
318 | ssl_cmd_tls1_3=("${ssl_cmd[@]}" -tls1_3) | 319 | ssl_cmd_tls1_3=("${ssl_cmd[@]}" -tls1_3) |
319 | 320 | ||
320 | # always try to connect with TLS v1.3 first | 321 | # always try to connect with TLS v1.3 first |
321 | run "${ssl_cmd_tls1_3[@]}" <<<"$url" 2>/dev/null || run "${ssl_cmd_tls1_2[@]}" <<<"$url" 2>/dev/null | 322 | run "${ssl_cmd_tls1_3[@]}" <<<"$url" 2>/dev/null || |
323 | run "${ssl_cmd_tls1_2[@]}" <<<"$url" 2>/dev/null | ||
322 | } | 324 | } |
323 | 325 | ||
324 | handle_response() { | 326 | handle_response() { |
325 | local URL="$1" code meta | 327 | local URL="$1" code meta |
326 | 328 | ||
327 | while read -r -d $'\r' hdr; do | 329 | read -r code meta |
328 | code="$(gawk '{print $1}' <<<"$hdr")" | 330 | log d "[$code] $meta" |
329 | meta="$( | ||
330 | gawk '{for(i=2;i<=NF;i++)printf "%s ",$i;printf "\n"}' <<<"$hdr" | ||
331 | )" | ||
332 | break | ||
333 | done | ||
334 | |||
335 | log x "[$code] $meta" | ||
336 | 331 | ||
337 | case "$code" in | 332 | case "$code" in |
338 | 1*) | 333 | 1*) |
339 | REDIRECTS=0 | 334 | REDIRECTS=0 |
340 | run history_append "$URL" "$meta" | 335 | run history_append "$URL" "$meta" |
341 | run prompt "$meta" QUERY | 336 | run prompt "$meta" |
342 | # shellcheck disable=2153 | 337 | run blastoff "?$REPLY" |
343 | run blastoff "?$QUERY" | ||
344 | ;; | 338 | ;; |
345 | 2*) | 339 | 2*) |
346 | REDIRECTS=0 | 340 | REDIRECTS=0 |
@@ -370,15 +364,15 @@ handle_response() { | |||
370 | ;; | 364 | ;; |
371 | 4*) | 365 | 4*) |
372 | REDIRECTS=0 | 366 | REDIRECTS=0 |
373 | die "$((100 + code))" "$code" | 367 | die "$((100 + code))" "Temporary error: $code" |
374 | ;; | 368 | ;; |
375 | 5*) | 369 | 5*) |
376 | REDIRECTS=0 | 370 | REDIRECTS=0 |
377 | die "$((100 + code))" "$code" | 371 | die "$((100 + code))" "Permanent error: $code" |
378 | ;; | 372 | ;; |
379 | 6*) | 373 | 6*) |
380 | REDIRECTS=0 | 374 | REDIRECTS=0 |
381 | die "$((100 + code))" "$code" | 375 | die "$((100 + code))" "Certificate error: $code" |
382 | ;; | 376 | ;; |
383 | *) | 377 | *) |
384 | [[ -z "${code-}" ]] && die 100 "Empty response code." | 378 | [[ -z "${code-}" ]] && die 100 "Empty response code." |
@@ -390,7 +384,7 @@ handle_response() { | |||
390 | display() { | 384 | display() { |
391 | # split header line | 385 | # split header line |
392 | local -a hdr | 386 | local -a hdr |
393 | local i | 387 | local i mime charset h |
394 | IFS=$'\n' read -d "" -ra hdr <<<"${1//;/$'\n'}" | 388 | IFS=$'\n' read -d "" -ra hdr <<<"${1//;/$'\n'}" |
395 | 389 | ||
396 | mime="$(trim "${hdr[0],,}")" | 390 | mime="$(trim "${hdr[0],,}")" |
@@ -398,6 +392,7 @@ display() { | |||
398 | h="$(trim "${hdr[$i]}")" | 392 | h="$(trim "${hdr[$i]}")" |
399 | case "$h" in | 393 | case "$h" in |
400 | charset=*) charset="${h#charset=}" ;; | 394 | charset=*) charset="${h#charset=}" ;; |
395 | # add mime-extensions here | ||
401 | esac | 396 | esac |
402 | done | 397 | done |
403 | 398 | ||
@@ -423,8 +418,7 @@ display() { | |||
423 | if declare -F | grep -q "$submime"; then | 418 | if declare -F | grep -q "$submime"; then |
424 | log d "typeset_$submime" | 419 | log d "typeset_$submime" |
425 | { | 420 | { |
426 | normalize_crlf | | 421 | iconv -f "${charset^^}" -t "UTF-8" | |
427 | iconv -f "${charset^^}" -t "UTF-8" | | ||
428 | tee "$BOLLUX_PAGESRC" | | 422 | tee "$BOLLUX_PAGESRC" | |
429 | run "typeset_$submime" | | 423 | run "typeset_$submime" | |
430 | run "${less_cmd[@]}" && bollux_quit | 424 | run "${less_cmd[@]}" && bollux_quit |
@@ -432,8 +426,7 @@ display() { | |||
432 | else | 426 | else |
433 | log "cat" | 427 | log "cat" |
434 | { | 428 | { |
435 | normalize_crlf | | 429 | iconv -f "${charset^^}" -t "UTF-8" | |
436 | iconv -f "${charset^^}" -t "UTF-8" | | ||
437 | tee "$BOLLUX_PAGESRC" | | 430 | tee "$BOLLUX_PAGESRC" | |
438 | run "${less_cmd[@]}" && bollux_quit | 431 | run "${less_cmd[@]}" && bollux_quit |
439 | } || run handle_keypress "$?" | 432 | } || run handle_keypress "$?" |
@@ -495,12 +488,12 @@ typeset_gemini() { | |||
495 | fi | 488 | fi |
496 | continue | 489 | continue |
497 | ;; | 490 | ;; |
498 | =\>*) | 491 | '=>'*) |
499 | : $((ln += 1)) | 492 | : $((ln += 1)) |
500 | gemini_link "$REPLY" $pre "$ln" | 493 | gemini_link "$REPLY" $pre "$ln" |
501 | ;; | 494 | ;; |
502 | \#*) gemini_header "$REPLY" $pre ;; | 495 | '#'*) gemini_header "$REPLY" $pre ;; |
503 | \**) | 496 | '*'*) |
504 | if [[ "$REPLY" =~ ^\*[[:space:]]+ ]]; then | 497 | if [[ "$REPLY" =~ ^\*[[:space:]]+ ]]; then |
505 | gemini_list "$REPLY" $pre | 498 | gemini_list "$REPLY" $pre |
506 | else | 499 | else |
@@ -643,18 +636,19 @@ handle_keypress() { | |||
643 | 636 | ||
644 | select_url() { | 637 | select_url() { |
645 | run mapfile -t < <(extract_links <"$1") | 638 | run mapfile -t < <(extract_links <"$1") |
639 | PS3="OPEN> " | ||
646 | select u in "${MAPFILE[@]}"; do | 640 | select u in "${MAPFILE[@]}"; do |
647 | case "$REPLY" in | 641 | case "$REPLY" in |
648 | q) bollux_quit ;; | 642 | q) bollux_quit ;; |
649 | esac | 643 | esac |
650 | run blastoff "$(gawk '{print $1}' <<<"$u")" && break | 644 | run blastoff "${u%%[[:space:]]*}" && break |
651 | done </dev/tty | 645 | done </dev/tty |
652 | } | 646 | } |
653 | 647 | ||
654 | extract_links() { | 648 | extract_links() { |
655 | local url alt | 649 | local url alt |
656 | while read -r line; do | 650 | while read -r; do |
657 | if [[ "$line" =~ ^=\>[[:space:]]*([^[:space:]]+)([[:space:]]+(.*))?$ ]]; then | 651 | if [[ "$REPLY" =~ ^=\>[[:space:]]*([^[:space:]]+)([[:space:]]+(.*))?$ ]]; then |
658 | url="${BASH_REMATCH[1]}" | 652 | url="${BASH_REMATCH[1]}" |
659 | alt="${BASH_REMATCH[3]}" | 653 | alt="${BASH_REMATCH[3]}" |
660 | 654 | ||
diff --git a/bollux.1 b/bollux.1 index 08a8d82..4b6948d 100644 --- a/bollux.1 +++ b/bollux.1 | |||
@@ -1,4 +1,4 @@ | |||
1 | .TH bollux 1 0.2.2 | 1 | .TH bollux 1 0.3.0 |
2 | .SH NAME | 2 | .SH NAME |
3 | bollux \- gemini protocol browser written in bash(1) | 3 | bollux \- gemini protocol browser written in bash(1) |
4 | .SH SYNOPSIS | 4 | .SH SYNOPSIS |
diff --git a/bollux.conf.5 b/bollux.conf.5 index eecaff0..9cee1b5 100644 --- a/bollux.conf.5 +++ b/bollux.conf.5 | |||
@@ -1,4 +1,4 @@ | |||
1 | .TH bollux.conf 5 0.2.2 | 1 | .TH bollux.conf 5 0.3.0 |
2 | .SH NAME | 2 | .SH NAME |
3 | .B bollux.conf | 3 | .B bollux.conf |
4 | \- configuration file for | 4 | \- configuration file for |