ref: d10e05f2e32283d245691bd54a9bb6a9a7067578
parent: 87975e04eb1908e7a35089fc382fa945263242e5
author: Anthony Fok <[email protected]>
date: Sun Feb 8 03:11:04 EST 2015
[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
--- a/commands/new.go
+++ b/commands/new.go
@@ -1,3 +1,5 @@
+// Copyright © 2014-2015 Steve Francia <[email protected]>.
+//
// 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 @@
"os"
"path/filepath"
"strings"
+ "time"
"github.com/spf13/cobra"
"github.com/spf13/hugo/create"
@@ -72,7 +75,7 @@
Run: NewTheme,
}
-//NewContent adds new content to a Hugo site.
+// NewContent adds new content to a Hugo site.
func NewContent(cmd *cobra.Command, args []string) {
InitializeConfig()
@@ -135,7 +138,7 @@
createConfig(createpath, configFormat)
}
-//NewTheme creates a new Hugo theme.
+// NewTheme creates a new Hugo theme.
func NewTheme(cmd *cobra.Command, args []string) {
InitializeConfig()
@@ -169,7 +172,7 @@
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 @@
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,20 +220,25 @@
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 {
return
@@ -240,7 +248,11 @@
}
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))