1
0
Fork 0
forked from github/pelican

Get author information from settings if not specified in article's metadata.

This commit is contained in:
Alexis Metaireau 2010-08-18 16:17:05 +02:00
commit e585c83ac1
3 changed files with 8 additions and 4 deletions

1
TODO
View file

@ -1,3 +1,2 @@
* Fall back to settings + date of files when no metadata available
* Add RSS generation
* package it !

View file

@ -51,7 +51,7 @@ def generate_output(path=None, theme=None, output_path=None, markup=None,
# for each file, get the informations.
for f in files:
f = os.path.abspath(f)
article = Article(open(f, encoding='utf-8').read(), markup)
article = Article(open(f, encoding='utf-8').read(), markup, context)
articles.append(article)
if hasattr(article, 'date'):
update_dict(dates, article.date.strftime('%Y-%m-%d'), article)
@ -175,7 +175,7 @@ class Article(object):
:param markup: the markup language to use while parsing.
"""
def __init__(self, string, markup=None):
def __init__(self, string, markup=None, config={}):
if markup == None:
markup = 'rst'
@ -189,6 +189,10 @@ class Article(object):
self.title = rendered_content.get('title')
self.content = rendered_content.get('body')
if not hasattr(self, 'author'):
if 'AUTHOR' in config:
self.author = config['AUTHOR']
@property
def url(self):
return '%s.html' % slugify(self.title)

View file

@ -1,9 +1,10 @@
# -*- coding: utf-8 -*-
PATH = 'samples/content'
THEME = 'samples/themes/notmyidea'
AUTHOR = u'Alexis Métaireau'
BLOGNAME = 'NotMyIdea.org'
BLOGSUBTITLE = u"Alexis Métaireau's weblog"
BLOGSUBTITLE = u"%s's weblog" % AUTHOR
BLOGURL = 'http://blog.notmyidea.org'
BLOGROLL = (('Biologeek', 'http://biologeek.org'),