Mercurial > piecrust2
diff piecrust/page.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 | 0bdd938d6b9f |
children | aa6b7ff6a193 |
line wrap: on
line diff
--- a/piecrust/page.py Sat Nov 29 20:58:28 2014 -0800 +++ b/piecrust/page.py Sat Nov 29 21:00:44 2014 -0800 @@ -11,6 +11,7 @@ from werkzeug.utils import cached_property from piecrust.configuration import (Configuration, ConfigurationError, parse_config_header) +from piecrust.routing import IRouteMetadataProvider logger = logging.getLogger(__name__) @@ -36,7 +37,7 @@ FLAG_RAW_CACHE_VALID = 2**0 -class Page(object): +class Page(IRouteMetadataProvider): def __init__(self, source, source_metadata, rel_path): self.source = source self.source_metadata = source_metadata @@ -137,6 +138,13 @@ if was_cache_valid: self._flags |= FLAG_RAW_CACHE_VALID + def getRouteMetadata(self): + page_dt = self.datetime + return { + 'year': page_dt.year, + 'month': page_dt.month, + 'day': page_dt.day} + def _parse_config_date(page_date): if page_date is None: