-- Leo's gemini proxy
-- Connecting to git.thebackupbox.net:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
repo: uritools action: commit revision: path_from: revision_from: da5080c53ce8e9e520187e19eeb907c46607b4f0: path_to: revision_to:
commit da5080c53ce8e9e520187e19eeb907c46607b4f0 Author: epoch <epoch@enzo.thebackupbox.net> Date: Tue Feb 1 03:21:34 2022 +0000 wikipedia search handler added and normal handler updated diff --git a/contrib/Makefile b/contrib/Makefile
--- a/contrib/Makefile +++ b/contrib/Makefile @@ -7,4 +7,5 @@ all: install: install -Dt $(PREFIX)/bin wikipedia-handler + install -Dt $(PREFIX)/bin wikipedia-search-handler install -Dt ~/.config/uristart.conf.d/ wikipedia.uristart.conf diff --git a/contrib/wikipedia-handler b/contrib/wikipedia-handler
--- a/contrib/wikipedia-handler +++ b/contrib/wikipedia-handler @@ -1,10 +1,13 @@ #!/usr/bin/env bash -xmessage "loading page for: $1" page="$(uriescape "$1")" cache_file=~/.cache/wikipedia/"${page}.pdf" mkdir -p ~/.cache/wikipedia ## follow redirects (-L), silent (-s), and no globbing (-g), you can guess what -H does. last_modified="$(rfc7231date "$(stat -c '%Y' "${cache_file}")")" -curl -H "If-Modified-Since: ${last_modified}" -L -s -g "https://en.wikipedia.org/api/rest_v1/page/pdf/${page}" -o "${cache_file}" +if [ "$last_modified" ];then + curl -H "If-Modified-Since: ${last_modified}" -L -s -g "https://en.wikipedia.org/api/rest_v1/page/pdf/${page}" -o "${cache_file}" +else + curl -L -s -g "https://en.wikipedia.org/api/rest_v1/page/pdf/${page}" -o "${cache_file}" +fi fileuri=file://"${cache_file}" uristart "${fileuri}" diff --git a/contrib/wikipedia-search-handler b/contrib/wikipedia-search-handler new file mode 100755 index 0000000000000000000000000000000000000000..72f051fcf8bab5245e61280de807f026d0082847 --- /dev/null +++ b/contrib/wikipedia-search-handler @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +uri="$1" +shortened="$(unshorten.sh "${uri}")" +if [ "${shortened}" ];then + uri="${shortened}" +fi +shortened="$(unshorten.sh "${uri}")" +if [ "${shortened}" ];then + uri="${shortened}" + uristart "$uri" +else + curl -g "$uri" | grep '^<i>The page "<a href="/w/index' | sed 's|<i>\([^<]\)</i>||g' | tr '<' '\n' \ + | grep ^a \ + | cut '-d"' -f2 \ + | sed 's|^/|https://en.wikipedia.org/|g' \ + | text_uri-list +fi
-----END OF PAGE-----
-- Response ended
-- Page fetched on Sun Jun 2 15:34:36 2024