Fix encoding error with the feed plugin on PY2 (Ref #194)

This commit is contained in:
Simon Conseil
2016-02-22 23:57:55 +01:00
parent b4d1057a58
commit 3e8ef322cf
2 changed files with 7 additions and 2 deletions

View File

@@ -25,7 +25,7 @@ import os
from datetime import datetime
from feedgenerator import Atom1Feed, Rss201rev2Feed
from jinja2 import Markup
from sigal import signals
from sigal import signals, compat
logger = logging.getLogger(__name__)
@@ -72,7 +72,8 @@ def generate_feed(gallery, images, feed_type=None, feed_url='', nb_items=0):
output_file = os.path.join(root_album.dst_path, feed_url.split('/')[-1])
logger.info('Generate %s feeds: %s', feed_type.upper(), output_file)
with codecs.open(output_file, 'w', 'utf-8') as f:
encoding = 'utf-8' if not compat.PY2 else None
with codecs.open(output_file, 'w', encoding) as f:
feed.write(f, 'utf-8')

View File

@@ -0,0 +1,4 @@
Title: WÎth spécial chÆracters
This is a funny description of this image