From: Christopher Allan Webber Date: Thu, 23 May 2013 14:52:57 +0000 (-0500) Subject: Generalize "gmg theme assetlink" -> "gmg assetlink" and cover both theme and plugins X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=6afc8364e018d56f68f40761396ed74f907d5ff9;p=mediagoblin.git Generalize "gmg theme assetlink" -> "gmg assetlink" and cover both theme and plugins We've moved the module... probably I'll re-add theme just to give a warning that this is deprecated. This commit sponsored by Kevin Williams. Thank you! --- diff --git a/mediagoblin/gmg_commands/__init__.py b/mediagoblin/gmg_commands/__init__.py index 6aed4f6c..d8156126 100644 --- a/mediagoblin/gmg_commands/__init__.py +++ b/mediagoblin/gmg_commands/__init__.py @@ -41,11 +41,15 @@ SUBCOMMAND_MAP = { 'setup': 'mediagoblin.gmg_commands.dbupdate:dbupdate_parse_setup', 'func': 'mediagoblin.gmg_commands.dbupdate:dbupdate', 'help': 'Set up or update the SQL database'}, - 'theme': { - 'setup': 'mediagoblin.gmg_commands.theme:theme_parser_setup', - 'func': 'mediagoblin.gmg_commands.theme:theme', - 'help': 'Theming commands', - } + 'assetlink': { + 'setup': 'mediagoblin.gmg_commands.assetlink:assetlink_parser_setup', + 'func': 'mediagoblin.gmg_commands.assetlink:assetlink', + 'help': 'Link assets for themes and plugins for static serving'}, + # 'theme': { + # 'setup': 'mediagoblin.gmg_commands.theme:theme_parser_setup', + # 'func': 'mediagoblin.gmg_commands.theme:theme', + # 'help': 'Theming commands', + # } ## These might be useful, mayyyybe, but don't really work anymore ## due to mongo change and the "versatility" of sql options. diff --git a/mediagoblin/gmg_commands/theme.py b/mediagoblin/gmg_commands/assetlink.py similarity index 75% rename from mediagoblin/gmg_commands/theme.py rename to mediagoblin/gmg_commands/assetlink.py index adf50d5a..387658ac 100644 --- a/mediagoblin/gmg_commands/theme.py +++ b/mediagoblin/gmg_commands/assetlink.py @@ -16,6 +16,7 @@ import os +from mediagoblin import mg_globals from mediagoblin.init import setup_global_and_app_config from mediagoblin.gmg_commands import util as commands_util from mediagoblin.tools.theme import register_themes @@ -24,22 +25,23 @@ from mediagoblin.tools.common import simple_printer from mediagoblin.tools import pluginapi -def theme_parser_setup(subparser): - theme_subparsers = subparser.add_subparsers( - dest=u"subcommand", - help=u'Theme sub-commands') +def assetlink_parser_setup(subparser): + # theme_subparsers = subparser.add_subparsers( + # dest=u"subcommand", + # help=u'Assetlink options') - # Install command - install_parser = theme_subparsers.add_parser( - u'install', help=u'Install a theme to this mediagoblin instance') - install_parser.add_argument( - u'themefile', help=u'The theme archive to be installed') + # # Install command + # install_parser = theme_subparsers.add_parser( + # u'install', help=u'Install a theme to this mediagoblin instance') + # install_parser.add_argument( + # u'themefile', help=u'The theme archive to be installed') - theme_subparsers.add_parser( - u'assetlink', - help=( - u"Link the currently installed theme's assets " - u"to the served theme asset directory")) + # theme_subparsers.add_parser( + # u'assetlink', + # help=( + # u"Link the currently installed theme's assets " + # u"to the served theme asset directory")) + pass ########### @@ -132,47 +134,18 @@ def link_plugin_assets(plugin_static, plugins_link_dir, printer=simple_printer): link_dir)) -def install_theme(install_dir, themefile): - pass # TODO ;) - - -############# -# Subcommands -############# - -def assetlink_command(args): +def assetlink(args): """ Link the asset directory of the currently installed theme """ - global_config, app_config = setup_global_and_app_config(args.conf_file) - theme_registry, current_theme = register_themes(app_config) + mgoblin_app = commands_util.setup_app(args) + app_config = mg_globals.app_config # link theme - link_theme_assets(current_theme, app_config['theme_linked_assets_dir']) - - # Set up the app specifically so we can access the plugin infrastructure - commands_util.setup_app(args) + link_theme_assets(mgoblin_app.current_theme, app_config['theme_linked_assets_dir']) # link plugin assets ## ... probably for this we need the whole application initialized for plugin_static in pluginapi.hook_runall("static_setup"): link_plugin_assets( plugin_static, app_config['plugin_linked_assets_dir']) - - -def install_command(args): - """ - Handle the 'install this theme' subcommand - """ - global_config, app_config = setup_global_and_app_config(args.conf_file) - install_dir = app_config['theme_install_dir'] - install_theme(install_dir, args.themefile) - - -SUBCOMMANDS = { - 'assetlink': assetlink_command, - 'install': install_command} - - -def theme(args): - SUBCOMMANDS[args.subcommand](args)