1
0
Fork 0
forked from github/pelican

branch merge

Conflicts:
	pelican/generators.py
	pelican/settings.py
This commit is contained in:
Alexis Metaireau 2011-01-05 18:25:14 +01:00
commit 2f915caff2
21 changed files with 184 additions and 54 deletions

View file

@ -8,7 +8,7 @@ import os
from jinja2 import Environment, FileSystemLoader
from jinja2.exceptions import TemplateNotFound
from pelican.utils import copytree, process_translations, open
from pelican.utils import copytree, get_relative_path, process_translations, open
from pelican.contents import Article, Page, is_valid_content
from pelican.readers import read_file
@ -34,7 +34,7 @@ class Generator(object):
templates ready to use with Jinja2.
"""
path = os.path.expanduser(os.path.join(self.theme, 'templates'))
env = Environment(loader=FileSystemLoader(path))
env = Environment(loader=FileSystemLoader(path),extensions=self.settings.get('JINJA_EXTENSIONS', []))
templates = {}
for template in _TEMPLATES:
try:
@ -133,19 +133,25 @@ class ArticlesGenerator(Generator):
writer.write_file,
relative_urls = self.settings.get('RELATIVE_URLS')
)
# to minimize the number of relative path stuff modification in writer, articles pass first
for article in chain(self.translations, self.articles):
write('%s' % article.save_as,
templates['article'], self.context, article=article,
category=article.category)
for template in _DIRECT_TEMPLATES:
write('%s.html' % template, templates[template], self.context,
blog=True)
blog=True)
# and subfolders after that
for tag, articles in self.tags.items():
write('tag/%s.html' % tag, templates['tag'], self.context, tag=tag,
articles=articles)
for article in articles:
write('tag/%s.html' % tag, templates['tag'], self.context,
tag=tag, articles=articles)
for cat in self.categories:
write('category/%s.html' % cat, templates['category'], self.context,
category=cat, articles=self.categories[cat])
for article in chain(self.translations, self.articles):
write(article.save_as,
templates['article'], self.context, article=article,
category=article.category)
category=cat, articles=self.categories[cat])
def generate_context(self):
"""change the context"""