mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Bug #1493 — Memoize slugify when possible
This commit is contained in:
parent
7feb638b5c
commit
e39dc95c3b
3 changed files with 4 additions and 2 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue