mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Add some comments, remove trailing slashes.
This commit is contained in:
parent
3d7a10a298
commit
4abf7fa29d
1 changed files with 23 additions and 6 deletions
|
|
@ -21,9 +21,9 @@ _DEFAULT_THEME =\
|
||||||
_DEFAULT_CONFIG = {'PATH': None,
|
_DEFAULT_CONFIG = {'PATH': None,
|
||||||
'THEME': _DEFAULT_THEME,
|
'THEME': _DEFAULT_THEME,
|
||||||
'OUTPUT_PATH': 'output/',
|
'OUTPUT_PATH': 'output/',
|
||||||
|
'FEED_FILENAME': 'atom.xml',
|
||||||
'MARKUP': 'rst',
|
'MARKUP': 'rst',
|
||||||
'STATIC_PATHS': ['css', 'images'],
|
'STATIC_PATHS': ['css', 'images'],
|
||||||
'FEED_FILENAME': 'atom.xml',
|
|
||||||
'BLOGNAME': 'A Pelican Blog',
|
'BLOGNAME': 'A Pelican Blog',
|
||||||
'BLOGURL': ''}
|
'BLOGURL': ''}
|
||||||
|
|
||||||
|
|
@ -33,6 +33,8 @@ def generate_output(path=None, theme=None, output_path=None, markup=None,
|
||||||
"""Given a list of files, a template and a destination,
|
"""Given a list of files, a template and a destination,
|
||||||
output the static files.
|
output the static files.
|
||||||
|
|
||||||
|
That's the main logic of pelican.
|
||||||
|
|
||||||
:param path: the path where to find the files to parse
|
:param path: the path where to find the files to parse
|
||||||
:param theme: where to search for templates
|
:param theme: where to search for templates
|
||||||
:param output_path: where to output the generated files
|
:param output_path: where to output the generated files
|
||||||
|
|
@ -120,6 +122,14 @@ def generate_output(path=None, theme=None, output_path=None, markup=None,
|
||||||
|
|
||||||
|
|
||||||
def generate_file(path, name, template, context, **kwargs):
|
def generate_file(path, name, template, context, **kwargs):
|
||||||
|
"""Write the file with the given informations
|
||||||
|
|
||||||
|
:param path: where to generate the file.
|
||||||
|
:param name: name of the file to output
|
||||||
|
:param template: template to use to generate the content
|
||||||
|
:param context: dict to pass to the templates.
|
||||||
|
:param **kwargs: additional variables to pass to the templates
|
||||||
|
"""
|
||||||
context.update(kwargs)
|
context.update(kwargs)
|
||||||
output = template.render(context)
|
output = template.render(context)
|
||||||
filename = os.sep.join((path, name))
|
filename = os.sep.join((path, name))
|
||||||
|
|
@ -133,6 +143,7 @@ def generate_file(path, name, template, context, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
def get_templates(path=None):
|
def get_templates(path=None):
|
||||||
|
"""Return the templates to use"""
|
||||||
path = os.path.join(path, 'templates')
|
path = os.path.join(path, 'templates')
|
||||||
env = Environment(loader=FileSystemLoader(path))
|
env = Environment(loader=FileSystemLoader(path))
|
||||||
templates = {}
|
templates = {}
|
||||||
|
|
@ -142,6 +153,12 @@ def get_templates(path=None):
|
||||||
|
|
||||||
|
|
||||||
def update_dict(mapping, key, value):
|
def update_dict(mapping, key, value):
|
||||||
|
"""Update a dict intenal list
|
||||||
|
|
||||||
|
:param mapping: the mapping to update
|
||||||
|
:param key: the key of the mapping to update.
|
||||||
|
:param value: the value to append to the list.
|
||||||
|
"""
|
||||||
if key not in mapping:
|
if key not in mapping:
|
||||||
mapping[key] = []
|
mapping[key] = []
|
||||||
mapping[key].append(value)
|
mapping[key].append(value)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue