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

@@ -49,7 +49,7 @@ func Config() ConfigProvider {
return currentConfigProvider
}
// Some tests rely on this. We will fix that, eventually.
return viper.Get("CurrentContentLanguage").(ConfigProvider)
return viper.Get("currentContentLanguage").(ConfigProvider)
}
// CurrentPathSpec returns the current PathSpec.

View File

@@ -182,8 +182,8 @@ func BytesToHTML(b []byte) template.HTML {
// getHTMLRenderer creates a new Blackfriday HTML Renderer with the given configuration.
func getHTMLRenderer(defaultFlags int, ctx *RenderingContext) blackfriday.Renderer {
renderParameters := blackfriday.HtmlRendererParameters{
FootnoteAnchorPrefix: viper.GetString("FootnoteAnchorPrefix"),
FootnoteReturnLinkContents: viper.GetString("FootnoteReturnLinkContents"),
FootnoteAnchorPrefix: viper.GetString("footnoteAnchorPrefix"),
FootnoteReturnLinkContents: viper.GetString("footnoteReturnLinkContents"),
}
b := len(ctx.DocumentID) != 0
@@ -271,8 +271,8 @@ func markdownRender(ctx *RenderingContext) []byte {
// getMmarkHTMLRenderer creates a new mmark HTML Renderer with the given configuration.
func getMmarkHTMLRenderer(defaultFlags int, ctx *RenderingContext) mmark.Renderer {
renderParameters := mmark.HtmlRendererParameters{
FootnoteAnchorPrefix: viper.GetString("FootnoteAnchorPrefix"),
FootnoteReturnLinkContents: viper.GetString("FootnoteReturnLinkContents"),
FootnoteAnchorPrefix: viper.GetString("footnoteAnchorPrefix"),
FootnoteReturnLinkContents: viper.GetString("footnoteReturnLinkContents"),
}
b := len(ctx.DocumentID) != 0

View File

@@ -34,8 +34,8 @@ type HugoHTMLRenderer struct {
}
func (renderer *HugoHTMLRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string) {
if viper.GetBool("PygmentsCodeFences") && (lang != "" || viper.GetBool("PygmentsCodeFencesGuessSyntax")) {
opts := viper.GetString("PygmentsOptions")
if viper.GetBool("pygmentsCodeFences") && (lang != "" || viper.GetBool("pygmentsCodeFencesGuessSyntax")) {
opts := viper.GetString("pygmentsOptions")
str := html.UnescapeString(string(text))
out.WriteString(Highlight(str, lang, opts))
} else {
@@ -117,7 +117,7 @@ type HugoMmarkHTMLRenderer struct {
}
func (renderer *HugoMmarkHTMLRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string, caption []byte, subfigure bool, callouts bool) {
if viper.GetBool("PygmentsCodeFences") && (lang != "" || viper.GetBool("PygmentsCodeFencesGuessSyntax")) {
if viper.GetBool("pygmentsCodeFences") && (lang != "" || viper.GetBool("pygmentsCodeFencesGuessSyntax")) {
str := html.UnescapeString(string(text))
out.WriteString(Highlight(str, lang, ""))
} else {

View File

@@ -62,11 +62,11 @@ func TestCodeFence(t *testing.T) {
viper.Reset()
defer viper.Reset()
viper.Set("PygmentsStyle", "monokai")
viper.Set("PygmentsUseClasses", true)
viper.Set("pygmentsStyle", "monokai")
viper.Set("pygmentsUseClasses", true)
for i, d := range data {
viper.Set("PygmentsCodeFences", d.enabled)
viper.Set("pygmentsCodeFences", d.enabled)
result := render(d.input)

View File

@@ -54,7 +54,7 @@ func NewLanguage(lang string) *Language {
}
func NewDefaultLanguage() *Language {
defaultLang := viper.GetString("DefaultContentLanguage")
defaultLang := viper.GetString("defaultContentLanguage")
if defaultLang == "" {
defaultLang = "en"
@@ -83,7 +83,7 @@ func (l *Language) Params() map[string]interface{} {
// Merge with global config.
// TODO(bep) consider making this part of a constructor func.
globalParams := viper.GetStringMap("Params")
globalParams := viper.GetStringMap("params")
for k, v := range globalParams {
if _, ok := l.params[k]; !ok {
l.params[k] = v

View File

@@ -154,13 +154,13 @@ func AbsPathify(inPath string) string {
}
// TODO(bep): Consider moving workingDir to argument list
return filepath.Clean(filepath.Join(viper.GetString("WorkingDir"), inPath))
return filepath.Clean(filepath.Join(viper.GetString("workingDir"), inPath))
}
// GetStaticDirPath returns the absolute path to the static file dir
// for the current Hugo project.
func GetStaticDirPath() string {
return AbsPathify(viper.GetString("StaticDir"))
return AbsPathify(viper.GetString("staticDir"))
}
// GetThemeDir gets the root directory of the current theme, if there is one.
@@ -342,7 +342,7 @@ func GetRelativePath(path, base string) (final string, err error) {
// PaginateAliasPath creates a path used to access the aliases in the paginator.
func PaginateAliasPath(base string, page int) string {
paginatePath := Config().GetString("paginatePath")
uglify := viper.GetBool("UglyURLs")
uglify := viper.GetBool("uglyURLs")
var p string
if base != "" {
p = filepath.FromSlash(fmt.Sprintf("/%s/%s/%d", base, paginatePath, page))

View File

@@ -34,7 +34,7 @@ import (
)
func initCommonTestConfig() {
viper.Set("CurrentContentLanguage", NewLanguage("en"))
viper.Set("currentContentLanguage", NewLanguage("en"))
}
func TestMakePath(t *testing.T) {
@@ -61,7 +61,7 @@ func TestMakePath(t *testing.T) {
}
for _, test := range tests {
viper.Set("RemovePathAccents", test.removeAccents)
viper.Set("removePathAccents", test.removeAccents)
p := NewPathSpecFromConfig(viper.GetViper())
output := p.MakePath(test.input)
if output != test.expected {
@@ -102,7 +102,7 @@ func TestMakePathSanitizedDisablePathToLower(t *testing.T) {
defer viper.Reset()
initCommonTestConfig()
viper.Set("DisablePathToLower", true)
viper.Set("disablePathToLower", true)
p := NewPathSpecFromConfig(viper.GetViper())
tests := []struct {
@@ -549,7 +549,7 @@ func TestAbsPathify(t *testing.T) {
for i, d := range data {
viper.Reset()
// todo see comment in AbsPathify
viper.Set("WorkingDir", d.workingDir)
viper.Set("workingDir", d.workingDir)
expected := AbsPathify(d.inPath)
if d.expected != expected {
@@ -559,7 +559,7 @@ func TestAbsPathify(t *testing.T) {
t.Logf("Running platform specific path tests for %s", runtime.GOOS)
if runtime.GOOS == "windows" {
for i, d := range windowsData {
viper.Set("WorkingDir", d.workingDir)
viper.Set("workingDir", d.workingDir)
expected := AbsPathify(d.inPath)
if d.expected != expected {
@@ -568,7 +568,7 @@ func TestAbsPathify(t *testing.T) {
}
} else {
for i, d := range unixData {
viper.Set("WorkingDir", d.workingDir)
viper.Set("workingDir", d.workingDir)
expected := AbsPathify(d.inPath)
if d.expected != expected {

View File

@@ -17,15 +17,16 @@ import (
"bytes"
"crypto/sha1"
"fmt"
"github.com/spf13/hugo/hugofs"
jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/viper"
"io"
"io/ioutil"
"os/exec"
"path/filepath"
"sort"
"strings"
"github.com/spf13/hugo/hugofs"
jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/viper"
)
const pygmentsBin = "pygmentize"
@@ -62,8 +63,8 @@ func Highlight(code, lang, optsStr string) string {
fs := hugofs.Os()
ignoreCache := viper.GetBool("IgnoreCache")
cacheDir := viper.GetString("CacheDir")
ignoreCache := viper.GetBool("ignoreCache")
cacheDir := viper.GetString("cacheDir")
var cachefile string
if !ignoreCache && cacheDir != "" {
@@ -198,17 +199,17 @@ func createOptionsString(options map[string]string) string {
func parseDefaultPygmentsOpts() (map[string]string, error) {
options := make(map[string]string)
err := parseOptions(options, viper.GetString("PygmentsOptions"))
err := parseOptions(options, viper.GetString("pygmentsOptions"))
if err != nil {
return nil, err
}
if viper.IsSet("PygmentsStyle") {
options["style"] = viper.GetString("PygmentsStyle")
if viper.IsSet("pygmentsStyle") {
options["style"] = viper.GetString("pygmentsStyle")
}
if viper.IsSet("PygmentsUseClasses") {
if viper.GetBool("PygmentsUseClasses") {
if viper.IsSet("pygmentsUseClasses") {
if viper.GetBool("pygmentsUseClasses") {
options["noclasses"] = "false"
} else {
options["noclasses"] = "true"

View File

@@ -35,8 +35,8 @@ func TestParsePygmentsArgs(t *testing.T) {
{"style", "foo", false, false},
} {
viper.Reset()
viper.Set("PygmentsStyle", this.pygmentsStyle)
viper.Set("PygmentsUseClasses", this.pygmentsUseClasses)
viper.Set("pygmentsStyle", this.pygmentsStyle)
viper.Set("pygmentsUseClasses", this.pygmentsUseClasses)
result1, err := parsePygmentsOpts(this.in)
if b, ok := this.expect1.(bool); ok && !b {
@@ -72,14 +72,14 @@ func TestParseDefaultPygmentsArgs(t *testing.T) {
} {
viper.Reset()
viper.Set("PygmentsOptions", this.pygmentsOptions)
viper.Set("pygmentsOptions", this.pygmentsOptions)
if s, ok := this.pygmentsStyle.(string); ok {
viper.Set("PygmentsStyle", s)
viper.Set("pygmentsStyle", s)
}
if b, ok := this.pygmentsUseClasses.(bool); ok {
viper.Set("PygmentsUseClasses", b)
viper.Set("pygmentsUseClasses", b)
}
result, err := parsePygmentsOpts(this.in)

View File

@@ -157,7 +157,7 @@ func (p *PathSpec) AbsURL(in string, addLanguage bool) string {
return in
}
baseURL := viper.GetString("BaseURL")
baseURL := viper.GetString("baseURL")
if strings.HasPrefix(in, "/") {
p, err := url.Parse(baseURL)
if err != nil {
@@ -219,7 +219,7 @@ func IsAbsURL(path string) bool {
// RelURL creates a URL relative to the BaseURL root.
// Note: The result URL will not include the context root if canonifyURLs is enabled.
func (p *PathSpec) RelURL(in string, addLanguage bool) string {
baseURL := viper.GetString("BaseURL")
baseURL := viper.GetString("baseURL")
canonifyURLs := p.canonifyURLs
if (!strings.HasPrefix(in, baseURL) && strings.HasPrefix(in, "http")) || strings.HasPrefix(in, "//") {
return in

View File

@@ -62,10 +62,10 @@ func TestAbsURL(t *testing.T) {
func doTestAbsURL(t *testing.T, defaultInSubDir, addLanguage, multilingual bool, lang string) {
viper.Reset()
viper.Set("Multilingual", multilingual)
viper.Set("CurrentContentLanguage", NewLanguage(lang))
viper.Set("DefaultContentLanguage", "en")
viper.Set("DefaultContentLanguageInSubdir", defaultInSubDir)
viper.Set("multilingual", multilingual)
viper.Set("currentContentLanguage", NewLanguage(lang))
viper.Set("defaultContentLanguage", "en")
viper.Set("defaultContentLanguageInSubdir", defaultInSubDir)
tests := []struct {
input string
@@ -86,7 +86,7 @@ func doTestAbsURL(t *testing.T, defaultInSubDir, addLanguage, multilingual bool,
}
for _, test := range tests {
viper.Set("BaseURL", test.baseURL)
viper.Set("baseURL", test.baseURL)
p := NewPathSpecFromConfig(viper.GetViper())
output := p.AbsURL(test.input, addLanguage)
expected := test.expected
@@ -136,10 +136,10 @@ func TestRelURL(t *testing.T) {
func doTestRelURL(t *testing.T, defaultInSubDir, addLanguage, multilingual bool, lang string) {
viper.Reset()
viper.Set("Multilingual", multilingual)
viper.Set("CurrentContentLanguage", NewLanguage(lang))
viper.Set("DefaultContentLanguage", "en")
viper.Set("DefaultContentLanguageInSubdir", defaultInSubDir)
viper.Set("multilingual", multilingual)
viper.Set("currentContentLanguage", NewLanguage(lang))
viper.Set("defaultContentLanguage", "en")
viper.Set("defaultContentLanguageInSubdir", defaultInSubDir)
tests := []struct {
input string
@@ -162,7 +162,7 @@ func doTestRelURL(t *testing.T, defaultInSubDir, addLanguage, multilingual bool,
}
for i, test := range tests {
viper.Set("BaseURL", test.baseURL)
viper.Set("baseURL", test.baseURL)
viper.Set("canonifyURLs", test.canonify)
p := NewPathSpecFromConfig(viper.GetViper())