Skip to content

Commit 8845dfd

Browse files
committedSep 15, 2015
fix #1370
1 parent 256e410 commit 8845dfd

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed
 

‎CHANGES.txt

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Features
1919
Bugfixes
2020
--------
2121

22+
* Look for bundle assets also in output/, allowing bundling of files
23+
created by plugins (Issue #1370)
2224
* Remove bogus ambiguity on listing links (Issue #2080)
2325
* Unix-slash caused conflict in windows (Issue #2079)
2426
* Locale is now threadsafe, avoid races in threaded builds (Issue #2071)

‎nikola/plugins/task/bundles.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ def build_bundle(output, inputs):
101101
files.append(os.path.join(dname, fname))
102102
file_dep = [os.path.join(kw['output_folder'], fname)
103103
for fname in files if
104-
utils.get_asset_path(fname, self.site.THEMES, self.site.config['FILES_FOLDERS']) or fname == os.path.join('assets', 'css', 'code.css')]
104+
utils.get_asset_path(
105+
fname,
106+
self.site.THEMES,
107+
self.site.config['FILES_FOLDERS'],
108+
output_dir=kw['output_folder']) or fname == os.path.join('assets', 'css', 'code.css')]
105109
# code.css will be generated by us if it does not exist in
106110
# FILES_FOLDERS or theme assets. It is guaranteed that the
107111
# generation will happen before this task.

‎nikola/utils.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -968,12 +968,14 @@ def get_crumbs(path, is_file=False, index_folder=None):
968968
return list(reversed(_crumbs))
969969

970970

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

1005+
candidate = os.path.join(output_dir, path)
1006+
if os.path.isfile(candidate):
1007+
return candidate
1008+
10031009
# whatever!
10041010
return None
10051011

0 commit comments

Comments
 (0)
Please sign in to comment.