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:
Alexander Artemenko 2010-12-21 00:21:29 +03:00
commit 1d74de2559
3 changed files with 13 additions and 5 deletions

View file

@ -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