Mercurial > piecrust2
view piecrust/sources/array.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 | f130365568ff |
children | e7b865f8f335 |
line wrap: on
line source
from piecrust.sources.base import PageSource from piecrust.sources.mixins import SimplePaginationSourceMixin class CachedPageFactory(object): """ A `PageFactory` (in appearance) that already has a page built. """ def __init__(self, page): self._page = page @property def rel_path(self): return self._page.rel_path @property def metadata(self): return self._page.source_metadata @property def ref_spec(self): return self._page.ref_spec @property def path(self): return self._page.path def buildPage(self): return self._page class ArraySource(PageSource, SimplePaginationSourceMixin): def __init__(self, app, inner_source, name='array', config=None): super(ArraySource, self).__init__(app, name, config or {}) self.inner_source = inner_source @property def page_count(self): return len(self.inner_source) def getPageFactories(self): for p in self.inner_source: yield CachedPageFactory(p)