mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Get author information from settings if not specified in article's metadata.
This commit is contained in:
parent
46ccee2038
commit
e585c83ac1
3 changed files with 8 additions and 4 deletions
1
TODO
1
TODO
|
|
@ -1,3 +1,2 @@
|
||||||
* Fall back to settings + date of files when no metadata available
|
|
||||||
* Add RSS generation
|
* Add RSS generation
|
||||||
* package it !
|
* package it !
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ def generate_output(path=None, theme=None, output_path=None, markup=None,
|
||||||
# for each file, get the informations.
|
# for each file, get the informations.
|
||||||
for f in files:
|
for f in files:
|
||||||
f = os.path.abspath(f)
|
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)
|
articles.append(article)
|
||||||
if hasattr(article, 'date'):
|
if hasattr(article, 'date'):
|
||||||
update_dict(dates, article.date.strftime('%Y-%m-%d'), article)
|
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.
|
: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:
|
if markup == None:
|
||||||
markup = 'rst'
|
markup = 'rst'
|
||||||
|
|
||||||
|
|
@ -189,6 +189,10 @@ class Article(object):
|
||||||
self.title = rendered_content.get('title')
|
self.title = rendered_content.get('title')
|
||||||
self.content = rendered_content.get('body')
|
self.content = rendered_content.get('body')
|
||||||
|
|
||||||
|
if not hasattr(self, 'author'):
|
||||||
|
if 'AUTHOR' in config:
|
||||||
|
self.author = config['AUTHOR']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def url(self):
|
def url(self):
|
||||||
return '%s.html' % slugify(self.title)
|
return '%s.html' % slugify(self.title)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
PATH = 'samples/content'
|
PATH = 'samples/content'
|
||||||
THEME = 'samples/themes/notmyidea'
|
THEME = 'samples/themes/notmyidea'
|
||||||
|
AUTHOR = u'Alexis Métaireau'
|
||||||
|
|
||||||
BLOGNAME = 'NotMyIdea.org'
|
BLOGNAME = 'NotMyIdea.org'
|
||||||
BLOGSUBTITLE = u"Alexis Métaireau's weblog"
|
BLOGSUBTITLE = u"%s's weblog" % AUTHOR
|
||||||
BLOGURL = 'http://blog.notmyidea.org'
|
BLOGURL = 'http://blog.notmyidea.org'
|
||||||
|
|
||||||
BLOGROLL = (('Biologeek', 'http://biologeek.org'),
|
BLOGROLL = (('Biologeek', 'http://biologeek.org'),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue