diff --git a/.gitignore b/.gitignore index 29ac491f..86021fe0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ .*.swp .*.swo *.pyc +docs/_build +build +dist diff --git a/docs/conf.py b/docs/conf.py index 0efe92b2..5b24d67c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -8,10 +8,11 @@ import sys, os # -- General configuration ----------------------------------------------------- templates_path = ['_templates'] +extensions = ['sphinx.ext.autodoc',] source_suffix = '.rst' master_doc = 'index' project = u'Pelican' -copyright = u'2010, Alexis Metaireau' +copyright = u'2010, Alexis Metaireau and contributors' exclude_patterns = ['_build'] pygments_style = 'sphinx' diff --git a/docs/settings.rst b/docs/settings.rst index e58243bc..e59d1b5b 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -41,6 +41,8 @@ Setting name what it does ? `feeds/all.atom.xml` `FEED_RSS` relative url to output the rss feed. Default is None (no rss) +`JINJA_EXTENSIONS` A list of any Jinja2 extensions you want to use. + Default is no extensions (the empty list). `KEEP_OUTPUT_DIRECTORY` Keep the output directory and just update all the generated files. Default is to delete the output directory. `MARKUP` A list of available markup languages you want to use. @@ -98,6 +100,9 @@ Setting name what it does ? the header. `SOCIAL` A list of tuples (Title, Url) to appear in the "social" section. +`TWITTER_USERNAME` Allows to add a button on the articles to tweet about + them. Add you twitter username if you want this + button to appear. ======================= ======================================================= In addition, you can use the "wide" version of the `notmyidea` theme, by diff --git a/docs/themes.rst b/docs/themes.rst index 633acaaf..0ddd2498 100644 --- a/docs/themes.rst +++ b/docs/themes.rst @@ -2,7 +2,10 @@ How to create themes for pelican ################################ Pelican uses the great `jinja2 `_ templating engine to -generate it's HTML output. +generate it's HTML output. The jinja2 syntax is really simple. If you want to +create your own theme, feel free to take inspiration from the "simple" theme, +which is available `here +`_ Structure ========= diff --git a/pelican/contents.py b/pelican/contents.py index bb6949fb..b6e71b75 100644 --- a/pelican/contents.py +++ b/pelican/contents.py @@ -11,12 +11,12 @@ class Page(object): mandatory_properties = ('title',) def __init__(self, content, metadatas={}, settings={}, filename=None): - self.content = content + self._content = content self.translations = [] self.status = "published" # default value for key, value in metadatas.items(): - setattr(self, key, value) + setattr(self, key.lower(), value) if not hasattr(self, 'author'): if 'AUTHOR' in settings: @@ -53,6 +53,14 @@ class Page(object): if not hasattr(self, prop): raise NameError(prop) + @property + def content(self): + if hasattr(self, "_get_content"): + content = self._get_content() + else: + content = self._content + return content + @property def summary(self): return truncate_html_words(self.content, 50) diff --git a/pelican/generators.py b/pelican/generators.py index 18dba81a..05620e69 100755 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -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""" diff --git a/pelican/settings.py b/pelican/settings.py index 0fef4fec..2178c5ca 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -23,6 +23,7 @@ _DEFAULT_CONFIG = {'PATH': None, 'RELATIVE_URLS': True, 'DEFAULT_LANG': 'en', 'PELICAN_CLASS': 'pelican.Pelican', + 'JINJA_EXTENSIONS': [], } def read_settings(filename): diff --git a/pelican/themes/notmyidea/templates/article.html b/pelican/themes/notmyidea/templates/article.html index 8b5e5bae..14fffe4d 100644 --- a/pelican/themes/notmyidea/templates/article.html +++ b/pelican/themes/notmyidea/templates/article.html @@ -7,18 +7,7 @@ rel="bookmark" title="Permalink to {{ article.title }}">{{ article.title }} {% include 'twitter.html' %}
- + {% include 'article_infos.html' %} {{ article.content }}
{% if DISQUS_SITENAME %} diff --git a/pelican/themes/notmyidea/templates/article_infos.html b/pelican/themes/notmyidea/templates/article_infos.html new file mode 100644 index 00000000..818b5277 --- /dev/null +++ b/pelican/themes/notmyidea/templates/article_infos.html @@ -0,0 +1,14 @@ + diff --git a/pelican/themes/notmyidea/templates/index.html b/pelican/themes/notmyidea/templates/index.html index e6e7d816..5969e6c8 100644 --- a/pelican/themes/notmyidea/templates/index.html +++ b/pelican/themes/notmyidea/templates/index.html @@ -7,19 +7,7 @@