Mercurial > piecrust2
comparison piecrust/sources/default.py @ 577:ff404adfcf45
sources: Add method to get a page factory from a path.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 30 Dec 2015 14:45:57 -0800 |
parents | 0c74a6c4533d |
children | 58ebf50235a5 |
comparison
equal
deleted
inserted
replaced
576:0c74a6c4533d | 577:ff404adfcf45 |
---|---|
55 slug = self._makeSlug(fac_path) | 55 slug = self._makeSlug(fac_path) |
56 metadata = {'slug': slug} | 56 metadata = {'slug': slug} |
57 fac_path = fac_path.replace('\\', '/') | 57 fac_path = fac_path.replace('\\', '/') |
58 self._populateMetadata(fac_path, metadata) | 58 self._populateMetadata(fac_path, metadata) |
59 yield PageFactory(self, fac_path, metadata) | 59 yield PageFactory(self, fac_path, metadata) |
60 | |
61 def buildPageFactory(self, path): | |
62 if not path.startswith(self.fs_endpoint_path): | |
63 raise Exception("Page path '%s' isn't inside '%s'." % ( | |
64 path, self.fs_enpoint_path)) | |
65 rel_path = path[len(self.fs_endpoint_path):].lstrip('\\/') | |
66 slug = self._makeSlug(rel_path) | |
67 metadata = {'slug': slug} | |
68 fac_path = rel_path.replace('\\', '/') | |
69 self._populateMetadata(fac_path, metadata) | |
70 return PageFactory(self, fac_path, metadata) | |
60 | 71 |
61 def resolveRef(self, ref_path): | 72 def resolveRef(self, ref_path): |
62 path = os.path.normpath( | 73 path = os.path.normpath( |
63 os.path.join(self.fs_endpoint_path, ref_path.lstrip("\\/"))) | 74 os.path.join(self.fs_endpoint_path, ref_path.lstrip("\\/"))) |
64 slug = self._makeSlug(ref_path) | 75 slug = self._makeSlug(ref_path) |