mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Fix for #245: return the summary of an article based on the :summary: metadata if it is set, else troncate the content.
This commit is contained in:
parent
71a5ba3283
commit
ff2426c4ad
1 changed files with 9 additions and 5 deletions
|
|
@ -89,9 +89,9 @@ class Page(object):
|
||||||
if hasattr(self, 'date') and self.date > datetime.now():
|
if hasattr(self, 'date') and self.date > datetime.now():
|
||||||
self.status = 'draft'
|
self.status = 'draft'
|
||||||
|
|
||||||
# set summary
|
# store the :summary: metadata if it is set
|
||||||
if not hasattr(self, 'summary'):
|
if 'summary' in metadata:
|
||||||
self.summary = truncate_html_words(self.content, 50)
|
self._summary = metadata['summary']
|
||||||
|
|
||||||
def check_properties(self):
|
def check_properties(self):
|
||||||
"""test that each mandatory property is set."""
|
"""test that each mandatory property is set."""
|
||||||
|
|
@ -126,8 +126,12 @@ class Page(object):
|
||||||
return content
|
return content
|
||||||
|
|
||||||
def _get_summary(self):
|
def _get_summary(self):
|
||||||
"""Returns the summary of an article, based on to the content"""
|
"""Returns the summary of an article, based on the :summary: metadata
|
||||||
return truncate_html_words(self.content, 50)
|
if it is set, else troncate the content."""
|
||||||
|
if hasattr(self, '_summary'):
|
||||||
|
return self._summary
|
||||||
|
else:
|
||||||
|
return truncate_html_words(self.content, 50)
|
||||||
|
|
||||||
def _set_summary(self, summary):
|
def _set_summary(self, summary):
|
||||||
"""Dummy function"""
|
"""Dummy function"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue