Small fixes
This commit is contained in:
@@ -4,7 +4,7 @@ from flask.blueprints import Blueprint
|
|||||||
api = Blueprint('api', __name__)
|
api = Blueprint('api', __name__)
|
||||||
|
|
||||||
def addApiView(route, func, static = False):
|
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 """
|
""" Api view """
|
||||||
def index():
|
def index():
|
||||||
|
|||||||
@@ -99,8 +99,8 @@ window.addEvent('domready', function(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
window.addEvent('load', function(){
|
window.addEvent('load', function(){
|
||||||
var your_version = $(document.body).get('data-userscript_version')
|
var your_version = $(document.body).get('data-userscript_version'),
|
||||||
latest_version = App.getOption('userscript_version')
|
latest_version = App.getOption('userscript_version') || '',
|
||||||
key = 'cp_version_check',
|
key = 'cp_version_check',
|
||||||
checked_already = Cookie.read(key);
|
checked_already = Cookie.read(key);
|
||||||
|
|
||||||
|
|||||||
@@ -54,11 +54,11 @@ class Settings():
|
|||||||
def set(self, section, option, value):
|
def set(self, section, option, value):
|
||||||
return self.p.set(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:
|
||||||
|
|
||||||
try: type = self.types[section][option]
|
try: type = self.types[section][option]
|
||||||
except: type = 'unicode'
|
except: type = 'unicode' if not type else type
|
||||||
|
|
||||||
if hasattr(self, 'get%s' % type.capitalize()):
|
if hasattr(self, 'get%s' % type.capitalize()):
|
||||||
return getattr(self, 'get%s' % type.capitalize())(section, option)
|
return getattr(self, 'get%s' % type.capitalize())(section, option)
|
||||||
|
|||||||
@@ -35,13 +35,13 @@ class Env(object):
|
|||||||
return setattr(Env, '_' + attr, value)
|
return setattr(Env, '_' + attr, value)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def setting(attr, section = 'core', value = None, default = ''):
|
def setting(attr, section = 'core', value = None, default = '', type = None):
|
||||||
|
|
||||||
s = Env.get('settings')
|
s = Env.get('settings')
|
||||||
|
|
||||||
# Return setting
|
# Return setting
|
||||||
if value == None:
|
if value == None:
|
||||||
return s.get(attr, default = default, section = section)
|
return s.get(attr, default = default, section = section, type = type)
|
||||||
|
|
||||||
# Set setting
|
# Set setting
|
||||||
s.set(section, attr, value)
|
s.set(section, attr, value)
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ def runCouchPotato(options, base_path, args):
|
|||||||
Env.set('options', options)
|
Env.set('options', options)
|
||||||
|
|
||||||
# Determine debug
|
# 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)
|
Env.set('debug', debug)
|
||||||
|
|
||||||
# Only run once when debugging
|
# Only run once when debugging
|
||||||
@@ -146,7 +146,7 @@ def runCouchPotato(options, base_path, args):
|
|||||||
from couchpotato import app
|
from couchpotato import app
|
||||||
api_key = Env.setting('api_key')
|
api_key = Env.setting('api_key')
|
||||||
url_base = '/' + Env.setting('url_base').lstrip('/') if Env.setting('url_base') else ''
|
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
|
# Basic config
|
||||||
app.secret_key = api_key
|
app.secret_key = api_key
|
||||||
|
|||||||
@@ -32,7 +32,12 @@ var CouchPotato = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getOption: function(name){
|
getOption: function(name){
|
||||||
return this.options[name];
|
try {
|
||||||
|
return this.options[name];
|
||||||
|
}
|
||||||
|
catch(e){
|
||||||
|
return null
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
pushState: function(e){
|
pushState: function(e){
|
||||||
|
|||||||
Reference in New Issue
Block a user