Merge branch 'master' of github.com:getpelican/pelican

This commit is contained in:
Alexis Métaireau 2012-10-28 23:50:49 +01:00
commit 92d8208309
9 changed files with 42 additions and 20 deletions

View file

@ -121,7 +121,8 @@ class Page(object):
'lang': getattr(self, 'lang', 'en'),
'date': getattr(self, 'date', datetime.now()),
'author': self.author,
'category': getattr(self, 'category', 'misc'),
'category': getattr(self, 'category',
self.settings['DEFAULT_CATEGORY']),
}
def _expand_settings(self, key):

View file

@ -280,11 +280,14 @@ class ArticlesGenerator(Generator):
# if no category is set, use the name of the path as a category
if 'category' not in metadata:
if os.path.dirname(f) == article_path: # if the article is not in a subdirectory
category = self.settings['DEFAULT_CATEGORY']
else:
if (self.settings['USE_FOLDER_AS_CATEGORY']
and os.path.dirname(f) != article_path):
# if the article is in a subdirectory
category = os.path.basename(os.path.dirname(f))\
.decode('utf-8')
.decode('utf-8')
else:
# if the article is not in a subdirectory
category = self.settings['DEFAULT_CATEGORY']
if category != '':
metadata['category'] = Category(category, self.settings)

View file

@ -34,6 +34,7 @@ _DEFAULT_CONFIG = {'PATH': '.',
'PDF_GENERATOR': False,
'OUTPUT_SOURCES': False,
'OUTPUT_SOURCES_EXTENSION': '.text',
'USE_FOLDER_AS_CATEGORY': True,
'DEFAULT_CATEGORY': 'misc',
'DEFAULT_DATE': 'fs',
'WITH_FUTURE_DATES': True,