Mercurial > piecrust2
diff piecrust/sources/mixins.py @ 853:f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
The asset pipeline is still the only function pipeline at this point.
* No more `QualifiedPage`, and several other pieces of code deleted.
* Data providers are simpler and more focused. For instance, the page iterator
doesn't try to support other types of items.
* Route parameters are proper known source metadata to remove the confusion
between the two.
* Make the baker and pipeline more correctly manage records and record
histories.
* Add support for record collapsing and deleting stale outputs in the asset
pipeline.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 21 May 2017 00:06:59 -0700 |
parents | 4850f8c21b6e |
children | fddaf43424e2 |
line wrap: on
line diff
--- a/piecrust/sources/mixins.py Wed May 17 00:11:48 2017 -0700 +++ b/piecrust/sources/mixins.py Sun May 21 00:06:59 2017 -0700 @@ -1,9 +1,7 @@ import os.path import logging from piecrust import osutil -from piecrust.data.paginationdata import PaginationData from piecrust.sources.base import ContentItem -from piecrust.sources.interfaces import IPaginationSource logger = logging.getLogger(__name__) @@ -11,57 +9,6 @@ assets_suffix = '-assets' -class ContentSourceIterator(object): - def __init__(self, source): - self.source = source - - # This is to permit recursive traversal of the - # iterator chain. It acts as the end. - self.it = None - - def __iter__(self): - return self.source.getAllContentItems() - - -class DateSortIterator(object): - def __init__(self, it, reverse=True): - self.it = it - self.reverse = reverse - - def __iter__(self): - return iter(sorted(self.it, - key=lambda x: x.datetime, reverse=self.reverse)) - - -class PaginationDataBuilderIterator(object): - def __init__(self, it): - self.it = it - - def __iter__(self): - for page in self.it: - if page is not None: - yield PaginationData(page) - else: - yield None - - -class SimplePaginationSourceMixin(IPaginationSource): - """ Implements the `IPaginationSource` interface in a standard way that - should fit most page sources. - """ - def getItemsPerPage(self): - return self.config['items_per_page'] - - def getSourceIterator(self): - return ContentSourceIterator(self) - - def getSorterIterator(self, it): - return DateSortIterator(it) - - def getTailIterator(self, it): - return PaginationDataBuilderIterator(it) - - class SimpleAssetsSubDirMixin: def _getRelatedAssetsContents(self, item, relationship): if not item.metadata.get('__has_assets', False):