mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge pull request #867 from avaris/summary-max-length
Fixes #708 SUMMARY_MAX_LENGTH=0 should return empty string
This commit is contained in:
commit
7706530aa8
2 changed files with 8 additions and 4 deletions
|
|
@ -231,10 +231,11 @@ class Content(object):
|
||||||
if hasattr(self, '_summary'):
|
if hasattr(self, '_summary'):
|
||||||
return self._summary
|
return self._summary
|
||||||
|
|
||||||
if self.settings['SUMMARY_MAX_LENGTH']:
|
if self.settings['SUMMARY_MAX_LENGTH'] is None:
|
||||||
return truncate_html_words(self.content,
|
return self.content
|
||||||
self.settings['SUMMARY_MAX_LENGTH'])
|
|
||||||
return self.content
|
return truncate_html_words(self.content,
|
||||||
|
self.settings['SUMMARY_MAX_LENGTH'])
|
||||||
|
|
||||||
def _set_summary(self, summary):
|
def _set_summary(self, summary):
|
||||||
"""Dummy function"""
|
"""Dummy function"""
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,9 @@ class TestPage(unittest.TestCase):
|
||||||
settings['SUMMARY_MAX_LENGTH'] = 10
|
settings['SUMMARY_MAX_LENGTH'] = 10
|
||||||
page = Page(**page_kwargs)
|
page = Page(**page_kwargs)
|
||||||
self.assertEqual(page.summary, truncate_html_words(TEST_CONTENT, 10))
|
self.assertEqual(page.summary, truncate_html_words(TEST_CONTENT, 10))
|
||||||
|
settings['SUMMARY_MAX_LENGTH'] = 0
|
||||||
|
page = Page(**page_kwargs)
|
||||||
|
self.assertEqual(page.summary, '')
|
||||||
|
|
||||||
def test_slug(self):
|
def test_slug(self):
|
||||||
# If a title is given, it should be used to generate the slug.
|
# If a title is given, it should be used to generate the slug.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue