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
Two years ago, I started to modify AV-98 in order to browser Gemini
offline.
https://ploum.net/2021-12-06-offline-av98.htmlhttps://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)
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.
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)
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.
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>
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.
--=-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)