Mercurial > piecrust2
comparison piecrust/processing/sitemap.py @ 852:4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
* Everything is a `ContentSource`, including assets directories.
* Most content sources are subclasses of the base file-system source.
* A source is processed by a "pipeline", and there are 2 built-in pipelines,
one for assets and one for pages. The asset pipeline is vaguely functional,
but the page pipeline is completely broken right now.
* Rewrite the baking process as just running appropriate pipelines on each
content item. This should allow for better parallelization.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 17 May 2017 00:11:48 -0700 |
parents | 62274d805a6e |
children | f070a4fc033c |
comparison
equal
deleted
inserted
replaced
851:2c7e57d80bba | 852:4850f8c21b6e |
---|---|
1 import time | 1 import time |
2 import logging | 2 import logging |
3 import yaml | 3 import yaml |
4 from piecrust.data.iterators import PageIterator | 4 from piecrust.data.iterators import PageIterator |
5 from piecrust.processing.base import SimpleFileProcessor | 5 from piecrust.processing.base import SimpleFileProcessor |
6 from piecrust.routing import create_route_metadata | |
7 | 6 |
8 | 7 |
9 logger = logging.getLogger(__name__) | 8 logger = logging.getLogger(__name__) |
10 | 9 |
11 | 10 |
12 SITEMAP_HEADER = \ | 11 SITEMAP_HEADER = \ |
13 """<?xml version="1.0" encoding="utf-8"?> | 12 """<?xml version="1.0" encoding="utf-8"?> |
14 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | 13 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> |
15 """ | 14 """ |
16 SITEMAP_FOOTER = "</urlset>\n" | 15 SITEMAP_FOOTER = "</urlset>\n" |
17 | 16 |
18 SITEURL_HEADER = " <url>\n" | 17 SITEURL_HEADER = " <url>\n" |
19 SITEURL_LOC = " <loc>%s</loc>\n" | 18 SITEURL_LOC = " <loc>%s</loc>\n" |
20 SITEURL_LASTMOD = " <lastmod>%s</lastmod>\n" | 19 SITEURL_LASTMOD = " <lastmod>%s</lastmod>\n" |
28 | 27 |
29 def __init__(self): | 28 def __init__(self): |
30 super(SitemapProcessor, self).__init__({'sitemap': 'xml'}) | 29 super(SitemapProcessor, self).__init__({'sitemap': 'xml'}) |
31 self._start_time = None | 30 self._start_time = None |
32 | 31 |
33 def onPipelineStart(self, pipeline): | 32 def onPipelineStart(self, ctx): |
34 self._start_time = time.time() | 33 self._start_time = time.time() |
35 | 34 |
36 def _doProcess(self, in_path, out_path): | 35 def _doProcess(self, in_path, out_path): |
37 with open(in_path, 'r') as fp: | 36 with open(in_path, 'r') as fp: |
38 sitemap = yaml.load(fp) | 37 sitemap = yaml.load(fp) |