Small fixes

This commit is contained in:
Ruud
2012-01-06 17:08:45 +01:00
parent 1c75bfb9b0
commit 168a9a2f95
6 changed files with 15 additions and 10 deletions
+1 -1
View File
@@ -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():
@@ -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);
+2 -2
View File
@@ -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)
+2 -2
View File
@@ -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)
+2 -2
View File
@@ -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
+6 -1
View File
@@ -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){