Added config option for opening links in new tab (#49)

main
Ben Busby 2020-05-15 16:10:31 -06:00 committed by GitHub
parent 0e9bbc737d
commit 3123789584
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 0 deletions

View File

@ -22,6 +22,7 @@ class Filter:
self.near = config['near'] if 'near' in config else '' self.near = config['near'] if 'near' in config else ''
self.dark = config['dark'] if 'dark' in config else False self.dark = config['dark'] if 'dark' in config else False
self.nojs = config['nojs'] if 'nojs' in config else False self.nojs = config['nojs'] if 'nojs' in config else False
self.new_tab = config['new_tab'] if 'new_tab' in config else False
self.mobile = mobile self.mobile = mobile
self.secret_key = secret_key self.secret_key = secret_key
@ -131,6 +132,8 @@ class Filter:
if '/advanced_search' in href: if '/advanced_search' in href:
a.decompose() a.decompose()
continue continue
elif self.new_tab:
a['target'] = '_blank'
result_link = urlparse.urlparse(href) result_link = urlparse.urlparse(href)
query_link = parse_qs(result_link.query)['q'][0] if '?q=' in href else '' query_link = parse_qs(result_link.query)['q'][0] if '?q=' in href else ''

View File

@ -57,6 +57,7 @@ class Config:
self.dark = False self.dark = False
self.nojs = False self.nojs = False
self.near = '' self.near = ''
self.new_tab = False
self.get_only = False self.get_only = False
for key, value in kwargs.items(): for key, value in kwargs.items():

View File

@ -21,6 +21,7 @@ const fillConfigValues = () => {
const noJS = document.getElementById("config-nojs"); const noJS = document.getElementById("config-nojs");
const dark = document.getElementById("config-dark"); const dark = document.getElementById("config-dark");
const url = document.getElementById("config-url"); const url = document.getElementById("config-url");
const newTab = document.getElementById("config-new-tab");
const getOnly = document.getElementById("config-get-only"); const getOnly = document.getElementById("config-get-only");
// Request existing config info // Request existing config info
@ -39,6 +40,7 @@ const fillConfigValues = () => {
noJS.checked = !!configSettings["nojs"]; noJS.checked = !!configSettings["nojs"];
dark.checked = !!configSettings["dark"]; dark.checked = !!configSettings["dark"];
getOnly.checked = !!configSettings["get_only"]; getOnly.checked = !!configSettings["get_only"];
newTab.checked = !!configSettings["new_tab"];
// Addresses the issue of incorrect URL being used behind reverse proxy // Addresses the issue of incorrect URL being used behind reverse proxy
url.value = configSettings["url"] ? configSettings["url"] : ""; url.value = configSettings["url"] ? configSettings["url"] : "";

View File

@ -66,6 +66,10 @@
<label for="config-dark">Dark Mode: </label> <label for="config-dark">Dark Mode: </label>
<input type="checkbox" name="dark" id="config-dark"> <input type="checkbox" name="dark" id="config-dark">
</div> </div>
<div class="config-div">
<label for="config-new-tab">Open Links in New Tab: </label>
<input type="checkbox" name="new_tab" id="config-new-tab">
</div>
<div class="config-div"> <div class="config-div">
<label for="config-get-only">GET Requests Only: </label> <label for="config-get-only">GET Requests Only: </label>
<input type="checkbox" name="get_only" id="config-get-only"> <input type="checkbox" name="get_only" id="config-get-only">