1
0
Fork 0
forked from github/pelican

Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
Alexis Métaireau
e39dc95c3b Bug #1493 — Memoize slugify when possible 2014-10-09 11:42:11 +02:00
3 changed files with 4 additions and 2 deletions

View file

@ -388,7 +388,7 @@ class TestArticle(TestPage):
def test_slugify_category_author(self):
settings = get_settings()
settings['SLUG_SUBSTITUTIONS'] = [ ('C#', 'csharp') ]
settings['SLUG_SUBSTITUTIONS'] = (('C#', 'csharp'),)
settings['ARTICLE_URL'] = '{author}/{category}/{slug}/'
settings['ARTICLE_SAVE_AS'] = '{author}/{category}/{slug}/index.html'
article_kwargs = self._copy_page_kwargs()

View file

@ -41,6 +41,8 @@ class URLWrapper(object):
return self.slug
def _normalize_key(self, key):
if hasattr(key, 'name'):
key = key.name
subs = self.settings.get('SLUG_SUBSTITUTIONS', ())
return six.text_type(slugify(key, subs))

View file

@ -239,7 +239,7 @@ def pelican_open(filename):
content = content[1:]
yield content
@memoized
def slugify(value, substitutions=()):
"""
Normalizes string, converts to lowercase, removes non-alpha characters,