From 168a9a2f957ce2535ea2e4a4cd5341815f960949 Mon Sep 17 00:00:00 2001 From: Ruud Date: Fri, 6 Jan 2012 17:08:45 +0100 Subject: [PATCH] Small fixes --- couchpotato/api/__init__.py | 2 +- couchpotato/core/plugins/userscript/static/userscript.js | 4 ++-- couchpotato/core/settings/__init__.py | 4 ++-- couchpotato/environment.py | 4 ++-- couchpotato/runner.py | 4 ++-- couchpotato/static/scripts/couchpotato.js | 7 ++++++- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/couchpotato/api/__init__.py b/couchpotato/api/__init__.py index 1f2f1a3..3e866e4 100644 --- a/couchpotato/api/__init__.py +++ b/couchpotato/api/__init__.py @@ -4,7 +4,7 @@ from flask.blueprints import Blueprint api = Blueprint('api', __name__) def addApiView(route, func, static = False): - api.add_url_rule(route + ('' if static else '/'), endpoint = route if route else 'index', view_func = func) + api.add_url_rule(route + ('' if static else '/'), endpoint = route.replace('.', '_') if route else 'index', view_func = func) """ Api view """ def index(): diff --git a/couchpotato/core/plugins/userscript/static/userscript.js b/couchpotato/core/plugins/userscript/static/userscript.js index 2975075..c17bc2c 100644 --- a/couchpotato/core/plugins/userscript/static/userscript.js +++ b/couchpotato/core/plugins/userscript/static/userscript.js @@ -99,8 +99,8 @@ window.addEvent('domready', function(){ }); window.addEvent('load', function(){ - var your_version = $(document.body).get('data-userscript_version') - latest_version = App.getOption('userscript_version') + var your_version = $(document.body).get('data-userscript_version'), + latest_version = App.getOption('userscript_version') || '', key = 'cp_version_check', checked_already = Cookie.read(key); diff --git a/couchpotato/core/settings/__init__.py b/couchpotato/core/settings/__init__.py index d1a1b0b..10b2a14 100644 --- a/couchpotato/core/settings/__init__.py +++ b/couchpotato/core/settings/__init__.py @@ -54,11 +54,11 @@ class Settings(): def set(self, section, option, value): return self.p.set(section, option, value) - def get(self, option = '', section = 'core', default = ''): + def get(self, option = '', section = 'core', default = '', type = None): try: try: type = self.types[section][option] - except: type = 'unicode' + except: type = 'unicode' if not type else type if hasattr(self, 'get%s' % type.capitalize()): return getattr(self, 'get%s' % type.capitalize())(section, option) diff --git a/couchpotato/environment.py b/couchpotato/environment.py index 21fbaa2..ea7f01d 100644 --- a/couchpotato/environment.py +++ b/couchpotato/environment.py @@ -35,13 +35,13 @@ class Env(object): return setattr(Env, '_' + attr, value) @staticmethod - def setting(attr, section = 'core', value = None, default = ''): + def setting(attr, section = 'core', value = None, default = '', type = None): s = Env.get('settings') # Return setting if value == None: - return s.get(attr, default = default, section = section) + return s.get(attr, default = default, section = section, type = type) # Set setting s.set(section, attr, value) diff --git a/couchpotato/runner.py b/couchpotato/runner.py index 66e2b5e..62711f6 100644 --- a/couchpotato/runner.py +++ b/couchpotato/runner.py @@ -73,7 +73,7 @@ def runCouchPotato(options, base_path, args): Env.set('options', options) # Determine debug - debug = options.debug or Env.setting('debug', default = False) + debug = options.debug or Env.setting('debug', default = False, type = 'bool') Env.set('debug', debug) # Only run once when debugging @@ -146,7 +146,7 @@ def runCouchPotato(options, base_path, args): from couchpotato import app api_key = Env.setting('api_key') url_base = '/' + Env.setting('url_base').lstrip('/') if Env.setting('url_base') else '' - reloader = debug and not options.daemonize + reloader = debug is True and not options.daemonize # Basic config app.secret_key = api_key diff --git a/couchpotato/static/scripts/couchpotato.js b/couchpotato/static/scripts/couchpotato.js index 7ab21d0..4134f55 100644 --- a/couchpotato/static/scripts/couchpotato.js +++ b/couchpotato/static/scripts/couchpotato.js @@ -32,7 +32,12 @@ var CouchPotato = new Class({ }, getOption: function(name){ - return this.options[name]; + try { + return this.options[name]; + } + catch(e){ + return null + } }, pushState: function(e){