Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Start to support bundles in plugins
- Loading branch information
Showing
with
29 additions
and
6 deletions.
-
+1
−0
CHANGES.txt
-
+0
−1
nikola/plugin_categories.py
-
+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 |