mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Added support for category and lang for period generator
This commit is contained in:
parent
34ef5ab098
commit
226b5db6bb
1 changed files with 12 additions and 2 deletions
|
|
@ -309,6 +309,8 @@ class ArticlesGenerator(Generator):
|
|||
# format string syntax can be used for specifying the
|
||||
# period archive dates
|
||||
date = archive[0].date
|
||||
category = archive[0].category
|
||||
lang = archive[0].lang
|
||||
# Under python 2, with non-ascii locales, u"{:%b}".format(date) might raise UnicodeDecodeError
|
||||
# because u"{:%b}".format(date) will call date.__format__(u"%b"), which will return a byte string
|
||||
# and not a unicode string.
|
||||
|
|
@ -316,12 +318,20 @@ class ArticlesGenerator(Generator):
|
|||
# locale.setlocale(locale.LC_ALL, 'ja_JP.utf8')
|
||||
# date.__format__(u"%b") == '12\xe6\x9c\x88' # True
|
||||
try:
|
||||
save_as = save_as_fmt.format(date=date)
|
||||
save_as = save_as_fmt.format(
|
||||
date=date,
|
||||
category=category,
|
||||
lang=lang
|
||||
)
|
||||
except UnicodeDecodeError:
|
||||
# Python2 only:
|
||||
# Let date.__format__() work with byte strings instead of characters since it fails to work with characters
|
||||
bytes_save_as_fmt = save_as_fmt.encode('utf8')
|
||||
bytes_save_as = bytes_save_as_fmt.format(date=date)
|
||||
bytes_save_as = bytes_save_as_fmt.format(
|
||||
date=date,
|
||||
category=category,
|
||||
lang=lang
|
||||
)
|
||||
save_as = unicode(bytes_save_as,'utf8')
|
||||
context = self.context.copy()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue