Skip to content

Commit

Permalink
Merge pull request #2083 from getnikola/fix-1370
Browse files Browse the repository at this point in the history
fix #1370
  • Loading branch information
ralsina committed Sep 15, 2015
2 parents 4e0142b + da80804 commit 6e7be0c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -19,6 +19,8 @@ Features
Bugfixes
--------

* Look for bundle assets also in output/, allowing bundling of files
created by plugins (Issue #1370)
* In listings, if lexer is not specified, use literal (Issue #2078)
* Remove bogus ambiguity on listing links (Issue #2080)
* Unix-slash caused conflict in windows (Issue #2079)
Expand Down
6 changes: 5 additions & 1 deletion nikola/plugins/task/bundles.py
Expand Up @@ -101,7 +101,11 @@ def build_bundle(output, inputs):
files.append(os.path.join(dname, fname))
file_dep = [os.path.join(kw['output_folder'], fname)
for fname in files if
utils.get_asset_path(fname, self.site.THEMES, self.site.config['FILES_FOLDERS']) or fname == os.path.join('assets', 'css', 'code.css')]
utils.get_asset_path(
fname,
self.site.THEMES,
self.site.config['FILES_FOLDERS'],
output_dir=kw['output_folder']) or fname == os.path.join('assets', 'css', 'code.css')]
# code.css will be generated by us if it does not exist in
# FILES_FOLDERS or theme assets. It is guaranteed that the
# generation will happen before this task.
Expand Down
8 changes: 7 additions & 1 deletion nikola/utils.py
Expand Up @@ -968,12 +968,14 @@ def get_crumbs(path, is_file=False, index_folder=None):
return list(reversed(_crumbs))


def get_asset_path(path, themes, files_folders={'files': ''}, _themes_dir='themes'):
def get_asset_path(path, themes, files_folders={'files': ''}, _themes_dir='themes', output_dir='output'):
"""Return the "real", absolute path to the asset.
By default, it checks which theme provides the asset.
If the asset is not provided by a theme, then it will be checked for
in the FILES_FOLDERS.
If it's not provided by either, it will be chacked in output, where
it may have been created by another plugin.
>>> print(get_asset_path('assets/css/rst.css', ['bootstrap3', 'base']))
/.../nikola/data/themes/base/assets/css/rst.css
Expand All @@ -1000,6 +1002,10 @@ def get_asset_path(path, themes, files_folders={'files': ''}, _themes_dir='theme
if os.path.isfile(candidate):
return candidate

candidate = os.path.join(output_dir, path)
if os.path.isfile(candidate):
return candidate

# whatever!
return None

Expand Down

0 comments on commit 6e7be0c

Please sign in to comment.