Experimental VF-1-derived client for the "Gemini" protocol
Go to file
Lionel Dricot 4b39b7eac1 releasing 0.3 2022-02-11 11:33:37 +01:00
.gitignore Initial commit 2019-06-22 08:54:45 -04:00
CHANGELOG releasing 0.3 2022-02-11 11:33:37 +01:00
LICENSE Fill out LICENSE template! Closes #17. 2020-06-04 20:29:03 +02:00
README.md improved handling of gopher connections and support for animated gif 2022-02-11 11:12:36 +01:00
offpunk.py releasing 0.3 2022-02-11 11:33:37 +01:00
setup.py releasing 0.3 2022-02-11 11:33:37 +01:00

README.md

OFFPUNK

A command-line, text-based and offline-first Gemini, Gopher and Web browser by Ploum.

The goal of Offpunk is to be able to synchronise your content once (a day, a week, a month) and then browse/organise it while staying disconnected.

Offpunk is a fork of the original AV-98 by Solderpunk and was originally called AV-98-offline as an experimental branch.

How to use

Offpunk is a single python file. Installation is optional, you can simply download and run "./offpunk.py" or "python3 offpunk.py" in a terminal.

You use the go command to visit a URL, e.g. go gemini.circumlunar.space. (gemini:// is assumed is no protocol is specified).

Links in pages are assigned numerical indices. Just type an index to follow that link. If page is too long to fit on your screen, the content is displayed in the less pager (by default). Type q to quit and go back to Offpunk prompt. Type less or l to display it again in less. (less full or l full allows to see the full html page instead of the article view. This only applies to html pages)

Use add to add a capsule to your bookmarks and bookmarks or bm to show your bookmarks (you can create multiple bookmarks lists, edit and remove them. See the list manual with help list).

Use offline to only browse cached content and online to go back online. While offline, the reload command will force a re-fetch during the next synchronisation.

Use the help command to learn about additional commands. Some abreviations are available. See abbrevs.

When launched with the "--sync" option, offpunk will run non-interactively and fetch content from your bookmarks, lists and ressources tentatively accessed while offline. New content found in your subscriptions (see help subscribe) will be automatically added to your tour (use tour ls to see your current tour, tour without argument to access the next item and tour X where X is a link number to add the content of a link to your tour).

With "--sync", one could specify a "--cache validity" in seconds. This option will not refresh content if a cache exists and is less than the specified amount of seconds old.

For example, running

offpunk --sync --cache-validity 43200

will refresh your bookmarks if those are at least 12h old. If cache-validity is not set or set to 0, any cache is considered good and only content never cached before will be fetched.

Offpunk can also be configured as a browser by other tool. If you want to use offpunk directly with a given URL, simply type:

offpunk URL

To have offpunk fetch the URL at next sync and close immediately, run:

offpunk --fetch-later URL

Roadmap to 1.0 (and beyond)

Known issues in the code:

  • NOT_FIXABLE : consider root file is always index.gmi or index.html

I would happily mentor anyone willing to implement those:

  • TODO0: Hard - Make a manual within the git repository and have it automatically deployed as a website.
  • TODO1: Easy - Update blackbox to reflect cache hits.
  • TODO2: Hard - "pdf" - Implement retrieving PDF version of pages
  • TODO3: Medium - Transparent privacy redirects (twitter->nitter, etc)
  • TODO4: Medium - Rendering themes to allow customizing of colors ? (if any interest in the feature)
  • TODO6: Hard - "search" - Offline search engine to search in the cache (hard, no idea on how to do that)
  • TODO7: Easy - "share" - send a page by email

More

See how I browse Web/Gemini offline => gemini://rawtext.club/~ploum/2021-12-17-offline-gemini.gmi

Announces about Offpunk will be made on Ploums Gemlog => gemini://rawtext.club/~ploum/

Dependencies

Offpunk has no "strict dependencies", i.e. it will run and work without anything else beyond the Python standard library. However, it will "opportunistically import" a few other libraries if they are available to offer an improved experience or some other features. Python libraries requests, bs4 and readabliity are required for http/html support.

To avoid using unstable or too recent libraries, the rule of thumb is that a library should be packaged in Debian/Ubuntu.

  • Python-xdg will place your data, config and cache in place recommended by the XDG specs (usually its .local/share/offpunk, .config/offpunk and .cache/offpunk). Without it, look for ~/.offpunk or ~/.config/offpunk while the cache will be in ~/.cache/offpunk/. If installation is done later, some config files may need to be migrated by hand.
  • Python-requests is needed to handle http/https requests natively (apt-get install python3-requests). Without it, http links will be opened in an external browser
  • BeautifulSoup4 and Readability are both needed to render HTML. Without them, HTML will not be rendered or be sent to an external parser like Lynx. (apt-get install python3-bs4 python3-readability or pip3 install readability-lxml)
  • Python-feedparser will allow parsing of RSS/Atom feeds and thus subscriptions to them. (apt-get install python3-feedparser)
  • The ansiwrap library may result in neater display of text which makes use of ANSI escape codes to control colour. Ansiwrap is also required to display pictures in HTML pages (together with Chafa and python-pil) (not in Debian?).
  • The cryptography library will provide a better and slightly more secure experience when using the default TOFU certificate validation mode and is highly recommended (apt-get install python3-cryptography).
  • Python magic is useful to determine the MIME type of cached object. If not present, the file extension will be used but some capsules provide wrong extension or no extension at all. (apt-get install python3-magic)
  • Python editor is used to edit your lists with "list edit". (apt-get install python3-editor)
  • Xsel allows to go to the URL copied in the clipboard without having to paste it (both X and traditional clipboards are supported). Also needed to use the copy command. (apt-get install xsel)
  • Chafa allows to display pictures in your console. Install it and browse to an HTML page with picture to see the magic.
  • Python-pil is required to only display the first frame of animated gif with chafa.

Features

  • Browse https/gemini/gopher without leaving your keyboard and without distractions
  • Built-in documentation: type help to get the list of command or a specific help about a command.
  • Offline mode to browse cached content without a connection. Requested elements are automatically fetched during the next synchronization and are added to your tour.
  • HTML pages are prettified to focus on content. Read without being disturbed.
  • Support "subscriptions" to a page. New content seen in subscribed pages are automatically added to your next tour.
  • Complex bookmarks management through multiple lists, built-in edition and archiving.
  • Advanced navigation tools like tour and mark (as per VF-1). Unlike AV-98, tour is saved on disk accross sessions.
  • Ability to specify external handler programs for different MIME types (use handler)
  • Non-interactive cache-building with configurable depth through the --sync command. The cache can easily be used by other software.
  • IPv6 support
  • Supports any character encoding recognised by Python
  • Cryptography : TOFU or CA server certificate validation
  • Cryptography : Extensive client certificate support if an openssl binary is available

RC files

You can use an RC file to automatically run any sequence of valid Offpunk commands upon start up. This can be used to make settings controlled with the set or handler commanders persistent. You can also put a go command in your RC file to visit a "homepage" automatically on startup, or to pre-prepare a tour of your favourite Gemini sites or offline to go offline by default.

The RC file should be called offpunkrc and goes in $XDG_CONFIG_DIR/offpunk (or .config/offpunk or .offpunk if xdg not available)

Cache design

The offline content is stored in ~/.cache/offpunk/ as plain .gmi/.html files. The structure of the Gemini-space is tentatively recreated. One key element of the design is to avoid any database. The cache can thus be modified by hand, content can be removed, used or added by software other than offpunk.

Theres no feature to automatically trim the cache. It is believed that gemini content being lightweight, one would have to seriously browse a lot before cache size is an issue. If cache becomes too big, simply rm -rf the folders of the capsules taking too much space.