diff --git a/pelican/contents.py b/pelican/contents.py index 49f30316..aab6b330 100644 --- a/pelican/contents.py +++ b/pelican/contents.py @@ -143,6 +143,26 @@ class Quote(Page): base_properties = ('author', 'date') +class Category(object): + def __init__(self, category): + self.category = unicode(category) + + def __hash__(self): + return hash(self.category) + + def __eq__(self, other): + return self.category == unicode(other) + + def __str__(self): + return str(self.category) + + def __unicode__(self): + return self.category + + @property + def url(self): + return 'category/%s.html' % self + def is_valid_content(content, f): try: content.check_properties() diff --git a/pelican/generators.py b/pelican/generators.py index 6715126a..116c0b0b 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -187,7 +187,7 @@ class ArticlesGenerator(Generator): category_template = self.get_template('category') for cat, articles in self.categories: dates = [article for article in self.dates if article in articles] - write('category/%s.html' % cat, category_template, self.context, + write(cat.url, category_template, self.context, category=cat, articles=articles, dates=dates, paginated={'articles': articles, 'dates': dates}, page_name='category/%s' % cat) @@ -228,7 +228,7 @@ class ArticlesGenerator(Generator): category = os.path.basename(os.path.dirname(f)).decode('utf-8') if category != '': - metadata['category'] = unicode(category) + metadata['category'] = Category(category) if 'date' not in metadata.keys()\ and self.settings['FALLBACK_ON_FS_DATE']: diff --git a/pelican/readers.py b/pelican/readers.py index ee3ecd2c..1a62237a 100644 --- a/pelican/readers.py +++ b/pelican/readers.py @@ -15,6 +15,7 @@ except ImportError: Markdown = False import re +from pelican.contents import Category from pelican.utils import get_date, open @@ -22,6 +23,7 @@ _METADATA_PROCESSORS = { 'tags': lambda x: map(unicode.strip, unicode(x).split(',')), 'date': lambda x: get_date(x), 'status': unicode.strip, + 'category': Category, } def _process_metadata(name, value): diff --git a/pelican/themes/notmyidea/templates/article_infos.html b/pelican/themes/notmyidea/templates/article_infos.html index e1803be8..09ecd595 100644 --- a/pelican/themes/notmyidea/templates/article_infos.html +++ b/pelican/themes/notmyidea/templates/article_infos.html @@ -8,7 +8,7 @@ By {{ article.author }} {% endif %} -

In {{ article.category }}. {% if PDF_PROCESSOR %}get the pdf{% endif %}

+

In {{ article.category }}. {% if PDF_PROCESSOR %}get the pdf{% endif %}

{% include 'taglist.html' %} {% include 'translations.html' %} diff --git a/pelican/themes/notmyidea/templates/categories.html b/pelican/themes/notmyidea/templates/categories.html index 7e4bd2c9..e4d9d0a7 100644 --- a/pelican/themes/notmyidea/templates/categories.html +++ b/pelican/themes/notmyidea/templates/categories.html @@ -2,7 +2,7 @@ {% block content %} {% endblock %} diff --git a/pelican/themes/simple/templates/categories.html b/pelican/themes/simple/templates/categories.html index 7e4bd2c9..e29be0ca 100644 --- a/pelican/themes/simple/templates/categories.html +++ b/pelican/themes/simple/templates/categories.html @@ -2,7 +2,7 @@ {% block content %} {% endblock %}