: gemini-print ( url body meta -- )
f pre [
PAGE delete-all
- gemini-charset decode string-lines [
+ gemini-charset decode split-lines [
{ [ pre get not ] [ "=>" ?head ] } 0&& [
swap gemini-link present over 2array PAGE push
PAGE length swap "[%s] %s\n" printf
: gemini-go ( args -- )
present [ DEFAULT-URL ] when-empty
- { [ "://" over subseq? ] [ "gemini://" head? ] } 1||
+ { [ dup "://" subseq-of? ] [ "gemini://" head? ] } 1||
[ "gemini://" prepend ] unless
dup "gemini://" head? [
[ add-history ] [ add-stack ] [ gemini-get ] tri
] [ open-url ] if ;
: gemini-reload ( -- )
- HISTORY ?last gemini-go ;
+ URL ?first gemini-go ;
: gemini-back ( -- )
-1 stack-url [ gemini-get ] when* ;
: gemini-up ( -- )
URL ?first [
>url f >>query f >>anchor
- [ "/" ?tail drop "/" split1-last drop "/" append ] change-path
+ [ dup "/" tail? "./../" "./" ? url-append-path ] change-path
gemini-go
] when* ;
: gemini-less ( -- )
- "gemini.txt" temp-file dup exists? [
+ "gemini.txt" temp-file dup file-exists? [
"less" swap 2array try-process
] [ drop ] if ;
URL ?first [ >url "/" >>path gemini-go ] when* ;
: gemini-shell ( args -- )
- "|" split "gemini.txt" temp-file dup exists? [
+ "|" split "gemini.txt" temp-file dup file-exists? [
"cat" swap 2array prefix run-pipeline drop
] [ 2drop ] if ;