Oz N Tiram 9 năm trước cách đây
mục cha
commit
fcd9e195d5
3 tập tin đã thay đổi với 6 bổ sung27 xóa
  1. 2 23
      blogit/blogit.py
  2. 1 1
      templates/entry.html
  3. 3 3
      templates/entry_index.html

+ 2 - 23
blogit/blogit.py

@@ -231,9 +231,7 @@ class Entry(object):
         return summarya+more
 
     @property
-    def published_html(self):
-        if self.kind in ['link', 'note', 'photo']:
-            return self.header['published'].strftime("%B %d, %Y %I:%M %p")
+    def publish_date(self):
         return self.header['published'].strftime("%B %d, %Y")
 
     @property
@@ -285,7 +283,7 @@ class Entry(object):
     def prepare(self):
         file = codecs.open(self.abspath, 'r')
         self.header = self._read_header(file)
-        self.date = self.header['published']
+        self.date = self.header.get('published', datetime.date.today())
         for k, v in self.header.items():
             try:
                 setattr(self, k, v)
@@ -297,15 +295,6 @@ class Entry(object):
         self.body = ''.join(body)
         file.close()
 
-        if self.kind == 'link':
-            from urlparse import urlparse
-            self.domain_name = urlparse(self.url).netloc
-        elif self.kind == 'photo':
-            pass
-        elif self.kind == 'note':
-            pass
-        elif self.kind == 'writing':
-            pass
 
     def render(self):
         if not self.header['public']:
@@ -334,16 +323,6 @@ class Entry(object):
         return True
 
 
-class Link(Entry):  # pragma: no coverage
-    def __init__(self, path):
-        super(Link, self).__init__(path)
-
-    @property
-    def permalink(self):
-        print "self.url", self.url
-        return self.url
-
-
 def _sort_entries(entries):
     """Sort all entries by date and reverse the list"""
     return list(reversed(sorted(entries, key=operator.attrgetter('date'))))

+ 1 - 1
templates/entry.html

@@ -2,7 +2,7 @@
 {% block title %} {{ entry.title }} {% endblock %}
 {% block content %}
 <div class="index">
-<div id="header" class="published"><a href="{{site_url}}">{{ entry.author }}</a> &ndash; {{ entry.published_html }}</div>
+<div id="header" class="published"><a href="{{site_url}}">{{ entry.author }}</a> &ndash; {{ entry.publish_date }}</div>
 <h1>{{ entry.title }}</h1>
   {{ entry.body_html }}
 <div class="tags">

+ 3 - 3
templates/entry_index.html

@@ -4,8 +4,8 @@
   {% for entry in entries %}
   <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.published_html }}</div>
+	<div class="clearfix">
+    <div class="date-published">{{ entry.publish_date }}</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 %}
@@ -16,7 +16,7 @@
 
 	<div class="link-url"><p><a href="{{ entry.permalink }}">continue reading ...</a></p></div>
 	<div class="permalink"><a title="Permalink to: {{ entry.title }}" href="{{ entry.permalink }}"><span>&para;</span></a></div>
-			
+
    </div>
    {% endfor %}
 </div>