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:
Ondrej Grover 2014-04-27 10:25:57 +02:00 committed by Deniz Turgut
commit 3f6b130d6e
91 changed files with 5704 additions and 77 deletions

View file

@ -11,13 +11,12 @@ import os
import re
import sys
from datetime import datetime
from pelican import signals
from pelican.settings import DEFAULT_CONFIG
from pelican.utils import (slugify, truncate_html_words, memoized, strftime,
python_2_unicode_compatible, deprecated_attribute,
path_to_url)
path_to_url, SafeDatetime)
# Import these so that they're avalaible when you import from pelican.contents.
from pelican.urlwrappers import (URLWrapper, Author, Category, Tag) # NOQA
@ -127,7 +126,7 @@ class Content(object):
if not hasattr(self, 'status'):
self.status = settings['DEFAULT_STATUS']
if not settings['WITH_FUTURE_DATES']:
if hasattr(self, 'date') and self.date > datetime.now():
if hasattr(self, 'date') and self.date > SafeDatetime.now():
self.status = 'draft'
# store the summary metadata if it is set
@ -161,7 +160,7 @@ class Content(object):
'path': path_to_url(path),
'slug': getattr(self, 'slug', ''),
'lang': getattr(self, 'lang', 'en'),
'date': getattr(self, 'date', datetime.now()),
'date': getattr(self, 'date', SafeDatetime.now()),
'author': slugify(
getattr(self, 'author', ''),
slug_substitutions