From 9af62414dbcb6e5462257c84f26547e0dd9bec41 Mon Sep 17 00:00:00 2001 From: Deniz Turgut Date: Fri, 26 Apr 2013 19:37:31 -0400 Subject: [PATCH] Fixes #708 SUMMARY_MAX_LENGTH=0 should return empty string --- pelican/contents.py | 9 +++++---- pelican/tests/test_contents.py | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pelican/contents.py b/pelican/contents.py index a5604856..b130b174 100644 --- a/pelican/contents.py +++ b/pelican/contents.py @@ -231,10 +231,11 @@ class Content(object): if hasattr(self, '_summary'): return self._summary - if self.settings['SUMMARY_MAX_LENGTH']: - return truncate_html_words(self.content, - self.settings['SUMMARY_MAX_LENGTH']) - return self.content + if self.settings['SUMMARY_MAX_LENGTH'] is None: + return self.content + + return truncate_html_words(self.content, + self.settings['SUMMARY_MAX_LENGTH']) def _set_summary(self, summary): """Dummy function""" diff --git a/pelican/tests/test_contents.py b/pelican/tests/test_contents.py index c837ea03..0ec6bf21 100644 --- a/pelican/tests/test_contents.py +++ b/pelican/tests/test_contents.py @@ -71,6 +71,9 @@ class TestPage(unittest.TestCase): settings['SUMMARY_MAX_LENGTH'] = 10 page = Page(**page_kwargs) 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): # If a title is given, it should be used to generate the slug.