mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Adding more documentation about ARTICLE_PERMALINK_STRUCTURE in settings. Also, i deleted the try except because strftime never raises an exception. Issue #145
I set the ARTICLE_PERMALINK_STRUCTURE option as null in settings.py and remove it from pelican sample config file.
This commit is contained in:
parent
2609004719
commit
a13ae91f0b
4 changed files with 21 additions and 13 deletions
|
|
@ -61,13 +61,19 @@ 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.
|
||||
`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. It follows the python datetime directives:
|
||||
`ARTICLE_PERMALINK_STRUCTURE` (``''``) Empty by default. Allows to render URLs for
|
||||
articles sorted by date, in case you specify a
|
||||
format as specified in the 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].
|
||||
|
||||
Note: if you specify a datetime directive, it will
|
||||
be substituted using the date metadata field into
|
||||
the rest file. if the date is not specified, pelican
|
||||
will rely on the mtime of your file.
|
||||
|
||||
Check the python datetime documentation
|
||||
at http://bit.ly/cNcJUC for more information.
|
||||
|
||||
|
|
@ -77,6 +83,12 @@ Setting name (default value) what does it do?
|
|||
* author: '%(author)s'
|
||||
* tags: '%(tags)s'
|
||||
* date: '%(date)s'
|
||||
|
||||
Example usage:
|
||||
* '/%Y/%m/' it will be something like
|
||||
'/2011/07/sample-post.html'.
|
||||
* '/%Y/%(category)s/' it will be something like
|
||||
'/2011/life/sample-post.html'.
|
||||
================================================ =====================================================
|
||||
|
||||
|
||||
|
|
|
|||
11
pelican/generators.py
Normal file → Executable file
11
pelican/generators.py
Normal file → Executable file
|
|
@ -162,14 +162,13 @@ 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('ARTICLE_PERMALINK_STRUCTURE'):
|
||||
article_permalink_structure = self.settings.get('ARTICLE_PERMALINK_STRUCTURE')
|
||||
if 'ARTICLE_PERMALINK_STRUCTURE' in self.settings:
|
||||
article_permalink_structure = self.settings['ARTICLE_PERMALINK_STRUCTURE']
|
||||
article_permalink_structure = article_permalink_structure.lstrip('/')
|
||||
try:
|
||||
add_to_url = article.date.strftime(article_permalink_structure)
|
||||
except:
|
||||
pass
|
||||
|
||||
# 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)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ _DEFAULT_CONFIG = {'PATH': None,
|
|||
'DEFAULT_METADATA': (),
|
||||
'FILES_TO_COPY': (),
|
||||
'DEFAULT_STATUS': 'published',
|
||||
'ARTICLE_PERMALINK_STRUCTURE': '/%Y/%m/'
|
||||
'ARTICLE_PERMALINK_STRUCTURE': ''
|
||||
}
|
||||
|
||||
def read_settings(filename):
|
||||
|
|
|
|||
|
|
@ -9,9 +9,6 @@ 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'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue