do slug_substitutions on category and author ...

This commit is contained in:
Nick Moore 2013-07-14 23:01:16 +10:00
commit 6c5444eb68

View file

@ -141,14 +141,21 @@ class Content(object):
"""Returns the URL, formatted with the proper values""" """Returns the URL, formatted with the proper values"""
metadata = copy.copy(self.metadata) metadata = copy.copy(self.metadata)
path = self.metadata.get('path', self.get_relative_source_path()) path = self.metadata.get('path', self.get_relative_source_path())
default_category = self.settings['DEFAULT_CATEGORY']
slug_substitutions = self.settings.get('SLUG_SUBSTITUTIONS', ())
metadata.update({ metadata.update({
'path': path_to_url(path), 'path': path_to_url(path),
'slug': getattr(self, 'slug', ''), 'slug': getattr(self, 'slug', ''),
'lang': getattr(self, 'lang', 'en'), 'lang': getattr(self, 'lang', 'en'),
'date': getattr(self, 'date', datetime.now()), 'date': getattr(self, 'date', datetime.now()),
'author': getattr(self, 'author', ''), 'author': slugify(
'category': getattr(self, 'category', getattr(self, 'author', ''),
self.settings['DEFAULT_CATEGORY']), slug_substitutions
),
'category': slugify(
getattr(self, 'category', default_category),
slug_substitutions
)
}) })
return metadata return metadata