Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Unicode nikola init output (via #1644)
Requires UTF-8 input on Python 2.

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Mar 31, 2015
1 parent e30f892 commit fb3a7db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -4,6 +4,7 @@ New in master
Features
--------

* Produce Unicode output in ``nikola init`` (via Issue #1644)
* Add ``HIDDEN_TAGS`` and ``HIDDEN_CATEGORIES`` settings to hide some
tags and categories (eg. ``mathjax``) from view (Issue #1640)
* Instruct browsers to prefetch newest post when visiting the front page
Expand Down
8 changes: 6 additions & 2 deletions nikola/plugins/command/init.py
Expand Up @@ -188,7 +188,7 @@ def get_msg(lang):
pairs.append(f.format('DEFAULT_LANG', '', get_msg(default_lang)))

for l in additional_languages:
pairs.append(f.format(json.dumps(l), '/' + l, get_msg(l)))
pairs.append(f.format(json.dumps(l, ensure_ascii=False), '/' + l, get_msg(l)))

return u'{{\n{0}\n}}'.format('\n\n'.join(pairs))

Expand All @@ -198,7 +198,7 @@ def get_msg(lang):
def prepare_config(config):
"""Parse sample config with JSON."""
p = config.copy()
p.update(dict((k, json.dumps(v)) for k, v in p.items()
p.update(dict((k, json.dumps(v, ensure_ascii=False)) for k, v in p.items()
if k not in ('POSTS', 'PAGES', 'COMPILERS', 'TRANSLATIONS', 'NAVIGATION_LINKS', '_SUPPORTED_LANGUAGES', '_SUPPORTED_COMMENT_SYSTEMS', 'INDEX_READ_MORE_LINK', 'RSS_READ_MORE_LINK')))
# READ_MORE_LINKs require some special treatment.
p['INDEX_READ_MORE_LINK'] = "'" + p['INDEX_READ_MORE_LINK'].replace("'", "\\'") + "'"
Expand Down Expand Up @@ -399,6 +399,10 @@ def chandler(default, toconf):
query(default, toconf)
else:
answer = ask(query, default)
try:
answer = answer.decode('utf-8')
except (AttributeError, UnicodeDecodeError):
pass
if toconf:
SAMPLE_CONF[destination] = answer
if destination == '!target':
Expand Down

0 comments on commit fb3a7db

Please sign in to comment.