1
0
Fork 0
forked from github/pelican

control slug substitutions from settings with regex

This commit is contained in:
Oliver Urs Lenz 2018-08-07 17:35:16 +02:00
commit 5199fa51ea
12 changed files with 409 additions and 235 deletions

View file

@ -98,14 +98,16 @@ class Content(object):
if not hasattr(self, 'slug'):
if (settings['SLUGIFY_SOURCE'] == 'title' and
hasattr(self, 'title')):
self.slug = slugify(self.title,
settings.get('SLUG_SUBSTITUTIONS', ()))
self.slug = slugify(
self.title,
regex_subs=settings.get('SLUG_REGEX_SUBSTITUTIONS', []))
elif (settings['SLUGIFY_SOURCE'] == 'basename' and
source_path is not None):
basename = os.path.basename(
os.path.splitext(source_path)[0])
self.slug = slugify(
basename, settings.get('SLUG_SUBSTITUTIONS', ()))
basename,
regex_subs=settings.get('SLUG_REGEX_SUBSTITUTIONS', []))
self.source_path = source_path