Mercurial > piecrust2
comparison piecrust/importing/wordpress.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 | 1ddd18ad5e76 |
children | 4850f8c21b6e |
comparison
equal
deleted
inserted
replaced
362:ff595828a364 | 363:dd25bd3ce1f9 |
---|---|
110 source = self._posts_source | 110 source = self._posts_source |
111 elif post_info['type'] == 'page': | 111 elif post_info['type'] == 'page': |
112 source = self._pages_source | 112 source = self._pages_source |
113 else: | 113 else: |
114 raise Exception("Unknown post type: %s" % post_info['type']) | 114 raise Exception("Unknown post type: %s" % post_info['type']) |
115 rel_path, fac_metadata = source.findPagePath(finder, MODE_CREATING) | 115 factory = source.findPageFactory(finder, MODE_CREATING) |
116 | 116 |
117 metadata = post_info['metadata'].copy() | 117 metadata = post_info['metadata'].copy() |
118 for name in ['title', 'author', 'status', 'post_id', 'post_guid', | 118 for name in ['title', 'author', 'status', 'post_id', 'post_guid', |
119 'description', 'categories']: | 119 'description', 'categories']: |
120 val = post_info.get(name) | 120 val = post_info.get(name) |
127 if excerpt is not None and excerpt.strip() != '': | 127 if excerpt is not None and excerpt.strip() != '': |
128 text = "%s\n\n---excerpt---\n\n%s" % (content, excerpt) | 128 text = "%s\n\n---excerpt---\n\n%s" % (content, excerpt) |
129 | 129 |
130 status = metadata.get('status') | 130 status = metadata.get('status') |
131 if status == 'publish': | 131 if status == 'publish': |
132 path = source.resolveRef(rel_path) | 132 path = factory.path |
133 create_page(self.app, path, metadata, text) | 133 create_page(self.app, path, metadata, text) |
134 elif status == 'draft': | 134 elif status == 'draft': |
135 filename = '-'.join(metadata['title'].split(' ')) + '.html' | 135 filename = '-'.join(metadata['title'].split(' ')) + '.html' |
136 path = os.path.join(self.app.root_dir, 'drafts', filename) | 136 path = os.path.join(self.app.root_dir, 'drafts', filename) |
137 create_page(self.app, path, metadata, text) | 137 create_page(self.app, path, metadata, text) |