mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
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:
parent
068a3d2f1d
commit
2609004719
4 changed files with 28 additions and 8 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue