elinks icon indicating copy to clipboard operation
elinks copied to clipboard

Integrate "reader view" via readability-cli?

Open ebrensi opened this issue 3 years ago • 3 comments

I ran across this project, which uses Firefox's reader-mode functionality as a terminal app. https://gitlab.com/gardenappl/readability-cli

I think having this option as a plugin would make a lot of sites render much better.

How would I go about preprocessing html in (f)elinks with an external program? I am a web developer but unfamiliar with writing native apps. Can someone point me in the right direction?

ebrensi avatar Sep 01 '20 18:09 ebrensi

Combining browser scripting with local CGI can do it. I tried it, but had problems with relative links. CGI script ~/cgi/read.cgi looks like this:

#!/usr/bin/python3
import os
import subprocess
import sys

sys.stdout.write('Content-Type: text/html\r\n\r\n')
sys.stdout.flush()
subprocess.call(('readable', '-q', '--base', os.environ['QUERY_STRING'], '--', os.environ['QUERY_STRING']))

follow_url_hook:

def follow_url_hook(url): # in Python
    if url.startswith('http'):
        return 'file:///home/users/witekfl/cgi/read.cgi?' + url

Compile elinks with --enable-cgi and your favourite scripting backend. Enable CGI in configuration, set path for CGI scripts, so read.cgi is on it, and check.

rkd77 avatar Sep 02 '20 14:09 rkd77

You said to

Compile elinks with --enable-cgi and your favourite scripting backend.

Suppose my favorite scripting backend is Python. Where do I specify that? I did not see anything about that in features.conf.

I see CONFIG_SCRIPTING_PYTHON in configure, but I'm not sure what to do with that.

ebrensi avatar Sep 03 '20 21:09 ebrensi

./autogen.sh ./configure --enable-cgi --with-python (other options) make make install

Copy contrib/python/* to ~/.elinks/ and modify to your needs. python3 devel package is required.

rkd77 avatar Sep 04 '20 09:09 rkd77