Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7427c2d

Browse files
committedJul 11, 2015
Add new variables to init and handle bools better
cc @felixfontein Signed-off-by: Chris Warrick <kwpolska@gmail.com>
1 parent 0a9b7be commit 7427c2d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed
 

Diff for: ‎nikola/plugins/command/init.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
'TIMEZONE': 'UTC',
6565
'COMMENT_SYSTEM': 'disqus',
6666
'COMMENT_SYSTEM_ID': 'nikolademo',
67+
'CATEGORY_ALLOW_HIERARCHIES': False,
68+
'CATEGORY_OUTPUT_FLAT_HIERARCHY': False,
6769
'TRANSLATIONS_PATTERN': DEFAULT_TRANSLATIONS_PATTERN,
6870
'INDEX_READ_MORE_LINK': DEFAULT_INDEX_READ_MORE_LINK,
6971
'RSS_READ_MORE_LINK': DEFAULT_RSS_READ_MORE_LINK,
@@ -194,18 +196,18 @@ def get_msg(lang):
194196
return u'{{\n{0}\n}}'.format('\n\n'.join(pairs))
195197

196198

197-
# In order to ensure proper escaping, all variables but the three
198-
# pre-formatted ones are handled by json.dumps().
199+
# In order to ensure proper escaping, all variables but the pre-formatted ones
200+
# are handled by json.dumps().
199201
def prepare_config(config):
200202
"""Parse sample config with JSON."""
201203
p = config.copy()
202-
p.update(dict((k, json.dumps(v, ensure_ascii=False)) for k, v in p.items()
203-
if k not in ('POSTS', 'PAGES', 'COMPILERS', 'TRANSLATIONS', 'NAVIGATION_LINKS', '_SUPPORTED_LANGUAGES', '_SUPPORTED_COMMENT_SYSTEMS', 'INDEX_READ_MORE_LINK', 'RSS_READ_MORE_LINK', 'PRETTY_URLS')))
204+
p.update({k: json.dumps(v, ensure_ascii=False) for k, v in p.items()
205+
if k not in ('POSTS', 'PAGES', 'COMPILERS', 'TRANSLATIONS', 'NAVIGATION_LINKS', '_SUPPORTED_LANGUAGES', '_SUPPORTED_COMMENT_SYSTEMS', 'INDEX_READ_MORE_LINK', 'RSS_READ_MORE_LINK')})
204206
# READ_MORE_LINKs require some special treatment.
205207
p['INDEX_READ_MORE_LINK'] = "'" + p['INDEX_READ_MORE_LINK'].replace("'", "\\'") + "'"
206208
p['RSS_READ_MORE_LINK'] = "'" + p['RSS_READ_MORE_LINK'].replace("'", "\\'") + "'"
207-
# json would make that `true` instead of `True`
208-
p['PRETTY_URLS'] = str(p['PRETTY_URLS'])
209+
# fix booleans and None
210+
p.update({k: str(v) for k, v in config.items() if isinstance(v, bool) or v is None})
209211
return p
210212

211213

0 commit comments

Comments
 (0)
Please sign in to comment.