commit aa232d73f6e55c8818bf9b9946f6de52a1cc94c5
parent 6883b37df0b022aa08640c5a125c0ff8075043d7
Author: Alex Balgavy <alex@balgavy.eu>
Date: Mon, 11 Jan 2021 12:05:10 +0100
Readability: switch to Go
Diffstat:
6 files changed, 31 insertions(+), 23 deletions(-)
diff --git a/.gitmodules b/.gitmodules
@@ -56,3 +56,6 @@
[submodule "tools/pipe-viewer"]
path = tools/pipe-viewer
url = https://github.com/trizen/pipe-viewer.git
+[submodule "tools/go-readability"]
+ path = tools/go-readability
+ url = https://github.com/go-shiori/go-readability
diff --git a/scripts/linkhandler b/scripts/linkhandler
@@ -24,7 +24,7 @@ case "$1" in
w3m -config ~/.config/w3m/config "$1"
;;
http://*|https://*) # everything else gets filtered through readability
- python3 -W ignore -m readability.readability -u "$1" | w3m -config ~/.config/w3m/config -T text/html
+ go-readability "$1" | w3m -config ~/.config/w3m/config -T text/html
;;
*)
if [ -f "$1" ]; then "$EDITOR" "$1"
diff --git a/shell/env b/shell/env
@@ -22,6 +22,7 @@ export LC_MONETARY="en_US.UTF-8"
export LC_NUMERIC="en_US.UTF-8"
export LC_TIME="en_US.UTF-8"
+export WWW_HOME="https://search.alex.balgavy.eu"
# Icons for lf {{{1
export LF_ICONS="\
di=:\
@@ -186,18 +187,21 @@ ex=:\
"
# Force use of XDG Base Directory {{{1
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
-alias irssi='irssi --home=$HOME/.config/irssi'
-alias tmux='tmux -f $HOME/.config/tmux/tmux.conf'
-alias w3m='w3m -config $HOME/.config/w3m/config'
-export JUPYTER_CONFIG_DIR="$HOME/.config/jupyter"
-export BUNDLE_USER_HOME="$HOME/.config/bundle"
-export BUNDLE_USER_CACHE="$HOME/.cache/bundle"
-export _Z_DATA="$HOME/.cache/z/z-data"
-export HTTPIE_CONFIG_DIR="$HOME/.config/httpie"
-export CABAL_DIR="$HOME/.config/cabal"
-export GHCUP_INSTALL_BASE_PREFIX="$HOME/.config"
-export ZDOTDIR="$HOME/.config/zsh"
-export GEM_HOME="$HOME/.local/share/gems"
-export NOTMUCH_CONFIG="$HOME/.config/notmuch/config"
-export GNUPGHOME="$HOME/.config/gnupg"
-export R_PROFILE_USER="$HOME/.config/R/Rprofile"
+export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
+export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
+alias irssi='irssi --home=$XDG_CONFIG_HOME/irssi'
+alias tmux='tmux -f $XDG_CONFIG_HOME/tmux/tmux.conf'
+alias w3m='w3m -config $XDG_CONFIG_HOME/w3m/config'
+export GOPATH="$XDG_DATA_HOME"/go
+export JUPYTER_CONFIG_DIR="$XDG_CONFIG_HOME/jupyter"
+export BUNDLE_USER_HOME="$XDG_CONFIG_HOME/bundle"
+export BUNDLE_USER_CACHE="$XDG_CACHE_HOME/bundle"
+export _Z_DATA="$XDG_CACHE_HOME/z/z-data"
+export HTTPIE_CONFIG_DIR="$XDG_CONFIG_HOME/httpie"
+export CABAL_DIR="$XDG_CONFIG_HOME/cabal"
+export GHCUP_INSTALL_BASE_PREFIX="$XDG_CONFIG_HOME"
+export ZDOTDIR="$XDG_CONFIG_HOME/zsh"
+export GEM_HOME="$XDG_DATA_HOME/gems"
+export NOTMUCH_CONFIG="$XDG_CONFIG_HOME/notmuch/config"
+export GNUPGHOME="$XDG_CONFIG_HOME/gnupg"
+export R_PROFILE_USER="$XDG_CONFIG_HOME/R/Rprofile"
diff --git a/shell/paths b/shell/paths
@@ -1,16 +1,16 @@
#!/bin/sh
[ -x /usr/libexec/path_helper ] && unset PATH && eval "$(/usr/libexec/path_helper -s)"
[ -d "$HOME/.local/bin" ] || [ -L "$HOME/.local/bin" ] && [ -n "${PATH##*"$HOME/.local/bin"*}" ] && PATH="$HOME/.local/bin:$PATH"
-[ -d "$HOME/go/bin" ] || [ -L "$HOME/go/bin" ] && [ -n "${PATH##*"$HOME/go/bin"*}" ] && PATH="$HOME/go/bin:$PATH"
+[ -d "$GOPATH/bin" ] || [ -L "$GOPATH/bin" ] && [ -n "${PATH##*"$GOPATH/bin"*}" ] && PATH="$GOPATH/bin:$PATH"
[ -d "/usr/local/opt/util-linux/bin" ] || [ -L "/usr/local/opt/util-linux/bin" ] && [ -n "${PATH##*"/usr/local/opt/util-linux/bin"*}" ] && PATH="/usr/local/opt/util-linux/bin:$PATH"
-[ -d "$HOME/.config/.ghcup/bin" ] || [ -L "$HOME/.config/.ghcup/bin" ] && [ -n "${PATH##*"$HOME/.config/.ghcup/bin"*}" ] && PATH="$HOME/.config/.ghcup/bin:$PATH"
+[ -d "$XDG_CONFIG_HOME/.ghcup/bin" ] || [ -L "$XDG_CONFIG_HOME/.ghcup/bin" ] && [ -n "${PATH##*"$XDG_CONFIG_HOME/.ghcup/bin"*}" ] && PATH="$XDG_CONFIG_HOME/.ghcup/bin:$PATH"
[ -d "/usr/local/sbin" ] || [ -L "/usr/local/sbin" ] && [ -n "${PATH##*"/usr/local/sbin"*}" ] && PATH="/usr/local/sbin:$PATH"
[ -d "/usr/local/opt/coreutils/libexec/gnubin" ] || [ -L "/usr/local/opt/coreutils/libexec/gnubin" ] && [ -n "${PATH##*"/usr/local/opt/coreutils/libexec/gnubin"*}" ] && PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
[ -d "$HOME/.local/gnat/bin" ] || [ -L "$HOME/.local/gnat/bin" ] && [ -n "${PATH##*"$HOME/.local/gnat/bin"*}" ] && PATH="$HOME/.local/gnat/bin:$PATH"
[ -d "$HOME/bin" ] || [ -L "$HOME/bin" ] && [ -n "${PATH##*"$HOME/bin"*}" ] && PATH="$HOME/bin:$PATH"
[ -d "$HOME/.bin" ] || [ -L "$HOME/.bin" ] && [ -n "${PATH##*"$HOME/.bin"*}" ] && PATH="$HOME/.bin:$PATH"
[ -d "$HOME/.scripts" ] || [ -L "$HOME/.scripts" ] && [ -n "${PATH##*"$HOME/.scripts"*}" ] && PATH="$HOME/.scripts:$PATH"
-[ -d "$HOME/.local/share/gems/bin" ] || [ -L "$HOME/.local/share/gems/bin" ] && [ -n "${PATH##*"$HOME/.local/share/gems/bin"*}" ] && PATH="$HOME/.local/share/gems/bin:$PATH"
+[ -d "$XDG_DATA_HOME/gems/bin" ] || [ -L "$XDG_DATA_HOME/gems/bin" ] && [ -n "${PATH##*"$XDG_DATA_HOME/gems/bin"*}" ] && PATH="$XDG_DATA_HOME/gems/bin:$PATH"
[ -d "$HOME/.elan/bin" ] && [ -n "${PATH##*"$HOME/.elan/bin"*}" ] && PATH="$HOME/.elan/bin:$PATH"
[ -d /usr/local/opt/man-db/libexec/bin ] && [ -n "${PATH##*"/usr/local/opt/man-db/libexec/bin"*}" ] && PATH="/usr/local/opt/man-db/libexec/bin:$PATH"
[ -d "$DOTFILES/tools/shfm" ] && [ -n "${PATH##*"$DOTFILES/tools/shfm"*}" ] && PATH="$DOTFILES/tools/shfm:$PATH"
diff --git a/tools/go-readability b/tools/go-readability
@@ -0,0 +1 @@
+Subproject commit bdc8717724080c047d78cfc76060afee29775d13
diff --git a/w3m/keymap b/w3m/keymap
@@ -15,7 +15,7 @@ keymap C-f NEXT_PAGE
keymap C-b PREV_PAGE
keymap C-d NEXT_HALF_PAGE
keymap C-u PREV_HALF_PAGE
-keymap SPCr PIPE_SHELL 'python3 -W ignore -m readability.readability -u $W3M_URL | w3m -config ~/.config/w3m/config -T text/html -cols $(($(tput cols)*6/10))'
+keymap SPCr PIPE_SHELL 'go-readability $W3M_URL | w3m -config ~/.config/w3m/config -T text/html -cols $(($(tput cols)*6/10))'
keymap SPCo SHELL 'open "$W3M_URL"'
keymap SPCt SHELL 'open "$W3M_CURRENT_LINK"'
keymap SPCy EXEC_SHELL 'printf "%s" $W3M_CURRENT_LINK | clc'
@@ -28,12 +28,14 @@ keymap C-t NEW_TAB
keymap gt NEXT_TAB
keymap gT PREV_TAB
keymap C-o TAB_GOTO
-keymap M-t TAB_LINK
+keymap o GOTO
+keymap O TAB_LINK
keymap r RELOAD
keymap M-r REINIT
keymap U LIST
keymap u PEEK
keymap I INFO
+keymap ~ GOTO_HOME
# ABORT Quit at once
# ACCESSKEY Pop up accesskey menu
# ADD_BOOKMARK Add current page to bookmarks
@@ -63,8 +65,6 @@ keymap I INFO
# EXTERN Display using an external browser
# EXTERN_LINK Display target using an external browser
# FRAME Toggle rendering HTML frames
-# GOTO Open specified document in a new buffer
-# GOTO_HOME Return to the homepage (specified HTTP_HOME or WWW_HOME variable)
# GOTO_LINE Go to the specified line
# GOTO_LINK Follow current hyperlink in a new buffer
# GOTO_RELATIVE Go to relative address