Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
e18ff5eaf9 | |||
4375aad574 | |||
b6782d7a80 | |||
27ec4e627a | |||
e2a242c58e |
|
@ -82,6 +82,11 @@ To change the default settings for users of the system, amend the following opti
|
|||
|
||||
Customise the command used to execute the default browser used by linkulator. Default is *lynx*
|
||||
|
||||
#### Default gemini browser
|
||||
*String gemini*
|
||||
|
||||
Customise the command used to execute the default gemini browser used by linkulator. Default is *amfora*
|
||||
|
||||
### User settings
|
||||
|
||||
Users can select their preferred browser by changing the browser setting in their settings file (default is $HOME/.linkulator/linkulatorrc).
|
||||
|
|
12
config.py
12
config.py
|
@ -28,12 +28,23 @@ class DefaultUser:
|
|||
settingsfile: Path = datadir / PATHS.settingsfile
|
||||
lastlogin: str = "0.0"
|
||||
browser: str = "lynx"
|
||||
handler: dict = {
|
||||
"http": "lynx",
|
||||
"https": "lynx",
|
||||
"gopher": "lynx",
|
||||
"gemini": "amfora",
|
||||
"ssh": "putty"
|
||||
}
|
||||
|
||||
|
||||
|
||||
def save(self):
|
||||
"""Saves config data to file"""
|
||||
config = configparser.ConfigParser()
|
||||
config["User Status"] = {"lastlogin": time()}
|
||||
config["User Settings"] = {"browser": self.browser}
|
||||
config["URL Handler"] = self.handler
|
||||
|
||||
with open(self.settingsfile, "w") as file:
|
||||
config.write(file)
|
||||
|
||||
|
@ -44,6 +55,7 @@ class DefaultUser:
|
|||
if len(ret) > 0:
|
||||
self.lastlogin = config["User Status"]["lastlogin"]
|
||||
self.browser = config["User Settings"]["browser"]
|
||||
self.handler = config["URL Handler"]
|
||||
|
||||
|
||||
USER = DefaultUser()
|
||||
|
|
|
@ -74,10 +74,7 @@ def print_category_details(view_cat):
|
|||
for link in category_details:
|
||||
link_count += 1
|
||||
thread_index[link_count] = link["postid"]
|
||||
if(desclen > 0):
|
||||
desc = textwrap.shorten(link["description"], width=desclen, placeholder="...")
|
||||
else:
|
||||
desc = link["description"]
|
||||
newmarker = (
|
||||
"*" if link["last_modified_timestamp"] >= config.USER.lastlogin else ""
|
||||
)
|
||||
|
@ -218,19 +215,11 @@ def search():
|
|||
|
||||
def view_link_in_browser(url):
|
||||
"""Attempts to view the specified URL in the configured browser"""
|
||||
if which(config.USER.browser) is None:
|
||||
print(
|
||||
"Sorry, "
|
||||
+ config.USER.browser
|
||||
+ " is not installed on your system. Ask your sysadmin to install it."
|
||||
)
|
||||
return
|
||||
|
||||
url_scheme = urlparse(url).scheme
|
||||
if url_scheme in ["gopher", "https", "http"]:
|
||||
subprocess.call([config.USER.browser, url])
|
||||
if url_scheme in config.USER.handler and which(config.USER.handler[url_scheme]):
|
||||
subprocess.call([config.USER.handler[url_scheme], url])
|
||||
else:
|
||||
print("Sorry, that url doesn't start with gopher://, http:// or https://")
|
||||
print("Sorry, there is no handler assigned to '{}'".format(url_scheme))
|
||||
try_anyway = input(
|
||||
"Do you want to try it in {} anyway? Y/[N]".format(config.USER.browser)
|
||||
).lower()
|
||||
|
@ -421,7 +410,8 @@ def menu_view_thread_details(post_id):
|
|||
option_text = "Type {} to reply, {} to view in {}, {} to search, {} to post a new link, {} to go back, or {} to quit: ".format(
|
||||
style_text("r", True, "underline"),
|
||||
style_text("b", True, "underline"),
|
||||
config.USER.browser,
|
||||
# config.USER.browser,
|
||||
"browser",
|
||||
style_text("s", True, "underline"),
|
||||
style_text("p", True, "underline"),
|
||||
style_text("m", True, "underline"),
|
||||
|
|
Loading…
Reference in New Issue
Block a user