[commands/new.go] Update theme.toml etc.

- Add copyright years and author to the top of the file

- Write the current year from time.Now() to LICENSE.md

- Correct comment regarding `os.MkdirAll(p, 0777)`

- In createConfig(), split the `map[string]string` definition into
  multiple lines to facilitate future expansion.  Also add a trailing
  slash to sample "baseurl" definition.

- Update theme.toml template to match that listed at
  https://github.com/spf13/hugoThemes/blob/master/README.md#themetoml

  See #883 for an equivalent `struct` implementation
This commit is contained in:
Anthony Fok 2015-02-08 08:11:04 -07:00
parent 87975e04eb
commit d10e05f2e3

View file

@ -1,3 +1,5 @@
// Copyright © 2014-2015 Steve Francia <spf@spf13.com>.
//
// Licensed under the Simple Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@ -16,6 +18,7 @@ import (
"os"
"path/filepath"
"strings"
"time"
"github.com/spf13/cobra"
"github.com/spf13/hugo/create"
@ -169,7 +172,7 @@ func NewTheme(cmd *cobra.Command, args []string) {
by := []byte(`The MIT License (MIT)
Copyright (c) 2014 YOUR_NAME_HERE
Copyright (c) ` + time.Now().Format("2006") + ` YOUR_NAME_HERE
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
@ -200,7 +203,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
func mkdir(x ...string) {
p := filepath.Join(x...)
err := os.MkdirAll(p, 0777) // rwx, rw, r
err := os.MkdirAll(p, 0777) // before umask
if err != nil {
jww.FATAL.Fatalln(err)
}
@ -217,19 +220,24 @@ func touchFile(x ...string) {
func createThemeMD(inpath string) (err error) {
in := map[string]interface{}{
"name": helpers.MakeTitle(filepath.Base(inpath)),
"license": "MIT",
"source_repo": "",
"author": "",
"description": "",
"tags": []string{"", ""},
}
by := []byte(`name = "` + strings.Title(helpers.MakeTitle(filepath.Base(inpath))) + `"
license = "MIT"
licenselink = "https://github.com/.../.../LICENSE.md"
description = ""
homepage = "http://siteforthistheme.com/"
tags = ["", ""]
features = ["", ""]
by, err := parser.InterfaceToConfig(in, parser.FormatToLeadRune("toml"))
if err != nil {
return err
}
[author]
name = ""
homepage = ""
# If porting an existing theme
[original]
name = ""
homepage = ""
repo = ""
`)
err = helpers.WriteToDisk(filepath.Join(inpath, "theme.toml"), bytes.NewReader(by), hugofs.SourceFs)
if err != nil {
@ -240,7 +248,11 @@ func createThemeMD(inpath string) (err error) {
}
func createConfig(inpath string, kind string) (err error) {
in := map[string]string{"baseurl": "http://yourSiteHere", "title": "my new hugo site", "languageCode": "en-us"}
in := map[string]string{
"baseurl": "http://yourSiteHere/",
"title": "My New Hugo Site",
"languageCode": "en-us",
}
kind = parser.FormatSanitize(kind)
by, err := parser.InterfaceToConfig(in, parser.FormatToLeadRune(kind))