diff piecrust/baking/baker.py @ 147:ab6e7e0e9d44

Pass date information to routing when building URLs. This is so that URLs with dates in them can be built even when the date information is not coming from the source metadata, but from the page's config.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 29 Nov 2014 21:00:44 -0800
parents 0609739169bd
children 91dcbb5fe1e8
line wrap: on
line diff
--- a/piecrust/baking/baker.py	Sat Nov 29 20:58:28 2014 -0800
+++ b/piecrust/baking/baker.py	Sat Nov 29 21:00:44 2014 -0800
@@ -84,8 +84,9 @@
 
     def bake(self, factory, route, record_entry,
             taxonomy_name=None, taxonomy_term=None):
+        custom_data = None
         pagination_filter = None
-        custom_data = None
+        route_metadata = dict(factory.metadata)
         if taxonomy_name and taxonomy_term:
             # Must bake a taxonomy listing page... we'll have to add a
             # pagination filter for only get matching posts, and the output
@@ -108,10 +109,11 @@
                         taxonomy_term))
                 slugified_term = taxonomy_term
             custom_data = {tax.term_name: taxonomy_term}
-            uri = route.getUri({tax.term_name: slugified_term})
-        else:
-            # Normal page bake.
-            uri = route.getUri(factory.metadata)
+            route_metadata.update({tax.term_name: slugified_term})
+
+        # Generate the URL using the route.
+        page = factory.buildPage()
+        uri = route.getUri(route_metadata, page)
 
         override = self.record.getOverrideEntry(factory, uri)
         if override is not None:
@@ -131,7 +133,6 @@
         has_more_subs = True
         force_this = self.force
         invalidate_formatting = False
-        page = factory.buildPage()
         record_entry.config = page.config.get().copy()
         prev_record_entry = self.record.getPreviousEntry(
                 factory.source.name, factory.rel_path,