Mercurial > piecrust2
comparison piecrust/app.py @ 363:dd25bd3ce1f9
serve: Refactoring and fixes to be able to serve taxonomy pages.
* Page sources' `findPagePath` is renamed to `findPageFactory`, so that it
also returns source metadata.
* Page refs now store possible hits more properly, and use the previous point
to also store metadata. As a result, they can also return a proper factory.
* Implement `findPageFactory` correctly in all built-in sources.
* When the Chef server matches a taxonomy page, get the source metadata from
the page ref in order to make a more proper page.
* Make the `getRoute(s)` functions explicitely say if they want taxonomy routes
or not.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 26 Apr 2015 15:07:40 -0700 |
parents | ad3e6496f5c3 |
children | 81480d0219ba |
comparison
equal
deleted
inserted
replaced
362:ff595828a364 | 363:dd25bd3ce1f9 |
---|---|
529 for source in self.sources: | 529 for source in self.sources: |
530 if source.name == source_name: | 530 if source.name == source_name: |
531 return source | 531 return source |
532 return None | 532 return None |
533 | 533 |
534 def getRoutes(self, source_name, skip_taxonomies=False): | 534 def getRoutes(self, source_name, *, skip_taxonomies=False): |
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): | 540 def getRoute(self, source_name, source_metadata, *, skip_taxonomies=False): |
541 for route in self.getRoutes(source_name, True): | 541 for route in self.getRoutes(source_name, |
542 skip_taxonomies=skip_taxonomies): | |
542 if route.matchesMetadata(source_metadata): | 543 if route.matchesMetadata(source_metadata): |
543 return route | 544 return route |
544 return None | 545 return None |
545 | 546 |
546 def getTaxonomyRoute(self, tax_name, source_name): | 547 def getTaxonomyRoute(self, tax_name, source_name): |