Commit Graph

855 Commits

Author SHA1 Message Date
É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