mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Log warnings on creating (tag) slugs directly
This commit is contained in:
parent
902640ee99
commit
49096578ef
3 changed files with 15 additions and 5 deletions
|
|
@ -576,9 +576,10 @@ class ArticlesGenerator(CachingGenerator):
|
|||
)
|
||||
except RuntimeError:
|
||||
if not tag.slug:
|
||||
logger.warning(
|
||||
logger.info(
|
||||
'Tag "%s" has an invalid slug; skipping writing tag page...',
|
||||
tag,
|
||||
extra={"limit_msg": "Further tags with invalid slugs."},
|
||||
)
|
||||
continue
|
||||
else:
|
||||
|
|
@ -606,9 +607,10 @@ class ArticlesGenerator(CachingGenerator):
|
|||
)
|
||||
except RuntimeError:
|
||||
if not cat.slug:
|
||||
logger.warning(
|
||||
logger.info(
|
||||
'Category "%s" has an invalid slug; skipping writing category page...',
|
||||
cat,
|
||||
extra={"limit_msg": "Further categories with invalid slugs."},
|
||||
)
|
||||
continue
|
||||
else:
|
||||
|
|
@ -636,9 +638,10 @@ class ArticlesGenerator(CachingGenerator):
|
|||
)
|
||||
except RuntimeError:
|
||||
if not aut.slug:
|
||||
logger.warning(
|
||||
logger.info(
|
||||
'Author "%s" has an invalid slug; skipping writing author page...',
|
||||
aut,
|
||||
extra={"limit_msg": "Further authors with invalid slugs."},
|
||||
)
|
||||
continue
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -42,11 +42,18 @@ class URLWrapper:
|
|||
preserve_case=preserve_case,
|
||||
use_unicode=self.settings.get("SLUGIFY_USE_UNICODE", False),
|
||||
)
|
||||
if not self._slug:
|
||||
logger.warning(
|
||||
'Unable to generate valid slug for %s "%s".',
|
||||
self.__class__.__name__,
|
||||
self.name,
|
||||
extra={"limit_msg": "Other invalid slugs."},
|
||||
)
|
||||
return self._slug
|
||||
|
||||
@slug.setter
|
||||
def slug(self, slug):
|
||||
# if slug is expliticly set, changing name won't alter slug
|
||||
# if slug is explicitly set, changing name won't alter slug
|
||||
self._slug_from_name = False
|
||||
self._slug = slug
|
||||
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ def slugify(value, regex_subs=(), preserve_case=False, use_unicode=False):
|
|||
Normalizes string, converts to lowercase, removes non-alpha characters,
|
||||
and converts spaces to hyphens.
|
||||
|
||||
Took from Django sources.
|
||||
Taken from Django sources.
|
||||
|
||||
For a set of sensible default regex substitutions to pass to regex_subs
|
||||
look into pelican.settings.DEFAULT_CONFIG['SLUG_REGEX_SUBSTITUTIONS'].
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue