From ec06e6ed9590f0d7dbaff9a5f4b58cf94136a1fb Mon Sep 17 00:00:00 2001 From: Alexis Metaireau Date: Tue, 8 Mar 2011 15:40:12 +0000 Subject: [PATCH] Add a possibility to define the summary of an article directly in rst. --- THANKS | 1 + pelican/contents.py | 8 +++----- samples/content/super_article.rst | 1 + 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/THANKS b/THANKS index e0275b7a..6a74b068 100644 --- a/THANKS +++ b/THANKS @@ -12,3 +12,4 @@ bugs or giving ideas. Thanks to them ! - nblock (Florian) - Bruno Bord - Laureline Guérin +- Samuel Martin diff --git a/pelican/contents.py b/pelican/contents.py index e4dfd037..397b7fdb 100644 --- a/pelican/contents.py +++ b/pelican/contents.py @@ -57,6 +57,9 @@ class Page(object): if hasattr(self, 'date'): self.locale_date = self.date.strftime(self.date_format.encode('ascii','xmlcharrefreplace')).decode('utf') + if not hasattr(self, 'summary'): + self.summary = property(lambda self: truncate_html_words(self.content, 50)) + # store the settings ref. self._settings = settings @@ -74,11 +77,6 @@ class Page(object): content = self._content return content - @property - def summary(self): - return truncate_html_words(self.content, 50) - - class Article(Page): mandatory_properties = ('title', 'date', 'category') diff --git a/samples/content/super_article.rst b/samples/content/super_article.rst index e2f933d2..b3e22051 100644 --- a/samples/content/super_article.rst +++ b/samples/content/super_article.rst @@ -5,6 +5,7 @@ This is a super article ! :date: 2010-12-02 10:14 :category: yeah :author: Alexis Métaireau +:summary: This is a simple test Some content here !