changeset 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 5336e146ac8d
children 171051e1aca5
files piecrust/commands/builtin/util.py piecrust/resources/webinit/config.yml piecrust/resources/webinit/theme_config.yml
diffstat 3 files changed, 25 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/piecrust/commands/builtin/util.py	Thu Jun 09 22:25:16 2016 -0700
+++ b/piecrust/commands/builtin/util.py	Thu Jun 09 22:26:18 2016 -0700
@@ -4,7 +4,7 @@
 import codecs
 import logging
 import yaml
-from piecrust import CACHE_DIR
+from piecrust import CACHE_DIR, RESOURCES_DIR
 from piecrust.app import CONFIG_PATH, THEME_CONFIG_PATH
 from piecrust.commands.base import ChefCommand
 
@@ -39,18 +39,13 @@
         if not os.path.isdir(os.path.dirname(config_path)):
             os.makedirs(os.path.dirname(config_path), 0o755)
 
-        config_text = yaml.dump({
-                'site': {
-                    'title': "My New Website",
-                    'description': "A website recently generated with PieCrust",
-                    'pretty_urls': True
-                    },
-                'smartypants': {
-                    'enable': True
-                    }
-                },
-                default_flow_style=False)
-        with codecs.open(config_path, 'w', 'utf-8') as fp:
+        tpl_path = os.path.join(RESOURCES_DIR, 'webinit', CONFIG_PATH)
+        if ctx.args.theme:
+            tpl_path = os.path.join(RESOURCES_DIR, 'webinit', THEME_CONFIG_PATH)
+        with open(tpl_path, 'r', encoding='utf-8') as fp:
+            config_text = fp.read()
+
+        with open(config_path, 'w', encoding='utf-8') as fp:
             fp.write(config_text)
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/piecrust/resources/webinit/config.yml	Thu Jun 09 22:26:18 2016 -0700
@@ -0,0 +1,8 @@
+
+# For more settings, see: https://bolt80.com/piecrust/en/latest/docs/reference/website-configuration/
+
+site:
+    title: My New Website
+    description: A website recently generated with PieCrust
+    pretty_urls: true
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/piecrust/resources/webinit/theme_config.yml	Thu Jun 09 22:26:18 2016 -0700
@@ -0,0 +1,9 @@
+
+theme:
+   name: MyNewTheme
+   url: https://example.org
+   description: A PieCrust theme.
+
+site:
+   pretty_urls: true
+