mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge pull request #152 from mviera/master
Fixing errors in ARTICLE_PERMALINK_STRUCTURE option
This commit is contained in:
commit
4685e41173
3 changed files with 17 additions and 16 deletions
|
|
@ -161,20 +161,6 @@ class ArticlesGenerator(Generator):
|
||||||
# in writer, articles pass first
|
# in writer, articles pass first
|
||||||
article_template = self.get_template('article')
|
article_template = self.get_template('article')
|
||||||
for article in chain(self.translations, self.articles):
|
for article in chain(self.translations, self.articles):
|
||||||
add_to_url = u''
|
|
||||||
if 'ARTICLE_PERMALINK_STRUCTURE' in self.settings:
|
|
||||||
article_permalink_structure = self.settings['ARTICLE_PERMALINK_STRUCTURE']
|
|
||||||
article_permalink_structure = article_permalink_structure.lstrip('/')
|
|
||||||
|
|
||||||
# try to substitute any python datetime directive
|
|
||||||
add_to_url = article.date.strftime(article_permalink_structure)
|
|
||||||
# try to substitute any article metadata in rest file
|
|
||||||
add_to_url = add_to_url % article.__dict__
|
|
||||||
add_to_url = [slugify(i) for i in add_to_url.split('/')]
|
|
||||||
add_to_url = os.path.join(*add_to_url)
|
|
||||||
|
|
||||||
article.url = urlparse.urljoin(add_to_url, article.url)
|
|
||||||
article.save_as = urlparse.urljoin(add_to_url, article.save_as)
|
|
||||||
write(article.save_as,
|
write(article.save_as,
|
||||||
article_template, self.context, article=article,
|
article_template, self.context, article=article,
|
||||||
category=article.category)
|
category=article.category)
|
||||||
|
|
@ -247,6 +233,21 @@ class ArticlesGenerator(Generator):
|
||||||
if not is_valid_content(article, f):
|
if not is_valid_content(article, f):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
add_to_url = u''
|
||||||
|
if 'ARTICLE_PERMALINK_STRUCTURE' in self.settings:
|
||||||
|
article_permalink_structure = self.settings['ARTICLE_PERMALINK_STRUCTURE']
|
||||||
|
article_permalink_structure = article_permalink_structure.lstrip('/')
|
||||||
|
|
||||||
|
# try to substitute any python datetime directive
|
||||||
|
add_to_url = article.date.strftime(article_permalink_structure)
|
||||||
|
# try to substitute any article metadata in rest file
|
||||||
|
add_to_url = add_to_url % article.__dict__
|
||||||
|
add_to_url = [slugify(i) for i in add_to_url.split('/')]
|
||||||
|
add_to_url = os.path.join(*add_to_url)
|
||||||
|
|
||||||
|
article.url = urlparse.urljoin(add_to_url, article.url)
|
||||||
|
article.save_as = urlparse.urljoin(add_to_url, article.save_as)
|
||||||
|
|
||||||
if article.status == "published":
|
if article.status == "published":
|
||||||
if hasattr(article, 'tags'):
|
if hasattr(article, 'tags'):
|
||||||
for tag in article.tags:
|
for tag in article.tags:
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{% if DISQUS_SITENAME %}<p>There are <a href="{{ SITEURL }}/{{ article.slug }}.html#disqus_thread">comments</a>.</p>{% endif %}
|
{% if DISQUS_SITENAME %}<p>There are <a href="{{ SITEURL }}/{{ article.url }}#disqus_thread">comments</a>.</p>{% endif %}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<section id="content" class="body">
|
<section id="content" class="body">
|
||||||
<header> <h2 class="entry-title"><a href="{{ article.url }}" rel="bookmark" title="Permalink to {{ article.title}}">{{ article.title }}</a></h2> </header>
|
<header> <h2 class="entry-title"><a href="{{ pagename }}" rel="bookmark" title="Permalink to {{ article.title}}">{{ article.title }}</a></h2> </header>
|
||||||
<footer class="post-info">
|
<footer class="post-info">
|
||||||
<abbr class="published" title="{{ article.date.isoformat() }}">
|
<abbr class="published" title="{{ article.date.isoformat() }}">
|
||||||
{{ article.locale_date }}
|
{{ article.locale_date }}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue