Skip to content

Commit

Permalink
Fix #1838 -- default to PRETTY_URLS in the wizard
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jun 21, 2015
1 parent 0ed7211 commit 6d43c6b
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 Features
-------- --------


* Enable ``PRETTY_URLS`` by default on new sites created by the wizard
(Issue #1838)
* Add print CSS to all default themes (Issue #1817) * Add print CSS to all default themes (Issue #1817)
* Support other kernels for ipynb/Jupyter using * Support other kernels for ipynb/Jupyter using
``nikola new_post -f ipynb@kernel`` (Issues #1774, #1834) ``nikola new_post -f ipynb@kernel`` (Issues #1774, #1834)
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.txt and /sitemap.xml, and to inform search engines about /sitemapindex.xml.
# ROBOTS_EXCLUSIONS = ["/archive.html", "/category/*.html"] # ROBOTS_EXCLUSIONS = ["/archive.html", "/category/*.html"]


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


# If True, publish future dated posts right away instead of scheduling them. # If True, publish future dated posts right away instead of scheduling them.
# Defaults to False. # 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/", 'SITE_URL': "https://example.com/",
'BLOG_EMAIL': "joe@demo.site", 'BLOG_EMAIL': "joe@demo.site",
'BLOG_DESCRIPTION': "This is a demo site for Nikola.", 'BLOG_DESCRIPTION': "This is a demo site for Nikola.",
'PRETTY_URLS': False,
'DEFAULT_LANG': "en", 'DEFAULT_LANG': "en",
'TRANSLATIONS': """{ 'TRANSLATIONS': """{
DEFAULT_LANG: "", DEFAULT_LANG: "",
Expand Down Expand Up @@ -199,10 +200,12 @@ def prepare_config(config):
"""Parse sample config with JSON.""" """Parse sample config with JSON."""
p = config.copy() p = config.copy()
p.update(dict((k, json.dumps(v, ensure_ascii=False)) 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'))) 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. # READ_MORE_LINKs require some special treatment.
p['INDEX_READ_MORE_LINK'] = "'" + p['INDEX_READ_MORE_LINK'].replace("'", "\\'") + "'" p['INDEX_READ_MORE_LINK'] = "'" + p['INDEX_READ_MORE_LINK'].replace("'", "\\'") + "'"
p['RSS_READ_MORE_LINK'] = "'" + p['RSS_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 return p




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


SAMPLE_CONF['SITE_URL'] = answer 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): def lhandler(default, toconf, show_header=True):
if show_header: if show_header:
print("We will now ask you to provide the list of languages you want to use.") 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 author\'s e-mail', 'n.tesla@example.com', True, 'BLOG_EMAIL'),
('Site description', 'This is a demo site for Nikola.', True, 'BLOG_DESCRIPTION'), ('Site description', 'This is a demo site for Nikola.', True, 'BLOG_DESCRIPTION'),
(urlhandler, None, True, True), (urlhandler, None, True, True),
(prettyhandler, None, True, True),
('Questions about languages and locales', None, None, None), ('Questions about languages and locales', None, None, None),
(lhandler, None, True, True), (lhandler, None, True, True),
(tzhandler, None, True, True), (tzhandler, None, True, True),
Expand Down

0 comments on commit 6d43c6b

Please sign in to comment.