From b1c9220fc5b74baa58864c0e85c8f9be5e246ecf Mon Sep 17 00:00:00 2001 From: Lionel Dricot Date: Mon, 6 Dec 2021 16:43:16 +0100 Subject: [PATCH] offline switchg --- av98.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/av98.py b/av98.py index 384e0e5..b32dacd 100755 --- a/av98.py +++ b/av98.py @@ -95,6 +95,7 @@ _MIME_HANDLERS = { "text/*": "cat %s", } + # 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") @@ -276,6 +277,7 @@ class GeminiClient(cmd.Cmd): self.tmp_filename = "" self.visited_hosts = set() self.waypoints = [] + self.offline_only = False self.client_certs = { "active": None @@ -1235,6 +1237,15 @@ you'll be able to transparently follow links to Gopherspace!""") self.stdout.write("{:<7} {}\n".format(k, v)) self.stdout.write("\n") + def do_offline(self, *args): + """Use AV-98 offline by only accessing cached content""" + if self.offline_only: + self.offline_only = False + print("AV-98 is online and will access the network") + else: + self.offline_only = True + print("AV-98 is now offline and will only access cached content") + ### Stuff for getting around def do_go(self, line): """Go to a gemini URL or marked item."""