mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Add settings to change the URL's and SAVE_AS paths
Example usage:
* ARTICLE_URL = 'posts/{date:%Y}/{date:%b}/{date:%d}/{slug}/'
* ARTICLE_SAVE_AS = 'posts/{date:%Y}/{date:%b}/{date:%d}/{slug}/index.html'
This removes CLEAN_URLS and ARTICLE_PERMALINK_STRUCTURE because these
new settings can produce the same result.
This commit is contained in:
parent
ff9c786149
commit
a39787c1a2
4 changed files with 82 additions and 60 deletions
|
|
@ -239,21 +239,6 @@ class ArticlesGenerator(Generator):
|
|||
if not is_valid_content(article, f):
|
||||
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('/').replace('%(', "%%(")
|
||||
|
||||
# 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 hasattr(article, 'tags'):
|
||||
for tag in article.tags:
|
||||
|
|
@ -348,7 +333,7 @@ class PagesGenerator(Generator):
|
|||
|
||||
def generate_output(self, writer):
|
||||
for page in chain(self.translations, self.pages):
|
||||
writer.write_file('pages/%s' % page.save_as, self.get_template('page'),
|
||||
writer.write_file(page.save_as, self.get_template('page'),
|
||||
self.context, page=page,
|
||||
relative_urls = self.settings.get('RELATIVE_URLS'))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue