Mercurial > piecrust2
changeset 230:016d42c23ba9
internal: Make the simple page source use `slug` everywhere.
Before, it would use `slug` in some places, and `path` in other places, which
would be quite confusing.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 11 Feb 2015 08:29:09 -0800 |
parents | a951cd4ef361 |
children | 137bcd498ef9 |
files | piecrust/app.py piecrust/sources/base.py |
diffstat | 2 files changed, 11 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/piecrust/app.py Wed Feb 11 08:27:52 2015 -0800 +++ b/piecrust/app.py Wed Feb 11 08:29:09 2015 -0800 @@ -26,7 +26,7 @@ logger = logging.getLogger(__name__) -CACHE_VERSION = 14 +CACHE_VERSION = 15 class VariantNotFoundError(Exception): @@ -199,9 +199,9 @@ routesc = [] routesc.append({ - 'url': '/%path:path%', + 'url': '/%path:slug%', 'source': 'pages', - 'func': 'pcurl(path)'}) + 'func': 'pcurl(slug)'}) sitec['routes'] = routesc taxonomiesc = collections.OrderedDict() @@ -302,9 +302,9 @@ 'item_name': 'page', 'realm': REALM_THEME} sitec['routes'].append({ - 'url': '/%path:path%', + 'url': '/%path:slug%', 'source': 'theme_pages', - 'func': 'pcurl(path)'}) + 'func': 'pcurl(slug)'}) # Sources have the `default` scanner by default, duh. Also, a bunch # of other default values for other configuration stuff.
--- a/piecrust/sources/base.py Wed Feb 11 08:27:52 2015 -0800 +++ b/piecrust/sources/base.py Wed Feb 11 08:29:09 2015 -0800 @@ -336,7 +336,7 @@ if rel_dirpath != '.': fac_path = os.path.join(rel_dirpath, f) slug = self._makeSlug(fac_path) - metadata = {'path': slug} + metadata = {'slug': slug} fac_path = fac_path.replace('\\', '/') self._populateMetadata(fac_path, metadata) yield PageFactory(self, fac_path, metadata) @@ -346,10 +346,10 @@ os.path.join(self.fs_endpoint_path, ref_path.lstrip("\\/"))) def findPagePath(self, metadata, mode): - uri_path = metadata.setdefault('path', '') + uri_path = metadata.get('slug', '') if not uri_path: uri_path = '_index' - path = os.path.normpath(os.path.join(self.fs_endpoint_path, uri_path)) + path = os.path.join(self.fs_endpoint_path, uri_path) _, ext = os.path.splitext(path) if mode == MODE_CREATING: @@ -387,7 +387,7 @@ else: if self._filterPageFilename(name): slug = self._makeSlug(os.path.join(rel_path, name)) - metadata = {'path': slug} + metadata = {'slug': slug} fac_path = name if rel_path != '.': @@ -411,14 +411,14 @@ parser.add_argument('uri', help='The URI for the new page.') def buildMetadata(self, args): - return {'path': args.uri} + return {'slug': args.uri} def _makeSlug(self, rel_path): slug, ext = os.path.splitext(rel_path) slug = slug.replace('\\', '/') if ext.lstrip('.') not in self.supported_extensions: slug += ext - if slug.startswith('./') or slug.startswith('.\\'): + if slug.startswith('./'): slug = slug[2:] if slug == '_index': slug = ''