Add image URL's (thumb & full)
[mediagoblin.git] / mediagoblin / tools / theme.py
index dc83e0ff657720e60af127b5018d0c1aa8e1b622..97b041a61a5cb2cb769dcbc9c21b51e591ddb7d6 100644 (file)
@@ -32,7 +32,7 @@ def themedata_for_theme_dir(name, theme_dir):
     Given a theme directory, extract important theme information.
     """
     # open config
-    config = ConfigObj(os.path.join(theme_dir, 'theme.ini'))
+    config = ConfigObj(os.path.join(theme_dir, 'theme.ini')).get('theme', {})
 
     templates_dir = os.path.join(theme_dir, 'templates')
     if not os.path.exists(templates_dir):
@@ -45,6 +45,7 @@ def themedata_for_theme_dir(name, theme_dir):
     themedata = {
         'name': config.get('name', name),
         'description': config.get('description'),
+        'licensing': config.get('licensing'),
         'dir': theme_dir,
         'templates_dir': templates_dir,
         'assets_dir': assets_dir,
@@ -69,11 +70,20 @@ def register_themes(app_config, builtin_dir=BUILTIN_THEME_DIR):
             registry[themedir] = themedata
         
     # Built-in themes
-    _install_themes_in_dir(builtin_dir)
+    if os.path.exists(builtin_dir):
+        _install_themes_in_dir(builtin_dir)
 
     # Installed themes
     theme_install_dir = app_config.get('theme_install_dir')
     if theme_install_dir and os.path.exists(theme_install_dir):
         _install_themes_in_dir(theme_install_dir)
 
-    return registry
+    current_theme_name = app_config.get('theme')
+    if current_theme_name \
+            and registry.has_key(current_theme_name):
+        current_theme = registry[current_theme_name]
+    else:
+        current_theme = None
+
+    return registry, current_theme
+