offline web browser option

This commit is contained in:
Lionel Dricot 2021-12-13 14:30:40 +01:00
parent a5c2341785
commit 2ac144dc00
2 changed files with 10 additions and 4 deletions

View File

@ -11,10 +11,9 @@ Use "av-98.py --synconly" to build a cache containing your bookmarks and all lin
* FIXME: consider root file is always index.gmi
* FIXME: if a file exists in the cache where it should have been a folder, it fails (should instead remove the file)
* FIXME: certificates error are not handled in --synconly
* FIXME: offline web browser use os.system because its the only one that understands the ">> file.txt"
* TODO: handle request done offline and retrieve them later
* TODO: add option for an offline HTTP browser
* TODO: know when to refresh the cache instead of always downloading everything.
This is a fork of the original [AV-98](https://tildegit.org/solderpunk/AV-98)
by Solderpunk.

11
av98.py
View File

@ -321,7 +321,8 @@ class GeminiClient(cmd.Cmd):
"gopher_proxy" : None,
"tls_mode" : "tofu",
"http_proxy": None,
"cache" : False
"cache" : False,
"offline_web" : None
}
self.log = {
@ -363,9 +364,15 @@ class GeminiClient(cmd.Cmd):
# Don't try to speak to servers running other protocols
if gi.scheme in ("http", "https") and not self.sync_only:
if not self.options.get("http_proxy",None):
if not self.options.get("http_proxy",None) and not self.offline_only:
webbrowser.open_new_tab(gi.url)
return
elif self.offline_only and self.options.get("offline_web"):
offline_browser = self.options.get("offline_web")
cmd = offline_browser % gi.url
#FIXME : subprocess doesnt understand shell redirection
os.system(cmd)
return
else:
print("Do you want to try to open this link with a http proxy?")
resp = input("(Y)/N ")