summaryrefslogtreecommitdiffstats
path: root/helpers
diff options
context:
space:
mode:
authorAlbert Nigmatzianov <albertnigma@gmail.com>2016-10-24 20:56:00 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-10-24 20:56:00 +0200
commitf21e2f25c99c547a2f35d209935f8f1c52fa2671 (patch)
treef2bb860213e88b0244c31144cfcd872665096f06 /helpers
parentd9f54a13c14f12ccc8af33e9dbd611c2cd113324 (diff)
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.
Diffstat (limited to 'helpers')
-rw-r--r--helpers/configProvider.go2
-rw-r--r--helpers/content.go8
-rw-r--r--helpers/content_renderer.go6
-rw-r--r--helpers/content_renderer_test.go6
-rw-r--r--helpers/language.go4
-rw-r--r--helpers/path.go6
-rw-r--r--helpers/path_test.go12
-rw-r--r--helpers/pygments.go21
-rw-r--r--helpers/pygments_test.go10
-rw-r--r--helpers/url.go4
-rw-r--r--helpers/url_test.go20
11 files changed, 50 insertions, 49 deletions
diff --git a/helpers/configProvider.go b/helpers/configProvider.go
index a631ea63d..e63112c0c 100644
--- a/helpers/configProvider.go
+++ b/helpers/configProvider.go
@@ -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.
diff --git a/helpers/content.go b/helpers/content.go
index 5c9533330..eb8987b33 100644
--- a/helpers/content.go
+++ b/helpers/content.go
@@ -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
diff --git a/helpers/content_renderer.go b/helpers/content_renderer.go
index 6bd2212e1..dbc29f431 100644
--- a/helpers/content_renderer.go
+++ b/helpers/content_renderer.go
@@ -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 {
diff --git a/helpers/content_renderer_test.go b/helpers/content_renderer_test.go
index 7baaadb20..82168fcfd 100644
--- a/helpers/content_renderer_test.go
+++ b/helpers/content_renderer_test.go
@@ -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)
diff --git a/helpers/language.go b/helpers/language.go
index 0a1affd18..4bde0aff6 100644
--- a/helpers/language.go
+++ b/helpers/language.go
@@ -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
diff --git a/helpers/path.go b/helpers/path.go
index cf49858ee..68a72b71a 100644
--- a/helpers/path.go
+++ b/helpers/path.go
@@ -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))
diff --git a/helpers/path_test.go b/helpers/path_test.go
index ef0c16505..049499108 100644
--- a/helpers/path_test.go
+++ b/helpers/path_test.go
@@ -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 {
diff --git a/helpers/pygments.go b/helpers/pygments.go
index 6f7485845..d729be5dc 100644
--- a/helpers/pygments.go
+++ b/helpers/pygments.go
@@ -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"
diff --git a/helpers/pygments_test.go b/helpers/pygments_test.go
index 7ee07828c..1cca68eac 100644
--- a/helpers/pygments_test.go
+++ b/helpers/pygments_test.go
@@ -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)
diff --git a/helpers/url.go b/helpers/url.go
index ffb0ba234..3c178f0ff 100644
--- a/helpers/url.go
+++ b/helpers/url.go
@@ -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
diff --git a/helpers/url_test.go b/helpers/url_test.go
index 5394e9573..4072b40e2 100644
--- a/helpers/url_test.go
+++ b/helpers/url_test.go
@@ -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())