changeset 54:a46354306738

Use properly formatted date components for the blog sources.
author Ludovic Chabant <ludovic@chabant.com>
date Mon, 25 Aug 2014 08:46:11 -0700
parents 73956224eb67
children 45828c4167ad
files piecrust/sources/posts.py
diffstat 1 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/piecrust/sources/posts.py	Mon Aug 25 08:45:44 2014 -0700
+++ b/piecrust/sources/posts.py	Mon Aug 25 08:46:11 2014 -0700
@@ -36,6 +36,13 @@
         day = metadata.get('day')
         slug = metadata.get('slug')
 
+        if year is not None:
+            year = int(year)
+        if month is not None:
+            month = int(month)
+        if day is not None:
+            day = int(day)
+
         ext = metadata.get('ext')
         if ext is None:
             if len(self.supported_extensions) == 1:
@@ -44,9 +51,9 @@
                 ext = self.default_auto_format
 
         replacements = {
-                'year': year,
-                'month': month,
-                'day': day,
+                'year': '%04d' % year,
+                'month': '%02d' % month,
+                'day': '%02d' % day,
                 'slug': slug,
                 'ext': ext
                 }
@@ -86,10 +93,6 @@
                 'slug': '(?P<slug>.*)',
                 'ext': '(?P<ext>.*)'
                 }
-        #sanitized_fs_endpoint_path = (self.fs_endpoint_path.
-        #        replace('\\', '/').rstrip('/'))
-        #pattern = (re.escape(sanitized_fs_endpoint_path) + '/' +
-        #        self.path_format % regex_repl)
         pattern = self.path_format % regex_repl + '$'
         m = re.search(pattern, path.replace('\\', '/'))
         if not m: