Ver Fonte

fix publication date, always return an object

Oz N Tiram há 9 anos atrás
pai
commit
13b7e92c84
2 ficheiros alterados com 13 adições e 3 exclusões
  1. 12 2
      blogit/blogit.py
  2. 1 1
      templates/entry_index.html

+ 12 - 2
blogit/blogit.py

@@ -146,6 +146,7 @@ class Tag(object):
         if not os.path.exists(render_to):  # pragma: no coverage
             os.makedirs(render_to)
         _render(context, 'tag_index.html', os.path.join(render_to, 'index.html'))
+
         # render atom.xml
         context['entries'] = context['entries'][:10]
         context['last_build'] = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ")
@@ -242,8 +243,11 @@ class Entry(object):
 
     @property
     def publish_date(self):
-        return self.header.get('published',
-                               datetime.date.today().strftime("%Y-%m-%d"))
+        try:
+            r = datetime.datetime.strptime(self.header.get('published', ''), "%Y-%m-%d")
+        except ValueError:
+            r = datetime.date.today()
+        return r
 
     @property
     def permalink(self):
@@ -310,6 +314,7 @@ class Entry(object):
                 print(context)
                 print(self.path)
                 print(e)
+                import pdb; pdb.set_trace()
                 sys.exit(1)
 
 
@@ -526,3 +531,8 @@ def main():   # pragma: no coverage
 
 if __name__ == '__main__':  # pragma: no coverage
     main()
+
+# TODO:
+
+# Change font size of the tag in the index to 100%
+# Replace the fonts to CDN fonts (Roboto and some others)

+ 1 - 1
templates/entry_index.html

@@ -5,7 +5,7 @@
   <div class="clearfix entry">
 	 <h2><a title="Goes to &rarr; {{ entry.permalink }}" href="{{ entry.permalink }}">{{ entry.title }}</a></h2>
 	<div class="clearfix">
-    <div class="date-published">{{ entry.publish_date }}</div>
+    <div class="date-published">{{ entry.publish_date.strftime("%B %d, %Y") }}</div>
 		<div class="tags">tagged:
 		  {% for tag in entry.tags %}
 		   <a class="tag" href="/tags/{{ tag.slug }}"><span>{{ tag.name }}</span></a>{% if not loop.last %}, {% endif %}