changeset 473:eb3ace870708 2.0.0a13

bake: Fix a bug with copying assets when `pretty_urls` are disabled. Added unit tests.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 14 Jul 2015 23:59:08 -0700
parents dc78ade3f320
children 750160edefb7
files piecrust/baking/single.py tests/bakes/test_assets.yaml
diffstat 2 files changed, 32 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/piecrust/baking/single.py	Tue Jul 14 23:41:25 2015 -0700
+++ b/piecrust/baking/single.py	Tue Jul 14 23:59:08 2015 -0700
@@ -131,7 +131,8 @@
                     out_assets_dir, out_name = os.path.split(out_path)
                     if sub_uri != self.site_root:
                         out_name_noext, _ = os.path.splitext(out_name)
-                        out_assets_dir += out_name_noext
+                        out_assets_dir = os.path.join(out_assets_dir,
+                                                      out_name_noext)
 
                 logger.debug("Copying page assets to: %s" % out_assets_dir)
                 _ensure_dir_exists(out_assets_dir)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/bakes/test_assets.yaml	Tue Jul 14 23:59:08 2015 -0700
@@ -0,0 +1,30 @@
+---
+in:
+    posts/2010-01-01_post1-assets/blah.png: 'fake image'
+    posts/2010-01-01_post1.md: 'my image: {{assets.blah}}'
+    pages/_index.md: 'something'
+out:
+    '2010':
+        '01':
+            '01':
+                post1.html: 'my image: /2010/01/01/post1/blah.png'
+                post1:
+                    blah.png: 'fake image'
+    index.html: 'something'
+---
+config:
+    site:
+        pretty_urls: true
+in:
+    posts/2010-01-01_post1-assets/blah.png: 'fake image'
+    posts/2010-01-01_post1.md: 'my image: {{assets.blah}}'
+    pages/_index.md: 'something'
+out:
+    '2010':
+        '01':
+            '01':
+                'post1':
+                    index.html: 'my image: /2010/01/01/post1/blah.png'
+                    blah.png: 'fake image'
+    index.html: 'something'
+