all: Unify case of config variable names

All config variables starts with low-case and uses camelCase.

If there is abbreviation at the beginning of the name, the whole
abbreviation will be written in low-case.
If there is abbreviation at the end of the name, the
whole abbreviation will be written in upper-case.
For example, rssURI.
This commit is contained in:
Albert Nigmatzianov 2016-10-24 20:56:00 +02:00 committed by Bjørn Erik Pedersen
parent d9f54a13c1
commit f21e2f25c9
67 changed files with 469 additions and 469 deletions

View file

@ -134,7 +134,7 @@ func convertContents(mark rune) (err error) {
metadata = newmetadata
}
page.SetDir(filepath.Join(helpers.AbsPathify(viper.GetString("ContentDir")), file.Dir()))
page.SetDir(filepath.Join(helpers.AbsPathify(viper.GetString("contentDir")), file.Dir()))
page.SetSourceContent(psr.Content())
if err = page.SetSourceMetaData(metadata, mark); err != nil {
jww.ERROR.Printf("Failed to set source metadata for file %q: %s. For more info see For more info see https://github.com/spf13/hugo/issues/2458", page.FullFilePath(), err)

View file

@ -117,7 +117,7 @@ Complete documentation is available at http://gohugo.io/.`,
}
if buildWatch {
viper.Set("DisableLiveReload", true)
viper.Set("disableLiveReload", true)
watchConfig()
}
@ -284,55 +284,55 @@ func InitializeConfig(subCmdVs ...*cobra.Command) error {
for _, cmdV := range append([]*cobra.Command{hugoCmdV}, subCmdVs...) {
if flagChanged(cmdV.PersistentFlags(), "verbose") {
viper.Set("Verbose", verbose)
viper.Set("verbose", verbose)
}
if flagChanged(cmdV.PersistentFlags(), "logFile") {
viper.Set("LogFile", logFile)
viper.Set("logFile", logFile)
}
if flagChanged(cmdV.Flags(), "cleanDestinationDir") {
viper.Set("cleanDestinationDir", cleanDestination)
}
if flagChanged(cmdV.Flags(), "buildDrafts") {
viper.Set("BuildDrafts", draft)
viper.Set("buildDrafts", draft)
}
if flagChanged(cmdV.Flags(), "buildFuture") {
viper.Set("BuildFuture", future)
viper.Set("buildFuture", future)
}
if flagChanged(cmdV.Flags(), "buildExpired") {
viper.Set("BuildExpired", expired)
viper.Set("buildExpired", expired)
}
if flagChanged(cmdV.Flags(), "uglyURLs") {
viper.Set("UglyURLs", uglyURLs)
viper.Set("uglyURLs", uglyURLs)
}
if flagChanged(cmdV.Flags(), "canonifyURLs") {
viper.Set("CanonifyURLs", canonifyURLs)
viper.Set("canonifyURLs", canonifyURLs)
}
if flagChanged(cmdV.Flags(), "disable404") {
viper.Set("Disable404", disable404)
viper.Set("disable404", disable404)
}
if flagChanged(cmdV.Flags(), "disableRSS") {
viper.Set("DisableRSS", disableRSS)
viper.Set("disableRSS", disableRSS)
}
if flagChanged(cmdV.Flags(), "disableSitemap") {
viper.Set("DisableSitemap", disableSitemap)
viper.Set("disableSitemap", disableSitemap)
}
if flagChanged(cmdV.Flags(), "enableRobotsTXT") {
viper.Set("EnableRobotsTXT", enableRobotsTXT)
viper.Set("enableRobotsTXT", enableRobotsTXT)
}
if flagChanged(cmdV.Flags(), "pluralizeListTitles") {
viper.Set("PluralizeListTitles", pluralizeListTitles)
viper.Set("pluralizeListTitles", pluralizeListTitles)
}
if flagChanged(cmdV.Flags(), "preserveTaxonomyNames") {
viper.Set("PreserveTaxonomyNames", preserveTaxonomyNames)
viper.Set("preserveTaxonomyNames", preserveTaxonomyNames)
}
if flagChanged(cmdV.Flags(), "ignoreCache") {
viper.Set("IgnoreCache", ignoreCache)
viper.Set("ignoreCache", ignoreCache)
}
if flagChanged(cmdV.Flags(), "forceSyncStatic") {
viper.Set("ForceSyncStatic", forceSync)
viper.Set("forceSyncStatic", forceSync)
}
if flagChanged(cmdV.Flags(), "noTimes") {
viper.Set("NoTimes", noTimes)
viper.Set("noTimes", noTimes)
}
}
@ -341,10 +341,10 @@ func InitializeConfig(subCmdVs ...*cobra.Command) error {
if !strings.HasSuffix(baseURL, "/") {
baseURL = baseURL + "/"
}
viper.Set("BaseURL", baseURL)
viper.Set("baseURL", baseURL)
}
if !viper.GetBool("RelativeURLs") && viper.GetString("BaseURL") == "" {
if !viper.GetBool("relativeURLs") && viper.GetString("baseURL") == "" {
jww.ERROR.Println("No 'baseurl' set in configuration or as a flag. Features like page menus will not work without one.")
}
@ -353,27 +353,27 @@ func InitializeConfig(subCmdVs ...*cobra.Command) error {
}
if destination != "" {
viper.Set("PublishDir", destination)
viper.Set("publishDir", destination)
}
var dir string
if source != "" {
dir, _ := filepath.Abs(source)
viper.Set("WorkingDir", dir)
dir, _ = filepath.Abs(source)
} else {
dir, _ := os.Getwd()
viper.Set("WorkingDir", dir)
dir, _ = os.Getwd()
}
viper.Set("workingDir", dir)
if contentDir != "" {
viper.Set("ContentDir", contentDir)
viper.Set("contentDir", contentDir)
}
if layoutDir != "" {
viper.Set("LayoutDir", layoutDir)
viper.Set("layoutDir", layoutDir)
}
if cacheDir != "" {
viper.Set("CacheDir", cacheDir)
viper.Set("cacheDir", cacheDir)
}
cacheDir = viper.GetString("cacheDir")
@ -386,14 +386,14 @@ func InitializeConfig(subCmdVs ...*cobra.Command) error {
if isDir == false {
mkdir(cacheDir)
}
viper.Set("CacheDir", cacheDir)
viper.Set("cacheDir", cacheDir)
} else {
viper.Set("CacheDir", helpers.GetTempDir("hugo_cache", hugofs.Source()))
viper.Set("cacheDir", helpers.GetTempDir("hugo_cache", hugofs.Source()))
}
if verboseLog || logging || (viper.IsSet("LogFile") && viper.GetString("LogFile") != "") {
if viper.IsSet("LogFile") && viper.GetString("LogFile") != "" {
jww.SetLogFile(viper.GetString("LogFile"))
if verboseLog || logging || (viper.IsSet("logFile") && viper.GetString("logFile") != "") {
if viper.IsSet("logFile") && viper.GetString("logFile") != "" {
jww.SetLogFile(viper.GetString("logFile"))
} else {
jww.UseTempLogFile("hugo")
}
@ -448,7 +448,7 @@ func watchConfig() {
fmt.Println("Config file changed:", e.Name)
// Force a full rebuild
utils.CheckErr(reCreateAndbuildSites(true))
if !viper.GetBool("DisableLiveReload") {
if !viper.GetBool("disableLiveReload") {
// Will block forever trying to write to a channel that nobody is reading if livereload isn't initialized
livereload.ForceRefresh()
}
@ -463,11 +463,11 @@ func build(watches ...bool) error {
if renderToMemory {
hugofs.SetDestination(new(afero.MemMapFs))
// Rendering to memoryFS, publish to Root regardless of publishDir.
viper.Set("PublishDir", "/")
viper.Set("publishDir", "/")
}
if err := copyStatic(); err != nil {
return fmt.Errorf("Error copying static files to %s: %s", helpers.AbsPathify(viper.GetString("PublishDir")), err)
return fmt.Errorf("Error copying static files to %s: %s", helpers.AbsPathify(viper.GetString("publishDir")), err)
}
watch := false
if len(watches) > 0 && watches[0] {
@ -478,7 +478,7 @@ func build(watches ...bool) error {
}
if buildWatch {
jww.FEEDBACK.Println("Watching for changes in", helpers.AbsPathify(viper.GetString("ContentDir")))
jww.FEEDBACK.Println("Watching for changes in", helpers.AbsPathify(viper.GetString("contentDir")))
jww.FEEDBACK.Println("Press Ctrl+C to stop")
utils.CheckErr(NewWatcher(0))
}
@ -532,7 +532,7 @@ func getStaticSourceFs() afero.Fs {
}
func copyStatic() error {
publishDir := helpers.AbsPathify(viper.GetString("PublishDir")) + helpers.FilePathSeparator
publishDir := helpers.AbsPathify(viper.GetString("publishDir")) + helpers.FilePathSeparator
// If root, remove the second '/'
if publishDir == "//" {
@ -567,10 +567,10 @@ func copyStatic() error {
// getDirList provides NewWatcher() with a list of directories to watch for changes.
func getDirList() []string {
var a []string
dataDir := helpers.AbsPathify(viper.GetString("DataDir"))
i18nDir := helpers.AbsPathify(viper.GetString("I18nDir"))
layoutDir := helpers.AbsPathify(viper.GetString("LayoutDir"))
staticDir := helpers.AbsPathify(viper.GetString("StaticDir"))
dataDir := helpers.AbsPathify(viper.GetString("dataDir"))
i18nDir := helpers.AbsPathify(viper.GetString("i18nDir"))
layoutDir := helpers.AbsPathify(viper.GetString("layoutDir"))
staticDir := helpers.AbsPathify(viper.GetString("staticDir"))
var themesDir string
if helpers.ThemeSet() {
@ -580,22 +580,22 @@ func getDirList() []string {
walker := func(path string, fi os.FileInfo, err error) error {
if err != nil {
if path == dataDir && os.IsNotExist(err) {
jww.WARN.Println("Skip DataDir:", err)
jww.WARN.Println("Skip dataDir:", err)
return nil
}
if path == i18nDir && os.IsNotExist(err) {
jww.WARN.Println("Skip I18nDir:", err)
jww.WARN.Println("Skip i18nDir:", err)
return nil
}
if path == layoutDir && os.IsNotExist(err) {
jww.WARN.Println("Skip LayoutDir:", err)
jww.WARN.Println("Skip layoutDir:", err)
return nil
}
if path == staticDir && os.IsNotExist(err) {
jww.WARN.Println("Skip StaticDir:", err)
jww.WARN.Println("Skip staticDir:", err)
return nil
}
@ -636,9 +636,9 @@ func getDirList() []string {
}
helpers.SymbolicWalk(hugofs.Source(), dataDir, walker)
helpers.SymbolicWalk(hugofs.Source(), helpers.AbsPathify(viper.GetString("ContentDir")), walker)
helpers.SymbolicWalk(hugofs.Source(), helpers.AbsPathify(viper.GetString("contentDir")), walker)
helpers.SymbolicWalk(hugofs.Source(), i18nDir, walker)
helpers.SymbolicWalk(hugofs.Source(), helpers.AbsPathify(viper.GetString("LayoutDir")), walker)
helpers.SymbolicWalk(hugofs.Source(), helpers.AbsPathify(viper.GetString("layoutDir")), walker)
helpers.SymbolicWalk(hugofs.Source(), staticDir, walker)
if helpers.ThemeSet() {
@ -801,7 +801,7 @@ func NewWatcher(port int) error {
}
if len(staticEvents) > 0 {
publishDir := helpers.AbsPathify(viper.GetString("PublishDir")) + helpers.FilePathSeparator
publishDir := helpers.AbsPathify(viper.GetString("publishDir")) + helpers.FilePathSeparator
// If root, remove the second '/'
if publishDir == "//" {
@ -812,11 +812,11 @@ func NewWatcher(port int) error {
const layout = "2006-01-02 15:04 -0700"
fmt.Println(time.Now().Format(layout))
if viper.GetBool("ForceSyncStatic") {
if viper.GetBool("forceSyncStatic") {
jww.FEEDBACK.Printf("Syncing all static files\n")
err := copyStatic()
if err != nil {
utils.StopOnErr(err, fmt.Sprintf("Error copying static files to %s", helpers.AbsPathify(viper.GetString("PublishDir"))))
utils.StopOnErr(err, fmt.Sprintf("Error copying static files to %s", helpers.AbsPathify(viper.GetString("publishDir"))))
}
} else {
staticSourceFs := getStaticSourceFs()
@ -896,7 +896,7 @@ func NewWatcher(port int) error {
}
}
if !buildWatch && !viper.GetBool("DisableLiveReload") {
if !buildWatch && !viper.GetBool("disableLiveReload") {
// Will block forever trying to write to a channel that nobody is reading if livereload isn't initialized
// force refresh when more than one file
@ -919,7 +919,7 @@ func NewWatcher(port int) error {
rebuildSites(dynamicEvents)
if !buildWatch && !viper.GetBool("DisableLiveReload") {
if !buildWatch && !viper.GetBool("disableLiveReload") {
// Will block forever trying to write to a channel that nobody is reading if livereload isn't initialized
livereload.ForceRefresh()
}
@ -933,7 +933,7 @@ func NewWatcher(port int) error {
}()
if port > 0 {
if !viper.GetBool("DisableLiveReload") {
if !viper.GetBool("disableLiveReload") {
livereload.Initialize()
http.HandleFunc("/livereload.js", livereload.ServeJS)
http.HandleFunc("/livereload", livereload.Handler)

View file

@ -221,7 +221,7 @@ func loadJekyllConfig(jekyllRoot string) map[string]interface{} {
func createConfigFromJekyll(inpath string, kind string, jekyllConfig map[string]interface{}) (err error) {
title := "My New Hugo Site"
baseurl := "http://example.org/"
baseURL := "http://example.org/"
for key, value := range jekyllConfig {
lowerKey := strings.ToLower(key)
@ -234,13 +234,13 @@ func createConfigFromJekyll(inpath string, kind string, jekyllConfig map[string]
case "url":
if str, ok := value.(string); ok {
baseurl = str
baseURL = str
}
}
}
in := map[string]interface{}{
"baseurl": baseurl,
"baseURL": baseURL,
"title": title,
"languageCode": "en-us",
"disablePathToLower": true,

View file

@ -49,7 +49,7 @@ var listDraftsCmd = &cobra.Command{
return err
}
viper.Set("BuildDrafts", true)
viper.Set("buildDrafts", true)
sites, err := hugolib.NewHugoSitesFromConfiguration()
@ -84,7 +84,7 @@ posted in the future.`,
return err
}
viper.Set("BuildFuture", true)
viper.Set("buildFuture", true)
sites, err := hugolib.NewHugoSitesFromConfiguration()
@ -119,7 +119,7 @@ expired.`,
return err
}
viper.Set("BuildExpired", true)
viper.Set("buildExpired", true)
sites, err := hugolib.NewHugoSitesFromConfiguration()

View file

@ -89,11 +89,11 @@ func NewContent(cmd *cobra.Command, args []string) error {
}
if flagChanged(cmd.Flags(), "format") {
viper.Set("MetaDataFormat", configFormat)
viper.Set("metaDataFormat", configFormat)
}
if flagChanged(cmd.Flags(), "editor") {
viper.Set("NewContentEditor", contentEditor)
viper.Set("newContentEditor", contentEditor)
}
if len(args) < 1 {

View file

@ -90,7 +90,7 @@ func init() {
serverCmd.Flags().IntVarP(&serverPort, "port", "p", 1313, "port on which the server will listen")
serverCmd.Flags().StringVarP(&serverInterface, "bind", "", "127.0.0.1", "interface to which the server will bind")
serverCmd.Flags().BoolVarP(&serverWatch, "watch", "w", true, "watch filesystem for changes and recreate as needed")
serverCmd.Flags().BoolVarP(&serverAppend, "appendPort", "", true, "append port to baseurl")
serverCmd.Flags().BoolVarP(&serverAppend, "appendPort", "", true, "append port to baseURL")
serverCmd.Flags().BoolVar(&disableLiveReload, "disableLiveReload", false, "watch without enabling live browser reload on rebuild")
serverCmd.Flags().BoolVar(&renderToDisk, "renderToDisk", false, "render to Destination path (default is render to memory & serve from there)")
serverCmd.Flags().String("memstats", "", "log memory usage to this file")
@ -109,11 +109,11 @@ func server(cmd *cobra.Command, args []string) error {
}
if flagChanged(cmd.Flags(), "disableLiveReload") {
viper.Set("DisableLiveReload", disableLiveReload)
viper.Set("disableLiveReload", disableLiveReload)
}
if serverWatch {
viper.Set("Watch", true)
viper.Set("watch", true)
}
if viper.GetBool("watch") {
@ -139,11 +139,11 @@ func server(cmd *cobra.Command, args []string) error {
viper.Set("port", serverPort)
BaseURL, err := fixURL(baseURL)
baseURL, err = fixURL(baseURL)
if err != nil {
return err
}
viper.Set("BaseURL", BaseURL)
viper.Set("baseURL", baseURL)
if err := memStats(); err != nil {
jww.ERROR.Println("memstats error:", err)
@ -158,7 +158,7 @@ func server(cmd *cobra.Command, args []string) error {
if !renderToDisk {
hugofs.SetDestination(new(afero.MemMapFs))
// Rendering to memoryFS, publish to Root regardless of publishDir.
viper.Set("PublishDir", "/")
viper.Set("publishDir", "/")
}
if err := build(serverWatch); err != nil {
@ -168,7 +168,7 @@ func server(cmd *cobra.Command, args []string) error {
// Watch runs its own server as part of the routine
if serverWatch {
watchDirs := getDirList()
baseWatchDir := viper.GetString("WorkingDir")
baseWatchDir := viper.GetString("workingDir")
for i, dir := range watchDirs {
watchDirs[i], _ = helpers.GetRelativePath(dir, baseWatchDir)
}
@ -190,19 +190,19 @@ func server(cmd *cobra.Command, args []string) error {
func serve(port int) {
if renderToDisk {
jww.FEEDBACK.Println("Serving pages from " + helpers.AbsPathify(viper.GetString("PublishDir")))
jww.FEEDBACK.Println("Serving pages from " + helpers.AbsPathify(viper.GetString("publishDir")))
} else {
jww.FEEDBACK.Println("Serving pages from memory")
}
httpFs := afero.NewHttpFs(hugofs.Destination())
fs := filesOnlyFs{httpFs.Dir(helpers.AbsPathify(viper.GetString("PublishDir")))}
fs := filesOnlyFs{httpFs.Dir(helpers.AbsPathify(viper.GetString("publishDir")))}
fileserver := http.FileServer(fs)
// We're only interested in the path
u, err := url.Parse(viper.GetString("BaseURL"))
u, err := url.Parse(viper.GetString("baseURL"))
if err != nil {
jww.ERROR.Fatalf("Invalid BaseURL: %s", err)
jww.ERROR.Fatalf("Invalid baseURL: %s", err)
}
if u.Path == "" || u.Path == "/" {
http.Handle("/", fileserver)
@ -221,12 +221,12 @@ func serve(port int) {
}
}
// fixURL massages the BaseURL into a form needed for serving
// fixURL massages the baseURL into a form needed for serving
// all pages correctly.
func fixURL(s string) (string, error) {
useLocalhost := false
if s == "" {
s = viper.GetString("BaseURL")
s = viper.GetString("baseURL")
useLocalhost = true
}
@ -262,7 +262,7 @@ func fixURL(s string) (string, error) {
if strings.Contains(u.Host, ":") {
u.Host, _, err = net.SplitHostPort(u.Host)
if err != nil {
return "", fmt.Errorf("Failed to split BaseURL hostpost: %s", err)
return "", fmt.Errorf("Failed to split baseURL hostpost: %s", err)
}
}
u.Host += fmt.Sprintf(":%d", serverPort)

View file

@ -46,7 +46,7 @@ func TestFixURL(t *testing.T) {
for i, test := range tests {
viper.Reset()
baseURL = test.CLIBaseURL
viper.Set("BaseURL", test.CfgBaseURL)
viper.Set("baseURL", test.CfgBaseURL)
serverAppend = test.AppendPort
serverPort = test.Port
result, err := fixURL(baseURL)