From 3833b6ead146592f0ead258aed1c997b09bc03f8 Mon Sep 17 00:00:00 2001 From: Ruud Date: Tue, 12 Apr 2011 09:29:04 +0200 Subject: [PATCH] ClientScript always load first --- couchpotato/core/plugins/_clientscript/__init__.py | 6 +++ couchpotato/core/plugins/_clientscript/main.py | 56 ++++++++++++++++++++++ couchpotato/core/plugins/clientscript/__init__.py | 6 --- couchpotato/core/plugins/clientscript/main.py | 56 ---------------------- 4 files changed, 62 insertions(+), 62 deletions(-) create mode 100644 couchpotato/core/plugins/_clientscript/__init__.py create mode 100644 couchpotato/core/plugins/_clientscript/main.py delete mode 100644 couchpotato/core/plugins/clientscript/__init__.py delete mode 100644 couchpotato/core/plugins/clientscript/main.py diff --git a/couchpotato/core/plugins/_clientscript/__init__.py b/couchpotato/core/plugins/_clientscript/__init__.py new file mode 100644 index 0000000..8490eae --- /dev/null +++ b/couchpotato/core/plugins/_clientscript/__init__.py @@ -0,0 +1,6 @@ +from .main import ClientScript + +def start(): + return ClientScript() + +config = [] diff --git a/couchpotato/core/plugins/_clientscript/main.py b/couchpotato/core/plugins/_clientscript/main.py new file mode 100644 index 0000000..8d9f28d --- /dev/null +++ b/couchpotato/core/plugins/_clientscript/main.py @@ -0,0 +1,56 @@ +from couchpotato.core.event import addEvent +from couchpotato.core.logger import CPLog +from couchpotato.core.plugins.base import Plugin + +log = CPLog(__name__) + + +class ClientScript(Plugin): + + urls = { + 'style': {}, + 'script': {}, + } + + html = { + 'style': '', + 'script': '', + } + + def __init__(self): + addEvent('register_style', self.registerStyle) + addEvent('register_script', self.registerScript) + + addEvent('clientscript.get_styles', self.getStyles) + addEvent('clientscript.get_scripts', self.getScripts) + + def getStyles(self, *args, **kwargs): + return self.get('style', *args, **kwargs) + + def getScripts(self, *args, **kwargs): + return self.get('script', *args, **kwargs) + + def get(self, type, as_html = False, location = 'head'): + + data = '' if as_html else [] + + try: + return self.urls[type][location] + except Exception, e: + log.error(e) + + return data + + def registerStyle(self, path, position = 'head'): + self.register(path, 'style', position) + + def registerScript(self, path, position = 'head'): + self.register(path, 'script', position) + + def register(self, file, type, location): + + if not self.urls[type].get(location): + self.urls[type][location] = [] + + filePath = file + self.urls[type][location].append(filePath) diff --git a/couchpotato/core/plugins/clientscript/__init__.py b/couchpotato/core/plugins/clientscript/__init__.py deleted file mode 100644 index 8490eae..0000000 --- a/couchpotato/core/plugins/clientscript/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -from .main import ClientScript - -def start(): - return ClientScript() - -config = [] diff --git a/couchpotato/core/plugins/clientscript/main.py b/couchpotato/core/plugins/clientscript/main.py deleted file mode 100644 index 8d9f28d..0000000 --- a/couchpotato/core/plugins/clientscript/main.py +++ /dev/null @@ -1,56 +0,0 @@ -from couchpotato.core.event import addEvent -from couchpotato.core.logger import CPLog -from couchpotato.core.plugins.base import Plugin - -log = CPLog(__name__) - - -class ClientScript(Plugin): - - urls = { - 'style': {}, - 'script': {}, - } - - html = { - 'style': '', - 'script': '', - } - - def __init__(self): - addEvent('register_style', self.registerStyle) - addEvent('register_script', self.registerScript) - - addEvent('clientscript.get_styles', self.getStyles) - addEvent('clientscript.get_scripts', self.getScripts) - - def getStyles(self, *args, **kwargs): - return self.get('style', *args, **kwargs) - - def getScripts(self, *args, **kwargs): - return self.get('script', *args, **kwargs) - - def get(self, type, as_html = False, location = 'head'): - - data = '' if as_html else [] - - try: - return self.urls[type][location] - except Exception, e: - log.error(e) - - return data - - def registerStyle(self, path, position = 'head'): - self.register(path, 'style', position) - - def registerScript(self, path, position = 'head'): - self.register(path, 'script', position) - - def register(self, file, type, location): - - if not self.urls[type].get(location): - self.urls[type][location] = [] - - filePath = file - self.urls[type][location].append(filePath)