Skip to content
Permalink
Browse files

Start to support bundles in plugins

  • Loading branch information
ralsina committed May 3, 2015
1 parent 0b93441 commit c217059ad9b49d7930fce25677cbe72ccd3d8405
Showing with 29 additions and 6 deletions.
  1. +1 −0 CHANGES.txt
  2. +0 −1 nikola/plugin_categories.py
  3. +28 −5 nikola/plugins/task/bundles.py
@@ -4,6 +4,7 @@ New in master
Features
--------

* 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.
pass


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.isfile,
[os.path.join(utils.get_theme_path(theme_name), 'bundles') for theme_name in site.THEMES]
)
plugins = filter(
os.path.isfile,
[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:
try:
@@ -136,3 +142,20 @@ def get_theme_bundles(themes):
pass
break
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:
try:
name, files = line.split('=')
files = [f.strip() for f in files.split(',')]
bundles[name.strip().replace('/', os.sep)] = files
except ValueError:
# for empty lines
pass
return bundles

0 comments on commit c217059

Please sign in to comment.