mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Add timezone prompt to quickstart. Refs 1337.
This commit is contained in:
parent
7e961061e1
commit
bbbb3247ea
2 changed files with 23 additions and 2 deletions
|
|
@ -9,6 +9,7 @@ import string
|
||||||
import argparse
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
import codecs
|
import codecs
|
||||||
|
import pytz
|
||||||
|
|
||||||
from pelican import __version__
|
from pelican import __version__
|
||||||
|
|
||||||
|
|
@ -39,9 +40,13 @@ CONF = {
|
||||||
'github_pages_branch': _GITHUB_PAGES_BRANCHES['project'],
|
'github_pages_branch': _GITHUB_PAGES_BRANCHES['project'],
|
||||||
'default_pagination': 10,
|
'default_pagination': 10,
|
||||||
'siteurl': '',
|
'siteurl': '',
|
||||||
'lang': 'en'
|
'lang': 'en',
|
||||||
|
'timezone': 'Europe/Paris'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#url for list of valid timezones
|
||||||
|
_TZ_URL = 'http://en.wikipedia.org/wiki/List_of_tz_database_time_zones'
|
||||||
|
|
||||||
def _input_compat(prompt):
|
def _input_compat(prompt):
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
r = input(prompt)
|
r = input(prompt)
|
||||||
|
|
@ -155,6 +160,20 @@ def ask(question, answer=str_compat, default=None, l=None):
|
||||||
raise NotImplemented('Argument `answer` must be str_compat, bool, or integer')
|
raise NotImplemented('Argument `answer` must be str_compat, bool, or integer')
|
||||||
|
|
||||||
|
|
||||||
|
def ask_timezone(question, default, tzurl):
|
||||||
|
"""Prompt for time zone and validate input"""
|
||||||
|
lower_tz = map(str.lower, pytz.all_timezones)
|
||||||
|
while True:
|
||||||
|
r = ask(question, str_compat, default)
|
||||||
|
r = r.strip().replace(' ', '_').lower()
|
||||||
|
if r in lower_tz:
|
||||||
|
r = pytz.all_timezones[lower_tz.index(r)]
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
print('Please enter a valid time zone:\n (check [{0}])'.format(tzurl))
|
||||||
|
return r
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="A kickstarter for Pelican",
|
description="A kickstarter for Pelican",
|
||||||
|
|
@ -203,6 +222,8 @@ needed by Pelican.
|
||||||
else:
|
else:
|
||||||
CONF['default_pagination'] = False
|
CONF['default_pagination'] = False
|
||||||
|
|
||||||
|
CONF['timezone'] = ask_timezone('What is your time zone?', CONF['timezone'], _TZ_URL)
|
||||||
|
|
||||||
automation = ask('Do you want to generate a Fabfile/Makefile to automate generation and publishing?', bool, True)
|
automation = ask('Do you want to generate a Fabfile/Makefile to automate generation and publishing?', bool, True)
|
||||||
develop = ask('Do you want an auto-reload & simpleHTTP script to assist with theme and site development?', bool, True)
|
develop = ask('Do you want an auto-reload & simpleHTTP script to assist with theme and site development?', bool, True)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ SITEURL = ''
|
||||||
|
|
||||||
PATH = 'content'
|
PATH = 'content'
|
||||||
|
|
||||||
TIMEZONE = 'Europe/Paris'
|
TIMEZONE = $timezone
|
||||||
|
|
||||||
DEFAULT_LANG = $lang
|
DEFAULT_LANG = $lang
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue