aboutsummaryrefslogtreecommitdiffstats
path: root/nikola/plugins/task_copy_assets.py
diff options
context:
space:
mode:
authorLibravatarAgustin Henze <tin@sluc.org.ar>2012-12-12 20:15:50 -0300
committerLibravatarAgustin Henze <tin@sluc.org.ar>2012-12-12 20:15:50 -0300
commit540e6aa6fcd86a98e270715d1d4e49493eacc270 (patch)
treead1b1fcca82d9638f5edcf7a4d9149ca113ba2d2 /nikola/plugins/task_copy_assets.py
parent25744f4bf462020e353c503db3ec558604c19137 (diff)
parent0f2c04e70a0ffdd0892d6970cafbcd952d221db5 (diff)
Merge tag 'upstream/5'
Upstream version 5
Diffstat (limited to 'nikola/plugins/task_copy_assets.py')
-rw-r--r--nikola/plugins/task_copy_assets.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/nikola/plugins/task_copy_assets.py b/nikola/plugins/task_copy_assets.py
new file mode 100644
index 0000000..ac31fd7
--- /dev/null
+++ b/nikola/plugins/task_copy_assets.py
@@ -0,0 +1,35 @@
+import os
+
+from nikola.plugin_categories import Task
+from nikola import utils
+
+
+class CopyAssets(Task):
+ """Copy theme assets into output."""
+
+ name = "copy_assets"
+
+ def gen_tasks(self):
+ """Create tasks to copy the assets of the whole theme chain.
+
+ If a file is present on two themes, use the version
+ from the "youngest" theme.
+ """
+
+ kw = {
+ "themes": self.site.THEMES,
+ "output_folder": self.site.config['OUTPUT_FOLDER'],
+ "filters": self.site.config['FILTERS'],
+ }
+
+ tasks = {}
+ for theme_name in kw['themes']:
+ src = os.path.join(utils.get_theme_path(theme_name), 'assets')
+ dst = os.path.join(kw['output_folder'], 'assets')
+ for task in utils.copy_tree(src, dst):
+ if task['name'] in tasks:
+ continue
+ tasks[task['name']] = task
+ task['uptodate'] = [utils.config_changed(kw)]
+ task['basename'] = self.name
+ yield utils.apply_filters(task, kw['filters'])