less has been renamed view and feed/feeds options have been added

This commit is contained in:
Lionel Dricot 2022-03-07 23:16:17 +01:00
parent b37fb2f599
commit c1f2206937
3 changed files with 55 additions and 21 deletions

View File

@ -1,7 +1,9 @@
# Offpunk History
## 1.0 - Unreleased
- Content is now centered for more elegant reading
- 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
- Fixed a crash when accessing links in list (thanks Matthieu Talbot for the report)
- Fixed a crash due to a typo in a variable name rarely accessed.

View File

@ -13,9 +13,9 @@ Offpunk is a fork of the original [AV-98](https://tildegit.org/solderpunk/AV-98)
Offpunk is a single python file. Installation is optional, you can simply download and run "./offpunk.py" or "python3 offpunk.py" in a terminal.
You use the `go` command to visit a URL, e.g. `go gemini.circumlunar.space`. (gemini:// is assumed is no protocol is specified).
You use the `go` command to visit a URL, e.g. `go gemini.circumlunar.space`. (gemini:// is assumed is no protocol is specified. Supported protocols are gemini, gopher, http, https, mailto, spartan and file).
Links in pages are assigned numerical indices. Just type an index to follow that link. If page is too long to fit on your screen, the content is displayed in the less pager (by default). Type `q` to quit and go back to Offpunk prompt. Type `less` or `l` to display it again in less. (`less full` or `l full` allows to see the full html page instead of the article view. This only applies to html pages)
Links in pages are assigned numerical indices. Just type an index to follow that link. If page is too long to fit on your screen, the content is displayed in the less pager (by default). Type `q` to quit and go back to Offpunk prompt. Type `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`display a list of available fedes. This only applies to html pages)
Use `add` to add a capsule to your bookmarks and `bookmarks` or `bm` to show your bookmarks (you can create multiple bookmarks lists, edit and remove them. See the `list` manual with `help list`).
@ -31,7 +31,7 @@ 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.
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.
Offpunk can also be configured as a browser by other tool. If you want to use offpunk directly with a given URL, simply type:
@ -41,7 +41,7 @@ To have offpunk fetch the URL at next sync and close immediately, run:
`offpunk --fetch-later URL`
## Roadmap to 1.0 (and beyond)
## Roadmap post 1.0
Known issues in the code:
* NOT_FIXABLE : consider root file is always index.gmi or index.html
@ -58,6 +58,9 @@ See how I browse Web/Gemini offline => gemini://rawtext.club/~ploum/2021-12-17-o
Announces about Offpunk will be made on Ploums Gemlog => gemini://rawtext.club/~ploum/
`go gemini://rawtext.club/~ploum/`
`subscribe`
## Dependencies
@ -92,10 +95,10 @@ Run command `version` in offpunk to see if you are missing some dependencies.
* Browse https/gemini/gopher/spartan without leaving your keyboard and without distractions
* Built-in documentation: type `help` to get the list of command or a specific help about a command.
* Offline mode to browse cached content without a connection. Requested elements are automatically fetched during the next synchronization and are added to your tour.
* HTML pages are prettified to focus on content. Read without being disturbed.
* RSS/Atom feeds are automatically discovered by `subscribe` and rendered as gemlogs.
* 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 and archiving.
* 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`)
* Non-interactive cache-building with configurable depth through the --sync command. The cache can easily be used by other software.

View File

@ -238,12 +238,13 @@ _ABBREVS = {
"bm": "bookmarks",
"book": "bookmarks",
"cp": "copy",
"f": "fold",
"fo": "forward",
"fo": "fold",
"f": "forward",
"g": "go",
"h": "history",
"hist": "history",
"l": "less",
"l": "view",
"less": "view",
"mv": "move",
"n": "next",
"off": "offline",
@ -257,6 +258,7 @@ _ABBREVS = {
"/": "search",
"t": "tour",
"u": "up",
"v": "view",
}
_MIME_HANDLERS = {
@ -861,9 +863,9 @@ class HtmlRenderer(AbstractRenderer):
rendered_body = ansi_img + "\x1b[2;33m" + alttext + "\x1b[0m\n\n"
elif element.name == "br":
rendered_body = "\n"
elif element.name != "script" and element.string:
elif element.name not in ["script","style"] and element.string:
rendered_body = sanitize_string(element.string)
elif element.name != "script": #we drop javascript
elif element.name not in ["script","style"]: #we drop javascript and css
for child in element.children:
rendered_body += recursive_render(child,indent=indent)
return indent + rendered_body
@ -1168,7 +1170,13 @@ class GeminiItem():
if not self.renderer:
self._set_renderer()
if self.renderer:
return self.renderer.get_subscribe_links()
subs = self.renderer.get_subscribe_links()
abssubs = []
# some rss links are relatives
for s in subs:
s[0] = self.absolutise_url(s[0])
abssubs.append(s)
return abssubs
else:
return []
@ -2836,13 +2844,35 @@ Use 'ls -l' to see URLs."""
subprocess.call(shlex.split("cat %s" % self._get_active_tmpfile()))
@needs_gi
def do_less(self, *args):
def do_view(self, *args):
"""Run most recently visited item through "less" command, restoring \
previous position.
Use "less full" to see a complete html page instead of the article view.
(the "full" argument has no effect on Gemtext content but doesnt restore position)."""
if self.gi and args and args[0] == "full":
self._go_to_gi(self.gi,readable=False)
Use "view full" to see a complete html page instead of the article view.
Use "view feed" to see the the linked feed of the page (in any).
Use "view feeds" to see available feeds on this page.
(full, feed, feeds have no effect on non-html content)."""
if self.gi and args and args[0] != "":
if args[0] == "full":
self._go_to_gi(self.gi,readable=False)
elif args[0] == "feed":
subs = self.gi.get_subscribe_links()
if len(subs) > 1:
self.do_go(subs[1][0])
else:
print("No other feed found on %s"%self.gi.url)
elif args[0] == "feeds":
subs = self.gi.get_subscribe_links()
stri = "Available views :\n"
counter = 0
for s in subs:
counter += 1
stri += "[%s] %s [%s]\n"%(counter,s[0],s[1])
stri += "Which view do you want to see ? >"
ans = input(stri)
if ans.isdigit() and 0 < int(ans) <= len(subs):
self.do_go(subs[int(ans)-1][0])
else:
print("Valid argument for less are : full, feed, feeds")
elif self.gi.is_cache_valid() and self.gi.scheme not in ["mailto"]:
less_cmd(self._get_active_tmpfile(),histfile=self.less_histfile)
else:
@ -2999,7 +3029,6 @@ To unsubscribe, remove the page from the "subscribed" list."""
stri = "No feed detected. You can still watch the page :\n"
counter = 0
for l in subs:
link = self.gi.absolutise_url(l[0])
already = []
for li in self.list_lists():
if self.list_is_subscribed(li):
@ -3374,7 +3403,7 @@ See also :
print("? is an alias for 'help'")
elif arg in _ABBREVS:
full_cmd = _ABBREVS[arg]
print("%s is aan alias for '%s'" %(arg,full_cmd))
print("%s is an alias for '%s'" %(arg,full_cmd))
print("See the list of aliases with 'abbrevs'")
print("'help %s':"%full_cmd)
cmd.Cmd.do_help(self, full_cmd)