Fix #5298 (Article Dates not set with custom parse_index)

This commit is contained in:
Kovid Goyal 2010-05-21 11:19:06 -06:00
parent 6de89762ee
commit 09a21b8529
2 changed files with 14 additions and 1 deletions

View File

@ -49,6 +49,17 @@ class Article(object):
self.date = published self.date = published
self.utctime = dt_factory(self.date, assume_utc=True, as_utc=True) self.utctime = dt_factory(self.date, assume_utc=True, as_utc=True)
self.localtime = self.utctime.astimezone(local_tz) self.localtime = self.utctime.astimezone(local_tz)
self._formatted_date = None
@dynamic_property
def formatted_date(self):
def fget(self):
if self._formatted_date is None:
self._formatted_date = self.localtime.strftime(" [%a, %d %b %H:%M]")
return self._formatted_date
def fset(self, val):
self._formatted_date = val
return property(fget=fget, fset=fset)
@dynamic_property @dynamic_property
def title(self): def title(self):
@ -150,6 +161,8 @@ class Feed(object):
self.articles.append(article) self.articles.append(article)
else: else:
self.logger.debug('Skipping article %s (%s) from feed %s as it is too old.'%(title, article.localtime.strftime('%a, %d %b, %Y %H:%M'), self.title)) self.logger.debug('Skipping article %s (%s) from feed %s as it is too old.'%(title, article.localtime.strftime('%a, %d %b, %Y %H:%M'), self.title))
d = item.get('date', '')
article.formatted_date = d
def parse_article(self, item): def parse_article(self, item):

View File

@ -160,7 +160,7 @@ class FeedTemplate(Template):
<li id="${'article_%d'%i}" py:if="getattr(article, 'downloaded', <li id="${'article_%d'%i}" py:if="getattr(article, 'downloaded',
False)" style="padding-bottom:0.5em" class="calibre_rescale_100"> False)" style="padding-bottom:0.5em" class="calibre_rescale_100">
<a class="article calibre_rescale_120" href="${article.url}">${article.title}</a> <a class="article calibre_rescale_120" href="${article.url}">${article.title}</a>
<span class="article_date">${article.localtime.strftime(" [%a, %d %b %H:%M]")}</span> <span class="article_date">${article.formatted_date}</span>
<div class="article_description calibre_rescale_70" py:if="article.summary"> <div class="article_description calibre_rescale_70" py:if="article.summary">
${Markup(cutoff(article.text_summary))} ${Markup(cutoff(article.text_summary))}
</div> </div>