comparison piecrust/commands/builtin/util.py @ 748:6db54bed2417

init: Use a better config template when creating websites.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 09 Jun 2016 22:26:18 -0700
parents 6e92b5cd0163
children 58ae026b4c31
comparison
equal deleted inserted replaced
747:5336e146ac8d 748:6db54bed2417
2 import os.path 2 import os.path
3 import shutil 3 import shutil
4 import codecs 4 import codecs
5 import logging 5 import logging
6 import yaml 6 import yaml
7 from piecrust import CACHE_DIR 7 from piecrust import CACHE_DIR, RESOURCES_DIR
8 from piecrust.app import CONFIG_PATH, THEME_CONFIG_PATH 8 from piecrust.app import CONFIG_PATH, THEME_CONFIG_PATH
9 from piecrust.commands.base import ChefCommand 9 from piecrust.commands.base import ChefCommand
10 10
11 11
12 logger = logging.getLogger(__name__) 12 logger = logging.getLogger(__name__)
37 config_path = os.path.join(destination, THEME_CONFIG_PATH) 37 config_path = os.path.join(destination, THEME_CONFIG_PATH)
38 38
39 if not os.path.isdir(os.path.dirname(config_path)): 39 if not os.path.isdir(os.path.dirname(config_path)):
40 os.makedirs(os.path.dirname(config_path), 0o755) 40 os.makedirs(os.path.dirname(config_path), 0o755)
41 41
42 config_text = yaml.dump({ 42 tpl_path = os.path.join(RESOURCES_DIR, 'webinit', CONFIG_PATH)
43 'site': { 43 if ctx.args.theme:
44 'title': "My New Website", 44 tpl_path = os.path.join(RESOURCES_DIR, 'webinit', THEME_CONFIG_PATH)
45 'description': "A website recently generated with PieCrust", 45 with open(tpl_path, 'r', encoding='utf-8') as fp:
46 'pretty_urls': True 46 config_text = fp.read()
47 }, 47
48 'smartypants': { 48 with open(config_path, 'w', encoding='utf-8') as fp:
49 'enable': True
50 }
51 },
52 default_flow_style=False)
53 with codecs.open(config_path, 'w', 'utf-8') as fp:
54 fp.write(config_text) 49 fp.write(config_text)
55 50
56 51
57 class PurgeCommand(ChefCommand): 52 class PurgeCommand(ChefCommand):
58 def __init__(self): 53 def __init__(self):