Compare commits

...

691 Commits

Author SHA1 Message Date
Ploum 9a7e88d01b fix crash when feedparser is crashing on a bad RSS 2024-04-23 13:07:23 +02:00
Étienne Mollier 339acef720 opnk.py: fix warning with python3.12.
As initially identified by Paul Wise in [Debian Bug#1064209], opnk.py
experiences the following warning when running under python3.12:

	$ python3.12 opnk.py gemini://ploum.net >/dev/null
	/home/emollier/debian/forward-upstream/offpunk/opnk.py:52: SyntaxWarning: invalid escape sequence '\%'
	  less_prompt = "page %%d/%%D- lines %%lb/%%L - %%Pb\%%"

This is due to the interpretation of escape sequences being less
relaxed in the new Python interpreter version.  Doubling the backslash
is one way to resolve this issue.

[Debian Bug#1064209]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1064209

Signed-off-by: Étienne Mollier <emollier@debian.org>
2024-02-20 15:16:51 +01:00
Ploum 9c8693dc09 display empty files instead of opening them with xdg-open 2024-02-20 10:45:43 +01:00
Ploum 4e3d3ce62d netcache: add support for IPv6 hostname bug #40 2024-02-15 22:59:27 +01:00
Ploum d427287784 offpunk: fix IPv6 as an URL (bug #40) 2024-02-15 16:16:37 +01:00
Ploum 4a3ec61f1f 2.2 - February 13th 2023
- cache folder is now configurable through $OFFPUNK_CACHE_PATH environment variable (by prx)
- offpunk: adding an URL to a list now update the view mode if url already present
- netcache: solve an infinite gemini loop with code 6X (see also bug #31)
- ansicat: added support for <video> HTML-element
- ansicat: if chafa fails to load an image, fallback to timg if available
- offpunk: add list autocompletion to "tour"
- offpunk: removed "blackbox", which has not been used nor maintained
- offpunk: "gus" was broken, it is functionnal again
- opnk/offpunk: more informative prompt in less
- ansicat: added support for HTML description elements <dt> and <dd> (by Bert Livens)
- opnk: added "--mode" command-line argument (bug #39)
- offpunk: support for "preformatted" theming (bug #38)
- opnk/netcache: added "--cache-validity" command-line argument (bug #37)
- ansicat: consider files as XML, not SVG, if they don’t have .svg extension
- offpunk: fix "view link" crashing with link to empty files
2024-02-12 22:25:46 +01:00
Ploum 9bec3b48dd fix view link crashing with empty files 2024-02-11 12:14:52 +01:00
Ploum 36c9709bc4 consider files as XML, not SVG, if no .svg extension 2024-02-10 22:09:28 +01:00
Ploum 6ad59020a1 force new paragraph after a preformatted html block 2024-02-07 10:22:24 +01:00
Ploum 95b5c96534 adding a linebreak after a preformatted block 2024-02-06 15:10:31 +01:00
Ploum 8be531e5e2 a simple type was forcing images to be rendered twice 2024-02-01 14:33:44 +01:00
Ploum 0fda6f5623 --cache-validity argument added to opnk and netcach (#37) 2024-01-31 17:54:50 +01:00
Ploum 1bf98cf060 support for preformatted them - close #38 2024-01-31 17:25:33 +01:00
Ploum 2faf460f0f close #39: implement --mode in opnk 2024-01-31 16:30:49 +01:00
Ploum 6484cf3426 less prompts: last line of the screen 2024-01-30 16:21:58 +01:00
Bert Livens 1cd331170c Added support for <dd> and <dt> tags to ansicat to render websites like https://fsl.software/ better.
Signed-off-by: Bert Livens <bert@bertlivens.be>
2024-01-29 16:51:21 +01:00
Ploum eea914018c remove old blackbox call 2024-01-29 15:26:13 +01:00
Ploum 79a3f9875f More informative prompt in LESS 2024-01-29 15:15:00 +01:00
Ploum 0a9fb62582 check that the cache_path ends with / 2024-01-23 21:21:15 +01:00
prx 87837fd1fb implement set cache directory
Hi,
find below a patch which let user set a custom chache folder.

Environment variable OFFPUNK_CACHE_PATH is used.
This way, it can be set globally in a profile, or occasionnaly before running offpunk.
It also avoid the pain to parse options and dealing with flags in scripts.
Thank you for your attention.

Regards.

prx
2024-01-23 21:11:52 +01:00
Ploum 01de6fe6ae changelog update 2024-01-23 14:12:22 +01:00
Ploum cf459e5295 offpunk: "gus" was broken, it is functionnal again 2024-01-06 21:24:51 +01:00
Ploum c86a377d98 offpunk: removed "blackbox", which has not been used nor maintained 2024-01-06 21:21:08 +01:00
Ploum fa0793ef16 Migrating self.current_url to the modded URL
- adding an URL to a list now update the view mode if url already present
- self.current_url now contains the modded URL
2024-01-06 00:27:51 +01:00
Ploum 9d1fb1a3d4 add list autocompletion to tour 2023-12-25 00:14:04 +01:00
Ploum 6d7c45188f fallback to timg if chafa fails to load an image 2023-12-22 18:50:03 +01:00
Bert Livens 426161e35d Added initial support for html <video> elements, including for their poster tag.
Signed-off-by: Bert Livens <bert@bertlivens.be>
2023-12-19 22:24:35 +01:00
Ploum 1ed8ba749e solve an infinite loop with certificate 6X 2023-12-18 10:11:17 +01:00
Ploum ba5f6ecb91 easier error messages for pictures 2023-12-16 23:50:15 +01:00
Ploum 1bbd317c1d v2.1 - December 15th 2023
Two years ago, I started to modify AV-98 in order to browser Gemini
offline.
https://ploum.net/2021-12-06-offline-av98.html
https://ploum.net/2021-12-17-offline-gemini.html

It is interesting to reflect on those last two years and look at what
this little experiment has become. A tool I use daily. In fact, on of my
main tools with Neovim and Neomutt. Also a community. People
contributing. Sending patches, bug reports or even thank you notes. A
few people hanging out on the offpunk:matrix.org room. I’m really
grateful for that and for all the people who make the Gemini-sphere
alive.

This 2.1 release is also a more relaxed release. The 2.0 release was
well received, widely packaged and has very few bugs (comparing to 1.0).

So nothing ground breaking but, besides a few bug fixed (including the
infamous gemini redirection bug), some little nice-to-have features.
Like highlighting "new links" in Gemini and RSS pages. I was unsure if
it would work, turns out that it is the best thing ever invented to read
Gemini Antenna or long RSS feeds.

Also added: "copy title" and "copy link", allowing you to quickly
reference a page in a personnal note or an email.

And, one day, I realized that I often wanted to know where a given link
was pointing to (a bit like hovering your mouse on a link in a
traditional browser). So I added a "view XX" where XX is the number of
the link.

What is really interesting with this feature is how I wrote it: I
realized I had a need, opened the offpunk.py, wrote a few lines of code
to test it and… that was it. No correction to do. It was good at the
very first try. Which is a testament to the fact that the 2.0
refactorisation was actually a good thing.

So, here is it, the 2.1 release. Enjoy!

Changelog since 2.0:
- freshly updated gemtext/rss links are highlighted ("new_link" theme option)
- offpunk : new "copy title" and "copy link" function
- offpunk : new "view XX" feature where XX is a number to view information about a link
- ansicat: added "--mode" option
- redirections are now reflected in links and the cache (bug #28)
- ansicat: avoid a crash when urllib.parse.urljoin fails
- offpunk: Fix a crash when gus is called without parameters (Von Hohenheiden)
- ansicat: fixed a crash when parsing wrong hidden_url in gemini (bug #32)
- offpunk: offpunk --version doesn’t create the cache anymore (bug #27)
- ansicat: fix a crash with HTML without title (bug #33)
- netcache: gemini socket code can crash when IPv6 is disabled (mailing-list)
2023-12-12 16:53:54 +01:00
Ploum 52a3ef643a IPv6 might crash if disabled on the OS level
In his message "Bug in some gemini capsule", user Y C had crashes when
connecting to IPv6 enabled capsule while IPv6 was disabled at OS level.

This raised a crash when creating the socket in netcache gemini code.
For whatever reason, the socket creation was not in the "try/catch"
section.

This should fix the issue.
2023-12-11 23:45:19 +01:00
Ploum e3e81fe344 tentatively fix #33 2023-12-10 22:54:37 +01:00
Ploum f9e33914aa typo in changelog 2023-12-06 15:21:26 +01:00
Ploum f373144cca New view link feature
"view 12" will now gives you hindsight about link 12
2023-12-06 15:11:18 +01:00
Ploum 92516082c1 Access to xdg folders now refactored to be a function
Instead of creating three global variables, a xdg() function now returns
the DATA,CONFIG and CACHE folders.

This allows us to create the cache only when tentatively accessed
(this fixes bug #27)
2023-12-04 11:10:20 +01:00
Ploum aad1730cd8 New "copy link" and "copy title" features 2023-12-03 13:18:12 +01:00
Ploum 3164658352 Fixed a crash when parsing hidden_urls bug #32
GemtextRenderer is parsing the text for URLs not starting with "=>" and
adding them later to the list to avoid having to copy/paste with the
mouse. This is an hidden feature.

In this case, the url was not supposed to be one and included [] chars
which prevent urllib to know how to handle it.

The fix involved refactoring the looks_like_url functions out of offpunk
and add it to offutils so it can be used by ansicat to ensure a function
looks_like_url before giving it to urllib.
2023-12-02 00:11:34 +01:00
Ploum c3aff6755e follow redirects everywhere. Should fix #28$
«
2023-12-01 17:14:22 +01:00
vonhohenheiden@tutanota.com 3862183fee fix crash on calling 'gus' without query parameter
Apologies for the additional work and thanks for accepting the patch!
Please find it attached.
Best,
Von

Nov 26, 2023, 10:20 by sourcehut23@ploum.eu:

> On 23/11/26 08:04, vonhohenheiden@tutanota.com wrote:
> >This is a simple fix for a crash I observed when calling 'gus' without any parameters. The following stacktrace can be reproduced by ´python3 offpunk.py <http://offpunk.py> > gus [Enter]´
>
>
> Hi,
>
> Thanks for catching this. The patch looks good but cannot apply. It
> might be because the stacktrace is also considered as a patch by git am
> (that’s my only explanation).
>
> Do you mind sending it again without the stacktrace or as an attachment.
>
> A good practice in offpunk is also to add a line in the CHANGELOG (with
> your name at the end).  If not done, don’t worry, I will do it in a
> later commit.
>
> Thanks!
>
> Ploum
>
>>
>>
> >---
> >Traceback (most recent call last):
> >  File "offpunk/offpunk.py", line 1910, in <module>
> >    main()
> >  File "offpunk/offpunk.py", line 1905, in main
> >    gc.cmdloop()
> >  File "python3.11/cmd.py", line 138, in cmdloop
> >    stop = self.onecmd(line)
> >           ^^^^^^^^^^^^^^^^^
> >  File "python3.11/cmd.py", line 217, in onecmd
> >    return func(arg)
> >           ^^^^^^^^^
> >  File "offpunk/offpunk.py", line 949, in do_gus
> >    self._go_to_url(urllib.parse.urlunparse("gemini","geminispace.info <http://geminispace.info>","/search","",line,""))
> >                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >TypeError: urlunparse() takes 1 positional argument but 6 were given
> >---
>
>>
>>
> >Proposed patch follows.
> >Thanks,
> >Von
>
>>
>>
> >Signed-off-by: vonhohenheiden <vonhohenheiden@tutanota.com>
> >---
> >offpunk.py <http://offpunk.py> | 3 +++
> >1 file changed, 3 insertions(+)
>
>>
>>
> >diff --git a/offpunk.py b/offpunk.py
> >index a76ac0a..6e82c72 100755
> >--- a/offpunk.py
> >+++ b/offpunk.py
> >@@ -945,6 +945,9 @@ Use 'ls -l' to see URLs."""
> > 
> >     def do_gus(self, line):
> >         """Submit a search query to the geminispace.info <http://geminispace.info> search engine."""
> >+        if not line:
> >+            print("What?")
> >+            return 
> >         self._go_to_url(urllib.parse.urlunparse("gemini","geminispace.info <http://geminispace.info>","/search","",line,""))
> > 
> >     def do_history(self, *args):
> >-- 
> >2.43.0
>
>>
>>
>
> --
> Ploum - Lionel Dricot
> Blog: https://www.ploum.net
> Livres: https://ploum.net/livres.html
>

>From 8ffc15145bad3a74c7771d488df3cb751c4b8039 Mon Sep 17 00:00:00 2001
From: vonhohenheiden <vonhohenheiden@tutanota.com>
Date: Sun, 26 Nov 2023 07:38:19 +0100
Subject: [PATCH] fix crash on calling 'gus' without parameters

Signed-off-by: vonhohenheiden <vonhohenheiden@tutanota.com>
2023-11-26 20:51:50 +01:00
Ploum 233f237e15 added new_link to help theme 2023-11-25 11:44:16 +01:00
Ploum 1dddec0e86 switch the new_page duration from 60 to 600 seconds to catch the same reload 2023-11-24 11:10:03 +01:00
Ploum 6e09f0264b New theme option: new_link
In gemtext and RSS rendering, if a link point to a page which is
considered as "new" (it has been cached less than 60 seconds after the
page itself), we display it differently (by default in bold white).

This feature allows to quickcly see new links in RSS pages or aggregator
such as antenna.
2023-11-21 22:04:09 +01:00
Ploum b03cbd9c64 ansicat : added --mode option 2023-11-19 22:07:15 +01:00
Ploum 7e4bdd0601 Releasing 2.0 2023-11-16 12:00:00 +01:00
Ploum 5b5a2d6551 removing file from pyproject 2023-11-12 23:32:48 +01:00
Ploum 8ad571a269 remove timg from pyproject.toml 2023-11-12 22:50:46 +01:00
Ploum 512189256e updating README for 2.0 2023-11-12 15:51:48 +01:00
Ploum c9e5310a07 preparing changelog for 2.0 2023-11-12 15:13:27 +01:00
Ploum 63db80c7be introduced default_protocol option which default to gemini, solving #21 2023-11-12 15:01:58 +01:00
Ploum b5640cc474 typo reported on mastodon 2023-11-09 13:13:19 +01:00
Ploum e7831338de don’t crash ansicat if run without arguments 2023-11-09 12:46:47 +01:00
Ploum 5bf84c91fa documentation for ansicat/netcache/opnk 2023-11-09 12:36:32 +01:00
Ploum 24fe364f51 returns the good version number 2023-11-08 18:18:33 +01:00
Ploum 818257bcef renaming cache_migration to netcache_migration: fixes #25 2023-11-08 16:45:27 +01:00
Ploum ac78e85d04 Fixes bug #26
- make python-requests optional again
- reimplement --disable-http which had no effect
2023-11-08 16:37:13 +01:00
Ploum 8d082cb2df migration to hatchling and 2.0-beta2 release 2023-11-08 11:37:29 +01:00
Jean Abou Samra e1e25b9456 Simple packaging fix
--=-6tQG7FEKAZyWWN9kR8o8
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi Ploum,

I'm the author of the "d=C3=A9p=C3=AAche" you commented on here:

https://linuxfr.org/news/l-installation-et-la-distribution-de-paquets-pytho=
n-1-4#comment-1940663

I skimmed at your problem. I admit I have not read all packaging-related
threads on this mailing list. If I understand correctly, you want
to keep using the (relatively non-standard) current setup of
Offpunk, namely a bunch of scripts at the root of the source tree.

You can't do that with Flit, because it's an opinionated tool
which insists that you do it the more standard way. So here's
a simple patch that does it with hatchling instead.

You might also want to review the dependency list in pyproject.toml.
I see "timg>=3D1.3.2", but the latest version of timg on PyPI
is 1.1.6.

Best,
Jean

From 90b3b2ab3700c57f76d3ae5760a4f49048bca70d Mon Sep 17 00:00:00 2001
From: Jean Abou Samra <jean@abou-samra.fr>
Date: Tue, 7 Nov 2023 23:16:43 +0100
Subject: [PATCH] Basic fix for packaging

Flit is not suitable for this project because it insists on packaging a
single package, while Ploum insists on keeping top-level scripts that
aren't inside a package. Use hatchling instead.

To test:

$ python -m venv temp-test-venv # may require "apt install python3-venv" or such
$ source temp-test-venv/bin/activate
$ pip install .[http]
$ offpunk
$ deactivate

To check the build artifacts:

$ python -m build # may require "apt install python3-build" or such
$ cd dist
$ tar -xvf offpunk-2.0b1.tar.gz # check files, this should contain everything
$ unzip offpunk-2.0b1-py3-none-any.whl # check files, this should contain only Python modules (plus a dist-info directory)
2023-11-08 11:34:03 +01:00
Ploum 51dc856161 small debug for netcache 2023-11-08 10:25:39 +01:00
Ploum 856b89ff45 fixes a crash when parsing invalid RSS dates 2023-11-03 23:01:46 +01:00
Ploum bf17b21b30 fixes hang/crash when meeting ; itemtype in gopher 2023-11-01 23:45:47 +01:00
Ploum 29c447cd8e Revert completely previous fix.
Instead, if we do not support an inline image format, we don’t display
it at all instead of displaying a fake URL
2023-10-20 00:06:59 +02:00
Ploum 979b80c5bd fixes a crash with data:image/svg+xml links 2023-10-20 00:02:35 +02:00
Ploum f05adf1b59 solve a crash with tour when argument and no url 2023-10-19 13:34:26 +02:00
Ploum 924eed3775 fixes a crash with some invalid URLs 2023-10-14 17:22:47 +02:00
Ploum 010288a6fb fixes input in Gemini 2023-10-12 15:23:59 +02:00
Ploum 2b234cdc43 initial tentative to support podcast RSS/atom feeds 2023-10-09 13:26:12 +02:00
Ploum deaa199303 gemtext renderer should be the default, not plaintextrenderer 2023-10-08 00:23:08 +02:00
Ploum 1baf311f2c new html parsing for titles 2023-10-07 23:54:58 +02:00
Ploum d50bc5a8e2 force closing html title elements 2023-10-07 23:45:01 +02:00
Ploum f6cb7723e1 experimental: new plaintext renderer. Also used to view source 2023-10-07 23:30:09 +02:00
Ploum c19576bc43 shame on me: never commit without having launching the thing 2023-10-05 18:22:10 +02:00
Ploum d50925ce03 should fix ~lioploum/offpunk#24 2023-10-05 18:17:01 +02:00
Ploum 5dd2238ef2 don’t crash if there’s no XMLParsedAsHTMLWarning in BS4 (as we are trying to avoid them anyway 2023-10-05 14:27:58 +02:00
Ploum 4892b9e450 fixes a crash reported by Xavier Maillard for RSS feeds without link elemnet 2023-10-01 14:04:17 +02:00
Lionel Dricot eeae7e3ad7 put blocked URLs in its own file to make contributions easier 2023-09-26 22:21:19 +02:00
Lionel Dricot 7ffbd1b288 adding a comment to understand what I did 2023-09-25 11:05:55 +02:00
Austreelis 39c5f17a39 Fix None prompt until manually changed
The GeminiClient's constructor expected set_prompt to return the prompt,
while the function directly mutated it without returning anything.

This manifested as having "None" as prompt instead of the default "ON>", until
entering the offline command.

This patch both fixes the constructor by not setting self.prompt to the
result of GeminiClient.set_prompt, *and* make that function return the
prompt as well. Each of those is a separated hunk, feel free to only
apply whichever feels best (though applying both should warrant any
future mistake of the sort).

Signed-off-by: Austreelis <dev@austreelis.net>
2023-09-23 11:00:35 +02:00
Lionel Dricot f8d185eac9 ignoring encoding errors in ansicat 2023-09-23 10:42:45 +02:00
Lionel Dricot 8c752d7b44 fixed an an/or logical confusion that would cause non-displayable documents to be marked as to be refetched even when not necessary 2023-09-19 14:24:18 +02:00
Lionel Dricot f33a4cb1e9 use chafa by default if version >= 1.10 2023-09-15 21:54:51 +02:00
Lionel Dricot a2678bfdf5 prompt color is now part of the theme too 2023-09-14 21:35:23 +02:00
Lionel Dricot ea82e81d75 Improve handling of base64 images
Also makes images links absolute in the rendering
2023-09-13 21:49:52 +02:00
Lionel Dricot 7a606b71cf some ugly code to filter XMLparsedAsHTMLWarning from BS4 2023-09-12 18:06:42 +02:00
Lionel Dricot 0666aaaa7a fixes opening mailto links 2023-09-11 17:26:57 +02:00
Lionel Dricot dc238309dd fixes gophermap being badly rendered as gemtext 2023-09-11 10:47:38 +02:00
Austreelis 5f3d8d69be Update license classifier in pyproject.toml
The previous one wasn't listed on
[pypy's list](https://pypi.org/pypi?%3Aaction=list_classifiers), which
made flit 3.9.0 refuse to build offpunk (I didn't investigate this
much).
2023-09-08 15:29:58 +02:00
Lionel Dricot 47317ca113 --sync now taking list names as arguments 2023-09-07 16:38:48 +02:00
Lionel Dricot 4c47f28f3f Releasing 2.0-beta1 - September 05th 2023
This is an an experimental release. Bug reports and feedbacks are welcome on the offpunk-devel list.
- WARNING: pyproject.toml has not been updated and is currently non-functional. Help needed!
- IMPORTANT: Licence has been changed to AGPL for ideological reasons
- IMPORTANT: Contact adress has been changed to offpunk2 on the same domain (because of spam)
- IMPORTANT: code has been splitted into 7 differents files. Installation/packaging should be adapted.
Major features:
- New command-line tool: "netcache"
- New command-line tool: "ansicat"
- New command-line tool: "opnk"
- "theme" command allows customization of the colours
- "--config-file" allows to start offpunk with custom config (#16)
Improvments:
- Reading position is saved for the whole session
- Rendering is cached for the session, allowing faster browsing of a page already visited
- "redirect" supports domains starting with "*" to also block all subdomins
- "--images-mode" allow to choose at startup which images should be dowloaded (none,readable,full)
- Support for multi-format rendering (such as RSS feeds with html elements)
- The cache is now automatically upgraded if needed (see .version in your cache)
Other changes from 1.X:
- Images of html files are now downloaded with the html (slower sync but better reading experience)
- URL do not default anymore to "gemini://" if not protocol are indicated. (ongoing discussion in #21)
- "accept_bad_ssl_certificates" now more agressive for http and really accepts them all
- Gopher-only: we don’t support naming a page after the name of the incoming link
- Gemini-only: support for client generated certificates has been removed
- "file" is now marked as a dependency (thank Guillaume Loret)
2023-09-05 14:03:15 +02:00
Lionel Dricot 53b310507f allows offpunk to run with older cryptography package 2023-09-05 11:52:30 +02:00
Lionel Dricot be71ba8c75 - version was crashing since the refactoring
- History is now created if it doesn’t exist
2023-09-04 20:59:32 +02:00
Lionel Dricot b1effe57b6 not trying to display absent images 2023-09-04 10:29:14 +02:00
Lionel Dricot e14009f2a4 ansicat working again alone 2023-09-03 23:20:54 +02:00
Lionel Dricot 1a2cff83af themes are now applied instantly 2023-09-02 12:41:55 +02:00
Lionel Dricot 2fa2fbc718 support blocking subdomains with * 2023-08-31 21:35:08 +02:00
Lionel Dricot 28d22c4d11 do not try to open files if they dont exist 2023-08-31 20:45:52 +02:00
Lionel Dricot 446c940820 error proofing fetch-later 2023-08-31 20:39:13 +02:00
Lionel Dricot 4c328e32aa don’t add history to itself 2023-08-31 15:49:20 +02:00
Lionel Dricot b001ade107 correctly close background ansi codes 2023-08-31 14:59:18 +02:00
Lionel Dricot 514e853b6b create cache dir if it doesn’t exists. Thanks mart-e for reporting the bug. 2023-08-31 11:01:52 +02:00
Lionel Dricot 0c2b24dd89 Themes and reload
- added background colours to theme
- theme for blockquote and preformatted in gemtext (untested)
- cleanup cache on reload
2023-08-31 10:53:24 +02:00
Lionel Dricot 699fed78b9 Introducing themes
You can now customize the colors of offpunk by using the command
"theme".

See "help theme" or use the autocomplete.
2023-08-31 00:40:35 +02:00
Lionel Dricot 1e002f3456 early support for themes in ansicat 2023-08-30 17:02:54 +02:00
Lionel Dricot 97b02a666f do not use cache for local files 2023-08-30 14:06:07 +02:00
Lionel Dricot 5c5fcb3f9e new full_links_only mode to fetch all links from links saved in mode=full 2023-08-30 11:54:24 +02:00
Étienne Mollier 7ad75380a6 Homogenize shebang
Before the change, ansicat, netcache and opnk assume that the
interpreter location is always /bin/python.  While some distributions
do provide python at this location, even as a python3 interpreter,
some others such as Debian do not provide a plain python interpreter
anymore, at least not by default.  There exist packages to provide the
version 2 or the version 3 of the interpreter at that location, but
the three possible configurations (v2, v3 or none) are left at the
discretion of the administrator, so in practice can't really be
predicted in advance.

This change applies the same shebang as offpunk.py and the cache
migration script.  Use of /usr/bin/env has also the side effect of
easing use of python3 interpreters installed at weird locations.

Signed-off-by: Étienne Mollier <emollier@debian.org>
2023-08-30 09:22:08 +02:00
Lionel Dricot 5d9df83ea0 cache_migration doesn’t need to be executable 2023-08-29 12:21:43 +02:00
Lionel Dricot c356a4607c automatic handle of cache migration 2023-08-29 11:47:51 +02:00
Lionel Dricot 68451fbc0a tentative of upgrading pyproject 2023-08-28 23:52:59 +02:00
Lionel Dricot 751c4eb2b2 removing unecessary Debian reference from manpages 2023-08-28 23:18:07 +02:00
Lionel Dricot d8bba70fe2 cleanup of the cache should always be full 2023-08-28 14:54:24 +02:00
Lionel Dricot 11adf1aca9 changelog update 2023-08-27 23:25:01 +02:00
Étienne Mollier 5d675f4ceb offpunk.1: cross reference other manual pages.
Signed-off-by: Étienne Mollier <emollier@debian.org>
2023-08-27 22:47:02 +02:00
Étienne Mollier 7a22ea3c8a Provide manuals for new commands.
This patch add stubs of documentation for ansicat(1), netcache(1),
migrate-offpunk-cache(1) and opnk(1) in prevision of offpunk 2.0
release.  The migration script manual notably resolves issue #15.

Signed-off-by: Étienne Mollier <emollier@debian.org>
2023-08-27 22:46:49 +02:00
Lionel Dricot a1ce45403f I broke the feed renderer. Now it works 2023-08-27 13:46:33 +02:00
Lionel Dricot d7fe66b204 support for multiformat rendering (trying view full for RSS) 2023-08-27 13:11:34 +02:00
Lionel Dricot 95c790f69d fix bug #20 due to a stupid line added without testing 2023-08-25 14:14:06 +02:00
Lionel Dricot 7c17b4f15d fixes bug #18 2023-08-24 15:31:08 +02:00
Lionel Dricot 392c42ae48 "--images-mode" allow to choose at startup which images should be dowloaded (none,readable,full)
It default to downloading "readable" images.
download_images_first option will also be deprecated
2023-08-24 15:14:49 +02:00
Lionel Dricot 3f6a9df107 fixes bug #19 2023-08-23 15:04:19 +02:00
Lionel Dricot 8c4f4eee65 compute size of lists 2023-08-22 15:43:17 +02:00
Lionel Dricot 10b3a84be5 Solve the infamous application/javascript bug
Lot of html pages are now recognized as application/javascript. We now
force the HtmlRenderer for application/javascript.

Contact address has also be changed to offpunk2 everywhere
2023-08-22 14:59:20 +02:00
Lionel Dricot f4818c966e adding file as a dependancy 2023-08-21 01:08:13 +02:00
Lionel Dricot 8beae920a7 removing code of the client-side certificate (untested and unused for years) 2023-08-19 10:17:37 +02:00
Lionel Dricot 238d4352a9 missed an import in opnk 2023-08-18 12:45:28 +02:00
Lionel Dricot 68581d4ff0 removing unecessary message when accessing unavailable ressources 2023-08-17 16:43:44 +02:00
Lionel Dricot fe06f17b16 better handling of changing width with opnk 2023-08-17 15:38:47 +02:00
Lionel Dricot 38fcc89193 fixed do_cat and do_shell 2023-08-17 14:16:40 +02:00
Lionel Dricot e14c9dcd09 now blocking subdomains too 2023-08-17 13:42:59 +02:00
Lionel Dricot 5d3453c4b9 removing client generated certificate code 2023-08-17 13:42:59 +02:00
Lionel Dricot 462d257c36 implemented grep and better restoring of last mode 2023-08-17 13:42:57 +02:00
Lionel Dricot 99a3730618 restore redirect code and accept_bad_ssl 2023-08-17 13:41:41 +02:00
Lionel Dricot c149cb17f4 added --config-file (bug #16) 2023-08-17 13:41:41 +02:00
Lionel Dricot 147e628bc2 fixes reload of local ressources 2023-08-17 13:41:41 +02:00
Lionel Dricot af18214c41 except when reloading, we use the cache if younger than 60 seconds 2023-08-17 13:41:41 +02:00
Lionel Dricot 39f080036c small changelog 2023-08-17 13:41:41 +02:00
Lionel Dricot e34de67015 comment out some certificate code 2023-08-17 13:41:41 +02:00
Lionel Dricot 091e41ecf9 fix root function 2023-08-17 13:41:41 +02:00
Lionel Dricot 392b4c085d inverted logic to restore position in lists 2023-08-17 13:41:41 +02:00
Lionel Dricot 24112ba2b4 fixed opnk with local files 2023-08-17 13:41:41 +02:00
Lionel Dricot d88d2cdc20 Removed blackbox (it was broken for years)
Also, fixed the non-interactive mode of fetch_gemini
2023-08-17 13:41:41 +02:00
Lionel Dricot 91013f5d3d removing debugging output 2023-08-17 13:41:41 +02:00
Lionel Dricot c7740e0d5e fixing crashes in the network code 2023-08-17 13:41:41 +02:00
Lionel Dricot b7286b8039 lists are always displayed in cat 2023-08-17 13:41:41 +02:00
Lionel Dricot 67e7c6d7e7 images are now displayed using chafa 2023-08-17 13:41:41 +02:00
Lionel Dricot 58af0d61ca shit with env variable not expanded 2023-08-17 13:41:41 +02:00
Lionel Dricot 33def82b2a things start to look usable 2023-08-17 13:41:41 +02:00
Lionel Dricot 13fffcd882 list of todos 2023-08-17 13:41:41 +02:00
Lionel Dricot dbb32a9a45 user expanding of XDG variables 2023-08-17 13:41:41 +02:00
Lionel Dricot 0ee76865f5 debug folders wrongly added to git 2023-08-17 13:41:41 +02:00
Lionel Dricot 4e8418541d support for mailto 2023-08-17 13:41:39 +02:00
Lionel Dricot 1da149e2fa changing licence 2023-08-17 13:41:04 +02:00
Lionel Dricot 7464b80e3e awesome progress with caching. Everything starts to make sense 2023-08-17 13:40:18 +02:00
Lionel Dricot a6e293a301 debugged --sync 2023-08-17 13:40:16 +02:00
Lionel Dricot 21784dc0d6 debugging --sync 2023-08-17 13:39:29 +02:00
Lionel Dricot c03a161e56 last_mode is broken, Im confused 2023-08-17 13:39:29 +02:00
Lionel Dricot 1b0c3774b6 Ansirenderer has been renamed to ansicat.
Downloading of images has been moved into netcache.
Offpunk go_to_url starts to be sane and easier.
2023-08-17 13:39:29 +02:00
Lionel Dricot 09c37dee5c opnk seems to be functional. Lists are still missing 2023-08-17 13:39:29 +02:00
Lionel Dricot 323c088683 opnk is now basically working 2023-08-17 13:39:29 +02:00
Lionel Dricot 654f03c53c introducing openk 2023-08-17 13:39:29 +02:00
Lionel Dricot 10c07a794c we got rid of GeminiItem 2023-08-17 13:39:29 +02:00
Lionel Dricot ddd7dbd42c nearly got rid of geminiitem 2023-08-17 13:39:29 +02:00
Lionel Dricot f64b3da658 geminiitem got rid of get_body 2023-08-17 13:39:29 +02:00
Lionel Dricot 2a7509b7d1 working on get_body 2023-08-17 13:39:29 +02:00
Lionel Dricot b0b1fc43f5 moving out the self.url thing 2023-08-17 13:39:29 +02:00
Lionel Dricot 4526e39443 debug XDG folders 2023-08-17 13:39:29 +02:00
Lionel Dricot 6211d454be next work : reimplementing list and local files 2023-08-17 13:39:29 +02:00
Lionel Dricot ee96e2c3e7 works at Volvo 2023-08-17 13:39:29 +02:00
Lionel Dricot 4f6ab9225b get_link now in ansirenderer 2023-08-17 13:39:29 +02:00
Lionel Dricot 12c61f4317 pictures are working 2023-08-17 13:39:27 +02:00
Lionel Dricot 9ba09b2c01 continuing work to remove GeminiItem 2023-08-17 13:38:45 +02:00
Lionel Dricot 4f5a7af9ff more certificate management in netcache 2023-08-17 13:38:45 +02:00
Lionel Dricot 2ed2bd7a88 migrating certificate management to netcache 2023-08-17 13:38:45 +02:00
Lionel Dricot 9a9b5bb267 Cleaning up GeminiItem
Work has started to remove GeminiItem completely and switch to an
{url:renderer} dictionnary. Maybe also add a tmpfile.
2023-08-17 13:38:45 +02:00
Lionel Dricot acb49f83c0 Ok, it starts to work.
Offpunk is now able to display pages, pictures and follow links. A lot
of TODO have been clearly identified. I think that the whole
GeminiItem() object will be removed and URL will be accessed directly
with a dict{url, renderer} to avoid redrawing all the time.

Next challenge: remove GeminiItems!
2023-08-17 13:38:45 +02:00
Lionel Dricot 709fd853b0 debugging offpunk 2023-08-17 13:38:45 +02:00
Lionel Dricot 072eee8325 offpunk starts to work 2023-08-17 13:38:45 +02:00
Lionel Dricot d3c9957ec5 renderer in ansirenderer 2023-08-17 13:38:45 +02:00
Lionel Dricot 601cfdbba9 ansirenderer now working both directly or from stdin 2023-08-17 13:38:45 +02:00
Lionel Dricot c775590bac pour le moment incapable de décider si ansirenderer doit prendre le path du fichier ou directement le texte en input 2023-08-17 13:38:45 +02:00
Lionel Dricot 2e08b9a73c starting to adapt offpunk 2023-08-17 13:38:45 +02:00
Lionel Dricot 4c93e18037 default to stdin 2023-08-17 13:38:45 +02:00
Lionel Dricot b580a74530 first working pipe between netcache and ansirenderer 2023-08-17 13:38:45 +02:00
Lionel Dricot ffb31d6a27 ansirenderer cli 2023-08-17 13:38:45 +02:00
Lionel Dricot 0265d8489c --offline and --path arguments 2023-08-17 13:38:45 +02:00
Lionel Dricot f6ff77da2b monkey patching 2023-08-17 13:38:45 +02:00
Lionel Dricot 2b4bd04fa9 netcache now works for gemini 2023-08-17 13:38:45 +02:00
Lionel Dricot d4768d6e8d work in progress 2023-08-17 13:38:45 +02:00
Lionel Dricot cb2958e4b6 real work has started with porting Gemini code 2023-08-17 13:38:45 +02:00
Lionel Dricot 4038adf5a9 gopher,finger and spartan in netcache 2023-08-17 13:38:45 +02:00
Lionel Dricot 8e732d0cfa netcache now downloads http 2023-08-17 13:38:45 +02:00
Lionel Dricot 6a6c0c0907 netcache CLI 2023-08-17 13:38:45 +02:00
Lionel Dricot c4cdcde94d working on netcache 2023-08-17 13:38:40 +02:00
Lionel Dricot c3a98d761e first netcache 2023-08-17 13:37:45 +02:00
Lionel Dricot a644315ed2 to the point where netcache become an evidence 2023-08-17 13:37:45 +02:00
Lionel Dricot a5853d2d66 introducing offutils.py 2023-08-17 13:37:45 +02:00
Lionel Dricot f6b70f938d progress toward independance 2023-08-17 13:37:31 +02:00
Lionel Dricot 8800a6bbc2 experiment 2023-08-17 13:34:07 +02:00
Lionel Dricot e4bc908919 release 1.10 before breaking all the things 2023-07-31 13:33:27 +02:00
Lionel Dricot 1a40ad786f Improved help for list and sync, suggestion from smokey 2023-07-02 23:46:34 +02:00
Sotiris Papatheodorou - sotiris at papatheodorou.xyz 2cc599afdd Change the Gopher index filename to gophermap
This seems to be the most common convention among gopher servers (e.g.
Gophernicus, go-gopher).

Added a script to migrate the cache to the new format. Alternatively the
following command can be used for migration in a POSIX system:

find ~/.cache/offpunk/gopher/ -type f -name 'index.txt' -exec sh -c 'mv {} "$(dirname {})/gophermap"' \;
2023-04-14 11:11:24 +02:00
Maeve Sproule - code at sprock.dev a73790f0fb Rewrite gopher URL parsing code per RFC 4266
The previous code was using the first path segment as an item type, if
it was present and a single character long. However, the standard
requires the first character after the slash to be used, if present,
regardless of whether if forms a complete path segment. This rewrite
conforms the code to the standards behaviour, and fixes both the
original problem with gopher://alexschroeder.ch/ and the problem created
with other gopherholes in my attempt to fix it.

I've also changed one piece of code that generates a gopher URL to
better conform to the standard, by avoiding the introduction of leading
slashes. This should prevent any gopherholes that don't accept leading
slashes (including gopher://alexschroeder.ch/) from having problems with
requests sent from offpunk.
2023-04-09 12:10:34 +02:00
Maeve Sproule - code at sprock.dev be2836e218 Fix gopher requests 2023-04-08 22:09:30 +02:00
Lionel Dricot b1de7c59e4 forgot debug statement 2023-04-04 20:57:17 +02:00
Lionel Dricot 5b0e63b5a5 should fix gopher requests 2023-04-03 23:18:45 +02:00
Lionel Dricot 25b2c4ef53 removing an else condition which is obviously crashing and should not be there 2023-04-03 21:18:42 +02:00
Sotiris Papatheodorou - sotiris at papatheodorou.xyz 454994002a Fix merging dictionaries with common keys
The previous code would throw KeyError if a key was present in both
os.environ and env, e.g. when LESSHISTFILE is defined in the
environment. The current code ensures that for keys present in both
dictionaries the value from env will be used.
2023-04-02 14:39:56 +02:00
Lionel Dricot fff1f39877 set accept_bad_certificates now also works for expired Gemini certificates 2023-03-30 11:28:58 +02:00
Lionel Dricot a0ce56d45e Adding chardet to README 2023-03-27 20:51:03 +02:00
Anna “CyberTailor” - cyber+misc at sysrq.in 453f8af9f9 add chardet to optional dependencies 2023-03-27 20:45:41 +02:00
Sotiris Papatheodorou - sotiris at papatheodorou.xyz dc38a3f9bc Add missing chardet module
This fixes text encoding detection for gopher requests which was using
the chardet module without importing it.

Here's a URL that causes a crash before the fix:
gopher://sdf.org/0/users/d1337/textfiles/hacker_crackdown.txt
2023-03-27 17:39:54 +02:00
Lionel Dricot faf5e0c649 version 1.9.2 2023-03-13 17:02:15 +01:00
Lionel Dricot 8da1eff920 changelog for 3.7 2023-03-12 19:54:02 +01:00
Anna “CyberTailor” 5ddc06b903 bump requires-python to >=3.7 2023-03-12 19:52:58 +01:00
Lionel Dricot 7a05e211e6 changelog for flit 2023-03-12 12:53:27 +01:00
Anna “CyberTailor” 46668d2b4c switch to a PEP517 build system
Flit is the simplest of PEP517 build systems so I used it.

Packagers will need to switch from legacy (setup.py) mode to PEP517, if
not already.

Most offpunk.py changes are stripped whitespace. Relevant are:
- Added module docstring (__doc__ variable)
- Added __version__ variable

These two will be used by Flit so you will need to bump version in one
place only.
2023-03-12 12:52:43 +01:00
Lionel Dricot 826aa4e1c2 incrementing to 1.9.1 2023-03-11 00:00:32 +01:00
Lionel Dricot 65a445627e release 1.9.1 to fix #8 2023-03-08 23:11:32 +01:00
Lionel Dricot 1333d1b8e6 added debian package to README 2023-03-08 11:39:11 +01:00
Lionel Dricot ca6728e607 1.9 2023-03-08 11:21:04 +01:00
Lionel Dricot 520b53f2a3 man page created by phoebos 2023-03-07 16:23:25 +01:00
Lionel Dricot d14e1ba0a9 fix bug #11 2023-03-07 14:36:24 +01:00
Lionel Dricot 2fd2479b53 Assume utf-8 when the header answers with an unknown encoding 2023-03-05 22:57:34 +01:00
Lionel Dricot 891684136f fixing a crash related to bug #10 2023-03-03 15:21:03 +01:00
Lionel Dricot f7a773d03a removing custom debian 2023-02-28 19:56:23 +01:00
Lionel Dricot 2b4162be5b Fix a crash by casting HTML content a string (for whatever reason, it is sometimes
seen as bytes)
2023-02-15 15:54:11 +01:00
Lionel Dricot d8771cb267 Revert ""set cache" now allows to set a custom cache folder."
This reverts commit 2582e00cab.
2023-02-15 15:22:09 +01:00
Lionel Dricot 2582e00cab "set cache" now allows to set a custom cache folder.
The implementation is bad as it uses a global variable.
Also, there’s currently no way to revert to the default without restarting offpunk.
2023-01-26 15:20:48 +01:00
Lionel Dricot 39b5abeeac unionising env and os.environ should give precedence to env 2023-01-13 22:38:27 +01:00
Lionel Dricot 6fd1bd4341 Improve compatibility with python 3.7 by replacing a dict union 2023-01-13 09:56:29 +01:00
Lionel Dricot 3438a94155 This should fix #7
Starting now, we don’t assume a valid GeminiItem and thus a valid cache_path.
More crashes might be uncovered.
2023-01-12 17:11:54 +01:00
Lionel Dricot 99e3fc1772 fix error handling assuming that requests is installed 2022-12-29 14:44:09 +01:00
Maeve Sproule - code at sprock.dev 5b432112d0 Fix support for UTF-8 domains in Gemini (fixes #5)
Previously, offpunk would send the UTF-8 host in the Gemini request.
This changes it to first IDNA-encode the hostname in the URL before
making the request. This bug only existed for Gemini requests, since the
host is already being encoded for Spartan requests and `requests`
handles this for HTTP URLs.

Additionally, the code now treats both UTF-8 hosts and their IDNA
equivalents as the same host for the purposes of identifying
cross-domain redirects.
2022-12-22 12:13:47 +01:00
Lionel Dricot 7e363f740b better feedback of streaming urls 2022-12-18 20:09:48 +01:00
Lionel Dricot 5a5ff15f90 blocking doubleclick.net by default 2022-12-16 21:03:44 +01:00
Sotiris Papatheodorou - sotiris at papatheodorou.xyz 39669df9ec Handle .. as an alias to the up command
* It allows passing an argument as in the up command.
* Prevents some weird errors when passing an argument.
2022-12-16 12:40:36 +01:00
Lionel Dricot 250f3ebe66 added a comment about a function because it took me 15 minutes to understand why it was there 2022-12-14 16:26:03 +01:00
Lionel Dricot d1cbe0acf0 Default handlers have been removed.
Not everyone use zathura and feh so they are not removed by default.
To restore previous behaviour, add the following lines to your offpunkrc:

handler image/* feh -. %s
handler application/pdf zathura %s
2022-12-12 15:57:28 +01:00
Lionel Dricot 194e9ed62d fix crash when susbcribing without GI 2022-12-12 15:30:49 +01:00
Ben Winston - ben at benwinston.us 1667952153 bugfix: don't crash when there's no links to index 2022-12-11 00:51:42 +01:00
Lionel Dricot 45a689a5b8 RELEASE 1.8 2022-12-10 22:46:23 +01:00
Ben Winston - ben at benwinston.us 95d48fb38d bugfix: readline needs ANSI codes escaped
In order for `readline` to handle up/down arrow presses with ANSI
escape codes in the prompt, all non-printable characters must be
prefaced with \001 and suffixed with \002. Otherwise, long lines
do not get entirely cleared when scrolling up/down.
2022-12-10 22:22:18 +01:00
Lionel Dricot 1754f7a9dd preparing 1.8 release 2022-12-10 22:16:12 +01:00
Lionel Dricot 49705594f8 updating readme 2022-12-10 21:50:43 +01:00
Ben Winston - ben at benwinston.us 8875a0068c Detecting "New" Chafa 2022-12-09 22:51:34 +01:00
Lionel Dricot 7d57fd9919 adding a space after autocompleting a list 2022-12-07 23:23:31 +01:00
Lionel Dricot b773243623 misplaced check for mode was breaking elif 2022-12-02 13:11:26 +01:00
Lionel Dricot 7bcd0e2af5 fixing a crash with data:image svg 2022-12-02 12:49:37 +01:00
Lionel Dricot af65662f0f Fix images not being downloaded for "full" mode
(the mode was not preserved for each call. We now default to the gi.last_mode if 
no mode is explicitely set during the _go_to_gi call)
2022-12-01 17:39:04 +01:00
Maeve Sproule - code at sprock.dev 1f516b6733 Avoid passing improperly escaped paths to shell
This should fix https://notabug.org/ploum/offpunk/issues/9 . This
involves a few closely-related changes to subprogram execution:
- If a path, url or file contents were being passed using `cat` or
  `echo`, the code was changed to pass the file/string on stdin. This
  also makes several pipelines into single programs and should allow for
  the removal of `shell=True` in the future.
- For `file`, `xdg-open` and `less`, which either can't accept their
  input on stdin or otherwise use the path, the paths are now being
  escaped with `shlex.quote()`.
- Finally, the environment variable $LESSHISTFILE is now being set in
  python code, where escaping is not necessary.

Notably, the argument to `grep` in `less_cmd()` is not quoted in this
commit, since I was unsure of how it was meant to be used. If the
argument is not already quoted, this should probably be passed through
`shlex.quote()`.

This does not do the following, which may be desired:
- This does not disable `shell=True` anywhere, since `subprocess.run()`
  requires the command to be already split into a list of strings. I
  think this would just require a `shlex.split()` in `run()` when this
  is disabled, but it may require more thought.
- Some of the invoked programs (with the notable exception of `echo` and
  `xdg-open`) support the use of "--" to prevent any following arguments
  from being treated as program flags if they start with "-". I don't
  believe there are any paths that start with "-", but it may make sense
  to include this where possible.

I have briefly tested this commit, but it touches quite a few code
paths, so there might be bugs that I missed.
2022-12-01 17:07:44 +01:00
Lionel Dricot e76b2a13e0 accept_bad_ssl_certificates with --assume-yes 2022-11-30 21:02:17 +01:00
Lionel Dricot c15d452d34 deprecating restricted mode 2022-11-30 20:57:23 +01:00
Lionel Dricot fc8cb2f163 moved all references to sourcehut repository 2022-11-30 16:07:33 +01:00
Lionel Dricot 1c9380835c removing dependency on cgi and implementing our own mime parser 2022-11-30 00:11:44 +01:00
Lionel Dricot 75b20e4982 deep bug in handling display modes that became apparent by breaking cp raw 2022-11-27 01:15:37 +01:00
Lionel Dricot 464fcf3773 highly experimental : trying to access gemini://océane.fr and it still fails 2022-11-24 16:26:36 +01:00
Sotiris Papatheodorou - sotiris at papatheodorou.xyz c02eba5e3e add support for the finger protocol 2022-11-24 12:36:55 +01:00
Lionel Dricot afa89097b2 better feedback when streaming 2022-11-24 10:48:38 +01:00
Lionel Dricot 2d5c17d2fd changelog 2022-11-21 00:07:21 +01:00
Marty Oehme - marty.oehme at gmail.com 0af34aa7e1 fix crash on missing index when listing contents
Fixes a crash when trying to look up the contents of the current index
using `ls` command whenever there is no current page loaded by making a
current item a requirement.
2022-11-21 00:05:25 +01:00
Lionel Dricot c1f6119e80 accepting_bad_ssl_certificates requires python-requests 2022-11-17 10:30:12 +01:00
Lionel Dricot 2e566f7220 accept localhost as a valid url 2022-11-16 21:45:51 +01:00
Lionel Dricot ff04177d53 set accept_bad_ssl_certificates 2022-11-16 14:44:47 +01:00
Lionel Dricot 06b2a56ed3 certdir variable was not initialised without HAS_CRYPTOGRAPHY (see bug #2) 2022-11-16 10:06:35 +01:00
Lionel Dricot 7baccbb15f v 1.7.1 2022-11-15 17:01:13 +01:00
Lionel Dricot af361bd4ad typo in changelog 2022-11-15 14:13:37 +01:00
Lionel Dricot 041146e3f1 offpunk 1.7 2022-11-15 13:55:39 +01:00
Sotiris Papatheodorou - sotiris at papatheodorou.xyz fb550a19bc fix typo in package name 2022-11-15 13:36:07 +01:00
Lionel Dricot 539b287901 new search and wikipedia commands 2022-11-14 21:33:40 +01:00
Lionel Dricot 39ad7ee7b7 comment for debugging stuck requests 2022-11-14 19:17:20 +01:00
Lionel Dricot f9b8ccaf9b hidden links in gopher/gemini 2022-11-10 23:50:16 +01:00
Lionel Dricot dd02476ae2 fixing list creation with fetch-later 2022-11-09 23:30:54 +01:00
Lionel Dricot 01b1bd56c4 automatically create system lists when needed 2022-11-05 23:14:41 +01:00
Lionel Dricot a60cbd9297 solving crash when adding wrong url to tour 2022-11-03 12:59:15 +01:00
Lionel Dricot c1538f2f9b autocompletion now working as expected 2022-11-02 15:47:57 +01:00
Lionel Dricot 8bd68ca02b introducing autocompletion for list/add/move 2022-11-02 00:58:41 +01:00
Lionel Dricot fbdff91f01 trying to not use shell=True (Wip) 2022-11-01 17:34:04 +01:00
Lionel Dricot f3bb6cd7f0 avoid a crash related to bug #9 2022-11-01 17:04:30 +01:00
Lionel Dricot bee6fd9e40 computing size of http body out of the if condition seems to help being stuck in some strange cases 2022-10-25 01:15:57 +02:00
Lionel Dricot c6d52b3c19 investigating sync perf 2022-10-20 22:53:33 +02:00
Lionel Dricot 68b278fe13 solve a crash when loading html pages with empty links 2022-10-15 18:25:15 +02:00
Lionel Dricot b3b9bff849 fix screenshot link for sourcehut 2022-10-12 13:17:29 +02:00
Lionel Dricot f388be39d6 releasing offpunk 1.6 2022-10-12 11:29:37 +02:00
Lionel Dricot 1ff77e796d consider .xml as feeds to avoid false detection as SVG by file 2022-10-10 11:00:58 +02:00
Lionel Dricot addab31f49 yet another try at fixing timg bugs 2022-10-08 23:20:30 +02:00
Lionel Dricot 8d242ef06e workaround old timg bug 2022-10-08 00:42:46 +02:00
Lionel Dricot 15d76dd05d redirect reddit to teddit (fix #12) 2022-10-08 00:16:28 +02:00
Lionel Dricot 230c359aff handling the case where gi is none 2022-10-07 16:07:03 +02:00
Lionel Dricot 0b06c360da base64 support seems to work. More testing needed 2022-10-07 15:51:26 +02:00
Lionel Dricot f7f78564a2 refactoring: replacing the self.lookup table with calls to gi.get_links for consistency 2022-10-07 14:45:44 +02:00
Lionel Dricot 93c666458a refactoring base64 support 2022-10-07 13:56:55 +02:00
Lionel Dricot 9ae464f154 initial support for base64 images in html. Still a bug with link counting. 2022-10-07 11:19:23 +02:00
Lionel Dricot 0a3024f765 automatically download the rss feed of a webpage during sync (fix #14) 2022-10-06 22:30:09 +02:00
Lionel Dricot 268d864cdb Close #15, redirects are now working also in --sync mode (thanks kelbot) 2022-10-06 18:22:34 +02:00
Lionel Dricot d93db54f55 only use timg > 1.3.2 (thanks Valvin for the bug report) 2022-10-06 11:59:03 +02:00
Lionel Dricot 54dcec340a removing libreddit redirection 2022-10-03 20:35:19 +02:00
Lionel Dricot 45fd77603e small typo in README 2022-09-29 14:49:46 +02:00
Lionel Dricot e7ebff8d34 touring a list in one command 2022-09-25 23:33:36 +02:00
ploum 2eb5c63716 Merge branch 'doc-alpine-pkg' of miyopan/offpunk into master 2022-08-13 12:14:06 +00:00
mio d1793b6da0 add Alpine package in README 2022-08-12 16:36:41 +00:00
Lionel Dricot 2e5b4bff5c add link to mailing list 2022-08-08 22:29:36 +02:00
Lionel Dricot d646c9dccb date in changelog 2022-08-04 12:13:57 +02:00
Lionel Dricot 1663c1bc01 offpunk 1.5 2022-08-04 12:07:41 +02:00
Lionel Dricot e51d04ece8 changelog 2022-07-24 10:40:08 +02:00
Lionel Dricot cc7f92222d solving a bug with base64 images and blocking facebook by default 2022-07-24 10:17:33 +02:00
Lionel Dricot d7c1492150 refactor redirections and add blocking 2022-07-21 17:02:36 +02:00
Lionel Dricot 052d9fdb83 typo fixed thanks to shawn nock 2022-07-18 14:53:49 +02:00
ploum c240abe7ee Merge branch 'add-nixpkgs-to-readme' of DamienCassou/offpunk into master 2022-07-11 17:09:54 +00:00
Damien Cassou b0621842d9
adding Nix package in README 2022-07-10 11:36:17 +02:00
Lionel Dricot 329a1ad58a introducing --features for #3 2022-07-03 15:38:29 +02:00
Lionel Dricot a74229f1fd not creating config file when running --version, close #2 2022-07-03 15:31:33 +02:00
Lionel Dricot 5614cbdf01 explicit license close #4 2022-07-03 15:25:47 +02:00
Lionel Dricot 39c26fa59f removing an old commented out line 2022-05-07 17:45:56 +02:00
Lionel Dricot cdd040f19a open url 2022-04-29 10:41:08 +02:00
Lionel Dricot 947183e0a7 removing commented-out code 2022-04-28 23:06:36 +02:00
Lionel Dricot 3e76ca2368 removed optional dependency to ripgrep 2022-04-26 13:15:20 +02:00
Lionel Dricot 63ebb8067d release 1.4 2022-04-25 16:01:00 +02:00
Lionel Dricot 43bb41a37a slight improvement to handle transparency with chafa 2022-04-18 21:24:26 +02:00
Lionel Dricot 51f5b35a1e stupid bug in previous commit 2022-04-12 15:03:26 +02:00
Lionel Dricot ab2271e6bf archiving regardless of the view used 2022-04-10 23:45:34 +02:00
Lionel Dricot c1981b4cf2 official repo 2022-04-09 19:07:30 +02:00
Lionel Dricot 10ab7323bd do not try to render non-image files with chafa to avoid errors 2022-04-09 17:15:56 +02:00
Lionel Dricot ac80f537e2 removing next and previous 2022-04-06 12:14:57 +02:00
Lionel Dricot 2e9e236dc8 not stripping html from left CR 2022-04-06 11:41:56 +02:00
Lionel Dricot 292e53b031 adding draft of doc 2022-04-05 09:57:41 +02:00
Lionel Dricot a8cc54b4ee Merge branch 'master' of notabug.org:ploum/offpunk 2022-04-05 09:55:38 +02:00
ploum 30e83919e7 Merge branch 'master' of ivanruvalcaba/offpunk into master 2022-04-05 07:54:42 +00:00
Iván Ruvalcaba 03f02e0ce2 🎉 First Debian packaging commit 2022-04-04 20:26:07 -05:00
Lionel Dricot 614ff254d2 adding AUR package in README 2022-04-04 22:49:36 +02:00
Lionel Dricot fe948a66ad putting myself as the main licensee 2022-04-04 16:13:46 +02:00
Lionel Dricot 9707a1f2bf adding less to dependencies. 2022-04-02 22:08:51 +02:00
Lionel Dricot 217447f021 updating URL in setup.py 2022-04-02 21:09:55 +02:00
Lionel Dricot f0e151b40c python readability is now optional 2022-04-02 18:25:40 +02:00
Lionel Dricot 2cff973f3f try to not crash on empty pages 2022-04-02 17:55:45 +02:00
Lionel Dricot 5c59da3c16 adding url to changelog 2022-04-02 17:27:07 +02:00
Lionel Dricot 66454dc2e7 releasing 1.3 2022-04-02 16:56:03 +02:00
Lionel Dricot 3ddb782c7a cleaning some old comments 2022-04-01 00:20:34 +02:00
Lionel Dricot fcd279db16 escaping by default each time we call a shell command 2022-03-31 11:41:37 +02:00
Lionel Dricot 7f3ac6d273 adding pip requirements.txt 2022-03-31 11:13:11 +02:00
Lionel Dricot 9adfb955d7 automatically create bookmarks list 2022-03-31 11:00:55 +02:00
Lionel Dricot 97f31c0762 Refactor every call to subprocess to improve compatibility with python 3.6 2022-03-30 19:23:44 +02:00
Lionel Dricot b71dd77f7d replacing subproccess.call with subprocess.run 2022-03-30 17:42:48 +02:00
Lionel Dricot 6e5760f27d Introducting redirections for twitter,medium, youtube and reddit 2022-03-30 15:46:25 +02:00
Lionel Dricot 026ce534ac displaying animated gifs (but only one loop) 2022-03-30 14:35:37 +02:00
Lionel Dricot 3e560d21de downloading images only if support for them is enabled, of course 2022-03-30 12:09:08 +02:00
Lionel Dricot 9528d3d5f6 downloading images first to display them 2022-03-30 12:04:07 +02:00
Lionel Dricot 6dbeaa828e It seems a bunch of ssl validation code was dropped, I don’t know how. Got it back from AV-98 2022-03-29 22:30:57 +02:00
Lionel Dricot 5207164d3c removed dependency to python-magic 2022-03-29 22:08:30 +02:00
Lionel Dricot 007076ab0a adding documentation to install dependencies on Ubuntu 2022-03-29 16:15:28 +02:00
Lionel Dricot bbaa1dbbcb improved dependencies clarity 2022-03-29 13:28:20 +02:00
Lionel Dricot 5f16b89e95 removing dependency to python-editor 2022-03-29 13:12:49 +02:00
Lionel Dricot a401e75ec9 handle better old less versions 2022-03-29 10:26:53 +02:00
Lionel Dricot 040f077836 solving a crash when directly entering an unknown gopher address while offline 2022-03-27 16:25:03 +02:00
Lionel Dricot 9a3013fa5c experiment with lstrip 2022-03-27 16:15:34 +02:00
Lionel Dricot a227d7d000 bug in the streaming detection would sometimes make valid http request fail 2022-03-25 20:53:45 +01:00
Lionel Dricot ad56f82901 added support for html span 2022-03-25 14:08:34 +01:00
Lionel Dricot 4acebf6fba Implemented find with ripgrep/grep 2022-03-25 13:45:57 +01:00
Lionel Dricot 05da20801c Streaming servers without content-length are closed after 5Mo of download 2022-03-24 22:00:04 +01:00
Lionel Dricot c2879828d6 fixing a crash when the cache is already a directory 2022-03-24 21:03:03 +01:00
Lionel Dricot 9a1d0fa255 switch back to default width of 80 as most hard-wrapped gemlogs and gopher assume this width 2022-03-24 11:06:35 +01:00
Lionel Dricot 54f5be3bd5 crashing when requesting the title of a feed 2022-03-24 10:51:36 +01:00
Lionel Dricot c0ae6e4f47 1.2 Experimental release 2022-03-23 22:19:31 +01:00
Lionel Dricot 431d5d81cb exiting cleanly if less is not found 2022-03-23 16:35:10 +01:00
Lionel Dricot 5247813b21 view normal to get back from view full 2022-03-23 16:19:23 +01:00
Lionel Dricot d3775542ae support for bookmarking specific modes like full 2022-03-23 14:28:19 +01:00
Lionel Dricot c1f0146411 crash in --fetch-later 2022-03-23 08:48:45 +01:00
Lionel Dricot 2bd1f04571 lists now have their own protocol and solved the irritating namebug in history 2022-03-23 08:38:58 +01:00
Lionel Dricot 41b28d412a small improv to cleaning html 2022-03-22 18:21:31 +01:00
Lionel Dricot e89bd26cde small cleanup 2022-03-22 11:11:35 +01:00
Lionel Dricot 80cdf1bb5c small improv to version 2022-03-22 09:07:37 +01:00
Lionel Dricot af86a08e31 Removed definitely ansiwrap. This is a huge achievement. 2022-03-21 22:50:55 +01:00
Lionel Dricot 68fb345ccc switched Gemtext to the new renderer 2022-03-21 21:45:53 +01:00
Lionel Dricot 17066d0f86 stupid bug in the gemtext renderer that went nearly unnoticed 2022-03-21 17:49:37 +01:00
Lionel Dricot 48f9e9b8c1 new gemtext renderer in beta 2022-03-21 16:54:17 +01:00
Lionel Dricot d2dc6795e3 switching GemText to the new renderer 2022-03-21 16:21:02 +01:00
Lionel Dricot d2a0b38e5e NewHTML: we now switched to the new HTML rendering engine 2022-03-21 11:57:35 +01:00
Lionel Dricot 0499527da5 moving representation to abstract renderer 2022-03-21 11:36:01 +01:00
Lionel Dricot bf77dec666 NewHTML: handling PRE, indents and tables 2022-03-20 21:58:17 +01:00
Lionel Dricot ce36d1adbc NewHTML: add title before pictures 2022-03-20 11:29:06 +01:00
Lionel Dricot fedd4622a9 NewHTML : support for reverse indent and good centering of img alttext 2022-03-20 00:00:55 +01:00
Lionel Dricot 822ead9cfb NewHTML: simplifying outputed ANSI code by cancelling opposites and concatenating others 2022-03-19 23:01:53 +01:00
Lionel Dricot 20e09a6e28 improved link parsing logic in html 2022-03-19 22:03:31 +01:00
Lionel Dricot e2c07b6fab NewHTML: title set 2022-03-19 21:26:49 +01:00
Lionel Dricot 3ab7c76207 set beta to true to test the new html renderer 2022-03-19 20:58:18 +01:00
Lionel Dricot b19604525e NewHTML: support for indentations. It starts to look very promising. 2022-03-19 17:44:28 +01:00
Lionel Dricot 8957cda24e limit width of --sync output 2022-03-19 15:58:28 +01:00
Lionel Dricot 517e0f0e9e fix a crash when saving a folder 2022-03-19 12:17:02 +01:00
Lionel Dricot 1e16c415fd really tired 2022-03-18 23:17:59 +01:00
Lionel Dricot c64f633ebd fix view full for feeds 2022-03-18 23:02:21 +01:00
Lionel Dricot b6aa36d423 quick 1.1 fix 2022-03-18 22:30:40 +01:00
Lionel Dricot a49022d56f releasing 1.1 2022-03-18 22:27:45 +01:00
Lionel Dricot 0e8557480a NewHTML: solved centering and other stuff 2022-03-18 22:11:58 +01:00
Lionel Dricot a9b5c37b8a better performance by using links_only when needed 2022-03-18 21:12:21 +01:00
Lionel Dricot 6b1b527b04 NewHTML: trying to center img comments 2022-03-18 18:10:38 +01:00
Lionel Dricot f5c10392c3 working on a textwrap-compatible html renderer 2022-03-18 17:35:14 +01:00
Lionel Dricot ea31d72b9e force saving animation as gif to avoid a crash by PIL 2022-03-18 13:40:54 +01:00
Lionel Dricot 51c2bd966e first try at reimplementing the html renderer (currently commented out) 2022-03-18 11:25:47 +01:00
Lionel Dricot e388b4f49c understand links in html titles 2022-03-17 15:34:43 +01:00
Lionel Dricot 435ab36525 support for timg as an alternative to chafa 2022-03-17 10:23:35 +01:00
Lionel Dricot a651537052 initial work to support timg instead of chafa 2022-03-17 00:01:18 +01:00
Lionel Dricot c9f2191f71 fixing the fix_ipv6 which was breaking some domain names 2022-03-16 19:26:46 +01:00
Lionel Dricot ab08d28537 fix crash when getting links for pictures 2022-03-16 10:08:29 +01:00
Lionel Dricot 8170c26532 full support for multiple view modes 2022-03-16 10:03:29 +01:00
Lionel Dricot 5ddd309bce links were broken in v full 2022-03-16 09:47:53 +01:00
Lionel Dricot 452ae6015f dont crash if a picture is in the clipboard 2022-03-16 00:41:56 +01:00
Lionel Dricot 76ba0104d5 repair broken view full and got saved position in different views 2022-03-16 00:21:55 +01:00
Lionel Dricot 03f62d2e57 cp url X to copy the url of a link 2022-03-15 23:43:21 +01:00
Lionel Dricot 4f4e1cc72c fixed missing links in feeds 2022-03-15 23:23:29 +01:00
Lionel Dricot c6d164e743 refactor: display is now handled by the renderer. Also, removal of fold 2022-03-15 23:01:04 +01:00
Lionel Dricot 0d282b7ccf drop html comments 2022-03-15 20:24:06 +01:00
Lionel Dricot 190139e431 refactor: removing reable=True for mode=readable 2022-03-15 20:14:21 +01:00
Lionel Dricot 543455e1c6 starting refactorisation to support better chafa 2022-03-15 16:23:44 +01:00
Lionel Dricot 133be0dc13 ensure we are using chafa with symbols to allow upgrading to 1.8 2022-03-15 15:30:30 +01:00
Lionel Dricot 10a576838b use html unescape instead of implementing it ourselves 2022-03-15 00:04:11 +01:00
Lionel Dricot ca1cd780a3 cp cache to get the path of the cached file 2022-03-14 22:36:34 +01:00
Lionel Dricot 112ff11d3d proper support for <pre> 2022-03-14 18:46:14 +01:00
Lionel Dricot 378de2479e added 1.0 post 2022-03-14 12:10:11 +01:00
Lionel Dricot 7182059fa5 fix crash if python readability not present 2022-03-14 11:43:40 +01:00
Lionel Dricot 438d8b9363 error with NEW_CHAFA 2022-03-14 10:23:14 +01:00
Lionel Dricot ac07ddb5c4 release 1.0 and fix view full for feeds 2022-03-13 17:45:41 +01:00
Lionel Dricot 5589568d8b simplifying chafa detection 2022-03-13 14:36:21 +01:00
Lionel Dricot 58dc23b50f switching to the more standard width of 72 for 1.0 2022-03-12 22:19:54 +01:00
Lionel Dricot 9e37442d86 screenshots for 1.0 2022-03-12 22:18:37 +01:00
Lionel Dricot e92d57a94a Handling chafa > 1.10 2022-03-12 18:41:38 +01:00
Lionel Dricot d74d00feb1 crash in subscribe 2022-03-09 11:34:41 +01:00
Lionel Dricot 1e18cb71a3 added man as an abbrevs for help. Because I typed it spontanously. 2022-03-09 10:15:24 +01:00
Lionel Dricot db5e922af9 up can take an integer as argument 2022-03-08 22:21:44 +01:00
Lionel Dricot 672a1a9c4b dropping python-xdg dependancy. It’s easier to implement our own version of it 2022-03-08 10:14:36 +01:00
Lionel Dricot 7de6cf5d1f download limit seems to work 2022-03-08 09:12:01 +01:00
Lionel Dricot c1f2206937 less has been renamed view and feed/feeds options have been added 2022-03-07 23:16:17 +01:00
Lionel Dricot b37fb2f599 dropping javascript from full view 2022-03-07 22:29:55 +01:00
Lionel Dricot d6cf0962b7 centering pictures in html pages 2022-03-07 21:54:43 +01:00
Lionel Dricot 636e8bb4b8 content is now centered in the terminal 2022-03-07 18:23:48 +01:00
Lionel Dricot 35123e920c fix crash reported by Matthieu Talbot 2022-03-07 15:36:16 +01:00
Lionel Dricot 907fc70b5d fallback less frequently to text/gemini mime 2022-03-06 19:36:02 +01:00
Lionel Dricot f322c8d73c small typo inducing crash 2022-03-06 16:02:30 +01:00
Lionel Dricot 4e5dbe4882 added spartan to README 2022-03-05 16:36:39 +01:00
Lionel Dricot 100f69ebe7 releasing 0.9 2022-03-05 11:45:26 +01:00
Lionel Dricot 42f0f06494 Add support for spartan protocol 2022-03-04 23:38:35 +01:00
Lionel Dricot 1e44ae76a0 forgot to increase version number 2022-03-04 16:50:33 +01:00
Lionel Dricot 28feaf6f6d reload doesn’t care about cache anymore 2022-03-04 12:38:41 +01:00
Lionel Dricot b7c34f3bb9 stupid white space bug 2022-03-04 10:18:57 +01:00
Lionel Dricot d28a3423d6 Http download which are not to be put in tour are now limited to 20Mo, to avoid downloading large unwanted files 2022-03-03 16:16:32 +01:00
Lionel Dricot 484987e21f max 20mo for http downloads 2022-03-01 22:03:42 +01:00
Lionel Dricot 3faca54050 &mldr; spotted in a wild page and implemented 2022-02-27 22:54:28 +01:00
Lionel Dricot f73577ae08 warn if alreaday subscribed to a feed 2022-02-27 22:32:25 +01:00
Lionel Dricot b0a2961acc more feedback from subscribe 2022-02-27 22:20:42 +01:00
Lionel Dricot af57715f99 feed without entries are not feed but html pages 2022-02-25 22:13:40 +01:00
Lionel Dricot 7a05e5514e do not quit on ctrl+c, behaviour is annoying 2022-02-25 14:36:46 +01:00
Lionel Dricot edb71471dc rare crash on rss detection with some websites 2022-02-25 10:59:54 +01:00
Lionel Dricot 3231f425a9 binary files in gopher 2022-02-24 10:29:14 +01:00
Lionel Dricot ff12498b49 handle relative path for subscribing to feeds 2022-02-23 12:06:53 +01:00
Lionel Dricot 8b53ce8561 screenshots in README 2022-02-23 11:17:21 +01:00
Lionel Dricot 8c8b6763b2 quit on ctrl+c 2022-02-23 10:43:46 +01:00
Lionel Dricot 6d87b2f4bc solve a crash when calling less after a mailto link 2022-02-22 13:24:36 +01:00
Lionel Dricot 4f56a85e28 move from PROTOCOL_TLS to PROTOCOL_TLS_CLIENT. This should be enough to close #7 2022-02-22 11:15:19 +01:00
Lionel Dricot d468aced2f abstracting wrapping methods to try replace ansiwrap 2022-02-21 21:20:34 +01:00
Lionel Dricot 3b809c4146 Releasing 0.4 2022-02-21 00:46:14 +01:00
Lionel Dricot aa8e0cdb3e solve two gopher bugs related to path 2022-02-19 22:09:57 +01:00
Lionel Dricot fb29a83cc6 displaying lists where a page appear in info 2022-02-19 21:36:54 +01:00
Lionel Dricot f669bd9bed change process name to offpunk 2022-02-18 23:50:08 +01:00
Lionel Dricot f6820ba244 sync can now be called inside offpunk 2022-02-18 22:55:32 +01:00
Lionel Dricot d1ce7bd662 removing reference to cmdqueue in case we want to migrate to cmd2 2022-02-18 17:13:20 +01:00
Lionel Dricot 6f36970b34 new info command 2022-02-18 15:52:27 +01:00
Lionel Dricot cd5bba7b7b subscribe now detect embeded RSS feeds 2022-02-18 14:11:09 +01:00
Lionel Dricot f0623c1b93 should fix a rare crash when fetching redirected urls 2022-02-18 12:14:42 +01:00
Lionel Dricot 7d91ee0eb9 using new --incsearch for less if available 2022-02-17 23:16:16 +01:00
Lionel Dricot 87e8364932 cleaning up the less history file 2022-02-17 17:47:16 +01:00
Lionel Dricot 75397963cf restoring last position when less-ing a page 2022-02-17 17:19:11 +01:00
Lionel Dricot 80bf937f03 get less version 2022-02-17 15:57:04 +01:00
Lionel Dricot 279bd12748 proper separation of get_cache_path 2022-02-17 12:51:48 +01:00
Lionel Dricot 78e428d3a7 starting to remove self.path from GeminiItem 2022-02-17 12:38:50 +01:00
Lionel Dricot 136c8cfce7 cache_path is now generated upon request for case where it might become a folder afterward 2022-02-17 10:42:18 +01:00
Lionel Dricot 06f2c1b838 how a directory went to get mime ? 2022-02-17 10:02:45 +01:00
Lionel Dricot cf4dc86b03 tentatively improve html rendering 2022-02-17 09:58:42 +01:00
Lionel Dricot b9e0cf4b0b fix for gopher selectors 2022-02-16 09:45:38 +01:00
Lionel Dricot 45e894b041 changelog 2022-02-16 09:21:50 +01:00
Lionel Dricot 4fa3a718a8 fixing a tour bug and making the width dynamic 2022-02-15 21:57:14 +01:00
Lionel Dricot 430943a9b3 upgrade instructions 2022-02-15 19:43:50 +01:00
Lionel Dricot 0b5e516361 list help is synonym for help list 2022-02-15 16:50:33 +01:00
Lionel Dricot 33cc967df1 don’t save gi if it doesn’t exist 2022-02-15 16:05:10 +01:00
Lionel Dricot 39caf95381 we fetch frozen list if no valid cache exists 2022-02-15 15:18:07 +01:00
Lionel Dricot 4464a605b0 I was too quick to commit the new feature 2022-02-15 15:05:08 +01:00
Lionel Dricot bc0358f6c9 New list subscribe and list freeze commands 2022-02-15 14:56:35 +01:00
Lionel Dricot aa75f713ea reverting the non-recursive render of image in links 2022-02-15 10:17:00 +01:00
Lionel Dricot 8ae7587ab4 improving rendering of images nested in links and of non-breaking spaces 2022-02-15 00:04:30 +01:00
Lionel Dricot fdd1f36de6 vastly improved version command to see status of different features 2022-02-14 23:02:53 +01:00
Lionel Dricot 5cf26e28fa improve unicode handling and rss detection 2022-02-14 11:54:51 +01:00
Lionel Dricot e1ab504f69 --fetch-later now directly add to tour if a cached version already exists 2022-02-14 11:28:12 +01:00
Lionel Dricot 26009c7f75 RSS feeds are now rendered as gemlogs 2022-02-14 11:05:39 +01:00
Lionel Dricot 7781d7123c fixing blue title for RSS feeds 2022-02-14 10:25:55 +01:00
Lionel Dricot bf20721be5 fix crash with some mailto links 2022-02-13 23:18:42 +01:00
Lionel Dricot 176bcd438b Making Html renderer working with fragments to improve FeedRenderer 2022-02-13 22:59:16 +01:00
Lionel Dricot 85551f5af5 abstracting renderers to make them more coherent 2022-02-13 17:50:15 +01:00
Lionel Dricot 67fbf9902e fixing, once again, a crash wit too long path 2022-02-13 16:35:30 +01:00
Lionel Dricot ed5298b67e avoid crash with badly formatted images 2022-02-13 10:59:10 +01:00
Lionel Dricot 74bbf76814 FolderRenderer (currently only used for listing lists 2022-02-13 01:12:55 +01:00
Lionel Dricot 3029a3a218 Improving lists and making an abstract renderer 2022-02-13 00:37:31 +01:00
Lionel Dricot b85e9e8f04 handlers are now only used for non-text 2022-02-12 19:07:55 +01:00
Lionel Dricot 15b7591424 fixing a crash because a variable interfered witht the CMD module 2022-02-12 14:41:05 +01:00
Lionel Dricot 980ad72510 We now render images in terminal and introduce the open command. Beware, it is very experimental 2022-02-12 14:24:43 +01:00
Lionel Dricot ff9adf4aea Making offpunk working for variable width. Thanks to Kelbot for pointing it was not working 2022-02-12 13:12:37 +01:00
Lionel Dricot ec8fb1fda6 optimisation to not run image processor when syncing 2022-02-11 12:32:59 +01:00
Lionel Dricot 9cdb52383d improved image robustness 2022-02-11 12:01:05 +01:00
Lionel Dricot 4b39b7eac1 releasing 0.3 2022-02-11 11:33:37 +01:00
Lionel Dricot dc7e9156c8 improved handling of gopher connections and support for animated gif 2022-02-11 11:12:36 +01:00
Lionel Dricot 2413c1bf19 support for gopher 2022-02-10 23:46:59 +01:00
Lionel Dricot f0177f62f8 support for images nested in links 2022-02-10 17:19:20 +01:00
Lionel Dricot 691d2ee07c This is a very funny experiment with chapa to display image in
webpages
2022-02-09 21:46:29 +01:00
Lionel Dricot d0294fb58c trying to fallback on html if theres no entries in the feed. 2022-02-07 00:29:26 +01:00
Lionel Dricot f205dde0b6 full functionnal support for RSS and Atom 2022-02-06 15:48:24 +01:00
Lionel Dricot 8b1e28427b Basic support for RSS/Atom feeds 2022-02-06 14:08:25 +01:00
Lionel Dricot 81f3ff9f5b use magic by default if available to get mimetype 2022-02-06 12:55:54 +01:00
Lionel Dricot 79572a93ca small html rendering improvement 2022-02-05 14:42:35 +01:00
Lionel Dricot c405f8ddd9 improved title for non-fetched ressource 2022-02-05 12:46:32 +01:00
Lionel Dricot 08aedd4b42 improving html rendering 2022-02-05 00:26:51 +01:00
Lionel Dricot 11e6b3ccbc README improvments 2022-02-04 16:10:49 +01:00
Lionel Dricot 8de8c9ff7f new option --disable-http 2022-02-04 15:55:22 +01:00
Lionel Dricot 1cb3f48845 minor improvement in handling html titles 2022-02-04 13:38:33 +01:00
Lionel Dricot c985f1e8b4 aborting when an url is too long (this is an OS limitation) 2022-02-04 13:00:29 +01:00
Lionel Dricot 5d19662e3e adding depth and support for img in html 2022-02-04 01:14:22 +01:00
Lionel Dricot db991b2fd2 new argument to command less : full, allowing to disable readability 2022-02-03 21:56:23 +01:00
Lionel Dricot ba2c2f0d0e updated VERSIONS 2022-02-03 16:49:23 +01:00
Lionel Dricot e7f7e417e6 vastly improved syncing performance by building caches in more situation and disabling https_everywhere 2022-02-03 13:38:07 +01:00
Lionel Dricot ee1c660d74 This is an experiment to make --sync more intuitive based on Bjorn
Westergard’s feedback

See his post:
gemini://bjornwestergard.com/log/offpunk.gmi
2022-02-02 12:57:55 +01:00
Lionel Dricot 1881b98d96 adding our own user-agent else offpunk is considered as a bot by many http servers 2022-02-01 15:53:07 +01:00
Lionel Dricot c038fc9579 Merge branch 'master' of tildegit.org:ploum/AV-98-offline 2022-02-01 12:39:23 +01:00
Lionel Dricot 591c848478 close #6 (please test). It seems there are two XDG modules out there which are both incompatibles. The one is Debian seems to be a mix of both so I migrated to the correct way of using it (thanks to Klaus Alexander for providing code example). If this doesn’t work for everyone, we will have to support both way (code also provided by Klaus Alexander) 2022-02-01 12:32:51 +01:00
Lionel Dricot 19007edcd7 close #6 (please test). It seems there are two XDG modules out there which are both incompatibles. The one is Debian seems to be a mix of both so I migrated to the correct way of using it (thanks to Klaus Alexander for providing code example). If this doesn’t work for everyone, we will have to support both way (code also provided by Klaus Alexander) 2022-02-01 11:22:52 +01:00
Lionel Dricot 6b0c362b5e do not update history while syncing 2022-01-31 15:32:34 +01:00
Lionel Dricot ed81c3245f removing a forgotten print 2022-01-31 15:07:59 +01:00
Lionel Dricot d572f17903 Merge branch 'master' of tildegit.org:ploum/AV-98-offline 2022-01-31 14:55:55 +01:00
Lionel Dricot 635dfdbf80 releasing 0.2 2022-01-31 14:55:34 +01:00
Lionel Dricot dc3fbcc8a5 releasing 0.2 2022-01-31 14:43:00 +01:00
Lionel Dricot 4980890ac4 fixing a crash 2022-01-31 11:54:17 +01:00
Lionel Dricot 2dbe7de21c improving documentation 2022-01-30 19:33:04 +01:00
Lionel Dricot fb6511d51d pretty titles in list and not adding lists to history 2022-01-30 19:11:23 +01:00
Lionel Dricot b611c1ec87 fixing a bug where mailto: url were not counted as URL in a page 2022-01-30 17:47:03 +01:00
Lionel Dricot f2944d35af first step to transform renderers into their own objects 2022-01-29 15:37:18 +01:00
Lionel Dricot 69db426ab8 fixing bug #4 (thanks for the report) 2022-01-28 13:25:55 +01:00
Lionel Dricot 06b2e178fb history is now a list 2022-01-26 19:35:05 +01:00
Lionel Dricot 41f0900373 implementing the archive list 2022-01-26 18:52:38 +01:00
Lionel Dricot bd09d7cc61 localhost:// is now the widely used file:// 2022-01-25 12:20:11 +01:00
Lionel Dricot a961596f69 solved 2 nasty crashes and one infinite loop 2022-01-25 11:49:31 +01:00
Lionel Dricot 70cc059528 get_filename would crash while accessing local ressources 2022-01-24 19:23:03 +01:00
Lionel Dricot bd5ba00991 improving README 2022-01-24 17:15:54 +01:00
Lionel Dricot 9fa216c11e search is now find (because it’s on current page only) 2022-01-24 17:04:03 +01:00
Lionel Dricot 682631c4cd https_everywhere enabled by default 2022-01-24 16:50:22 +01:00
Lionel Dricot 2e7d213c26 improving subscribtions 2022-01-24 16:21:30 +01:00
Lionel Dricot 976c958bc3 lists can now be deleted 2022-01-24 15:11:49 +01:00
Lionel Dricot fd5da8761d new command : list edit 2022-01-24 12:24:19 +01:00
Lionel Dricot fcf8605af9 size of lists 2022-01-24 11:23:22 +01:00
Lionel Dricot daece10ce5 fixing bugs in the new sync code 2022-01-24 10:58:32 +01:00
Lionel Dricot 3c8db67844 multiple lists are now implemented 2022-01-23 23:14:06 +01:00
Lionel Dricot 1b4e1bf6bf added support for mailto links 2022-01-23 17:40:28 +01:00
Lionel Dricot ffc939094f tour is now a list 2022-01-23 17:09:05 +01:00
Lionel Dricot c8c32e4640 bookmarks are now a list 2022-01-23 13:52:34 +01:00
Lionel Dricot ac4d6547d2 debug of automatic choice 2022-01-23 10:44:19 +01:00
Lionel Dricot 9131c5621f new --assume-yes option for answering question when sync. Without it, no is assumed 2022-01-22 15:33:39 +01:00
Lionel Dricot 0894be5167 new method to manage lists: move 2022-01-22 15:08:06 +01:00
Lionel Dricot 5db7a47e72 you can create lists and add pages to them 2022-01-21 17:42:14 +01:00
Lionel Dricot 57c69df5b6 support query in the URL 2022-01-19 18:44:39 +01:00
Lionel Dricot 5505443132 I wrote offmini instead of offpunk in the README 2022-01-19 15:27:33 +01:00
Lionel Dricot 7ff4065493 added the --fetch-later command line 2022-01-19 15:21:28 +01:00
Lionel Dricot 7a17f04343 remove offline_web option (not used anymore) 2022-01-19 11:02:49 +01:00
Lionel Dricot d688a5d8ba better handling of paths 2022-01-19 10:46:53 +01:00
Lionel Dricot 9047dbd718 another stupid refactoring bug 2022-01-19 09:41:04 +01:00
Lionel Dricot 14e5fbcc83 refactoring and cleanup: now accessing links directly from gi instead of hiding a go_to 2022-01-18 22:19:43 +01:00
Lionel Dricot bdd006c896 offpunk now respects XDG 2022-01-18 18:04:29 +01:00
Lionel Dricot 9b8c06efce getting rid of from_map_line, never liked that odd method 2022-01-18 14:45:37 +01:00
Lionel Dricot 103610b077 t . was recognized as url, not a tour command 2022-01-18 14:42:09 +01:00
Lionel Dricot 7e9c535c1d stupid bug which break rendering with preformtted content 2022-01-18 14:16:14 +01:00
Lionel Dricot 00a8cf7580 stupid refactoring bug about localhost 2022-01-18 11:40:16 +01:00
Lionel Dricot ab645a82a6 solving bug #3 2022-01-18 11:39:01 +01:00
Lionel Dricot 94bed58364 fixing bugs after refactorisation 2022-01-18 10:53:56 +01:00
Lionel Dricot e40c0439b2 this is a huge refactorisation so gemtext/html renderers are now handled by each GeminiItem and not by the GeminiClient. Expect bugs 2022-01-17 23:37:12 +01:00
Lionel Dricot 76c2d9a491 consider that all .gmi files are text/gemini mimetype, even if they are not recognized as such 2022-01-17 14:32:46 +01:00
Lionel Dricot e3147d61d0 cosmetic change 2022-01-14 21:42:46 +01:00
Lionel Dricot c6a45ba819 cosmetic changes 2022-01-14 14:54:27 +01:00
Lionel Dricot 2158b78e77 improved README 2022-01-14 12:22:03 +01:00
Lionel Dricot b02b2603f0 fixed gemini:// not being added by default 2022-01-14 12:14:46 +01:00
Lionel Dricot 456095bd07 improve handling of nested <pre> 2022-01-14 11:28:30 +01:00
Lionel Dricot 5ad8dd61e7 html rendering starts to become really acceptable 2022-01-13 10:47:39 +01:00
Lionel Dricot 3bc6022348 fixed a bug while caching binary files 2022-01-13 10:06:10 +01:00
Lionel Dricot b1318e0289 solving that rendering bug where some spaces were removed 2022-01-12 16:23:55 +01:00
Lionel Dricot 2d26bc255c wrapping long links 2022-01-12 15:39:03 +01:00
Lionel Dricot bf6527d8e6 implemented blockquote 2022-01-12 13:23:22 +01:00
Lionel Dricot b7fa06322d makes the from_map_line method more robust to handle failures and bad URL 2022-01-12 12:21:11 +01:00
Lionel Dricot 0a26759d04 wrap long titles 2022-01-12 10:41:21 +01:00
Lionel Dricot 52735962c0 added standard_ports for http/https 2022-01-12 10:05:52 +01:00
Lionel Dricot e2d69df398 handle html page without body 2022-01-12 09:23:27 +01:00
Lionel Dricot 63e8c0e678 another crash with badly parsed url 2022-01-12 09:19:08 +01:00
Lionel Dricot fa9678895d vastly improved html rendering 2022-01-11 22:26:57 +01:00
Lionel Dricot 37918995d6 fix bad url crash 2022-01-11 14:04:20 +01:00
Lionel Dricot 4153a12f2b make to_fetch list more resilient to crashes 2022-01-11 09:39:09 +01:00
Lionel Dricot 257ee2f66d solving crashes 2022-01-11 09:16:34 +01:00
Lionel Dricot 305a736074 small changes 2022-01-10 21:29:19 +01:00
Lionel Dricot b3821d7719 removing debug log 2022-01-10 16:50:13 +01:00
Lionel Dricot 1d5f3b94b3 implementig hX 2022-01-10 16:48:35 +01:00
Lionel Dricot a92130db00 implement pre and li 2022-01-10 16:35:37 +01:00
Lionel Dricot a75cd96f65 less was not working with http 2022-01-10 15:53:41 +01:00
Lionel Dricot 6a77582606 README modified to announce web support 2022-01-10 15:42:39 +01:00
Lionel Dricot 35b884e9ff browsing the web seems to work 2022-01-10 15:30:23 +01:00
Lionel Dricot 8f5240f982 basic html rendering engine 2022-01-10 12:49:24 +01:00
Lionel Dricot 1d780fb1a3 refactor get_title 2022-01-10 11:19:29 +01:00
Lionel Dricot 1110bf5e0c gi might be None. Strange but it seems to happen in --sync. 2022-01-10 09:45:21 +01:00
Lionel Dricot d92a6db6b6 allowing http in --sync 2022-01-09 21:21:09 +01:00
Lionel Dricot 1edeab027c disable readability for now 2022-01-09 21:10:34 +01:00
Lionel Dricot fd88a5181f first working http support (work in progress) 2022-01-09 20:41:47 +01:00
Lionel Dricot c9a478d0eb starting to have http support 2022-01-09 16:12:07 +01:00
Lionel Dricot 2f7fa5daae starting to implement http support 2022-01-09 15:53:14 +01:00
Lionel Dricot a79f5da2cc refactoring write_body 2022-01-09 15:27:02 +01:00
Lionel Dricot 78c2728e96 some comments 2022-01-09 11:35:09 +01:00
Lionel Dricot 1d458c88f1 local files can be opened again 2022-01-08 22:18:54 +01:00
Lionel Dricot 818ae874a3 removing the never-used cache implementation 2022-01-08 21:55:19 +01:00
Lionel Dricot 28908078c3 fixing bugs introduced by the refactoring 2022-01-08 21:46:57 +01:00
Lionel Dricot 2f212848d8 big refactorisation incoming. Lot of bugs to expect. 2022-01-08 21:32:25 +01:00
Lionel Dricot 53d17d0f3b start of a huge refactoring : moving mime into a GeminiItem 2022-01-08 14:16:55 +01:00
Lionel Dricot 2f78452f9c add the longer prompt in less to see position 2022-01-06 13:44:02 +01:00
Lionel Dricot c9ec5eb243 new feature : copy content or url to main clipboard 2022-01-05 21:15:10 +01:00
Lionel Dricot 4aec75a753 new feature : copy content or url to main clipboard 2022-01-05 21:12:59 +01:00
Lionel Dricot 9974dab934 new feature: tour . 2022-01-03 16:40:52 +01:00
Lionel Dricot 3b0c69dcbf small README improvements 2022-01-03 14:48:58 +01:00
Lionel Dricot 74687a2ec8 Improving README 2022-01-01 22:36:06 +01:00
Lionel Dricot ae198f8f6e fixed a crash of the save command 2022-01-01 22:05:02 +01:00
Lionel Dricot c294e4cace improved README 2021-12-31 00:54:25 +01:00
Lionel Dricot 81e821f994 cache_path depends of the protocol 2021-12-30 16:46:52 +01:00
Lionel Dricot 4569bfeb1e Ploum’s url 2021-12-30 16:23:33 +01:00
Lionel Dricot 4303d451e6 Offpunk README 2021-12-30 16:18:35 +01:00
Lionel Dricot 700cba7184 Introducing Offpunk 2021-12-30 16:03:08 +01:00
Lionel Dricot 3d66f99c95 making magic dependancy optional 2021-12-30 15:43:00 +01:00
Lionel Dricot ed7b182281 better default for browsing (less instead of cat) 2021-12-27 14:05:16 +01:00
Lionel Dricot f4aec13ba6 access time added in title when offline 2021-12-24 14:52:55 +01:00
Lionel Dricot 5189cfac29 adding a title to each page, inspired by Lagrange 2021-12-23 21:47:44 +01:00
Lionel Dricot 16cde598c4 new feature: go automatically fetch content from clipboard if xsel is installed 2021-12-22 13:20:10 +01:00
Lionel Dricot 256c28e916 tour is now completely file based, reducing the risk of losing your tour 2021-12-22 10:21:32 +01:00
Lionel Dricot 0260bf1a04 small fixes 2021-12-20 16:32:54 +01:00
Lionel Dricot e26b10f668 strip URL to avoid blank lines being transformed as / 2021-12-20 15:32:19 +01:00
Lionel Dricot c09fa3fc2b we now cache errors (such as not found) in order to not try to refresh dead links all the time 2021-12-20 13:44:26 +01:00
Lionel Dricot 6c818f553a the refresh/add new to tour logic was broken after refactorisation 2021-12-19 15:51:59 +01:00
Lionel Dricot baa0aca61b sanitizing 2021-12-18 10:16:19 +01:00
Lionel Dricot 053502e214 only read text/gemini file and give all the rest to the mime handler 2021-12-17 23:29:47 +01:00
Lionel Dricot e23f80ab28 forgot to increment a counter 2021-12-17 18:09:55 +01:00
Lionel Dricot 586bffd30c gemlog link not working on tildegit 2 2021-12-17 16:11:29 +01:00
Lionel Dricot c7727bcb4a gemlog link not working on tildegit 2021-12-17 16:10:52 +01:00
Lionel Dricot 6bbcf3e0fe gemlog link in README 2021-12-17 16:07:34 +01:00
Lionel Dricot fa014ead75 fixing small bug with some bad formatted links 2021-12-17 15:50:20 +01:00
Lionel Dricot ba429946ec add / at the end of url if cache is a dir 2021-12-17 15:15:09 +01:00
Lionel Dricot 2e6bd28563 updating README 2021-12-17 14:11:46 +01:00
Lionel Dricot 8651a14e34 no blank line in tour file 2021-12-17 13:59:34 +01:00
Lionel Dricot 843ce388c8 solve a bug when white lines appended it tour file 2021-12-17 12:35:46 +01:00
Lionel Dricot 45a0da6d42 refactorization of fetch_catch, adding logic to add to tour smartly and to randomly reload some old stuff 2021-12-17 12:08:27 +01:00
Lionel Dricot 77ce33173e sugar: http and gemini link are understood without the go command 2021-12-16 16:09:54 +01:00
Lionel Dricot 8ede39dd4d adding --cache-validity option 2021-12-16 15:58:05 +01:00
Lionel Dricot 9d5a1a9e4c don’t refresh more than every 1h 2021-12-16 13:10:55 +01:00
Lionel Dricot de840bdf9f Solve accessing url without trailing / and add online command 2021-12-16 10:43:25 +01:00
Lionel Dricot ce38b49ba6 by default, mimetype is text/gemini 2021-12-15 11:49:40 +01:00
Lionel Dricot 502668c3c6 support for caching every MIMETYPE 2021-12-15 11:45:55 +01:00
Lionel Dricot 3d6c702fda more elegant solution when redirecting to index.gmi 2021-12-15 11:05:38 +01:00
Lionel Dricot 10d6c3110f Hell of a hack for naughty bug + handle offline reload 2021-12-14 16:33:17 +01:00
Lionel Dricot 1a21c902cb content not cached will be marked for next sync 2021-12-14 16:07:02 +01:00
Lionel Dricot f457f08c2f new links found while syncing are automatically added to tour (and tour is preserved accross session 2021-12-14 15:26:37 +01:00
Lionel Dricot f1d85094c9 tour is now saved accross session 2021-12-14 15:12:43 +01:00
Lionel Dricot 72f2b5f91c --synconly is now --sync and has a fancy output 2021-12-14 14:06:07 +01:00
Lionel Dricot 1bf23193c4 trying to not open xml files in synconly also prevented parsing and thus recursive retrieval 2021-12-14 13:29:09 +01:00
Lionel Dricot 2ac144dc00 offline web browser option 2021-12-13 14:30:40 +01:00
Lionel Dricot a5c2341785 synconly a lot more faster and efficient 2021-12-13 13:49:12 +01:00
Lionel Dricot 4212a4fd2b off-98 prompt 2021-12-10 15:24:26 +01:00
Lionel Dricot 9da4fd150b basic --synconly mode is now working 2021-12-10 11:27:48 +01:00
Lionel Dricot 6586f0834a some links are still crashing with sync_only 2021-12-09 18:05:46 +01:00
Lionel Dricot 0c333ce4bb sync-only mode now cache bookmarks 2021-12-09 17:23:50 +01:00
Lionel Dricot f58b96e894 first step for a sync_only mode 2021-12-09 15:12:32 +01:00
Lionel Dricot 9342bccec7 more bugs listed in README 2021-12-07 14:06:48 +01:00
Lionel Dricot 9fb7c610bf ugly hack to fix caching for URL without / at the end 2021-12-07 13:08:43 +01:00
Lionel Dricot 25247eaa90 README 2021-12-06 17:13:19 +01:00
Lionel Dricot 26e083d894 README 2021-12-06 17:12:45 +01:00
Lionel Dricot 9cc713431c Offline now works for basic usecase ! 2021-12-06 17:03:22 +01:00
Lionel Dricot b1c9220fc5 offline switchg 2021-12-06 16:43:16 +01:00
Lionel Dricot acdc83ed6d permanent cache is now created 2021-12-06 16:17:01 +01:00
Lionel Dricot 07ee2e9782 cache path by default 2021-12-04 21:01:11 +01:00
Lionel Dricot 1fff962e45 bad code to have cache_path 2021-12-04 19:52:08 +01:00
Lionel Dricot 79b24e960c adding comment to understand 2021-12-02 16:27:14 +01:00
Björn Wärmedal 62898d3938 Jake's solution for the local files bug 2021-11-18 12:02:00 +01:00
Björn Wärmedal 292a68fc23 Removed a bunch of unnecessary certificate checks. 2021-10-06 11:07:08 +02:00
Björn Wärmedal 37e2c671e4 Updated version in setup.py as well 2021-08-25 08:34:24 +02:00
Björn Wärmedal 49db2732be Updated contributors list. Thank you Jake for the tour reverse-range and https proxy solutions! 2021-08-25 08:07:18 +02:00
Björn Wärmedal 6c38132259 Added https proxy setting, similar to gopher proxy. Also bumped version number. 2021-08-25 08:03:12 +02:00
Björn Wärmedal 4408963c69 Reverse tour add: 'tour 50-40' will now add all links in that range in that order. 2021-08-25 08:01:16 +02:00
Björn Wärmedal 94c0de9b15 Clarify status as a fork of AV-98 in Readme 2021-05-05 09:13:49 +02:00
Björn Wärmedal 7468dcef77 replaced GUS with geminispace.info, since GUS is dead 2021-04-27 09:55:12 +02:00
Björn Wärmedal c86cbdedca Increased default timeout (geminispace.info searches usually take longer) 2021-04-27 09:53:58 +02:00
Björn Wärmedal b6bae540ba Show name of activated client cert 2021-02-03 08:06:27 +01:00
32 changed files with 6496 additions and 1742 deletions

338
CHANGELOG Normal file
View File

@ -0,0 +1,338 @@
# Offpunk History
## 2.3 - Unreleased
- offpunk/netcache: fix IPv6 as an URL (bug #40)
- ansicat: display empty files (instead of opening them with xdg-open)
- fix escape sequence warning in python 3.12 (by Étienne Mollier) (Debian #1064209)
- ansicat : fix crash when feedparser is crashing on bad RSS
## 2.2 - February 13th 2023
- cache folder is now configurable through $OFFPUNK_CACHE_PATH environment variable (by prx)
- offpunk: adding an URL to a list now update the view mode if url already present
- netcache: solve an infinite gemini loop with code 6X (see also bug #31)
- ansicat: added support for <video> HTML-element
- ansicat: if chafa fails to load an image, fallback to timg if available
- offpunk: add list autocompletion to "tour"
- offpunk: removed "blackbox", which has not been used nor maintained
- offpunk: "gus" was broken, it is functionnal again
- opnk/offpunk: more informative prompt in less
- ansicat: added support for HTML description elements <dt> and <dd> (by Bert Livens)
- opnk: added "--mode" command-line argument (bug #39)
- offpunk: support for "preformatted" theming (bug #38)
- opnk/netcache: added "--cache-validity" command-line argument (bug #37)
- ansicat: consider files as XML, not SVG, if they dont have .svg extension
- offpunk: fix "view link" crashing with link to empty files
## 2.1 - December 15th 2023
- freshly updated gemtext/rss links are highlighted ("new_link" theme option)
- offpunk : new "copy title" and "copy link" function
- offpunk : new "view XX" feature where XX is a number to view information about a link
- ansicat: added "--mode" option
- redirections are now reflected in links and the cache (bug #28)
- ansicat: avoid a crash when urllib.parse.urljoin fails
- offpunk: Fix a crash when gus is called without parameters (Von Hohenheiden)
- ansicat: fixed a crash when parsing wrong hidden_url in gemini (bug #32)
- offpunk: offpunk --version doesnt create the cache anymore (bug #27)
- ansicat: fix a crash with HTML without title (bug #33)
- netcache: gemini socket code can crash when IPv6 is disabled (mailing-list)
## 2.0 - November 16th 2023
Changes since 1.10
- IMPORTANT: Licence has been changed to AGPL for ideological reasons
- IMPORTANT: Contact adress has been changed to offpunk2 on the same domain (because of spam)
- IMPORTANT: code has been splitted into several differents files.
- IMPORTANT: migrating from flit to hatchling (patch by Jean Abou Samra)
Major features:
- New command-line tool: "netcache"
- New command-line tool: "ansicat"
- New command-line tool: "opnk"
- "theme" command allows customization of the colours
- "--config-file" allows to start offpunk with custom config (#16)
- "view source" to view the source code of a page
- introduced the "default_protocol" options (default to gemini)
Improvments:
- Reading position is saved in less for the whole session
- Rendering is cached for the session, allowing faster browsing of a page already visited
- "redirect" supports domains starting with "*" to also block all subdomins
- "--images-mode" allow to choose at startup which images should be dowloaded (none,readable,full)
- Support for embedded multi-format rendering (such as RSS feeds with html elements)
- The cache is now automatically upgraded if needed (see .version in your cache)
- Images of html files are now downloaded with the html (slower sync but better reading experience)
- "--sync" can optionnaly take some lists as arguments, in order to make for specific sync
- initial tentative to support podcasts in RSS/Atom feeds
Other notable changes from 1.X:
- "accept_bad_ssl_certificates" now more agressive for http and really accepts them all
- Gopher-only: we dont support naming a page after the name of the incoming link
- Gemini-only: support for client generated certificates has been removed
- "file" is now marked as a dependency (thank Guillaume Loret)
## 2.0 (beta3 - final 2.0) - Released as 2.0
Changes since beta2:
- bug #25 : makes python-requests optional again
- --disable-http had no effect: reimplemented
- introduced the "default_protocol" options (default to gemini) to enter URLs without the :// part (fixes bug #21)
## 2.0-beta2 - November 8th 2023
Changes since beta1
- IMPORTANT: migrating from flit to hatchling (patch by Jean Abou Samra)
- "--sync" can optionnaly take some lists as arguments, in order to make for specific sync
- "view source" to view the source code of a page
- initial tentative to support podcasts in RSS/Atom feeds
- new PlaintextRenderer which display .txt files without any margin/color/linebreaks
- default URL blocked list is now its own file to make contributions easier
- prompt color is now part of the theme
- improves handling of base64 images
- fixes gophermap being considered as gemtext files
- fixes opening mailto links
- fixes existing non-html ressources marked a to_fetch even when not needed (simple and/or confusion)
- fixes a crash with RSSfeeds without <link> element
- fixes a crash with data:image/svg+xml links
- fixes a bug in HTML renderer where some hX element were not closed properly
- fixes input in Gemini while online
- fixes a crash with invalid URL
- fixes a crash while parsing invalid dates in RSS
- fixes hang/crash when meeting the ";" itemtype in gopher
- attempt at hiding XMLparsedAsHTMLWarning from BS4 library
- chafa now used by default everywhere if version > 1.10
- ignoring encoding error in ansicat
## 2.0-beta1 - September 05th 2023
This is an an experimental release. Bug reports and feedbacks are welcome on the offpunk-devel list.
- WARNING: pyproject.toml has not been updated and is currently non-functional. Help needed!
- IMPORTANT: Licence has been changed to AGPL for ideological reasons
- IMPORTANT: Contact adress has been changed to offpunk2 on the same domain (because of spam)
- IMPORTANT: code has been splitted into 7 differents files. Installation/packaging should be adapted.
Major features:
- New command-line tool: "netcache"
- New command-line tool: "ansicat"
- New command-line tool: "opnk"
- "theme" command allows customization of the colours
- "--config-file" allows to start offpunk with custom config (#16)
Improvments:
- Reading position is saved for the whole session
- Rendering is cached for the session, allowing faster browsing of a page already visited
- "redirect" supports domains starting with "*" to also block all subdomins
- "--images-mode" allow to choose at startup which images should be dowloaded (none,readable,full)
- Support for multi-format rendering (such as RSS feeds with html elements)
- The cache is now automatically upgraded if needed (see .version in your cache)
Other changes from 1.X:
- Images of html files are now downloaded with the html (slower sync but better reading experience)
- URL do not default anymore to "gemini://" if not protocol are indicated. (ongoing discussion in #21)
- "accept_bad_ssl_certificates" now more agressive for http and really accepts them all
- Gopher-only: we dont support naming a page after the name of the incoming link
- Gemini-only: support for client generated certificates has been removed
- "file" is now marked as a dependency (thank Guillaume Loret)
## 1.10 - July 31st 2023
- IMPORTANT : new optional dependency : python-chardet
- IMPORTANT : Gopher directory index filename changed from "index.txt" to "gophermap". To update the cache to the new format run the `migrate-offpunk-cache` script (Sotiris Papatheodorou)
- "set accept_bad_ssl_certificates True" now also used for Gemini expired certificates
- Add missing chardet module (Sotiris Papatheodorou)
- Fix merging dictionaries with common keys (Sotiris Papatheodorou)
- Fix Gopher requests (rewrite URL parsing code per RFC 4266)
## 1.9.2 - March 13th 2023
- Switch from setup.py to flit (Anna cybertailor Vyalkova)
- Bump requirements to python >= 3.7 (Anna cybertailor Vyalkova)
## 1.9.1 - March 8th 2023
- Fixed crash with archive without GI (thanks Étienne Mollier)
## 1.9 - March 8th 2023
This is a bug-fixing release.
- We now have a man page thanks to phoebos!
- ".." as abbreviation to "up" (by Sotiris Papatheodorou)
- Fix support for UTF-8 domains in Gemini (Maeve Sproule, fixes #5)
- Assume UTF-8 when the header answer with an unknown encoding
- Default handlers have been removed (not everybody use feh and zathura)
- Fix a crash when subscribing without GI (reported by sodimel on linuxfr)
- Fix a crash when trying to access a link without GI (Ben Winston)
- Fix a crash when rss items dont have a title (eg: Mastodon rss)
- Fix a crash with badly formatted links in gopher ( #7 by xiu)
- Fix a crash were some HTML content is seen a bytes instead of a string
- Fix a crash when displaying embedded CDATA html in feed. But #10 is still open.
- Fix error handling assuming that requests is installed
- Ugly fix for a rare certificate bug (fix #11)
- Improve compatibility with python prior 3.9 by replacing a dict union
## 1.8 - December 11th 2022
- Official URL is now https://sr.ht/~lioploum/offpunk/
- SECURITY: Avoid passing improperly-escaped paths to shell (fixes notabug #9) (by Maeve Sproule)
- Add support for the finger protocol (by Sotiris Papatheodorou)
- "restricted" mode has been removed because unmaintained (code cleanup)
- "set accept_bad_ssl_certificates True" allows to lower HTTPS SSL requirements (also with --assume-yes)
- Accept "localhost" as a valid URL
- Better feedback when --sync an URL which is streaming
- Removed cgi dependency (soon deprecated)
- Fix: crash with some svg data:image (which are now ignored)
- Fix images from "full" mode not being downloaded
- Fix a crash when ls on empty page (thanks Marty Oehme)
- Fix: A variable was not initialised without python-cryptography
- Fix: "cp raw" was not accessing the temp_file correctly
- Fix: ANSI handling off arrows in readline (by Ben Winston)
## 1.7.1 - November 15th 2022
- Correcting a stupid crash in search (thanks kelbot for the report)
## 1.7 - November 15th 2022
- New "search" command which uses kennedy.gemi.dev by default.
- New "wikipedia" command, which uses vault.transjovian.org by default.
- Aliases "wen", "wfr" and "wes" for Wikipedia in English, French and Spanish.
- Autocompletion for the list/add/move commands (thats incredibly useful!)
- If a link is found in plain text in a gopher/gemini page, it is now
added to the list of links for that page. Useful for gopher.
- Create system lists when needed to avoid failure on clean system
- Solve a crash when parsing wrong URL (related to bug #9 )
- Solve a crash when loading webpages with empty links
- Solve a crash when trying to load a wrong URL into tour
=> gemini://ploum.be/2022-11-15-offpunk17-sourcehut.gmi
## 1.6 - October 12th 2022
- Support for base64 encoded pictures in HTML pages (opening them full screen only works offline)
- A list can be added to a tour with "tour $LIST_NAME".
- Check for timg > 1.3.2 to avoid dealing with old versions (bug reported by Valvin)
- Redirect are now honoured also when --sync (bug #15, thanks kelbot)
- RSS feeds are now automatically downloaded with a webpage (bug #14)
- Solved the bug where an invalid URL would break correspondance between url and numbers
- Considers .xml files as feed by default to avoid false-detection as SVG
- Replaced default libreddit.com redirection to teddit.net (bug #12 by kelbot)
- The "beta" option has been removed as it is not used (update your config if needed)
## 1.5 - August 4th 2022
- Removed optional dependency to ripgrep. "grep --color=auto" is good enough.
- "open url" to open current URL in a browser with xdg-open
- "redirect" now replaces "set redirects" to improve discoverability
- "redirect" now allows urls to be blocked. By default, facebook.com and google-analytics.com are blocked
- Fixed a bug when trying to download base64 image
=> gemini://rawtext.club/~ploum/2022-08-04-offpunk15.gmi
## 1.4 - April 25th 2022
- Making python-readability optional
- Removing "next" and "previous" which are quite confusing and not obvious
- Archiving now works regardless of the view you are in.
- Fixing a crash when accessing an empty html page
- Not trying to display non-image files to avoid errors. (this requires "file")
## 1.3 - April 2th 2022
- Removed dependency to python-magic. File is now used directly (and should be on every system).
- Removed dependency to python-editor. If no $VISUAL or $EDITOR, please use "set editor" in Offpunk.
- Images are now downloaded before displaying an HTML page (can be disabled with "set download_images_first False")
- Introduced "set redirects" which redirects twitter,youtube,medium,reddit to alternative frontends.
- New behaviour for "find" (or "/") which is to grep through current page (ripgrep used if detected)
- Default width set to 80 as many gopherholes and gemini capsules have it hardcoded
- Streaming URL without valid content-length are now closed after 5Mo of download (thanks to Eoin Carney for reporting the issue)
- Gif animations are now displayed once when viewed (instead of a still frame).
- Restored some AV-98 certificate validation code that was lost Idont know how.
- Improved clarity of dependencies in "version"
- Fixed a crash when the cache is already a dir inside a dir.
- Fixed a crash when manually entering an unknown gopher URL while offline
- Fixed an error with older less version
- Fixed bookmarks not being automatically created at first "add"
- Call to shell commands has been refactorised to improve compatibility with python 3.6 (with testing from Pelle Nilsson)
- requirements.txt has been contributed by Toby Kurien. Thanks!
=> gemini://rawtext.club/~ploum/2022-04-02-offpunk13.gmi
## 1.2 - March 24th 2022
Very experimental release:
- Completely rewritten the HMTL, Gemtext and Gopher renderer. Tests needed!
- Removed dependancy to ansiwrap. We dont use it anymore (which is an important achievement)
- Lists are now accessed via the protocol "list://".
- "view full" can now be bookmarked/synchronized as a separate entity.
- "view normal" introduced to get back to the normal view.
Small improvements:
- Limit width of --sync output
- Solved list names becoming very long in the history
- Fixed a crash when trying to save a folder
=> gemini://rawtext.club/~ploum/2022-03-24-ansi_html.gmi
## 1.1 - March 18th 2022
- Perfect rendering of pictures with chafa 1.8+ and compatible terminal (Kitty)
- timg is supported as an alternative to chafa (with a little glitch)
- "cp cache" put the path of the cached content in clipboard
- "cp url X" will copy the URL of link X (suggested by Eoin Carney)
- "fold" has been removed as it doesnt work well and can be replaced with "!fold".
- Improved clipboard URL detection an fixed crash when binary in clipboard
- HTML: renderering of <pre> has been improved
- HTML: links in titles were previously missed
- Fixed crash when chafa is not installed (Thanks Xavier Hinault for the report)
- Fixed crash when python-readability not installed (Thanks Nic for the report)
- Fixed some gif not being displayed
- Fixed some URL being wronlgy interpreted as IPv6
## 1.0 - March 14th 2022
- Default width is now the standard 72
- Content and pictures now centered for more elegant reading
- "less" has been renamed "view"
- "view feed" and "view feeds" to see the first/all feeds on a HTML page
- "view full" has been improved by dropping inline CSSand JS.
- "up" can now take integer as argument to go up multiple steps.
- Fixed a crash when accessing links in list (thanks Matthieu Talbot for the report)
- Fixed a crash in "info" due to a typo in a variable name rarely accessed.
- Removed dependancy to python-xdg by implementing the logic (which saved lines of code!)
- python-pil is only needed if chafa < 1.10
=> gemini://rawtext.club/~ploum/2022-03-14-offpunk_and_cyberpunk.gmi
## 0.9 - March 05th 2022
- Initial Spartan protocol support
- Http links with content above 20Mo are not downloaded during sync (except when explicitely requested)
- Improving subscriptions with more feedback and better detection
- Avoid deprecated SSL methods (thanks Phoebos for the report)
- Links in to_fetch are fetched, no matter the cache
- Fixed multiple crashes
=> gemini://rawtext.club/~ploum/2022-03-05-offpunk09.gmi
## 0.4 - Feb 21st 2022
UPGRADE: Users who subscribed to pages before 0.4 should run once the command "list subscribe subscribed". Without that, the subscribed list will be seen as a normal list by sync.
- New list command : "list freeze" and "list suscribe"
- Pictures are now displayed directely in terminal (suggested by kelbot)
- "open" command to open current page/image/file with external handler.
- "set width XX" now works to set the max width. If smaller, terminal width is used (thanks kelbot for reporting the bug)
- RSS feeds are now rendered as Gemlogs to improve consistency while browsing
- "subscribe" will detect feeds in html pages if any
- "less" will restore previous position in a page (requires less 572+)
- Improved syncing performances and multiple bug/crash fixes.
- "version" will now display info about your system installation
- "info" command will display technical information about current page
- "sync" allows you to do the sync from within Offpunk
=> gemini://rawtext.club/~ploum/2022-02-21-offpunk04.gmi
## 0.3 - Feb 11th 2022
New Features:
- Gopher supported natively (early version, might have many bugs)
- support for RSS and Atom feed (you can subscribe to them)
- "less full" allows to see the full html page instead of only the article view
(also works with feeds to see descriptions of each post instead of a simple list)
- Option --depth to customize your sync. Be warned, more than 1 is crazy.
- Option --disable-http to allows deep syncing of gemini-only ressources
- Vastly improved HTML rendering with support for images (you need the binary "chafa" on your system)
Other Small Improvements:
- Disabled https_everywhere by default (caching problems and some websites not supporting it)
- Modified --sync logic to make it more intuitive (thanks Bjorn Westergard)
- Caching more problems to avoid refetch
- Offpunk has now an User-Agent when http browsing to avoid being blocked as a bot
- Changed XDG logic to improve compatibility (thanks Klaus Alexander)
=> gemini://rawtext.club/~ploum/2022-02-11-offpunk03.gmi
## 0.2 - Jan 31st 2022
- config directories have been moved to follow the XDG specifications
- support for http, https and mailto links (https_everywhere is enabled by default, see "set" command)
- support for HTML pages, rendered as articles
- Mutiple bookmarks lists and management of them through commands list, add, archive, move
- Subscriptions have been moved to a separate list with the subscribe command
- History is persistent and saved to disk
- Copy command allows to copy content or url into buffer
- Search as been renamed find, in the hope of implementing a real search in the future
- --fetch-later allows to mark a content to be fetched from other software.
- --assume-yes allows to choose the default answer to certificates warnings during --sync.
=> gemini://rawtext.club/~ploum/2022-01-31-offpunk02.gmi Announcing Offpunk 0.2
## 0.1 - Jan 3rd 2022
- initial release as an independant software from AV-98 (thanks solarpunk)
- Including contributions published by Bjorn on Notabug (thanks ew0k)
- less used by default for all content with custom options
- online/offline mode
- content is cached for offline use
- bookmarks are cached and subscribed through the --sync option
- tour is persistent and saved to disk
- reload while offline mark the content to be fetched during next --sync
=> gemini://rawtext.club/~ploum/2022-01-03-offpunk.gmi Announce of Offpunk 0.1

19
CONTRIBUTORS Normal file
View File

@ -0,0 +1,19 @@
Offpunk Offline Gemini client
And the Offpunk tools suite: netcache, ansicat, opnk.
(C) From 2021: Ploum <offpunk2@ploum.eu>
Derived from AV-98 and Agena by Solderpunk,
(C) 2019, 2020: Solderpunk <solderpunk@sdf.org>
AV-98 received contributions from:
- danceka <hannu.hartikainen@gmail.com>
- <jprjr@tilde.club>
- <vee@vnsf.xyz>
- Klaus Alexander Seistrup <klaus@seistrup.dk>
- govynnus <govynnus@sdf.org>
- Björn Wärmedal <bjorn.warmedal@gmail.com>
- <jake@rmgr.dev>
Offpunk received contributions from:
- Maeve Sproule <code@sprock.dev>

677
LICENSE
View File

@ -1,23 +1,664 @@
Copyright (c) 2020, Solderpunk <solderpunk@sdf.org> and contributors.
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (c) 2022, Ploum <offpunk2 at ploum.eu> and contributors.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
Preamble
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<https://www.gnu.org/licenses/>.

164
README.md
View File

@ -1,62 +1,132 @@
# AV-98
# OFFPUNK
AV-98 is an experimental client for the
[Gemini protocol](https://gemini.circumlunar.space). It is derived from the
[gopher client VF-1](https://github.com/solderpunk/VF-1) by the same author.
AV-98 is "experimental" in the sense that it may occasionally extend or deviate
from the official Gemini specification for the purposes of, well,
experimentation. Despite this, it is expected to be stable enough for regular
daily use at the same time.
A command-line and offline-first smolnet browser/feed reader for Gemini, Gopher, Spartan and Web by [Ploum](https://ploum.net).
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.
Official project page (repository/mailing lists) : https://sr.ht/~lioploum/offpunk/
![Screenshot HTML page with picture](screenshot_offpunk1.png)
![Screenshot Gemini page](screenshot_offpunk2.png)
Offpunk is a fork of the original [AV-98](https://tildegit.org/solderpunk/AV-98) by Solderpunk and was originally called AV-98-offline as an experimental branch.
## How to use
Offpunk is a set of python files. Installation is optional, you can simply git clone the project 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 if no protocol is specified. Supported protocols are gemini, gopher, finger, http, https, mailto, spartan and file. Default protocol is configurable).
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. Type `q` to quit and go back to Offpunk prompt. Type `view` or `v` to display it again. (`view full` or `v full` allows to see the full html page instead of the article view. `v feed` try to display the linked RSS feed and `v feeds` displays a list of available feeds. This only applies to html pages. `v source` allows you to see the source code of a page and `v normal` to go back to normal view)
Use `add` to add a page 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. `--assume-yes` will automatically accept SSL certificates with errors instead of refusing them.
Sync can be applied to only a subset of list.
`offpunk --sync bookmarks tour to_fetch --cache-validity 3600`
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`
## More
Important news and releases will be announced on the offpunk-devel mailing list
=> https://lists.sr.ht/~lioploum/offpunk-devel
Questions can be asked on the users mailing list:
=> https://lists.sr.ht/~lioploum/offpunk-users
## Dependencies
AV-98 has no "strict dependencies", i.e. it will run and work without anything
else beyond the Python standard library. However, it will "opportunistically
Offpunk has few "strict dependencies", i.e. it should run and work without anything
else beyond the Python standard library and the "less" pager. However, it will "opportunistically
import" a few other libraries if they are available to offer an improved
experience.
experience or some other features such as HTTP/HTML or image support.
* The [ansiwrap library](https://pypi.org/project/ansiwrap/) may result in
neater display of text which makes use of ANSI escape codes to control colour.
* The [cryptography library](https://pypi.org/project/cryptography/) will
provide a better and slightly more secure experience when using the default
TOFU certificate validation mode and is highly recommended.
To avoid using unstable or too recent libraries, the rule of thumb is that a library should be packaged in Debian/Ubuntu. Keep in mind that Offpunk is mainly tested will all libraries installed. If you encounter a crash without one optional dependencies, please report it. Patches and contributions to remove dependencies or support alternatives are highly appreciated.
* [List of existing Offpunk packages (Repology)](https://repology.org/project/offpunk/versions)
* PIP: [requirements file to install dependencies with pip](requirements.txt)
* Ubuntu/Debian: [command to install dependencies on Ubuntu/Debian without pip](ubuntu_dependencies.txt)
* Please contribute packages for other systems, theres a [mailing-list dedicated to packaging](https://lists.sr.ht/~lioploum/offpunk-packagers).
Run command `version` in offpunk to see if you are missing some dependencies.
Mandatory or highly recommended (packagers should probably make those mandatory):
* [less](http://www.greenwoodsoftware.com/less/): mandatory but is probably already on your system
* [file](https://www.darwinsys.com/file/) is used to get the MIME type of cached objects. Should already be on your system.
* [xdg-utils](https://www.freedesktop.org/wiki/Software/xdg-utils/) provides xdg-open which is highly recommended to open files without a renderer or a handler. It is also used for mailto: command.
* The [cryptography library](https://pypi.org/project/cryptography/) will provide a better and slightly more secure experience when using the default TOFU certificate validation mode and is recommended (apt-get install python3-cryptography).
Dependencies to enable web browsing (packagers may put those in an offpunk-web meta-package but it is recommended to have it for a better offpunk experience)
* [Python-requests](http://python-requests.org) 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](https://www.crummy.com/software/BeautifulSoup) and [Readability](https://github.com/buriy/python-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](https://github.com/kurtmckee/feedparser) will allow parsing of RSS/Atom feeds and thus subscriptions to them. (apt-get install python3-feedparser)
* [Chafa](https://hpjansson.org/chafa/) allows to display pictures in your console. Install it and browse to an HTML page with picture to see the magic.
Gopher dependencies:
* [Python-chardet](https://github.com/chardet/chardet) is used to detect the character encoding on Gopher (and may be used more in the future)
Older dependencies which are only needed on older systems (where chafa < 1.10)
* [Timg](https://github.com/hzeller/timg) is a slower alternative to chafa for inline images. Might be deprecated in the future.
* [Python-pil](http://python-pillow.github.io/) is required to only display the first frame of animated gif with chafa if chafa version is lower than 1.10. Might be deprecated in the future.
Nice to have (packagers should may make those optional):
* [Xsel](http://www.vergenet.net/~conrad/software/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)
* [Python-setproctitle](https://github.com/dvarrazzo/py-setproctitle) will change the process name from "python" to "offpunk". Useful to kill it without killing every python service.
## Features
* TOFU or CA server certificate validation
* Extensive client certificate support if an `openssl` binary is available
* Ability to specify external handler programs for different MIME types
* Gopher proxy support (e.g. for use with
[Agena](https://tildegit.org/solderpunk/agena))
* Advanced navigation tools like `tour` and `mark` (as per VF-1)
* Bookmarks
* IPv6 support
* Supports any character encoding recognised by Python
## Lightning introduction
You use the `go` command to visit a URL, e.g. `go gemini.circumlunar.space`.
Links in Gemini documents are assigned numerical indices. Just type an index to
follow that link.
If a Gemini document is too long to fit on your screen, use the `less` command
to pipe it to the `less` pager.
Use the `help` command to learn about additional commands.
* Browse https/gemini/gopher without leaving your keyboard and without distractions
* Customize your experience with the `theme` command.
* 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 or see the full page with `view full`.
* RSS/Atom feeds are automatically discovered by `subscribe` and rendered as gemlogs. They can be explored with `view feed` and `view feeds`.
* 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, subscribing/freezing lists and archiving content.
* 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`)
* Enhanced privacy with `redirect` which allows to block a http domain or to redirect all request to a privacy friendly frontent (such as nitter for twitter).
* Non-interactive cache-building with configurable depth through the --sync command. The cache can easily be used by other software.
* `netcache`, a standalone CLI tool to retrieve the cached version of a network ressource.
* `ansicat`, a standalone CLI tool to render HTML/Gemtext/image in a terminal.
* `opnk`, a standalone CLI tool to open any kind of ressources (local or network) and display it in your terminal or, if not possible, fallback to `xdg-open`.
## RC files
You can use an RC file to automatically run any sequence of valid AV-98
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
`set`, `handler` or `themes` commands 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.
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). In that file, simply write one command per line, just like you would type them in offpunk.
## 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.
The cache can be accessed/built with the `netcache` tool. See `netcache -h` for more informations.
Theres no feature to automatically trim the cache. But any part of the cache can safely be removed manually as there are no databases or complex synchronisation.
The RC file should be called `av98rc`. AV-98 will look for it first in
`~/.av98/` and second in `~/.config/av98/`. Note that either directory might
already exist even if you haven't created it manually, as AV-98 will, if
necessary, create the directory itself the first time you save a bookmark (the
bookmark file is saved in the same location). AV-98 will create
`~/.config/av98` only if `~/.config/` already exists on your system, otherwise
it will create `~/.av98/`.

1520
ansicat.py Executable file

File diff suppressed because it is too large Load Diff

1654
av98.py

File diff suppressed because it is too large Load Diff

2
debug.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
XDG_DATA_HOME="~/debug/data" XDG_CONFIG_HOME="~/debug/config" XDG_CACHE_HOME="~/debug/cache" python offpunk.py

0
doc/config.gmi Normal file
View File

0
doc/dev.gmi Normal file
View File

17
doc/index.gmi Normal file
View File

@ -0,0 +1,17 @@
# OFFPUNK - An Offline-First Browser for the Smolnet
Offpunk is a command-line browser and feed reader dedicated to browsing the Web, Gemini, Gopher and Spartan. Thanks to its permanent cache, it is optimised to be used offline with rare connections but works as well when connected.
Offpunk is optimised for reading and supports readability mode, displaying pictures, subscribing to pages or RSS feeds, managing complex lists of bookmarks. Its integrated help and easy commands make it a perfect tool for command-line novices while power-users will be amazed by its shell integration.
Offpunk is written in Python 3 by Ploum. It aims to be portable and minimise dependencies, making them optional. It supports http/https/gopher/gemini/spartan on both IPv4 and IPv6.
=> install.gmi Installing Offpunk and dependencies
=> tutorial.gmi First steps
=> config.gmi Configuring Offpunk
=> offline.gmi Using Offpunk offline
=> lists.gmi Lists and subscriptions
=> shell.gmi Shell and OS integrations
=> dev.gmi Roadmap & Contributions

0
doc/install.gmi Normal file
View File

0
doc/lists.gmi Normal file
View File

0
doc/offline.gmi Normal file
View File

0
doc/shell.gmi Normal file
View File

0
doc/tutorial.gmi Normal file
View File

74
man/ansicat.1 Normal file
View File

@ -0,0 +1,74 @@
.Dd August 27, 2023
.Dt ANSICAT 1
.Os
.
.Sh NAME
.Nm ansicat
.Nd terminal gemini gemtext renderer for offpunk
.
.Sh SYNOPSIS
.Nm
.Op Fl \-format Ar RENDERER
.Op Fl \-mime Ar MIME
.Op Fl \-url Ar URL ...
.Op Ar INPUT ...
.Nm
.Fl h | \-help
.
.Sh DESCRIPTION
Ansicat is the rendering engine of the browser
.Xr offpunk 1 .
It will render nicely on the terminal any gemtext,
html,
gopher,
and a few other formats.
.Pp
.Xr Offpunk 1
is a command-line browser and feed reader dedicated to browsing the Web,
Gemini, Gopher and Spartan.
.Ss Positional arguments
.Bl -tag -width Ds -offset indent
.It Ar INPUT
path to the text to render.
It defaults to the standard input.
.El
.Ss Keyword arguments
.Bl -tag -width Ds -offset indent
.It Fl h , \-help
show a help message and exit.
.It Fl \-format Ar RENDERER
renderer to use.
Available renderers are
.Ic auto ,
.Ic gemtext ,
.Ic html ,
.Ic feed ,
.Ic gopher ,
.Ic image ,
and
.Ic folder .
The
.Ic auto
renderer will heuristically guess the format,
either thanks to the MIME type,
or from the file being rendered itself.
.It Fl \-mime Ar MIME
MIME type of the content to parse.
.It Fl \-mode Ar MODE
MODE to use to render to choose between normal (default), full or source
.It Fl \-url Ar URL ...
original URL of the content.
.El
.
.Sh EXIT STATUS
.Ex -std
.
.Sh SEE ALSO
.Xr migrate-offpunk-cache 1 ,
.Xr netcache 1 ,
.Xr offpunk 1 ,
.Xr opnk 1 ,
.Lk https://sr.ht/~lioploum/offpunk/
.
.Sh AUTHORS
.An Lionel Dricot (Ploum) Aq Mt offpunk2 at ploum.eu

74
man/netcache.1 Normal file
View File

@ -0,0 +1,74 @@
.Dd August 27, 2023
.Dt NETCACHE 1
.Os
.
.Sh NAME
.Nm netcache
.Nd local Internet cache handler for offpunk
.
.Sh SYNOPSIS
.Nm
.Op Fl \-path
.Op Fl \-offline
.Op Fl \-max\-size Ar MAX_SIZE
.Op Fl \-timeout Ar TIMEOUT
.Op Ar URL ...
.Nm
.Fl h | \-help
.
.Sh DESCRIPTION
Netcache is the download and cache management engine of the browser
.Xr offpunk 1 .
It allows one to fetch a link and get its content,
writing the content through the local cache for ulterior reference.
Netcache can be forced into offline mode,
in order to only fetch resources from the local cache,
otherwise it would always refresh it from the version available online.
It is also useful for mapping a given URL to its location in the cache,
independently of whether it has been downloaded first.
.Pp
Default cache path is
.Pa ~/.cache/offpunk .
Set
.Ev OFFPUNK_CACHE_PATH
environment variable to use another location.
.Bd -literal
OFFPUNK_CACHE_PATH=/home/ploum/custom-cache netcache.py gemini://some.url
.Ed
.Pp
.Xr Offpunk 1
is a command-line browser and feed reader dedicated to browsing the Web,
Gemini, Gopher and Spartan.
.Ss Positional arguments
.Bl -tag -width Ds -offset indent
.It Ar URL
download the URL and output the content.
.El
.Ss Keyword arguments
.Bl -tag -width Ds -offset indent
.It Fl h , \-help
show a help message and exit.
.It Fl \-path
output the path to the cache instead of the content of the URL.
.It Fl \-max-size Ar MAX_SIZE
cancel download of items above that size.
The value is expressed in megabytes.
.It Fl \-timeout Ar TIMEOUT
time to wait before cancelling connection.
The value is expressed in seconds.
.It Fl \-cache-validity CACHE_VALIDITY
Maximum age (in second) of the cached version before redownloading a new version.
.El
.
.Sh EXIT STATUS
.Ex -std
.
.Sh SEE ALSO
.Xr ansicat 1 ,
.Xr migrate-offpunk-cache 1 ,
.Xr offpunk 1 ,
.Xr opnk 1 ,
.Lk https://sr.ht/~lioploum/offpunk/
.
.Sh AUTHORS
.An Lionel Dricot (Ploum) Aq Mt offpunk2 at ploum.eu

93
man/offpunk.1 Normal file
View File

@ -0,0 +1,93 @@
.Dd March 3, 2023
.Dt OFFPUNK 1
.Os
.
.Sh NAME
.Nm offpunk
.Nd command line gemini client
.
.Sh SYNOPSIS
.Nm
.Op Fl \-bookmarks
.Op Fl \-tls\-cert Ar FILE
.Op Fl \-tls\-key Ar FILE
.Op Fl \-sync
.Op Fl \-assume\-yes
.Op Fl \-disable\-http
.Op Fl \-fetch\-later
.Op Fl \-depth Ar DEPTH
.Op Fl \-cache\-validity Ar CACHE_VALIDITY
.Op Ar URL ...
.Nm
.Fl h | \-help
.Nm
.Fl \-version
.Nm
.Fl \-features
.
.Sh DESCRIPTION
Offpunk is a command-line browser and feed reader dedicated to browsing the Web,
Gemini, Gopher and Spartan.
Thanks to its permanent cache, it is optimised to be used offline with rare
connections but works as well when connected.
.Pp
Offpunk is optimised for reading and supports readability mode, displaying
pictures, subscribing to pages or RSS feeds,
managing complex lists of bookmarks.
Its integrated help and easy commands make it a perfect tool for command-line
novices while power-users will be amazed by its shell integration.
.Ss Positional arguments
.Bl -tag -width Ds -offset indent
.It URL
start with this URL
.El
.Ss Keyword arguments
.Bl -tag -width Ds -offset indent
.It Fl h , \-help
Show a help message and exit
.It Fl \-bookmarks
start with your list of bookmarks
.It Fl \-tls\-cert Ar FILE
TLS client certificate file
.It Fl \-tls\-key Ar FILE
TLS client certificate private key file
.It Fl \-sync
run non\-interactively to build cache by exploring bookmarks
.It Fl \-assume\-yes
assume\-yes when asked questions about certificates/redirections during sync
(lower security)
.It Fl \-disable\-http
do not try to get http(s) links (but already cached will be displayed)
.It Fl \-fetch\-later
run non\-interactively with an URL as argument to fetch it later
.It Fl \-depth Ar DEPTH
depth of the cache to build.
Default is 1.
More is crazy.
Use at your own risks!
.It Fl \-cache\-validity Ar CACHE_VALIDITY
duration for which a cache is valid before sync (seconds)
.It Fl \-version
display version information and quit
.It Fl \-features
display available features and dependancies then quit
.El
.
.Sh EXIT STATUS
.Ex -std
.
.Sh SEE ALSO
.Xr ansicat 1 ,
.Xr migrate-offpunk-cache 1 ,
.Xr netcache 1 ,
.Xr opnk 1 ,
.Lk https://sr.ht/~lioploum/offpunk/
.
.Sh HISTORY
.Nm
is a fork of the original AV-98 by
.An Solderpunk
and was originally called AV-98-offline as an experimental branch.
.
.Sh AUTHORS
.An Lionel Dricot (Ploum) Aq Mt offpunk2 at ploum.eu

57
man/opnk.1 Normal file
View File

@ -0,0 +1,57 @@
.Dd August 27, 2023
.Dt OPNK 1
.Os
.
.Sh NAME
.Nm opnk
.Nd universal open (like a punk) for offpunk
.
.Sh SYNOPSIS
.Nm
.Op Ar INPUT ...
.Nm
.Fl h | \-help
.
.Sh DESCRIPTION
Opnk is the "universal open (like a punk)".
Opnk is a tool that will try to render any file or URL in the terminal,
using
.Xr netcache 1
and
.Xr ansicat 1 ,
and put them in
.Xr less 1 .
If that doesnt work,
it will fallback to
.Xr xdg-open 1 .
.Pp
.Xr Offpunk 1
is a command-line browser and feed reader dedicated to browsing the Web,
Gemini, Gopher and Spartan.
.Ss Positional arguments
.Bl -tag -width Ds -offset indent
.It Ar INPUT
path to the file or URL to open.
.El
.Ss Keyword arguments
.Bl -tag -width Ds -offset indent
.It Fl h , \-help
Show a help message and exit
.It Fl \-mode Ar MODE
MODE to use to render to choose between normal (default), full or source
.It Fl \-cache-validity CACHE_VALIDITY
Maximum age (in second) of the cached version before redownloading a new version.
.El
.
.Sh EXIT STATUS
.Ex -std
.
.Sh SEE ALSO
.Xr ansicat 1 ,
.Xr migrate-offpunk-cache 1 ,
.Xr netcache 1 ,
.Xr offpunk 1 ,
.Lk https://sr.ht/~lioploum/offpunk/
.
.Sh AUTHORS
.An Lionel Dricot (Ploum) Aq Mt offpunk2 at ploum.eu

911
netcache.py Executable file
View File

@ -0,0 +1,911 @@
#!/usr/bin/env python3
import os
import sys
import urllib.parse
import argparse
import codecs
import getpass
import socket
import ssl
import glob
import datetime
import hashlib
import sqlite3
from ssl import CertificateError
import ansicat
import offutils
from offutils import xdg
import time
try:
import chardet
_HAS_CHARDET = True
except ModuleNotFoundError:
_HAS_CHARDET = False
try:
from cryptography import x509
from cryptography.hazmat.backends import default_backend
_HAS_CRYPTOGRAPHY = True
_BACKEND = default_backend()
except(ModuleNotFoundError,ImportError):
_HAS_CRYPTOGRAPHY = False
try:
import requests
_DO_HTTP = True
except (ModuleNotFoundError,ImportError):
_DO_HTTP = False
# This list is also used as a list of supported protocols
standard_ports = {
"gemini" : 1965,
"gopher" : 70,
"finger" : 79,
"http" : 80,
"https" : 443,
"spartan": 300,
}
default_protocol = "gemini"
CRLF = '\r\n'
DEFAULT_TIMEOUT = 10
_MAX_REDIRECTS = 5
# monkey-patch Gemini support in urllib.parse
# see https://github.com/python/cpython/blob/master/Lib/urllib/parse.py
urllib.parse.uses_relative.append("gemini")
urllib.parse.uses_netloc.append("gemini")
urllib.parse.uses_relative.append("spartan")
urllib.parse.uses_netloc.append("spartan")
class UserAbortException(Exception):
pass
def parse_mime(mime):
options = {}
if mime:
if ";" in mime:
splited = mime.split(";",maxsplit=1)
mime = splited[0]
if len(splited) >= 1:
options_list = splited[1].split()
for o in options_list:
spl = o.split("=",maxsplit=1)
if len(spl) > 0:
options[spl[0]] = spl[1]
return mime, options
def normalize_url(url):
if "://" not in url and ("./" not in url and url[0] != "/"):
if not url.startswith("mailto:"):
url = "gemini://" + url
return url
def cache_last_modified(url):
if not url:
return None
path = get_cache_path(url)
if path and os.path.isfile(path):
return os.path.getmtime(path)
else:
return None
def is_cache_valid(url,validity=0):
# Validity is the acceptable time for
# a cache to be valid (in seconds)
# If 0, then any cache is considered as valid
# (use validity = 1 if you want to refresh everything)
if offutils.is_local(url):
return True
cache = get_cache_path(url)
if cache :
# If path is too long, we always return True to avoid
# fetching it.
if len(cache) > 259:
print("We return False because path is too long")
return False
if os.path.exists(cache) and not os.path.isdir(cache):
if validity > 0 :
last_modification = cache_last_modified(url)
now = time.time()
age = now - last_modification
return age < validity
else:
return True
else:
#Cache has not been build
return False
else:
#Theres not even a cache!
return False
def get_cache_path(url,add_index=True):
# Sometimes, cache_path became a folder! (which happens for index.html/index.gmi)
# In that case, we need to reconstruct it
# if add_index=False, we dont add that "index.gmi" at the ends of the cache_path
#First, we parse the URL
if not url:
return None
parsed = urllib.parse.urlparse(url)
if url[0] == "/" or url.startswith("./") or os.path.exists(url):
scheme = "file"
elif parsed.scheme:
scheme = parsed.scheme
else:
scheme = default_protocol
if scheme in ["file","mailto","list"]:
local = True
host = ""
port = None
# file:// is 7 char
if url.startswith("file://"):
path = url[7:]
elif scheme == "mailto":
path = parsed.path
elif url.startswith("list://"):
listdir = os.path.join(xdg("data"),"lists")
listname = url[7:].lstrip("/")
if listname in [""]:
name = "My Lists"
path = listdir
else:
name = listname
path = os.path.join(listdir, "%s.gmi"%listname)
else:
path = url
else:
local = False
# Convert unicode hostname to punycode using idna RFC3490
host = parsed.hostname #.encode("idna").decode()
port = parsed.port or standard_ports.get(scheme, 0)
# special gopher selector case
if scheme == "gopher":
if len(parsed.path) >= 2:
itemtype = parsed.path[1]
path = parsed.path[2:]
else:
itemtype = "1"
path = ""
if itemtype == "0":
mime = "text/gemini"
elif itemtype == "1":
mime = "text/gopher"
elif itemtype == "h":
mime = "text/html"
elif itemtype in ("9","g","I","s",";"):
mime = "binary"
else:
mime = "text/gopher"
else:
path = parsed.path
if parsed.query:
# we dont add the query if path is too long because path above 260 char
# are not supported and crash python.
# Also, very long query are usually useless stuff
if len(path+parsed.query) < 258:
path += "/" + parsed.query
# Now, we have a partial path. Lets make it full path.
if local:
cache_path = path
elif scheme and host:
cache_path = os.path.expanduser(xdg("cache") + scheme + "/" + host + path)
#Theres an OSlimitation of 260 characters per path.
#We will thus cut the path enough to add the index afterward
cache_path = cache_path[:249]
# this is a gross hack to give a name to
# index files. This will break if the index is not
# index.gmi. I dont know how to know the real name
# of the file. But first, we need to ensure that the domain name
# finish by "/". Else, the cache will create a file, not a folder.
if scheme.startswith("http"):
index = "index.html"
elif scheme == "finger":
index = "index.txt"
elif scheme == "gopher":
index = "gophermap"
else:
index = "index.gmi"
if path == "" or os.path.isdir(cache_path):
if not cache_path.endswith("/"):
cache_path += "/"
if not url.endswith("/"):
url += "/"
if add_index and cache_path.endswith("/"):
cache_path += index
#sometimes, the index itself is a dir
#like when folder/index.gmi?param has been created
#and we try to access folder
if add_index and os.path.isdir(cache_path):
cache_path += "/" + index
else:
#URL is missing either a supported scheme or a valid host
#print("Error: %s is not a supported url"%url)
return None
if len(cache_path) > 259:
print("Path is too long. This is an OS limitation.\n\n")
print(url)
return None
return cache_path
def write_body(url,body,mime=None):
## body is a copy of the raw gemtext
## Write_body() also create the cache !
#DEFAULT GEMINIMIME
mime, options = parse_mime(mime)
cache_path = get_cache_path(url)
if cache_path:
if mime and mime.startswith("text/"):
mode = "w"
else:
mode = "wb"
cache_dir = os.path.dirname(cache_path)
# If the subdirectory already exists as a file (not a folder)
# We remove it (happens when accessing URL/subfolder before
# URL/subfolder/file.gmi.
# This causes loss of data in the cache
# proper solution would be to save "sufolder" as "sufolder/index.gmi"
# If the subdirectory doesnt exist, we recursively try to find one
# until it exists to avoid a file blocking the creation of folders
root_dir = cache_dir
while not os.path.exists(root_dir):
root_dir = os.path.dirname(root_dir)
if os.path.isfile(root_dir):
os.remove(root_dir)
os.makedirs(cache_dir,exist_ok=True)
with open(cache_path, mode=mode) as f:
f.write(body)
f.close()
return cache_path
def set_error(url,err):
# If we get an error, we want to keep an existing cache
# but we need to touch it or to create an empty one
# to avoid hitting the error at each refresh
cache = get_cache_path(url)
if is_cache_valid(url):
os.utime(cache)
elif cache:
cache_dir = os.path.dirname(cache)
root_dir = cache_dir
while not os.path.exists(root_dir):
root_dir = os.path.dirname(root_dir)
if os.path.isfile(root_dir):
os.remove(root_dir)
os.makedirs(cache_dir,exist_ok=True)
if os.path.isdir(cache_dir):
with open(cache, "w") as c:
c.write(str(datetime.datetime.now())+"\n")
c.write("ERROR while caching %s\n\n" %url)
c.write("*****\n\n")
c.write(str(type(err)) + " = " + str(err))
#cache.write("\n" + str(err.with_traceback(None)))
c.write("\n*****\n\n")
c.write("If you believe this error was temporary, type ""reload"".\n")
c.write("The ressource will be tentatively fetched during next sync.\n")
c.close()
return cache
def _fetch_http(url,max_size=None,timeout=DEFAULT_TIMEOUT,accept_bad_ssl_certificates=False,**kwargs):
if not _DO_HTTP: return None
def too_large_error(url,length,max_size):
err = "Size of %s is %s Mo\n"%(url,length)
err += "Offpunk only download automatically content under %s Mo\n" %(max_size/1000000)
err += "To retrieve this content anyway, type 'reload'."
return set_error(url,err)
if accept_bad_ssl_certificates:
requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS = 'ALL:@SECLEVEL=1'
requests.packages.urllib3.disable_warnings()
verify=False
else:
requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS = 'ALL:@SECLEVEL=2'
verify=True
header = {}
header["User-Agent"] = "Netcache"
with requests.get(url,verify=verify,headers=header, stream=True,timeout=DEFAULT_TIMEOUT) as response:
if "content-type" in response.headers:
mime = response.headers['content-type']
else:
mime = None
if "content-length" in response.headers:
length = int(response.headers['content-length'])
else:
length = 0
if max_size and length > max_size:
response.close()
return too_large_error(url,str(length/100),max_size)
elif max_size and length == 0:
body = b''
downloaded = 0
for r in response.iter_content():
body += r
#We divide max_size for streamed content
#in order to catch them faster
size = sys.getsizeof(body)
max = max_size/2
current = round(size*100/max,1)
if current > downloaded:
downloaded = current
print(" -> Receiving stream: %s%% of allowed data"%downloaded,end='\r')
#print("size: %s (%s\% of maxlenght)"%(size,size/max_size))
if size > max_size/2:
response.close()
return too_large_error(url,"streaming",max_size)
response.close()
else:
body = response.content
response.close()
if mime and "text/" in mime:
body = body.decode("UTF-8","replace")
cache = write_body(url,body,mime)
return cache
def _fetch_gopher(url,timeout=DEFAULT_TIMEOUT,**kwargs):
parsed =urllib.parse.urlparse(url)
host = parsed.hostname
port = parsed.port or 70
if len(parsed.path) >= 2:
itemtype = parsed.path[1]
selector = parsed.path[2:]
else:
itemtype = "1"
selector = ""
addresses = socket.getaddrinfo(host, port, family=0,type=socket.SOCK_STREAM)
s = socket.create_connection((host,port))
for address in addresses:
s = socket.socket(address[0], address[1])
s.settimeout(timeout)
try:
s.connect(address[4])
break
except OSError as e:
err = e
if parsed.query:
request = selector + "\t" + parsed.query
else:
request = selector
request += "\r\n"
s.sendall(request.encode("UTF-8"))
response1 = s.makefile("rb")
response = response1.read()
# Transcode response into UTF-8
#if itemtype in ("0","1","h"):
if not itemtype in ("9","g","I","s",";"):
# Try most common encodings
for encoding in ("UTF-8", "ISO-8859-1"):
try:
response = response.decode("UTF-8")
break
except UnicodeDecodeError:
pass
else:
# try to find encoding
if _HAS_CHARDET:
detected = chardet.detect(response)
response = response.decode(detected["encoding"])
else:
raise UnicodeDecodeError
if itemtype == "0":
mime = "text/gemini"
elif itemtype == "1":
mime = "text/gopher"
elif itemtype == "h":
mime = "text/html"
elif itemtype in ("9","g","I","s",";"):
mime = None
else:
# by default, we should consider Gopher
mime = "text/gopher"
cache = write_body(url,response,mime)
return cache
def _fetch_finger(url,timeout=DEFAULT_TIMEOUT,**kwargs):
parsed = urllib.parse.urlparse(url)
host = parsed.hostname
port = parsed.port or standard_ports["finger"]
query = parsed.path.lstrip("/") + "\r\n"
with socket.create_connection((host,port)) as sock:
sock.settimeout(timeout)
sock.send(query.encode())
response = sock.makefile("rb").read().decode("UTF-8")
cache = write_body(response,"text/plain")
return cache
# Originally copied from reference spartan client by Michael Lazar
def _fetch_spartan(url,**kwargs):
cache = None
url_parts = urllib.parse.urlparse(url)
host = url_parts.hostname
port = url_parts.port or standard_ports["spartan"]
path = url_parts.path or "/"
query = url_parts.query
redirect_url = None
with socket.create_connection((host,port)) as sock:
if query:
data = urllib.parse.unquote_to_bytes(query)
else:
data = b""
encoded_host = host.encode("idna")
ascii_path = urllib.parse.unquote_to_bytes(path)
encoded_path = urllib.parse.quote_from_bytes(ascii_path).encode("ascii")
sock.send(b"%s %s %d\r\n" % (encoded_host,encoded_path,len(data)))
fp = sock.makefile("rb")
response = fp.readline(4096).decode("ascii").strip("\r\n")
parts = response.split(" ",maxsplit=1)
code,meta = int(parts[0]),parts[1]
if code == 2:
body = fp.read()
if meta.startswith("text"):
body = body.decode("UTF-8")
cache = write_body(url,body,meta)
elif code == 3:
redirect_url = url_parts._replace(path=meta).geturl()
else:
return set_error(url,"Spartan code %s: Error %s"%(code,meta))
if redirect_url:
cache = _fetch_spartan(redirect_url)
return cache
def _validate_cert(address, host, cert,accept_bad_ssl=False,automatic_choice=None):
"""
Validate a TLS certificate in TOFU mode.
If the cryptography module is installed:
- Check the certificate Common Name or SAN matches `host`
- Check the certificate's not valid before date is in the past
- Check the certificate's not valid after date is in the future
Whether the cryptography module is installed or not, check the
certificate's fingerprint against the TOFU database to see if we've
previously encountered a different certificate for this IP address and
hostname.
"""
now = datetime.datetime.utcnow()
if _HAS_CRYPTOGRAPHY:
# Using the cryptography module we can get detailed access
# to the properties of even self-signed certs, unlike in
# the standard ssl library...
c = x509.load_der_x509_certificate(cert, _BACKEND)
# Check certificate validity dates
if accept_bad_ssl:
if c.not_valid_before >= now:
raise CertificateError("Certificate not valid until: {}!".format(c.not_valid_before))
elif c.not_valid_after <= now:
raise CertificateError("Certificate expired as of: {})!".format(c.not_valid_after))
# Check certificate hostnames
names = []
common_name = c.subject.get_attributes_for_oid(x509.oid.NameOID.COMMON_NAME)
if common_name:
names.append(common_name[0].value)
try:
names.extend([alt.value for alt in c.extensions.get_extension_for_oid(x509.oid.ExtensionOID.SUBJECT_ALTERNATIVE_NAME).value])
except x509.ExtensionNotFound:
pass
names = set(names)
for name in names:
try:
ssl._dnsname_match(str(name), host)
break
except CertificateError:
continue
else:
# If we didn't break out, none of the names were valid
raise CertificateError("Hostname does not match certificate common name or any alternative names.")
sha = hashlib.sha256()
sha.update(cert)
fingerprint = sha.hexdigest()
db_path = os.path.join(xdg("config"), "tofu.db")
db_conn = sqlite3.connect(db_path)
db_cur = db_conn.cursor()
db_cur.execute("""CREATE TABLE IF NOT EXISTS cert_cache
(hostname text, address text, fingerprint text,
first_seen date, last_seen date, count integer)""")
# Have we been here before?
db_cur.execute("""SELECT fingerprint, first_seen, last_seen, count
FROM cert_cache
WHERE hostname=? AND address=?""", (host, address))
cached_certs = db_cur.fetchall()
# If so, check for a match
if cached_certs:
max_count = 0
most_frequent_cert = None
for cached_fingerprint, first, last, count in cached_certs:
if count > max_count:
max_count = count
most_frequent_cert = cached_fingerprint
if fingerprint == cached_fingerprint:
# Matched!
db_cur.execute("""UPDATE cert_cache
SET last_seen=?, count=?
WHERE hostname=? AND address=? AND fingerprint=?""",
(now, count+1, host, address, fingerprint))
db_conn.commit()
break
else:
certdir = os.path.join(xdg("config"), "cert_cache")
with open(os.path.join(certdir, most_frequent_cert+".crt"), "rb") as fp:
previous_cert = fp.read()
if _HAS_CRYPTOGRAPHY:
# Load the most frequently seen certificate to see if it has
# expired
previous_cert = x509.load_der_x509_certificate(previous_cert, _BACKEND)
previous_ttl = previous_cert.not_valid_after - now
print(previous_ttl)
print("****************************************")
print("[SECURITY WARNING] Unrecognised certificate!")
print("The certificate presented for {} ({}) has never been seen before.".format(host, address))
print("This MIGHT be a Man-in-the-Middle attack.")
print("A different certificate has previously been seen {} times.".format(max_count))
if _HAS_CRYPTOGRAPHY:
if previous_ttl < datetime.timedelta():
print("That certificate has expired, which reduces suspicion somewhat.")
else:
print("That certificate is still valid for: {}".format(previous_ttl))
print("****************************************")
print("Attempt to verify the new certificate fingerprint out-of-band:")
print(fingerprint)
if automatic_choice:
choice = automatic_choice
else:
choice = input("Accept this new certificate? Y/N ").strip().lower()
if choice in ("y", "yes"):
db_cur.execute("""INSERT INTO cert_cache
VALUES (?, ?, ?, ?, ?, ?)""",
(host, address, fingerprint, now, now, 1))
db_conn.commit()
with open(os.path.join(certdir, fingerprint+".crt"), "wb") as fp:
fp.write(cert)
else:
raise Exception("TOFU Failure!")
# If not, cache this cert
else:
db_cur.execute("""INSERT INTO cert_cache
VALUES (?, ?, ?, ?, ?, ?)""",
(host, address, fingerprint, now, now, 1))
db_conn.commit()
certdir = os.path.join(xdg("config"), "cert_cache")
if not os.path.exists(certdir):
os.makedirs(certdir)
with open(os.path.join(certdir, fingerprint+".crt"), "wb") as fp:
fp.write(cert)
def _fetch_gemini(url,timeout=DEFAULT_TIMEOUT,interactive=True,accept_bad_ssl_certificates=False,\
**kwargs):
cache = None
newurl = url
url_parts = urllib.parse.urlparse(url)
host = url_parts.hostname
port = url_parts.port or standard_ports["gemini"]
path = url_parts.path or "/"
query = url_parts.query
# In AV-98, this was the _send_request method
#Send a selector to a given host and port.
#Returns the resolved address and binary file with the reply."""
host = host.encode("idna").decode()
# Do DNS resolution
# DNS lookup - will get IPv4 and IPv6 records if IPv6 is enabled
if ":" in host:
# This is likely a literal IPv6 address, so we can *only* ask for
# IPv6 addresses or getaddrinfo will complain
family_mask = socket.AF_INET6
elif socket.has_ipv6:
# Accept either IPv4 or IPv6 addresses
family_mask = 0
else:
# IPv4 only
family_mask = socket.AF_INET
addresses = socket.getaddrinfo(host, port, family=family_mask,
type=socket.SOCK_STREAM)
# Sort addresses so IPv6 ones come first
addresses.sort(key=lambda add: add[0] == socket.AF_INET6, reverse=True)
## Continuation of send_request
# Prepare TLS context
protocol = ssl.PROTOCOL_TLS_CLIENT if sys.version_info.minor >=6 else ssl.PROTOCOL_TLSv1_2
context = ssl.SSLContext(protocol)
context.check_hostname=False
context.verify_mode = ssl.CERT_NONE
# Impose minimum TLS version
## In 3.7 and above, this is easy...
if sys.version_info.minor >= 7:
context.minimum_version = ssl.TLSVersion.TLSv1_2
## Otherwise, it seems very hard...
## The below is less strict than it ought to be, but trying to disable
## TLS v1.1 here using ssl.OP_NO_TLSv1_1 produces unexpected failures
## with recent versions of OpenSSL. What a mess...
else:
context.options |= ssl.OP_NO_SSLv3
context.options |= ssl.OP_NO_SSLv2
# Try to enforce sensible ciphers
try:
context.set_ciphers("AESGCM+ECDHE:AESGCM+DHE:CHACHA20+ECDHE:CHACHA20+DHE:!DSS:!SHA1:!MD5:@STRENGTH")
except ssl.SSLError:
# Rely on the server to only support sensible things, I guess...
pass
# Connect to remote host by any address possible
err = None
for address in addresses:
try:
s = socket.socket(address[0], address[1])
s.settimeout(timeout)
s = context.wrap_socket(s, server_hostname = host)
s.connect(address[4])
break
except OSError as e:
err = e
else:
# If we couldn't connect to *any* of the addresses, just
# bubble up the exception from the last attempt and deny
# knowledge of earlier failures.
raise err
# Do TOFU
cert = s.getpeercert(binary_form=True)
# Remember that we showed the current cert to this domain...
#TODO : accept badssl and automatic choice
_validate_cert(address[4][0], host, cert,automatic_choice="y")
# Send request and wrap response in a file descriptor
url = urllib.parse.urlparse(url)
new_netloc = host
#Handle IPV6 hostname
if ":" in new_netloc:
new_netloc = "[" + new_netloc + "]"
if port != standard_ports["gemini"]:
new_netloc += ":" + str(port)
url = urllib.parse.urlunparse(url._replace(netloc=new_netloc))
s.sendall((url + CRLF).encode("UTF-8"))
f= s.makefile(mode = "rb")
## end of send_request in AV98
# Spec dictates <META> should not exceed 1024 bytes,
# so maximum valid header length is 1027 bytes.
header = f.readline(1027)
header = urllib.parse.unquote(header.decode("UTF-8"))
if not header or header[-1] != '\n':
raise RuntimeError("Received invalid header from server!")
header = header.strip()
# Validate header
status, meta = header.split(maxsplit=1)
if len(meta) > 1024 or len(status) != 2 or not status.isnumeric():
f.close()
raise RuntimeError("Received invalid header from server!")
# Update redirect loop/maze escaping state
if not status.startswith("3"):
previous_redirectors = set()
#TODO FIXME
else:
#we set a previous_redirectors anyway because refactoring in progress
previous_redirectors = set()
# Handle non-SUCCESS headers, which don't have a response body
# Inputs
if status.startswith("1"):
if interactive:
print(meta)
if status == "11":
user_input = getpass.getpass("> ")
else:
#TODO:FIXME we should not ask for user input while non-interactive
user_input = input("> ")
newurl = url.split("?")[0]
return _fetch_gemini(newurl+"?"+user_input)
else:
return None,None
# Redirects
elif status.startswith("3"):
newurl = urllib.parse.urljoin(url,meta)
if newurl == url:
raise RuntimeError("URL redirects to itself!")
elif newurl in previous_redirectors:
raise RuntimeError("Caught in redirect loop!")
elif len(previous_redirectors) == _MAX_REDIRECTS:
raise RuntimeError("Refusing to follow more than %d consecutive redirects!" % _MAX_REDIRECTS)
# TODO: redirections handling should be refactored
# elif "interactive" in options and not options["interactive"]:
# follow = self.automatic_choice
# # Never follow cross-domain redirects without asking
# elif new_gi.host.encode("idna") != gi.host.encode("idna"):
# follow = input("Follow cross-domain redirect to %s? (y/n) " % new_gi.url)
# # Never follow cross-protocol redirects without asking
# elif new_gi.scheme != gi.scheme:
# follow = input("Follow cross-protocol redirect to %s? (y/n) " % new_gi.url)
# # Don't follow *any* redirect without asking if auto-follow is off
# elif not self.options["auto_follow_redirects"]:
# follow = input("Follow redirect to %s? (y/n) " % new_gi.url)
# # Otherwise, follow away
else:
follow = "yes"
if follow.strip().lower() not in ("y", "yes"):
raise UserAbortException()
previous_redirectors.add(url)
# if status == "31":
# # Permanent redirect
# self.permanent_redirects[gi.url] = new_gi.url
return _fetch_gemini(newurl)
# Errors
elif status.startswith("4") or status.startswith("5"):
raise RuntimeError(meta)
# Client cert
elif status.startswith("6"):
error = "Handling certificates for status 6X are not supported by offpunk\n"
error += "See bug #31 for discussion about the problem"
raise RuntimeError(error)
# Invalid status
elif not status.startswith("2"):
raise RuntimeError("Server returned undefined status code %s!" % status)
# If we're here, this must be a success and there's a response body
assert status.startswith("2")
mime = meta
# Read the response body over the network
fbody = f.read()
#DEFAULT GEMINIMIME
if mime == "":
mime = "text/gemini; charset=utf-8"
shortmime, mime_options = parse_mime(mime)
if "charset" in mime_options:
try:
codecs.lookup(mime_options["charset"])
except LookupError:
#raise RuntimeError("Header declared unknown encoding %s" % mime_options)
#If the encoding is wrong, theres a high probably its UTF-8 with a bad header
mime_options["charset"] = "UTF-8"
if shortmime.startswith("text/"):
#Get the charset and default to UTF-8 in none
encoding = mime_options.get("charset", "UTF-8")
try:
body = fbody.decode(encoding)
except UnicodeError:
raise RuntimeError("Could not decode response body using %s\
encoding declared in header!" % encoding)
else:
body = fbody
cache = write_body(url,body,mime)
return cache,newurl
def fetch(url,offline=False,download_image_first=True,images_mode="readable",validity=0,**kwargs):
url = normalize_url(url)
newurl = url
path=None
print_error = "print_error" in kwargs.keys() and kwargs["print_error"]
#Firt, we look if we have a valid cache, even if offline
#If we are offline, any cache is better than nothing
if is_cache_valid(url,validity=validity) or (offline and is_cache_valid(url,validity=0)):
path = get_cache_path(url)
#if the cache is a folder, we should add a "/" at the end of the URL
if not url.endswith("/") and os.path.isdir(get_cache_path(url,add_index=False)) :
newurl = url+"/"
elif offline and is_cache_valid(url,validity=0):
path = get_cache_path(url)
elif "://" in url and not offline:
try:
scheme = url.split("://")[0]
if scheme not in standard_ports:
if print_error:
print("%s is not a supported protocol"%scheme)
path = None
elif scheme in ("http","https"):
if _DO_HTTP:
path=_fetch_http(url,**kwargs)
else:
print("HTTP requires python-requests")
elif scheme == "gopher":
path=_fetch_gopher(url,**kwargs)
elif scheme == "finger":
path=_fetch_finger(url,**kwargs)
elif scheme == "gemini":
path,newurl=_fetch_gemini(url,**kwargs)
else:
print("scheme %s not implemented yet")
except UserAbortException:
return None, newurl
except Exception as err:
cache = set_error(url, err)
# Print an error message
# we fail silently when sync_only
if isinstance(err, socket.gaierror):
if print_error:
print("ERROR: DNS error!")
elif isinstance(err, ConnectionRefusedError):
if print_error:
print("ERROR1: Connection refused!")
elif isinstance(err, ConnectionResetError):
if print_error:
print("ERROR2: Connection reset!")
elif isinstance(err, (TimeoutError, socket.timeout)):
if print_error:
print("""ERROR3: Connection timed out!
Slow internet connection? Use 'set timeout' to be more patient.""")
elif isinstance(err, FileExistsError):
if print_error:
print("""ERROR5: Trying to create a directory which already exists
in the cache : """)
print(err)
elif _DO_HTTP and isinstance(err,requests.exceptions.SSLError):
if print_error:
print("""ERROR6: Bad SSL certificate:\n""")
print(err)
print("""\n If you know what you are doing, you can try to accept bad certificates with the following command:\n""")
print("""set accept_bad_ssl_certificates True""")
elif _DO_HTTP and isinstance(err,requests.exceptions.ConnectionError):
if print_error:
print("""ERROR7: Cannot connect to URL:\n""")
print(str(err))
else:
if print_error:
import traceback
print("ERROR4: " + str(type(err)) + " : " + str(err))
#print("\n" + str(err.with_traceback(None)))
print(traceback.format_exc())
return cache, newurl
# We download images contained in the document (from full mode)
if not offline and download_image_first and images_mode:
renderer = ansicat.renderer_from_file(path,newurl)
if renderer:
for image in renderer.get_images(mode=images_mode):
#Image should exist, should be an url (not a data image)
#and should not be already cached
if image and not image.startswith("data:image/") and not is_cache_valid(image):
width = offutils.term_width() - 1
toprint = "Downloading %s" %image
toprint = toprint[:width]
toprint += " "*(width-len(toprint))
print(toprint,end="\r")
#d_i_f and images_mode are False/None to avoid recursive downloading
#if that ever happen
fetch(image,offline=offline,download_image_first=False,\
images_mode=None,validity=0,**kwargs)
return path, newurl
def main():
descri="Netcache is a command-line tool to retrieve, cache and access networked content.\n\
By default, netcache will returns a cached version of a given URL, downloading it \
only if not existing. A validity duration, in seconds, can also be given so that \
netcache downloads the content only if the existing cache is older than the validity."
# Parse arguments
parser = argparse.ArgumentParser(prog="netcache",description=descri)
parser.add_argument("--path", action="store_true",
help="return path to the cache instead of the content of the cache")
parser.add_argument("--offline", action="store_true",
help="Do not attempt to download, return cached version or error")
parser.add_argument("--max-size", type=int,
help="Cancel download of items above that size (value in Mb).")
parser.add_argument("--timeout", type=int,
help="Time to wait before cancelling connection (in second).")
parser.add_argument("--cache-validity",type=int, default=0,
help="maximum age, in second, of the cached version before \
redownloading a new version")
# No argument: write help
parser.add_argument('url', metavar='URL', nargs='*',
help='download URL and returns the content or the path to a cached version')
# --validity : returns the date of the cached version, Null if no version
# --force-download : download and replace cache, even if valid
args = parser.parse_args()
param = {}
for u in args.url:
if args.offline:
path = get_cache_path(u)
else:
path,url = fetch(u,max_size=args.max_size,timeout=args.timeout,\
validity=args.cache_validity)
if args.path:
print(path)
else:
with open(path,"r") as f:
print(f.read())
f.close()
if __name__== '__main__':
main()

31
netcache_migration.py Normal file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2023 Sotiris Papatheodorou
# SPDX-License-Identifier: BSD-2-Clause
"""
A script to migrate the offpunk cache to the newest version.
For each new version of offpunk that requires changes to the cache a migration
function should be written. The name of the function should have the format
v<major-version>_<minor-version>_<patch-version> and it should accept the
offpunk cache directory as a string. The function should perform a migration
from the immediately previous cache format. All migration functions must be
called at the end of this script from oldest to newest.
"""
import argparse
import os
import os.path
def upgrade_to_1(cache_dir: str) -> None:
"""
Rename index.txt to gophermap in the Gopher protocol cache.
"""
print("Upgrading cache to version 1: migrating index.txt to gophermap")
for root, _, files in os.walk(os.path.join(cache_dir, 'gopher')):
for f in files:
if f == 'index.txt':
src = os.path.join(root, f)
dst = os.path.join(root, 'gophermap')
os.rename(src, dst)

33
offblocklist.py Normal file
View File

@ -0,0 +1,33 @@
# The following are the default redirections from Offpunk
# Those are by default because they should make sens with offpunk
redirects = {
"*twitter.com" : "nitter.net",
"youtube.com" : "yewtu.be",
"youtu.be" : "yewtu.be",
"*reddit.com" : "teddit.net",
"*medium.com" : "scribe.rip",
}
#following are blocked URLs. Visiting them with offpunk doesnt make sense.
#Blocking them will save a lot of bandwith
blocked = {
"*facebook.com",
"*facebook.net",
"*fbcdn.net",
"*linkedin.com",
"*licdn.com",
"*admanager.google.com",
"*google-health-ads.blogspot.com",
"*firebase.google.com",
"*google-webfonts-helper.herokuapp.com",
"*tiktok.com" ,
"*doubleclick.net",
"*google-analytics.com" ,
"*ads.yahoo.com",
"*advertising.amazon.com",
"*advertising.theguardian.com",
"*advertise.newrepublic.com",
}

1910
offpunk.py Executable file

File diff suppressed because it is too large Load Diff

49
offthemes.py Normal file
View File

@ -0,0 +1,49 @@
#!/bin/python
colors = {
"bold" : ["1","22"],
"faint" : ["2","22"],
"italic" : ["3","23"],
"underline": ["4","24"],
"black" : ["30","39"],
"red" : ["31","39"],
"green" : ["32","39"],
"yellow" : ["33","39"],
"blue" : ["34","39"],
"purple" : ["35","39"],
"cyan" : ["36","39"],
"white" : ["37","39"],
"background_black" : ["40","49"],
"background_red" : ["41","49"],
"background_green" : ["42","49"],
"background_yellow" : ["43","49"],
"background_blue" : ["44","49"],
"background_purple" : ["45","49"],
"background_cyan" : ["46","49"],
"background_white" : ["47","49"],
"bright_black" : ["90","39"],
"bright_red" : ["91","39"],
"bright_green" : ["92","39"],
"bright_yellow" : ["93","39"],
"bright_blue" : ["94","39"],
"bright_purple" : ["95","39"],
"bright_cyan" : ["96","39"],
"bright_white" : ["97","39"],
}
offpunk1 = {
"window_title" : ["red","bold"],
"window_subtitle" : ["red","faint"],
"title" : ["blue","bold","underline"],
"subtitle" : ["blue"],
"subsubtitle" : ["blue","faint"], #fallback to subtitle if none
"link" : ["blue","faint"],
"new_link": ["bold"],
"oneline_link": [], #for gopher/gemini. fallback to link if none
"image_link" : ["yellow","faint"],
"preformatted": ["faint"],
"blockquote" : ["italic"],
"prompt_on" : ["green"],
"prompt_off" : ["green"],
}
default = offpunk1

226
offutils.py Normal file
View File

@ -0,0 +1,226 @@
#!/bin/python
#This file contains some utilities common to offpunk, ansirenderer and netcache.
#Currently, there are the following utilities:
#
# run : run a shell command and get the results with some security
# term_width : get or set the width to display on the terminal
import os
import io
import subprocess
import shutil
import shlex
import urllib.parse
import urllib.parse
import netcache_migration
import netcache
CACHE_VERSION = 1
# We upgrade the cache only once at startup, hence the UPGRADED variable
# This is only to avoid unecessary checks each time the cache is accessed
UPGRADED=False
def upgrade_cache(cache_folder):
#Lets read current version of the cache
version_path = cache_folder + ".version"
current_version = 0
if os.path.exists(version_path):
current_str = None
with open(version_path) as f:
current_str = f.read()
f.close()
try:
current_version = int(current_str)
except:
current_version = 0
#Now, lets upgrade the cache if needed
while current_version < CACHE_VERSION:
current_version += 1
upgrade_func = getattr(netcache_migration,"upgrade_to_"+str(current_version))
upgrade_func(cache_folder)
with open(version_path,"w") as f:
f.write(str(current_version))
f.close()
UPGRADED=True
#get xdg folder. Folder should be "cache", "data" or "config"
def xdg(folder="cache"):
## Config directories
## We implement our own python-xdg to avoid conflict with existing libraries.
_home = os.path.expanduser('~')
data_home = os.environ.get('XDG_DATA_HOME') or \
os.path.join(_home,'.local','share')
config_home = os.environ.get('XDG_CONFIG_HOME') or \
os.path.join(_home,'.config')
_CONFIG_DIR = os.path.join(os.path.expanduser(config_home),"offpunk/")
_DATA_DIR = os.path.join(os.path.expanduser(data_home),"offpunk/")
_old_config = os.path.expanduser("~/.offpunk/")
## Look for pre-existing config directory, if any
if os.path.exists(_old_config):
_CONFIG_DIR = _old_config
#if no XDG .local/share and not XDG .config, we use the old config
if not os.path.exists(data_home) and os.path.exists(_old_config):
_DATA_DIR = _CONFIG_DIR
## get _CACHE_PATH from OFFPUNK_CACHE_PATH environment variable
# if OFFPUNK_CACHE_PATH empty, set default to ~/.cache/offpunk
cache_home = os.environ.get('XDG_CACHE_HOME') or\
os.path.join(_home,'.cache')
_CACHE_PATH = os.environ.get('OFFPUNK_CACHE_PATH', \
os.path.join(os.path.expanduser(cache_home),"offpunk/"))
#Check that the cache path ends with "/"
if not _CACHE_PATH.endswith("/"):
_CACHE_PATH += "/"
os.makedirs(_CACHE_PATH,exist_ok=True)
if folder == "cache" and not UPGRADED:
upgrade_cache(_CACHE_PATH)
if folder == "cache":
return _CACHE_PATH
elif folder == "config":
return _CONFIG_DIR
elif folder == "data":
return _DATA_DIR
else:
print("No XDG folder for %s. Check your code."%folder)
return None
#An IPV6 URL should be put between []
#We try to detect them has location with more than 2 ":"
def fix_ipv6_url(url):
if not url or url.startswith("mailto"):
return url
if "://" in url:
schema, schemaless = url.split("://",maxsplit=1)
else:
schema, schemaless = None, url
if "/" in schemaless:
netloc, rest = schemaless.split("/",1)
if netloc.count(":") > 2 and "[" not in netloc and "]" not in netloc:
schemaless = "[" + netloc + "]" + "/" + rest
elif schemaless.count(":") > 2 and "[" not in schemaless and "]" not in schemaless:
schemaless = "[" + schemaless + "]/"
if schema:
return schema + "://" + schemaless
return schemaless
# Cheap and cheerful URL detector
def looks_like_url(word):
try:
if not word.strip():
return False
url = fix_ipv6_url(word).strip()
parsed = urllib.parse.urlparse(url)
#sometimes, urllib crashed only when requesting the port
port = parsed.port
scheme = word.split("://")[0]
mailto = word.startswith("mailto:")
start = scheme in netcache.standard_ports
local = scheme in ["file","list"]
if mailto:
return "@" in word
elif not local:
if start:
#IPv4
if "." in word or "localhost" in word:
return True
#IPv6
elif "[" in word and ":" in word and "]" in word:
return True
else: return False
else: return False
return start and ("." in word or "localhost" in word or ":" in word)
else:
return "/" in word
except ValueError:
return False
## Those two functions add/remove the mode to the
# URLs. This is a gross hack to remember the mode
def mode_url(url,mode):
if mode and mode!= "readable" and "##offpunk=" not in url:
url += "##offpunk_mode=" + mode
return url
def unmode_url(url):
mode = None
splitted = url.split("##offpunk_mode=")
if len(splitted) > 1:
url = splitted[0]
mode = splitted[1]
return [url,mode]
# In terms of arguments, this can take an input file/string to be passed to
# stdin, a parameter to do (well-escaped) "%" replacement on the command, a
# flag requesting that the output go directly to the stdout, and a list of
# additional environment variables to set.
def run(cmd, *, input=None, parameter=None, direct_output=False, env={}):
if parameter:
cmd = cmd % shlex.quote(parameter)
e = os.environ
e.update(env)
if isinstance(input, io.IOBase):
stdin = input
input = None
else:
if input:
input = input.encode()
stdin = None
if not direct_output:
# subprocess.check_output() wouldn't allow us to pass stdin.
result = subprocess.run(cmd, check=True, env=e, input=input,
shell=True, stdin=stdin, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
return result.stdout.decode()
else:
subprocess.run(cmd, env=e, input=input, shell=True, stdin=stdin)
global TERM_WIDTH
TERM_WIDTH = 72
#if absolute, returns the real terminal width, not the text width
def term_width(new_width=None,absolute=False):
if new_width:
global TERM_WIDTH
TERM_WIDTH = new_width
cur = shutil.get_terminal_size()[0]
if absolute:
return cur
width = TERM_WIDTH
if cur < width:
width = cur
return width
def is_local(url):
if not url: return True
elif "://" in url:
scheme,path = url.split("://",maxsplit=1)
return scheme in ["file","mail","list","mailto"]
else:
return True
# This method return the image URL or invent it if its a base64 inline image
# It returns [url,image_data] where image_data is None for normal image
def looks_like_base64(src,baseurl):
imgdata = None
imgname = src
if src and src.startswith("data:image/"):
if ";base64," in src:
splitted = src.split(";base64,")
#splitted[0] is something like data:image/jpg
if "/" in splitted[0]:
extension = splitted[0].split("/")[1]
else:
extension = "data"
imgdata = splitted[1]
imgname = imgdata[:20] + "." + extension
imgurl = urllib.parse.urljoin(baseurl, imgname)
else:
#We cant handle other data:image such as svg for now
imgurl = None
else:
imgurl = urllib.parse.urljoin(baseurl, imgname)
return imgurl,imgdata

297
opnk.py Executable file
View File

@ -0,0 +1,297 @@
#!/usr/bin/env python3
#opnk stand for "Open like a PuNK".
#It will open any file or URL and display it nicely in less.
#If not possible, it will fallback to xdg-open
#URL are retrieved through netcache
import os
import sys
import tempfile
import argparse
import netcache
import ansicat
import offutils
import shutil
import time
import fnmatch
from offutils import run,term_width,mode_url,unmode_url,is_local
_HAS_XDGOPEN = shutil.which('xdg-open')
_GREP = "grep --color=auto"
less_version = 0
if not shutil.which("less"):
print("Please install the pager \"less\" to run Offpunk.")
print("If you wish to use another pager, send me an email!")
print("(Im really curious to hear about people not having \"less\" on their system.)")
sys.exit()
output = run("less --version")
# We get less Version (which is the only integer on the first line)
words = output.split("\n")[0].split()
less_version = 0
for w in words:
if w.isdigit():
less_version = int(w)
# restoring position only works for version of less > 572
if less_version >= 572:
_LESS_RESTORE_POSITION = True
else:
_LESS_RESTORE_POSITION = False
#_DEFAULT_LESS = "less -EXFRfM -PMurl\ lines\ \%lt-\%lb/\%L\ \%Pb\%$ %s"
# -E : quit when reaching end of file (to behave like "cat")
# -F : quit if content fits the screen (behave like "cat")
# -X : does not clear the screen
# -R : interpret ANSI colors correctly
# -f : suppress warning for some contents
# -M : long prompt (to have info about where you are in the file)
# -W : hilite the new first line after a page skip (space)
# -i : ignore case in search
# -S : do not wrap long lines. Wrapping is done by offpunk, longlines
# are there on purpose (surch in asciiart)
#--incsearch : incremental search starting rev581
def less_cmd(file, histfile=None,cat=False,grep=None):
less_prompt = "page %%d/%%D- lines %%lb/%%L - %%Pb\\%%"
if less_version >= 581:
less_base = "less --incsearch --save-marks -~ -XRfWiS -P \"%s\""%less_prompt
elif less_version >= 572:
less_base = "less --save-marks -XRfMWiS"
else:
less_base = "less -XRfMWiS"
_DEFAULT_LESS = less_base + " \"+''\" %s"
_DEFAULT_CAT = less_base + " -EF %s"
if histfile:
env = {"LESSHISTFILE": histfile}
else:
env = {}
if cat:
cmd_str = _DEFAULT_CAT
elif grep:
grep_cmd = _GREP
#case insensitive for lowercase search
if grep.islower():
grep_cmd += " -i"
cmd_str = _DEFAULT_CAT + "|" + grep_cmd + " %s"%grep
else:
cmd_str = _DEFAULT_LESS
run(cmd_str, parameter=file, direct_output=True, env=env)
class opencache():
def __init__(self):
# We have a cache of the rendering of file and, for each one,
# a less_histfile containing the current position in the file
self.temp_files = {}
self.less_histfile = {}
# This dictionary contains an url -> ansirenderer mapping. This allows
# to reuse a renderer when visiting several times the same URL during
# the same session
# We save the time at which the renderer was created in renderer_time
# This way, we can invalidate the renderer if a new version of the source
# has been downloaded
self.rendererdic = {}
self.renderer_time = {}
self.mime_handlers = {}
self.last_mode = {}
self.last_width = term_width(absolute=True)
def _get_handler_cmd(self, mimetype):
# Now look for a handler for this mimetype
# Consider exact matches before wildcard matches
exact_matches = []
wildcard_matches = []
for handled_mime, cmd_str in self.mime_handlers.items():
if "*" in handled_mime:
wildcard_matches.append((handled_mime, cmd_str))
else:
exact_matches.append((handled_mime, cmd_str))
for handled_mime, cmd_str in exact_matches + wildcard_matches:
if fnmatch.fnmatch(mimetype, handled_mime):
break
else:
# Use "xdg-open" as a last resort.
if _HAS_XDGOPEN:
cmd_str = "xdg-open %s"
else:
cmd_str = "echo \"Cant find how to open \"%s"
print("Please install xdg-open (usually from xdg-util package)")
return cmd_str
# Return the handler for a specific mimetype.
# Return the whole dic if no specific mime provided
def get_handlers(self,mime=None):
if mime and mime in self.mime_handlers.keys():
return self.mime_handlers[mime]
elif mime:
return None
else:
return self.mime_handlers
def set_handler(self,mime,handler):
previous = None
if mime in self.mime_handlers.keys():
previous = self.mime_handlers[mime]
self.mime_handlers[mime] = handler
if "%s" not in handler:
print("WARNING: this handler has no %%s, no filename will be provided to the command")
if previous:
print("Previous handler was %s"%previous)
def get_renderer(self,inpath,mode=None,theme=None):
# We remove the ##offpunk_mode= from the URL
# If mode is already set, we dont use the part from the URL
inpath,newmode = unmode_url(inpath)
if not mode: mode = newmode
# If we still doesnt have a mode, we see if we used one before
if not mode and inpath in self.last_mode.keys():
mode = self.last_mode[inpath]
elif not mode:
#default mode is readable
mode = "readable"
renderer = None
path = netcache.get_cache_path(inpath)
if path:
usecache = inpath in self.rendererdic.keys() and not is_local(inpath)
#Screen size may have changed
width = term_width(absolute=True)
if usecache and self.last_width != width:
self.cleanup()
usecache = False
self.last_width = width
if usecache:
if inpath in self.renderer_time.keys():
last_downloaded = netcache.cache_last_modified(inpath)
last_cached = self.renderer_time[inpath]
usecache = last_cached > last_downloaded
else:
usecache = False
if not usecache:
renderer = ansicat.renderer_from_file(path,url=inpath,theme=theme)
if renderer:
self.rendererdic[inpath] = renderer
self.renderer_time[inpath] = int(time.time())
else:
renderer = self.rendererdic[inpath]
return renderer
def get_temp_filename(self,url):
if url in self.temp_files.keys():
return self.temp_files[url]
else:
return None
def opnk(self,inpath,mode=None,terminal=True,grep=None,theme=None,**kwargs):
#Return True if inpath opened in Terminal
# False otherwise
# also returns the url in case it has been modified
#if terminal = False, we dont try to open in the terminal,
#we immediately fallback to xdg-open.
#netcache currently provide the path if its a file.
if not offutils.is_local(inpath):
kwargs["images_mode"] = mode
cachepath,inpath = netcache.fetch(inpath,**kwargs)
if not cachepath:
return False, inpath
# folowing line is for :// which are locals (file,list)
elif "://" in inpath:
cachepath,inpath = netcache.fetch(inpath,**kwargs)
elif inpath.startswith("mailto:"):
cachepath = inpath
elif os.path.exists(inpath):
cachepath = inpath
else:
print("%s does not exist"%inpath)
return False, inpath
renderer = self.get_renderer(inpath,mode=mode,theme=theme)
if renderer and mode:
renderer.set_mode(mode)
self.last_mode[inpath] = mode
if not mode and inpath in self.last_mode.keys():
mode = self.last_mode[inpath]
renderer.set_mode(mode)
#we use the full moded url as key for the dictionary
key = mode_url(inpath,mode)
if terminal and renderer:
#If this is an image and we have chafa/timg, we
#dont use less, we call it directly
if renderer.has_direct_display():
renderer.display(mode=mode,directdisplay=True)
return True, inpath
else:
body = renderer.display(mode=mode)
#Should we use the cache? only if it is not local and theres a cache
usecache = key in self.temp_files and not is_local(inpath)
if usecache:
#and the cache is still valid!
last_downloaded = netcache.cache_last_modified(inpath)
last_cached = os.path.getmtime(self.temp_files[key])
if last_downloaded > last_cached:
usecache = False
self.temp_files.pop(key)
self.less_histfile.pop(key)
# We actually put the body in a tmpfile before giving it to less
if not usecache:
tmpf = tempfile.NamedTemporaryFile("w", encoding="UTF-8", delete=False)
self.temp_files[key] = tmpf.name
tmpf.write(body)
tmpf.close()
if key not in self.less_histfile:
firsttime = True
tmpf = tempfile.NamedTemporaryFile("w", encoding="UTF-8", delete=False)
self.less_histfile[key] = tmpf.name
else:
#We dont want to restore positions in lists
firsttime = is_local(inpath)
less_cmd(self.temp_files[key], histfile=self.less_histfile[key],cat=firsttime,grep=grep)
return True, inpath
#maybe, we have no renderer. Or we want to skip it.
else:
mimetype = ansicat.get_mime(cachepath)
if mimetype == "mailto":
mail = inpath[7:]
resp = input("Send an email to %s Y/N? " %mail)
if resp.strip().lower() in ("y", "yes"):
if _HAS_XDGOPEN :
run("xdg-open mailto:%s", parameter=mail,direct_output=True)
else:
print("Cannot find a mail client to send mail to %s" %inpath)
print("Please install xdg-open (usually from xdg-util package)")
return False, inpath
else:
cmd_str = self._get_handler_cmd(mimetype)
try:
run(cmd_str, parameter=netcache.get_cache_path(inpath), direct_output=True)
except FileNotFoundError:
print("Handler program %s not found!" % shlex.split(cmd_str)[0])
print("You can use the ! command to specify another handler program or pipeline.")
return False, inpath
#We remove the renderers from the cache and we also delete temp files
def cleanup(self):
while len(self.temp_files) > 0:
os.remove(self.temp_files.popitem()[1])
while len(self.less_histfile) > 0:
os.remove(self.less_histfile.popitem()[1])
self.last_width = None
self.rendererdic = {}
self.renderer_time = {}
self.last_mode = {}
def main():
descri = "opnk is an universal open command tool that will try to display any file \
in the pager less after rendering its content with ansicat. If that fails, \
opnk will fallback to opening the file with xdg-open. If given an URL as input \
instead of a path, opnk will rely on netcache to get the networked content."
parser = argparse.ArgumentParser(prog="opnk",description=descri)
parser.add_argument("--mode", metavar="MODE",
help="Which mode should be used to render: normal (default), full or source.\
With HTML, the normal mode try to extract the article.")
parser.add_argument("content",metavar="INPUT", nargs="*",
default=sys.stdin, help="Path to the file or URL to open")
parser.add_argument("--cache-validity",type=int, default=0,
help="maximum age, in second, of the cached version before \
redownloading a new version")
args = parser.parse_args()
cache = opencache()
for f in args.content:
cache.opnk(f,mode=args.mode,validity=args.cache_validity)
if __name__ == "__main__":
main()

58
pyproject.toml Normal file
View File

@ -0,0 +1,58 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "offpunk"
authors = [
{name = "Solderpunk", email = "solderpunk@sdf.org"},
{name = "Lionel Dricot (Ploum)", email = "offpunk2@ploum.eu"},
]
maintainers = [
{name = "Lionel Dricot (Ploum)", email = "offpunk2@ploum.eu"},
]
readme = "README.md"
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Console",
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Communications",
"Topic :: Internet",
]
keywords = ["gemini", "browser"]
requires-python = ">=3.7"
dynamic = ["version", "description"]
[project.license]
file = "LICENSE"
[project.optional-dependencies]
better-tofu = ["cryptography"]
chardet = ["chardet"]
html = ["bs4", "readability-lxml"]
http = ["requests"]
process-title = ["setproctitle"]
rss = ["feedparser"]
[project.urls]
Homepage = "https://sr.ht/~lioploum/offpunk/"
Source = "https://git.sr.ht/~lioploum/offpunk"
"Bug Tracker" = "https://todo.sr.ht/~lioploum/offpunk"
[project.scripts]
offpunk = "offpunk:main"
netcache = "netcache:main"
ansicat = "ansicat:main"
opnk = "opnk:main"
[tool.hatch.version]
path = "offpunk.py" # read __version__
[tool.hatch.build.targets.wheel]
only-include = [
"ansicat.py", "netcache_migration.py", "netcache.py",
"offblocklist.py", "offpunk.py", "offthemes.py",
"offutils.py", "opnk.py",
]

10
requirements.txt Normal file
View File

@ -0,0 +1,10 @@
chardet
cryptography
requests
feedparser
bs4
readability-lxml
pillow
setproctitle
timg
file

BIN
screenshot_offpunk1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

BIN
screenshot_offpunk2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

View File

@ -1,23 +0,0 @@
from setuptools import setup
setup(
name='AV-98',
version='1.0.2dev',
description="Command line Gemini client.",
author="Solderpunk",
author_email="solderpunk@sdf.org",
url='https://tildegit.org/solderpunk/AV-98/',
classifiers=[
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 3 :: Only',
'Topic :: Communications',
'Intended Audience :: End Users/Desktop',
'Environment :: Console',
'Development Status :: 4 - Beta',
],
py_modules = ["av98"],
entry_points={
"console_scripts": ["av98=av98:main"]
},
install_requires=[],
)

1
ubuntu_dependencies.txt Normal file
View File

@ -0,0 +1 @@
sudo apt install less file xdg-utils xsel chafa timg python3-cryptography python3-requests python3-feedparser python3-bs4 python3-readability python3-pil python3-setproctitle python3-chardet file