Merge branch 'pr/555'

Conflicts:
	pelican/contents.py
This commit is contained in:
Bruno Binet 2012-11-13 01:23:31 +01:00
commit c787e02dcc
4 changed files with 10 additions and 10 deletions

View file

@ -53,11 +53,6 @@ class Page(object):
if not hasattr(self, 'author'):
if 'AUTHOR' in settings:
self.author = Author(settings['AUTHOR'], settings)
else:
title = filename.decode('utf-8') if filename else self.title
self.author = Author(getenv('USER', 'John Doe'), settings)
logger.warning(u"Author of `{0}' unknown, assuming that his name is "
"`{1}'".format(title, self.author))
# manage languages
self.in_default_lang = True
@ -120,7 +115,7 @@ class Page(object):
'slug': getattr(self, 'slug', ''),
'lang': getattr(self, 'lang', 'en'),
'date': getattr(self, 'date', datetime.now()),
'author': self.author,
'author': getattr(self, 'author', ''),
'category': getattr(self, 'category',
self.settings['DEFAULT_CATEGORY']),
}

View file

@ -358,7 +358,9 @@ class ArticlesGenerator(Generator):
for article in self.articles:
# only main articles are listed in categories, not translations
self.categories[article.category].append(article)
self.authors[article.author].append(article)
# ignore blank authors as well as undefined
if hasattr(article,'author') and article.author.name != '':
self.authors[article.author].append(article)
# sort the articles by date
self.articles.sort(key=attrgetter('date'), reverse=True)

View file

@ -43,7 +43,7 @@ class Writer(object):
item.date.date(), item.url),
description=item.content,
categories=item.tags if hasattr(item, 'tags') else None,
author_name=getattr(item, 'author', 'John Doe'),
author_name=getattr(item, 'author', ''),
pubdate=set_date_tzinfo(item.date,
self.settings.get('TIMEZONE', None)))

View file

@ -40,8 +40,11 @@ class TestPage(unittest.TestCase):
def test_mandatory_properties(self):
"""If the title is not set, must throw an exception."""
self.assertRaises(AttributeError, Page, 'content')
page = Page(**self.page_kwargs)
page = Page('content')
with self.assertRaises(NameError) as cm:
page.check_properties()
page = Page('content', metadata={'title': 'foobar'})
page.check_properties()
def test_summary_from_metadata(self):