mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Fix #1198, enable custom locale in template rendering, fixes links
reverts getpelican/pelican@ddcccfeaa9 If one used a locale that made use of unicode characters (like fr_FR.UTF-8) the files on disk would be in correct locale while links would be to C. Uses a SafeDatetime class that works with unicode format strigns by using custom strftime to prevent ascii decoding errors with Python2. Also added unicode decoding for the calendar module to fix period archives.
This commit is contained in:
parent
2432a22400
commit
3f6b130d6e
91 changed files with 5704 additions and 77 deletions
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals, print_function
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
|
@ -28,7 +27,7 @@ except ImportError:
|
|||
|
||||
from pelican import signals
|
||||
from pelican.contents import Page, Category, Tag, Author
|
||||
from pelican.utils import get_date, pelican_open, FileStampDataCacher
|
||||
from pelican.utils import get_date, pelican_open, FileStampDataCacher, SafeDatetime
|
||||
|
||||
|
||||
METADATA_PROCESSORS = {
|
||||
|
|
@ -494,7 +493,7 @@ def default_metadata(settings=None, process=None):
|
|||
value = process('category', value)
|
||||
metadata['category'] = value
|
||||
if settings.get('DEFAULT_DATE', None) and settings['DEFAULT_DATE'] != 'fs':
|
||||
metadata['date'] = datetime.datetime(*settings['DEFAULT_DATE'])
|
||||
metadata['date'] = SafeDatetime(*settings['DEFAULT_DATE'])
|
||||
return metadata
|
||||
|
||||
|
||||
|
|
@ -502,7 +501,7 @@ def path_metadata(full_path, source_path, settings=None):
|
|||
metadata = {}
|
||||
if settings:
|
||||
if settings.get('DEFAULT_DATE', None) == 'fs':
|
||||
metadata['date'] = datetime.datetime.fromtimestamp(
|
||||
metadata['date'] = SafeDatetime.fromtimestamp(
|
||||
os.stat(full_path).st_ctime)
|
||||
metadata.update(settings.get('EXTRA_PATH_METADATA', {}).get(
|
||||
source_path, {}))
|
||||
|
|
@ -525,7 +524,7 @@ def parse_path_metadata(source_path, settings=None, process=None):
|
|||
... process=reader.process_metadata)
|
||||
>>> pprint.pprint(metadata) # doctest: +ELLIPSIS
|
||||
{'category': <pelican.urlwrappers.Category object at ...>,
|
||||
'date': datetime.datetime(2013, 1, 1, 0, 0),
|
||||
'date': SafeDatetime(2013, 1, 1, 0, 0),
|
||||
'slug': 'my-slug'}
|
||||
"""
|
||||
metadata = {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue