comparison 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
comparison
equal deleted inserted replaced
146:0609739169bd 147:ab6e7e0e9d44
82 82
83 return os.path.normpath(os.path.join(*bake_path)) 83 return os.path.normpath(os.path.join(*bake_path))
84 84
85 def bake(self, factory, route, record_entry, 85 def bake(self, factory, route, record_entry,
86 taxonomy_name=None, taxonomy_term=None): 86 taxonomy_name=None, taxonomy_term=None):
87 custom_data = None
87 pagination_filter = None 88 pagination_filter = None
88 custom_data = None 89 route_metadata = dict(factory.metadata)
89 if taxonomy_name and taxonomy_term: 90 if taxonomy_name and taxonomy_term:
90 # Must bake a taxonomy listing page... we'll have to add a 91 # Must bake a taxonomy listing page... we'll have to add a
91 # pagination filter for only get matching posts, and the output 92 # pagination filter for only get matching posts, and the output
92 # URL will be a bit different. 93 # URL will be a bit different.
93 tax = self.app.getTaxonomy(taxonomy_name) 94 tax = self.app.getTaxonomy(taxonomy_name)
106 else: 107 else:
107 pagination_filter.addClause(IsFilterClause(taxonomy_name, 108 pagination_filter.addClause(IsFilterClause(taxonomy_name,
108 taxonomy_term)) 109 taxonomy_term))
109 slugified_term = taxonomy_term 110 slugified_term = taxonomy_term
110 custom_data = {tax.term_name: taxonomy_term} 111 custom_data = {tax.term_name: taxonomy_term}
111 uri = route.getUri({tax.term_name: slugified_term}) 112 route_metadata.update({tax.term_name: slugified_term})
112 else: 113
113 # Normal page bake. 114 # Generate the URL using the route.
114 uri = route.getUri(factory.metadata) 115 page = factory.buildPage()
116 uri = route.getUri(route_metadata, page)
115 117
116 override = self.record.getOverrideEntry(factory, uri) 118 override = self.record.getOverrideEntry(factory, uri)
117 if override is not None: 119 if override is not None:
118 override_source = self.app.getSource(override.source_name) 120 override_source = self.app.getSource(override.source_name)
119 if override_source.realm == factory.source.realm: 121 if override_source.realm == factory.source.realm:
129 131
130 cur_sub = 1 132 cur_sub = 1
131 has_more_subs = True 133 has_more_subs = True
132 force_this = self.force 134 force_this = self.force
133 invalidate_formatting = False 135 invalidate_formatting = False
134 page = factory.buildPage()
135 record_entry.config = page.config.get().copy() 136 record_entry.config = page.config.get().copy()
136 prev_record_entry = self.record.getPreviousEntry( 137 prev_record_entry = self.record.getPreviousEntry(
137 factory.source.name, factory.rel_path, 138 factory.source.name, factory.rel_path,
138 taxonomy_name, taxonomy_term) 139 taxonomy_name, taxonomy_term)
139 140