Remove unnecessary imports from cors plugin

This commit is contained in:
shortcutme 2018-01-28 16:43:50 +01:00
parent 1566da1f8f
commit 335a7a76b1
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -4,11 +4,10 @@ import copy
from Plugin import PluginManager from Plugin import PluginManager
from Translate import Translate from Translate import Translate
from util import helper
from Debug import Debug
if "_" not in locals(): if "_" not in locals():
_ = Translate("plugins/Cors/languages/") _ = Translate("plugins/Cors/languages/")
def getCorsPath(site, inner_path): def getCorsPath(site, inner_path):
match = re.match("^cors-([A-Za-z0-9]{26,35})/(.*)", inner_path) match = re.match("^cors-([A-Za-z0-9]{26,35})/(.*)", inner_path)
if not match: if not match:
@ -59,7 +58,7 @@ class UiWebsocketPlugin(object):
site_name = address site_name = address
button_title = _["Grant & Add"] button_title = _["Grant & Add"]
if site and "Cors:"+address in self.permissions: if site and "Cors:" + address in self.permissions:
return "ignored" return "ignored"
self.cmd( self.cmd(
@ -69,11 +68,12 @@ class UiWebsocketPlugin(object):
) )
def cbCorsPermission(self, to, address): def cbCorsPermission(self, to, address):
self.actionPermissionAdd(to, "Cors:"+address) self.actionPermissionAdd(to, "Cors:" + address)
site = self.server.sites.get(address) site = self.server.sites.get(address)
if not site: if not site:
self.server.site_manager.need(address) self.server.site_manager.need(address)
@PluginManager.registerTo("UiRequest") @PluginManager.registerTo("UiRequest")
class UiRequestPlugin(object): class UiRequestPlugin(object):
# Allow to load cross origin files using /cors-address/file.jpg # Allow to load cross origin files using /cors-address/file.jpg