Addressed comments from @avaris in PR getpelican/pelican#1348

This commit is contained in:
Mark Lee 2014-05-27 11:42:37 -07:00
commit b572cbeef1
2 changed files with 7 additions and 2 deletions

View file

@ -70,7 +70,7 @@ DEFAULT_CONFIG = {
'DRAFT_LANG_SAVE_AS': os.path.join('drafts', '{slug}-{lang}.html'),
'PAGE_URL': 'pages/{slug}.html',
'PAGE_SAVE_AS': os.path.join('pages', '{slug}.html'),
'PAGE_ORDER_BY': 'filename',
'PAGE_ORDER_BY': 'basename',
'PAGE_LANG_URL': 'pages/{slug}-{lang}.html',
'PAGE_LANG_SAVE_AS': os.path.join('pages', '{slug}-{lang}.html'),
'STATIC_URL': '{path}',

View file

@ -473,7 +473,12 @@ def process_translations(content_list, order_by=None):
elif order_by == 'basename':
index.sort(key=lambda x: os.path.basename(x.source_path or ''))
elif order_by != 'slug':
index.sort(key=attrgetter(order_by))
try:
index.sort(key=attrgetter(order_by))
except AttributeError:
error_msg = ('There is no "{}" attribute in the item metadata.'
'Defaulting to slug order.')
logger.warning(error_msg.format(order_by))
return index, translations