I change PERMALINK_STRUCTURE to ARTICLE_PERMALINK_STRUCTURE and updating the settings.rst documentation.

Also I have implemented other options to this setting, such as the category, the date, the author, this kind of things.

Finally, I have setted the ARTICLE_PERMALINK_STRUCTURE option as null in pelican.conf.py sample file.
This commit is contained in:
mviera 2011-07-29 01:11:35 +02:00
commit 2609004719
4 changed files with 28 additions and 8 deletions

View file

@ -61,10 +61,22 @@ Setting name (default value) what does it do?
on the output path "static". By default,
pelican will copy the 'images' folder to the
output folder.
`PERMALINK_STRUCTURE` (``'/%Y/%m/'``) Allows to render URLs for articles sorted by date,
`ARTICLE_PERMALINK_STRUCTURE` (``'/%Y/%m/'``) Allows to render URLs for articles sorted by date,
in case you specify a format as specified in the
example. Also, you can specify any other word
that you want.
example. It follows the python datetime directives:
* %Y: Year with century as a decimal number.
* %m: Month as a decimal number [01,12].
* %d: Day of the month as a decimal number [01,31].
Check the python datetime documentation
at http://bit.ly/cNcJUC for more information.
Also, you can use any metadata in the
restructured text files:
* category: '%(category)s'
* author: '%(author)s'
* tags: '%(tags)s'
* date: '%(date)s'
================================================ =====================================================

View file

@ -13,6 +13,7 @@ from jinja2 import Environment, FileSystemLoader, PrefixLoader, ChoiceLoader
from jinja2.exceptions import TemplateNotFound
from pelican.utils import copy, get_relative_path, process_translations, open
from pelican.utils import slugify
from pelican.contents import Article, Page, is_valid_content
from pelican.readers import read_file
from pelican.log import *
@ -161,14 +162,18 @@ class ArticlesGenerator(Generator):
article_template = self.get_template('article')
for article in chain(self.translations, self.articles):
add_to_url = u''
if self.settings.has_key('PERMALINK_STRUCTURE'):
permalink_structure = self.settings.get('PERMALINK_STRUCTURE')
permalink_structure = permalink_structure.lstrip('/')
if self.settings.has_key('ARTICLE_PERMALINK_STRUCTURE'):
article_permalink_structure = self.settings.get('ARTICLE_PERMALINK_STRUCTURE')
article_permalink_structure = article_permalink_structure.lstrip('/')
try:
add_to_url = article.date.strftime(permalink_structure)
add_to_url = article.date.strftime(article_permalink_structure)
except:
pass
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,

View file

@ -42,7 +42,7 @@ _DEFAULT_CONFIG = {'PATH': None,
'DEFAULT_METADATA': (),
'FILES_TO_COPY': (),
'DEFAULT_STATUS': 'published',
'PERMALINK_STRUCTURE': ''
'ARTICLE_PERMALINK_STRUCTURE': '/%Y/%m/'
}
def read_settings(filename):

View file

@ -9,6 +9,9 @@ PDF_GENERATOR = False
REVERSE_CATEGORY_ORDER = True
LOCALE = ""
DEFAULT_PAGINATION = 2
# Allows to construct an url like /2011/07/sample-post.html
# See documentation for more info.
ARTICLE_PERMALINK_STRUCTURE = ''
FEED_RSS = 'feeds/all.rss.xml'
CATEGORY_FEED_RSS = 'feeds/%s.rss.xml'