diff --git a/pandora/app/config.py b/pandora/app/config.py index 6a825bfc..0ad0ad9f 100644 --- a/pandora/app/config.py +++ b/pandora/app/config.py @@ -39,6 +39,12 @@ def load_config(): except: config = None + with open(settings.DEFAULT_CONFIG) as f: + try: + default = ox.jsonc.load(f) + except: + default = None + if config: settings.SITENAME = config['site']['name'] if getattr(settings, 'SITEURL', False): @@ -56,6 +62,24 @@ def load_config(): for key in config['itemKeys']: config['keys'][key['id']] = key + + #add missing defaults + for section in ('capabilities', 'user.ui', 'user.ui.showFolder'): + parts = map(lambda p: p.replace('\0', '\\.'), section.replace('\\.', '\0').split('.')) + #print 'checking', section + c = config + d = default + while len(parts): + part = parts.pop(0) + if part not in c: + c[part] = {} + c = c[part] + d = d[part] + for key in d: + if key not in c: + print "adding default value for %s.%s" % (section, key), '=', d[key] + c[key] = d[key] + old_formats = getattr(settings, 'CONFIG', {}).get('video', {}).get('formats', []) formats = config.get('video', {}).get('formats') if set(old_formats) != set(formats): @@ -110,20 +134,18 @@ def reloader_thread(): except: INOTIFY = False if INOTIFY: - class ConfigChanges: - def __init__(self): - name = os.path.realpath(settings.SITE_CONFIG) - self.name = name - self.wm = pyinotify.WatchManager() - self.reload_config() - notifier = pyinotify.Notifier(self.wm) - notifier.loop() - - def reload_config(self): - load_config() - self.wm.add_watch(self.name, pyinotify.IN_CLOSE_WRITE, - lambda event: self.reload_config()) - ConfigChanges() + def add_watch(): + name = os.path.realpath(settings.SITE_CONFIG) + wm.add_watch(name, pyinotify.IN_CLOSE_WRITE, reload_config) + + def reload_config(event): + load_config() + add_watch() + + wm = pyinotify.WatchManager() + add_watch() + notifier = pyinotify.Notifier(wm) + notifier.loop() else: while RUN_RELOADER: try: diff --git a/pandora/config.0xdb.jsonc b/pandora/config.0xdb.jsonc index b1ef167e..b29713ba 100644 --- a/pandora/config.0xdb.jsonc +++ b/pandora/config.0xdb.jsonc @@ -729,7 +729,9 @@ "level": "guest", "newsletter": true, "ui": { + "annotationsCalendarSize": 128, "annotationsFont": "small", + "annotationsMapSize": 128, "annotationsRange": "all", "annotationsSize": 256, "annotationsSort": "position", @@ -777,6 +779,8 @@ "sequenceSort": [{"key": "director", "operator": "+"}], "showAdvancedEmbedOptions": false, "showAnnotations": true, + "showAnnotationsCalendar": true, + "showAnnotationsMap": true, "showBrowser": true, "showCalendarControls": true, // fixme: should be false "showFilters": true, diff --git a/pandora/config.indiancinema.jsonc b/pandora/config.indiancinema.jsonc index 72fff6b5..df795862 100644 --- a/pandora/config.indiancinema.jsonc +++ b/pandora/config.indiancinema.jsonc @@ -767,7 +767,9 @@ "level": "guest", "newsletter": true, "ui": { + "annotationsCalendarSize": 128, "annotationsFont": "small", + "annotationsMapSize": 128, "annotationsRange": "all", "annotationsSize": 256, "annotationsSort": "position", @@ -815,6 +817,8 @@ "sequenceSort": [{"key": "director", "operator": "+"}], "showAdvancedEmbedOptions": false, "showAnnotations": true, + "showAnnotationsCalendar": true, + "showAnnotationsMap": true, "showBrowser": true, "showCalendarControls": true, // fixme: should be false "showFilters": true, diff --git a/pandora/settings.py b/pandora/settings.py index 0d324cad..a8d31806 100644 --- a/pandora/settings.py +++ b/pandora/settings.py @@ -181,6 +181,7 @@ XSENDFILE = False XACCELREDIRECT = False SITE_CONFIG = join(PROJECT_ROOT, 'config.jsonc') +DEFAULT_CONFIG = join(PROJECT_ROOT, 'config.pandora.jsonc') #used if CONFIG['video']['download'] is set TRACKER_URL="udp://tracker.openbittorrent.com:80"