Skip to content
Browse files
Start to support bundles in plugins
  • Loading branch information
ralsina committed May 3, 2015
1 parent 0b93441 commit c217059ad9b49d7930fce25677cbe72ccd3d8405
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
@@ -4,6 +4,7 @@ New in master

* Plugins can declare JS and CSS assets to be bundled (Issue #656)
* Compatibility with doit v0.28.0 (Issue #1655)
* AddThis is no longer added by default to users’ sites
* New translations (az, fil, tl, uk, zh_TW)
@@ -75,7 +75,6 @@ def inject_templates(self):
# so let’s just ignore it and be done with it.

class Command(BasePlugin, DoitCommand):
"""These plugins are exposed via the command line.
They implement the doit Command interface."""
@@ -118,13 +118,19 @@ def build_bundle(output, inputs):
yield utils.apply_filters(task, kw['filters'])

def get_theme_bundles(themes):
def get_all_bundles(site):
"""Given a theme chain, return the bundle definitions."""
bundles = {}
for theme_name in themes:
bundles_path = os.path.join(
utils.get_theme_path(theme_name), 'bundles')
if os.path.isfile(bundles_path):
themes = filter(
[os.path.join(utils.get_theme_path(theme_name), 'bundles') for theme_name in site.THEMES]
plugins = filter(
[os.path.join(p.path, 'bundles') for p in site.plugin_manager.getAllPlugins()]

for bundles_path in themes:
with open(bundles_path) as fd:
for line in fd:
@@ -136,3 +142,20 @@ def get_theme_bundles(themes):
return bundles

def get_plugin_bundles(site):
"""Get all the bundles declared by all the plugins in the site."""
bundles = {}

bundles_paths = filter(os.path.isfile, bundles_paths)
for p in bundles_paths:
with open(p) as fd:
for line in fd:
name, files = line.split('=')
files = [f.strip() for f in files.split(',')]
bundles[name.strip().replace('/', os.sep)] = files
except ValueError:
# for empty lines
return bundles

0 comments on commit c217059

Please sign in to comment.