--fetch-later now directly add to tour if a cached version already exists

This commit is contained in:
Lionel Dricot 2022-02-14 11:28:12 +01:00
parent 26009c7f75
commit e1ab504f69
2 changed files with 23 additions and 28 deletions

View File

@ -4,6 +4,7 @@
- Pictures are now displayed directely in terminal (suggested by kelbot)
- Introducing the "open" command to open current page/image/file with external handler.
- "set width XX" will now work everywhere (thanks kelbot for reporting the bug)
- RSS feeds are now rendered as Gemlogs to improve consistency while browsing
- Improved syncing performances and multiple bug/crash fixes.
## 0.3 - Feb 11th 2022

View File

@ -422,7 +422,7 @@ class GopherRenderer(AbstractRenderer):
class FolderRenderer(GemtextRenderer):
def prepare(self,body):
def prepare(self,body,mode=None):
def write_list(l):
path = os.path.join(listdir,l+".gmi")
gi = GeminiItem("file://" + path)
@ -2944,8 +2944,6 @@ See also :
else:
self.list_go_to_line(args[1],args[0].lower())
def do_help(self, arg):
"""ALARM! Recursion detected! ALARM! Prepare to eject!"""
if arg == "!":
@ -3011,7 +3009,6 @@ current gemini browsing session."""
certfile = os.path.join(_CONFIG_DIR, "transient_certs", cert+ext)
if os.path.exists(certfile):
os.remove(certfile)
print()
print("You can close your screen!")
sys.exit()
@ -3053,25 +3050,23 @@ def main():
# Instantiate client
gc = GeminiClient(restricted=args.restricted,synconly=args.sync)
# Process config file
rcfile = os.path.join(_CONFIG_DIR, "offpunkrc")
if os.path.exists(rcfile):
print("Using config %s" % rcfile)
with open(rcfile, "r") as fp:
for line in fp:
line = line.strip()
if ((args.bookmarks or args.url) and
any((line.startswith(x) for x in ("go", "g", "tour", "t")))
):
if args.bookmarks:
print("Skipping rc command \"%s\" due to --bookmarks option." % line)
else:
print("Skipping rc command \"%s\" due to provided URLs." % line)
continue
gc.cmdqueue.append(line)
# Say hi
if not args.sync and not args.fetch_later:
# Process config file
rcfile = os.path.join(_CONFIG_DIR, "offpunkrc")
if os.path.exists(rcfile):
print("Using config %s" % rcfile)
with open(rcfile, "r") as fp:
for line in fp:
line = line.strip()
if ((args.bookmarks or args.url) and
any((line.startswith(x) for x in ("go", "g", "tour", "t")))
):
if args.bookmarks:
print("Skipping rc command \"%s\" due to --bookmarks option." % line)
else:
print("Skipping rc command \"%s\" due to provided URLs." % line)
continue
gc.cmdqueue.append(line)
print("Welcome to Offpunk!")
if args.restricted:
print("Restricted mode engaged!")
@ -3099,14 +3094,13 @@ def main():
# Endless interpret loop
if args.fetch_later:
if args.url:
# we go offline to fetch later and in sync-only to not display anything
gc.onecmd("offline")
gc.sync_only = True
for u in args.url:
gc.onecmd("go %s"%u)
if gc.gi and u in gc.gi.url and gc.gi.is_cache_valid():
# forcing re-fetch in case an old catch already exists
gc.onecmd("reload")
gi = GeminiItem(u)
if gi and gi.is_cache_valid():
gc.list_add_line("tour",gi)
else:
gc.list_add_line("to_fetch",gi)
else:
print("--fetch-later requires an URL (or a list of URLS) as argument")
elif args.sync: