mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Added another option CLEAN_URLS, to use generated files with mod_rewrite and to show nice urls to the end user.
This commit is contained in:
parent
3afdb8fcff
commit
1d74de2559
3 changed files with 13 additions and 5 deletions
|
|
@ -31,11 +31,18 @@ class Page(object):
|
|||
if not hasattr(self, 'slug'):
|
||||
self.slug = slugify(self.title)
|
||||
|
||||
if not hasattr(self, 'url'):
|
||||
if not hasattr(self, 'save_as'):
|
||||
if self.in_default_lang:
|
||||
self.url = '%s.html' % self.slug
|
||||
self.save_as = '%s.html' % self.slug
|
||||
clean_url = '%s/' % self.slug
|
||||
else:
|
||||
self.url = '%s-%s.html' % (self.slug, self.lang)
|
||||
self.save_as = '%s-%s.html' % (self.slug, self.lang)
|
||||
clean_url = '%s-%s/' % (self.slug, self.lang)
|
||||
|
||||
if settings.get('CLEAN_URLS', False):
|
||||
self.url = clean_url
|
||||
else:
|
||||
self.url = self.save_as
|
||||
|
||||
if filename:
|
||||
self.filename = filename
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ class ArticlesGenerator(Generator):
|
|||
write('category/%s.html' % cat, templates['category'], self.context,
|
||||
category=cat, articles=self.categories[cat])
|
||||
for article in chain(self.translations, self.articles):
|
||||
write('%s' % article.url,
|
||||
write(article.save_as,
|
||||
templates['article'], self.context, article=article,
|
||||
category=article.category)
|
||||
|
||||
|
|
@ -211,7 +211,7 @@ class PagesGenerator(Generator):
|
|||
def generate_output(self, writer):
|
||||
templates = self.get_templates()
|
||||
for page in chain(self.translations, self.pages):
|
||||
writer.write_file('pages/%s' % page.url, templates['page'],
|
||||
writer.write_file('pages/%s' % page.save_as, templates['page'],
|
||||
self.context, page=page)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ _DEFAULT_CONFIG = {'PATH': None,
|
|||
'CSS_FILE': 'main.css',
|
||||
'REVERSE_ARCHIVE_ORDER': False,
|
||||
'KEEP_OUTPUT_DIRECTORY': False,
|
||||
'CLEAN_URLS': False, # use /blah/ instead /blah.html in urls
|
||||
}
|
||||
|
||||
def read_settings(filename):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue