From cd8294327968382eef62754ae215dbf0914b1570 Mon Sep 17 00:00:00 2001 From: Ruud Date: Wed, 3 Aug 2011 22:02:19 +0200 Subject: [PATCH] Auto import static files --- couchpotato/core/notifications/core/main.py | 3 +-- couchpotato/core/plugins/base.py | 6 +++++- couchpotato/core/plugins/file/main.py | 3 +-- couchpotato/core/plugins/movie/main.py | 7 +------ couchpotato/core/plugins/profile/main.py | 4 +--- couchpotato/core/plugins/quality/main.py | 4 +--- couchpotato/core/plugins/renamer/main.py | 2 +- couchpotato/core/plugins/searcher/__init__.py | 2 +- couchpotato/core/plugins/searcher/main.py | 2 +- couchpotato/core/plugins/status/main.py | 3 +-- couchpotato/core/plugins/wizard/main.py | 4 +--- 11 files changed, 15 insertions(+), 25 deletions(-) diff --git a/couchpotato/core/notifications/core/main.py b/couchpotato/core/notifications/core/main.py index 43bfce29..cbb272e9 100644 --- a/couchpotato/core/notifications/core/main.py +++ b/couchpotato/core/notifications/core/main.py @@ -19,8 +19,7 @@ class CoreNotifier(Plugin): addApiView('core_notifier.listener', self.listener) - static = self.registerStatic(__file__) - fireEvent('register_script', static + 'notification.js') + self.registerStatic(__file__) def notify(self, message = '', data = {}): self.add(data = { diff --git a/couchpotato/core/plugins/base.py b/couchpotato/core/plugins/base.py index e617fb1f..0d103219 100644 --- a/couchpotato/core/plugins/base.py +++ b/couchpotato/core/plugins/base.py @@ -1,6 +1,9 @@ from couchpotato import addView +from couchpotato.core.event import fireEvent +from couchpotato.core.helpers.variable import getExt from couchpotato.environment import Env from flask.helpers import send_from_directory +import glob import os.path import re @@ -25,7 +28,8 @@ class Plugin(): path = 'static/' + class_name + '/' addView(path + '', self.showStatic, static = True) - return path + for file in glob.glob(os.path.join(self.plugin_path, 'static', '*')): + fireEvent('register_script' if getExt(file) in 'js' else 'register_style', path + os.path.basename(file)) def showStatic(self, file = ''): dir = os.path.join(self.plugin_path, 'static') diff --git a/couchpotato/core/plugins/file/main.py b/couchpotato/core/plugins/file/main.py index 8ed09d09..53f98ba2 100644 --- a/couchpotato/core/plugins/file/main.py +++ b/couchpotato/core/plugins/file/main.py @@ -25,8 +25,7 @@ class FileManager(Plugin): addApiView('file.cache/', self.showImage) - path = self.registerStatic(__file__) - fireEvent('register_script', path + 'file.js') + self.registerStatic(__file__) def showImage(self, file = ''): diff --git a/couchpotato/core/plugins/movie/main.py b/couchpotato/core/plugins/movie/main.py index 3ed6216c..4763d444 100644 --- a/couchpotato/core/plugins/movie/main.py +++ b/couchpotato/core/plugins/movie/main.py @@ -19,12 +19,7 @@ class MoviePlugin(Plugin): addApiView('movie.edit', self.edit) addApiView('movie.delete', self.delete) - path = self.registerStatic(__file__) - fireEvent('register_script', path + 'search.js') - fireEvent('register_style', path + 'search.css') - fireEvent('register_script', path + 'movie.js') - fireEvent('register_style', path + 'movie.css') - fireEvent('register_script', path + 'list.js') + self.registerStatic(__file__) def list(self): diff --git a/couchpotato/core/plugins/profile/main.py b/couchpotato/core/plugins/profile/main.py index 7f8d9ebc..72512036 100644 --- a/couchpotato/core/plugins/profile/main.py +++ b/couchpotato/core/plugins/profile/main.py @@ -17,9 +17,7 @@ class ProfilePlugin(Plugin): addApiView('profile.save', self.save) addApiView('profile.delete', self.delete) - path = self.registerStatic(__file__) - fireEvent('register_script', path + 'profile.js') - fireEvent('register_style', path + 'profile.css') + self.registerStatic(__file__) def all(self): diff --git a/couchpotato/core/plugins/quality/main.py b/couchpotato/core/plugins/quality/main.py index 3ef0da6a..1d8a489d 100644 --- a/couchpotato/core/plugins/quality/main.py +++ b/couchpotato/core/plugins/quality/main.py @@ -33,9 +33,7 @@ class QualityPlugin(Plugin): addEvent('quality.guess', self.guess) addEvent('app.load', self.fill) - path = self.registerStatic(__file__) - fireEvent('register_script', path + 'quality.js') - fireEvent('register_style', path + 'quality.css') + self.registerStatic(__file__) def all(self): diff --git a/couchpotato/core/plugins/renamer/main.py b/couchpotato/core/plugins/renamer/main.py index 83b04930..9d4d5caf 100644 --- a/couchpotato/core/plugins/renamer/main.py +++ b/couchpotato/core/plugins/renamer/main.py @@ -176,7 +176,7 @@ class Renamer(Plugin): break for file in release.files: - log.info('Removing "%s"' % file.path) + log.info('Removing (not really) "%s"' % file.path) # Rename for src in rename_files: diff --git a/couchpotato/core/plugins/searcher/__init__.py b/couchpotato/core/plugins/searcher/__init__.py index 2d7d3c91..19336078 100644 --- a/couchpotato/core/plugins/searcher/__init__.py +++ b/couchpotato/core/plugins/searcher/__init__.py @@ -21,7 +21,7 @@ config = [{ { 'name': 'ignored_words', 'label': 'Ignored words', - 'default': '', + 'default': 'german, dutch, french, danish, swedish, dubbed, swesub, korsub', }, ], }, { diff --git a/couchpotato/core/plugins/searcher/main.py b/couchpotato/core/plugins/searcher/main.py index 64e6daf0..c61e88d2 100644 --- a/couchpotato/core/plugins/searcher/main.py +++ b/couchpotato/core/plugins/searcher/main.py @@ -46,7 +46,6 @@ class Searcher(Plugin): successful = False for type in movie['profile']['types']: - print type has_better_quality = 0 default_title = movie['library']['titles'][0]['title'] @@ -89,6 +88,7 @@ class Searcher(Plugin): for nzb in sorted_results: successful = fireEvent('download', data = nzb, movie = movie, single = True) + print successful if successful: log.info('Downloading of %s successful.' % nzb.get('name')) diff --git a/couchpotato/core/plugins/status/main.py b/couchpotato/core/plugins/status/main.py index ac9a5961..73a634a5 100644 --- a/couchpotato/core/plugins/status/main.py +++ b/couchpotato/core/plugins/status/main.py @@ -26,8 +26,7 @@ class StatusPlugin(Plugin): addEvent('status.all', self.all) addEvent('app.load', self.fill) - path = self.registerStatic(__file__) - fireEvent('register_script', path + 'status.js') + self.registerStatic(__file__) def all(self): diff --git a/couchpotato/core/plugins/wizard/main.py b/couchpotato/core/plugins/wizard/main.py index 66f4294a..9d1aeca3 100644 --- a/couchpotato/core/plugins/wizard/main.py +++ b/couchpotato/core/plugins/wizard/main.py @@ -8,6 +8,4 @@ log = CPLog(__name__) class Wizard(Plugin): def __init__(self): - path = self.registerStatic(__file__) - fireEvent('register_script', path + 'spotlight.js') - fireEvent('register_script', path + 'wizard.js') + self.registerStatic(__file__)