use hostname instead of domain and vacuum sqlite db
This commit is contained in:
parent
f97c68e045
commit
b793990748
|
@ -361,13 +361,13 @@ class StatusBar(ComponentBase):
|
|||
def handle_siteoptions_switch(self, name):
|
||||
active = self[f'siteoptions-{name}'].get_active()
|
||||
try:
|
||||
domain = self.window.active_tab.url.domain
|
||||
host = self.window.active_tab.url.hostname()
|
||||
|
||||
except:
|
||||
return
|
||||
|
||||
with self.db.session as s:
|
||||
s.put_permission(domain, name, active)
|
||||
s.put_permission(host, name, active)
|
||||
|
||||
logging.verbose(f'siteoptions: set {name}: {active}')
|
||||
self['siteoptions-reset'].set_sensitive(True)
|
||||
|
@ -375,10 +375,10 @@ class StatusBar(ComponentBase):
|
|||
|
||||
def handle_siteoptions_button(self, name):
|
||||
if name == 'reset':
|
||||
domain = self.window.active_tab.url.domain
|
||||
host = self.window.active_tab.url.hostname()
|
||||
|
||||
with self.db.session as s:
|
||||
s.del_permission(domain)
|
||||
s.del_permission(host)
|
||||
|
||||
self.handle_status_button('siteoptions')
|
||||
|
||||
|
|
|
@ -255,16 +255,16 @@ class WebviewHandler(ComponentBase):
|
|||
|
||||
|
||||
def handle_fullscreen(self, webview, state):
|
||||
domain = self.tab.url.domain
|
||||
host = self.tab.url.hostname()
|
||||
navbar = self.tab['navbar']
|
||||
statusbar = self.window['statusbar']
|
||||
tabs = self.window['tabs']
|
||||
|
||||
with self.app.db.session as s:
|
||||
row = s.get_permission(domain)
|
||||
row = s.get_permission(host)
|
||||
|
||||
if not row.fullscreen:
|
||||
self.window.notification(f'Denied fullscreen for domain: {domain}', 'error')
|
||||
self.window.notification(f'Denied fullscreen for domain: {host}', 'error')
|
||||
return True
|
||||
|
||||
# the navbar and status bars don't hide for some reason
|
||||
|
@ -429,23 +429,23 @@ class WebviewHandler(ComponentBase):
|
|||
|
||||
def handle_notification(self, webview, notif):
|
||||
try:
|
||||
domain = self.tab.url.domain
|
||||
host = self.tab.url.hostname()
|
||||
|
||||
## Not a url, so deny permission
|
||||
except AttributeError:
|
||||
return True
|
||||
|
||||
with self.app.db.session as s:
|
||||
row = s.get_permission(domain)
|
||||
row = s.get_permission(host)
|
||||
|
||||
if not row.notification:
|
||||
logging.debug(f'Denied notification for domain: {domain}')
|
||||
logging.debug(f'Denied notification for domain: {host}')
|
||||
return True
|
||||
|
||||
|
||||
def handle_permission_request(self, webview, permrequest):
|
||||
try:
|
||||
domain = self.tab.url.domain
|
||||
host = self.tab.url.hostname()
|
||||
|
||||
## Not a url, so deny perlmission
|
||||
except AttributeError:
|
||||
|
@ -453,42 +453,42 @@ class WebviewHandler(ComponentBase):
|
|||
return
|
||||
|
||||
with self.db.session as s:
|
||||
row = s.get_permission(domain)
|
||||
row = s.get_permission(host)
|
||||
|
||||
if type(permrequest) == WebKit2.NotificationPermissionRequest and row.notification:
|
||||
logging.verbose(f'Allowed notification permission request from {domain}')
|
||||
logging.verbose(f'Allowed notification permission request from {host}')
|
||||
permrequest.allow()
|
||||
|
||||
elif type(permrequest) == WebKit2.GeolocationPermissionRequest and row.location:
|
||||
logging.verbose(f'Allowed location permission request from {domain}')
|
||||
logging.verbose(f'Allowed location permission request from {host}')
|
||||
permrequest.allow()
|
||||
|
||||
elif type(permrequest) == WebKit2.UserMediaPermissionRequest:
|
||||
if permrequest.props.is_for_audio_device and row.microphone:
|
||||
logging.verbose(f'Allowed microphone permission request from {domain}')
|
||||
logging.verbose(f'Allowed microphone permission request from {host}')
|
||||
permrequest.allow()
|
||||
|
||||
elif permrequest.props.is_for_video_device and row.camera:
|
||||
logging.verbose(f'Allowed webcam permission request from {domain}')
|
||||
logging.verbose(f'Allowed webcam permission request from {host}')
|
||||
permrequest.allow()
|
||||
|
||||
else:
|
||||
logging.verbose(f'Rejected permission request from {domain}: {type(permrequest)}')
|
||||
logging.verbose(f'Rejected permission request from {host}: {type(permrequest)}')
|
||||
permrequest.deny()
|
||||
|
||||
|
||||
def handle_script_dialog(self, webview, dialog):
|
||||
try:
|
||||
domain = self.tab.url.domain
|
||||
host = self.tab.url.hostname()
|
||||
|
||||
except:
|
||||
return True
|
||||
|
||||
with self.db.session as s:
|
||||
row = s.get_permission(domain)
|
||||
row = s.get_permission(host)
|
||||
|
||||
if not row.dialog:
|
||||
logging.verbose('JS dialogs not allowed for domain:', domain)
|
||||
logging.verbose('JS dialogs not allowed for domain:', host)
|
||||
return True
|
||||
|
||||
|
||||
|
@ -568,11 +568,11 @@ class WebviewHandler(ComponentBase):
|
|||
|
||||
with self.db.session as s:
|
||||
if s.get_config('allow_local_unsigned') and url.address.is_type('local', 'loopback', 'private'):
|
||||
self.tab.context.allow_tls_certificate_for_host(cert, url.domain)
|
||||
self.tab.context.allow_tls_certificate_for_host(cert, url.hostname())
|
||||
webview.load_uri(url)
|
||||
return True
|
||||
|
||||
msg = cert_error_msg.get(err, 'TLS error: {url}')
|
||||
msg = cert_error_msg.get(err, f'TLS error: {url}')
|
||||
|
||||
if not msg:
|
||||
logging.debug('handlers.signal.TlsError: Unhandled error:', err)
|
||||
|
@ -700,11 +700,11 @@ class FediverseCheck(Thread):
|
|||
nodeinfo = tab.app.http_client.fetch_nodeinfo(permissions.domain)
|
||||
|
||||
except SSLCertVerificationError:
|
||||
logging.verbose(f'FediverseCheck: SSL Error for domain: {url.domain}')
|
||||
logging.verbose(f'FediverseCheck: SSL Error for domain: {url.hostname()}')
|
||||
return
|
||||
|
||||
except ConnectionRefusedError:
|
||||
logging.verbose(f'FediverseCheck: Failed to connect to domain: {url.domain}')
|
||||
logging.verbose(f'FediverseCheck: Failed to connect to domain: {url.hostname()}')
|
||||
return
|
||||
|
||||
except HttpClientError as e:
|
||||
|
|
|
@ -29,6 +29,9 @@ def get_database(app):
|
|||
tables = tables
|
||||
)
|
||||
|
||||
if db.cfg.type == 'sqlite':
|
||||
db.vacuum()
|
||||
|
||||
with db.session as s:
|
||||
## Check if database is up to date and migrate if necessary
|
||||
if not s.tables.get('config'):
|
||||
|
|
|
@ -443,7 +443,7 @@ class CustomSession(Session):
|
|||
title = title,
|
||||
url = url,
|
||||
last_access = datetime.now(),
|
||||
domain = url.domain
|
||||
domain = url.hostname()
|
||||
)
|
||||
|
||||
if row:
|
||||
|
|
|
@ -49,6 +49,12 @@
|
|||
connect_event('{{key}}', 'keypress', handle_key_enter);
|
||||
|
||||
|
||||
-macro config_clear(label, item):
|
||||
%span << {{label}}
|
||||
%span
|
||||
%a.button onclick='request("/action/clear/{{item}}");' << Clear
|
||||
|
||||
|
||||
-macro menu_item(label, path, icon):
|
||||
%a.menu-item.grid-container href='{{var.local}}{{path}}'
|
||||
%img.image.grid-item src='{{var.local}}/icon/{{icon}}' title='{{label}}'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
-set page = 'Preferences'
|
||||
-extends 'base.haml'
|
||||
-from 'macro.haml' import config_checkbox, config_textbox, config_dropdown, config_number
|
||||
-from 'macro.haml' import config_checkbox, config_textbox, config_dropdown, config_number, config_clear
|
||||
|
||||
-block meta
|
||||
%link rel='stylesheet' type='text/css' href='{{var.local}}/css/preferences.css'
|
||||
|
@ -101,16 +101,6 @@
|
|||
=config_number('Port for the api server to listen on', 'bw_port', config.bw_port, 1024, 65535)
|
||||
=config_checkbox('Use an external api server', 'bw_external', config.bw_external)
|
||||
|
||||
%details.category.section open
|
||||
%summary << Maintenance
|
||||
.container.grid-container
|
||||
%span << Cache
|
||||
%span
|
||||
%a.button onclick='request("/action/clear/cache");' << Clear
|
||||
%span << Site Options
|
||||
%span
|
||||
%a.button onclick='request("/action/clear/siteoptions");' << Clear
|
||||
|
||||
%details.category.section open
|
||||
%summary << Advanced
|
||||
.container.grid-container
|
||||
|
@ -119,6 +109,13 @@
|
|||
=config_checkbox('Use HTTPS by default', 'https_force', config.https_force)
|
||||
=config_dropdown('Console log level', 'log_level', config.log_level, log_levels)
|
||||
|
||||
%details.category.section open
|
||||
%summary << Maintenance
|
||||
.container.grid-container
|
||||
=config_clear('Cache', 'cache')
|
||||
=config_clear('History', 'history')
|
||||
=config_clear('Site Options', 'siteoption')
|
||||
|
||||
%details.category.section open
|
||||
%summary << Experimental
|
||||
.container.grid-container
|
||||
|
|
|
@ -82,14 +82,21 @@ def about(handler, request):
|
|||
def action_clear(handler, request, item):
|
||||
if item == 'cache':
|
||||
handler.app.context.clear_cache()
|
||||
return request.ok_or_redirect('Cleared cache')
|
||||
msg = 'Cleared cache'
|
||||
|
||||
elif item == 'siteoptions':
|
||||
elif item in ['history', 'siteoptions']:
|
||||
with handler.db.session as s:
|
||||
s.truncate('siteoptions')
|
||||
s.truncate(item)
|
||||
|
||||
handler.db.cache.siteoptions.clear()
|
||||
return request.ok_or_redirect('Cleared site options')
|
||||
handler.db.cache[item].clear()
|
||||
|
||||
if item == 'history':
|
||||
msg = 'Cleared history'
|
||||
|
||||
elif item == 'siteoptions':
|
||||
msg = 'Cleared site options'
|
||||
|
||||
return request.ok_or_redirect(msg)
|
||||
|
||||
|
||||
### Bookmarks ###
|
||||
|
|
Reference in a new issue