comparison piecrust/app.py @ 369:4b1019bb2533

serve: Giant refactor to change how we handle data when serving pages. * We need a distinction between source metadata and route metadata. In most cases they're the same, but in cases like taxonomy pages, route metadata contains more things that can't be in source metadata if we want to re-use cached pages. * Create a new `QualifiedPage` type which is a page with a specific route and route metadata. Pass this around in many places. * Instead of passing an URL around, use the route in the `QualifiedPage` to generate URLs. This is better since it removes the guess-work from trying to generate URLs for sub-pages. * Deep-copy app and page configurations before passing them around to things that could modify them, like data builders and such. * Exclude taxonomy pages from iterator data providers. * Properly nest iterator data providers for when the theme and user page sources are merged inside `site.pages`.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 03 May 2015 18:47:10 -0700
parents 81480d0219ba
children c2ca72fb7f0b
comparison
equal deleted inserted replaced
368:2408eb6f4da8 369:4b1019bb2533
535 for route in self.routes: 535 for route in self.routes:
536 if route.source_name == source_name: 536 if route.source_name == source_name:
537 if not skip_taxonomies or route.taxonomy_name is None: 537 if not skip_taxonomies or route.taxonomy_name is None:
538 yield route 538 yield route
539 539
540 def getRoute(self, source_name, source_metadata, *, skip_taxonomies=False): 540 def getRoute(self, source_name, route_metadata, *, skip_taxonomies=False):
541 for route in self.getRoutes(source_name, 541 for route in self.getRoutes(source_name,
542 skip_taxonomies=skip_taxonomies): 542 skip_taxonomies=skip_taxonomies):
543 if (source_metadata is None or 543 if (route_metadata is None or
544 route.matchesMetadata(source_metadata)): 544 route.matchesMetadata(route_metadata)):
545 return route 545 return route
546 return None 546 return None
547 547
548 def getTaxonomyRoute(self, tax_name, source_name): 548 def getTaxonomyRoute(self, tax_name, source_name):
549 for route in self.routes: 549 for route in self.routes: