Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Default to PRETTY_URLS in the wizard (#1838 1/2)
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jun 23, 2015
1 parent dcd17cb commit 9d6625b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -4,6 +4,8 @@ New in master
Features
--------

* Enable ``PRETTY_URLS`` by default on new sites created by the wizard
(Issue #1838)
* Add ``-F``, ``--available-compilers`` option to ``nikola new_post``
and ``nikola new_page`` (Issue #1837)
* Add print CSS to all default themes (Issue #1817)
Expand Down
8 changes: 4 additions & 4 deletions nikola/conf.py.in
Expand Up @@ -672,12 +672,12 @@ COMMENT_SYSTEM_ID = ${COMMENT_SYSTEM_ID}
# /robots.txt and /sitemap.xml, and to inform search engines about /sitemapindex.xml.
# ROBOTS_EXCLUSIONS = ["/archive.html", "/category/*.html"]

# Instead of putting files in <slug>.html, put them in
# <slug>/index.html. Also enables STRIP_INDEXES
# Instead of putting files in <slug>.html, put them in <slug>/index.html.
# No web server configuration is required. Also enables STRIP_INDEXES.
# This can be disabled on a per-page/post basis by adding
# .. pretty_url: False
# to the metadata
# PRETTY_URLS = False
# to the metadata.
PRETTY_URLS = ${PRETTY_URLS}

# If True, publish future dated posts right away instead of scheduling them.
# Defaults to False.
Expand Down
9 changes: 8 additions & 1 deletion nikola/plugins/command/init.py
Expand Up @@ -53,6 +53,7 @@
'SITE_URL': "https://example.com/",
'BLOG_EMAIL': "joe@demo.site",
'BLOG_DESCRIPTION': "This is a demo site for Nikola.",
'PRETTY_URLS': False,
'DEFAULT_LANG': "en",
'TRANSLATIONS': """{
DEFAULT_LANG: "",
Expand Down Expand Up @@ -199,10 +200,12 @@ def prepare_config(config):
"""Parse sample config with JSON."""
p = config.copy()
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')))
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')))
# READ_MORE_LINKs require some special treatment.
p['INDEX_READ_MORE_LINK'] = "'" + p['INDEX_READ_MORE_LINK'].replace("'", "\\'") + "'"
p['RSS_READ_MORE_LINK'] = "'" + p['RSS_READ_MORE_LINK'].replace("'", "\\'") + "'"
# json would make that `true` instead of `True`
p['PRETTY_URLS'] = str(p['PRETTY_URLS'])
return p


Expand Down Expand Up @@ -291,6 +294,9 @@ def urlhandler(default, toconf):

SAMPLE_CONF['SITE_URL'] = answer

def prettyhandler(default, toconf):
SAMPLE_CONF['PRETTY_URLS'] = ask_yesno('Enable pretty URLs (/page/ instead of /page.html) that don’t need web server configuration?', default=True)

def lhandler(default, toconf, show_header=True):
if show_header:
print("We will now ask you to provide the list of languages you want to use.")
Expand Down Expand Up @@ -406,6 +412,7 @@ def chandler(default, toconf):
('Site author\'s e-mail', 'n.tesla@example.com', True, 'BLOG_EMAIL'),
('Site description', 'This is a demo site for Nikola.', True, 'BLOG_DESCRIPTION'),
(urlhandler, None, True, True),
(prettyhandler, None, True, True),
('Questions about languages and locales', None, None, None),
(lhandler, None, True, True),
(tzhandler, None, True, True),
Expand Down

0 comments on commit 9d6625b

Please sign in to comment.