Remove hard-coded directory path from plugins
This commit is contained in:
parent
1eb97ea381
commit
3e97c154a0
8 changed files with 39 additions and 17 deletions
|
@ -2,6 +2,7 @@ import time
|
|||
import re
|
||||
import html
|
||||
import hashlib
|
||||
import os
|
||||
|
||||
from Plugin import PluginManager
|
||||
from Translate import Translate
|
||||
|
@ -10,8 +11,10 @@ from Config import config
|
|||
from .ContentFilterStorage import ContentFilterStorage
|
||||
|
||||
|
||||
plugin_dir = os.path.dirname(__file__)
|
||||
|
||||
if "_" not in locals():
|
||||
_ = Translate("plugins/ContentFilter/languages/")
|
||||
_ = Translate(plugin_dir + "/languages/")
|
||||
|
||||
|
||||
@PluginManager.registerTo("SiteManager")
|
||||
|
@ -210,7 +213,7 @@ class UiRequestPlugin(object):
|
|||
|
||||
def actionUiMedia(self, path, *args, **kwargs):
|
||||
if path.startswith("/uimedia/plugins/contentfilter/"):
|
||||
file_path = path.replace("/uimedia/plugins/contentfilter/", "plugins/ContentFilter/media/")
|
||||
file_path = path.replace("/uimedia/plugins/contentfilter/", plugin_dir + "/media/")
|
||||
return self.actionFile(file_path)
|
||||
else:
|
||||
return super(UiRequestPlugin, self).actionUiMedia(path)
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
import re
|
||||
import html
|
||||
import copy
|
||||
import os
|
||||
|
||||
from Plugin import PluginManager
|
||||
from Translate import Translate
|
||||
|
||||
|
||||
plugin_dir = os.path.dirname(__file__)
|
||||
|
||||
if "_" not in locals():
|
||||
_ = Translate("plugins/Cors/languages/")
|
||||
_ = Translate(plugin_dir + "/languages/")
|
||||
|
||||
|
||||
def getCorsPath(site, inner_path):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import re
|
||||
import time
|
||||
import copy
|
||||
import os
|
||||
|
||||
from Plugin import PluginManager
|
||||
from Translate import Translate
|
||||
|
@ -18,8 +19,11 @@ if "merger_db" not in locals().keys(): # To keep merger_sites between module re
|
|||
merged_to_merger = {} # {address: [site1, site2, ...]} cache
|
||||
site_manager = None # Site manager for merger sites
|
||||
|
||||
|
||||
plugin_dir = os.path.dirname(__file__)
|
||||
|
||||
if "_" not in locals():
|
||||
_ = Translate("plugins/MergerSite/languages/")
|
||||
_ = Translate(plugin_dir + "/languages/")
|
||||
|
||||
|
||||
# Check if the site has permission to this merger site
|
||||
|
@ -221,7 +225,7 @@ class UiWebsocketPlugin(object):
|
|||
site = self.server.sites.get(address)
|
||||
try:
|
||||
merged_sites.append(site.content_manager.contents.get("content.json").get("title", address))
|
||||
except Exception as err:
|
||||
except Exception:
|
||||
merged_sites.append(address)
|
||||
|
||||
details = _["Read and write permissions to sites with merged type of <b>%s</b> "] % merger_type
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import re
|
||||
import time
|
||||
import html
|
||||
import os
|
||||
|
||||
import gevent
|
||||
|
||||
|
@ -9,8 +10,11 @@ from Config import config
|
|||
from util import helper
|
||||
from Translate import Translate
|
||||
|
||||
|
||||
plugin_dir = os.path.dirname(__file__)
|
||||
|
||||
if "_" not in locals():
|
||||
_ = Translate("plugins/OptionalManager/languages/")
|
||||
_ = Translate(plugin_dir + "/languages/")
|
||||
|
||||
bigfile_sha512_cache = {}
|
||||
|
||||
|
@ -285,7 +289,7 @@ class UiWebsocketPlugin(object):
|
|||
def actionOptionalLimitSet(self, to, limit):
|
||||
if "ADMIN" not in self.site.settings["permissions"]:
|
||||
return self.response(to, {"error": "Forbidden"})
|
||||
config.optional_limit = re.sub("\.0+$", "", limit) # Remove unnecessary digits from end
|
||||
config.optional_limit = re.sub(r"\.0+$", "", limit) # Remove unnecessary digits from end
|
||||
config.saveValue("optional_limit", limit)
|
||||
self.response(to, "ok")
|
||||
|
||||
|
|
|
@ -18,9 +18,8 @@ from Translate import Translate
|
|||
from util import helper
|
||||
from .ZipStream import ZipStream
|
||||
|
||||
plugin_dir = "plugins/Sidebar"
|
||||
plugin_dir = os.path.dirname(__file__)
|
||||
media_dir = plugin_dir + "/media"
|
||||
sys.path.append(plugin_dir) # To able to load geoip lib
|
||||
|
||||
loc_cache = {}
|
||||
if "_" not in locals():
|
||||
|
|
|
@ -8,8 +8,11 @@ from Translate import Translate
|
|||
|
||||
allow_reload = False # No source reload supported in this plugin
|
||||
|
||||
|
||||
plugin_dir = os.path.dirname(__file__)
|
||||
|
||||
if "_" not in locals():
|
||||
_ = Translate("plugins/Trayicon/languages/")
|
||||
_ = Translate(plugin_dir + "/languages/")
|
||||
|
||||
|
||||
@PluginManager.registerTo("Actions")
|
||||
|
@ -23,8 +26,6 @@ class ActionsPlugin(object):
|
|||
|
||||
self.main = main
|
||||
|
||||
fs_encoding = sys.getfilesystemencoding()
|
||||
|
||||
icon = notificationicon.NotificationIcon(
|
||||
os.path.join(os.path.dirname(os.path.abspath(__file__)), 'trayicon.ico'),
|
||||
"ZeroNet %s" % config.version
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
import io
|
||||
import os
|
||||
|
||||
from Plugin import PluginManager
|
||||
from Config import config
|
||||
from Translate import Translate
|
||||
|
||||
|
||||
plugin_dir = os.path.dirname(__file__)
|
||||
|
||||
if "_" not in locals():
|
||||
_ = Translate("plugins/UiConfig/languages/")
|
||||
_ = Translate(plugin_dir + "/languages/")
|
||||
|
||||
|
||||
@PluginManager.afterLoad
|
||||
|
@ -35,7 +38,7 @@ class UiRequestPlugin(object):
|
|||
|
||||
def actionUiMedia(self, path, *args, **kwargs):
|
||||
if path.startswith("/uimedia/plugins/uiconfig/"):
|
||||
file_path = path.replace("/uimedia/plugins/uiconfig/", "plugins/UiConfig/media/")
|
||||
file_path = path.replace("/uimedia/plugins/uiconfig/", plugin_dir + "/media/")
|
||||
if config.debug and (file_path.endswith("all.js") or file_path.endswith("all.css")):
|
||||
# If debugging merge *.css to all.css and *.js to all.js
|
||||
from Debug import DebugMedia
|
||||
|
|
|
@ -3,12 +3,15 @@ import random
|
|||
import time
|
||||
import json
|
||||
import re
|
||||
|
||||
import os
|
||||
|
||||
from Config import config
|
||||
from Plugin import PluginManager
|
||||
from util import helper
|
||||
|
||||
|
||||
plugin_dir = os.path.dirname(__file__)
|
||||
|
||||
if "sessions" not in locals().keys(): # To keep sessions between module reloads
|
||||
sessions = {}
|
||||
|
||||
|
@ -21,6 +24,7 @@ def showPasswordAdvice(password):
|
|||
error_msgs.append("You are using a very short UI password!")
|
||||
return error_msgs
|
||||
|
||||
|
||||
@PluginManager.registerTo("UiRequest")
|
||||
class UiRequestPlugin(object):
|
||||
sessions = sessions
|
||||
|
@ -45,7 +49,7 @@ class UiRequestPlugin(object):
|
|||
# Action: Login
|
||||
@helper.encodeResponse
|
||||
def actionLogin(self):
|
||||
template = open("plugins/UiPassword/login.html").read()
|
||||
template = open(plugin_dir + "/login.html").read()
|
||||
self.sendHeader()
|
||||
posted = self.getPosted()
|
||||
if posted: # Validate http posted data
|
||||
|
@ -108,7 +112,6 @@ class UiRequestPlugin(object):
|
|||
yield "Error: Invalid session id"
|
||||
|
||||
|
||||
|
||||
@PluginManager.registerTo("ConfigPlugin")
|
||||
class ConfigPlugin(object):
|
||||
def createArguments(self):
|
||||
|
|
Loading…
Reference in a new issue