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

@ -21,7 +21,7 @@ from six.moves.urllib.error import URLError
from six.moves.urllib.parse import urlparse
from six.moves.urllib.request import urlretrieve
from pelican.utils import slugify
from pelican.utils import slugify, SafeDatetime
from pelican.log import init
logger = logging.getLogger(__name__)
@ -303,7 +303,7 @@ def dc2fields(file):
def posterous2fields(api_token, email, password):
"""Imports posterous posts"""
import base64
from datetime import datetime, timedelta
from datetime import timedelta
try:
# py3k import
import json
@ -340,7 +340,7 @@ def posterous2fields(api_token, email, password):
slug = slugify(post.get('title'))
tags = [tag.get('name') for tag in post.get('tags')]
raw_date = post.get('display_date')
date_object = datetime.strptime(raw_date[:-6], "%Y/%m/%d %H:%M:%S")
date_object = SafeDatetime.strptime(raw_date[:-6], "%Y/%m/%d %H:%M:%S")
offset = int(raw_date[-5:])
delta = timedelta(hours = offset / 100)
date_object -= delta