hugolib: Fix Java-styled all-caps consts

This commit is contained in:
Bjørn Erik Pedersen 2016-03-22 23:59:07 +01:00
parent b0e21f967b
commit df92fc31ca
3 changed files with 29 additions and 29 deletions

View file

@ -30,7 +30,7 @@ import (
) )
const ( const (
CONF_MENU1 = ` confMenu1 = `
[[menu.main]] [[menu.main]]
name = "Go Home" name = "Go Home"
url = "/" url = "/"
@ -84,7 +84,7 @@ const (
url = "/новости-проекта"` // Russian => "news-project" url = "/новости-проекта"` // Russian => "news-project"
) )
var MENU_PAGE_1 = []byte(`+++ var menuPage1 = []byte(`+++
title = "One" title = "One"
[menu] [menu]
[menu.p_one] [menu.p_one]
@ -92,7 +92,7 @@ weight = 1
+++ +++
Front Matter with Menu Pages`) Front Matter with Menu Pages`)
var MENU_PAGE_2 = []byte(`+++ var menuPage2 = []byte(`+++
title = "Two" title = "Two"
weight = 2 weight = 2
[menu] [menu]
@ -103,7 +103,7 @@ weight = 2
+++ +++
Front Matter with Menu Pages`) Front Matter with Menu Pages`)
var MENU_PAGE_3 = []byte(`+++ var menuPage3 = []byte(`+++
title = "Three" title = "Three"
weight = 3 weight = 3
[menu] [menu]
@ -113,7 +113,7 @@ weight = 3
+++ +++
Front Matter with Menu Pages`) Front Matter with Menu Pages`)
var MENU_PAGE_4 = []byte(`+++ var menuPage4 = []byte(`+++
title = "Four" title = "Four"
weight = 4 weight = 4
[menu] [menu]
@ -123,17 +123,17 @@ weight = 4
+++ +++
Front Matter with Menu Pages`) Front Matter with Menu Pages`)
var MENU_PAGE_SOURCES = []source.ByteSource{ var menuPageSources = []source.ByteSource{
{filepath.FromSlash("sect/doc1.md"), MENU_PAGE_1}, {filepath.FromSlash("sect/doc1.md"), menuPage1},
{filepath.FromSlash("sect/doc2.md"), MENU_PAGE_2}, {filepath.FromSlash("sect/doc2.md"), menuPage2},
{filepath.FromSlash("sect/doc3.md"), MENU_PAGE_3}, {filepath.FromSlash("sect/doc3.md"), menuPage3},
} }
var MENU_PAGE_SECTIONS_SOURCES = []source.ByteSource{ var menuPageSectionsSources = []source.ByteSource{
{filepath.FromSlash("first/doc1.md"), MENU_PAGE_1}, {filepath.FromSlash("first/doc1.md"), menuPage1},
{filepath.FromSlash("first/doc2.md"), MENU_PAGE_2}, {filepath.FromSlash("first/doc2.md"), menuPage2},
{filepath.FromSlash("second-section/doc3.md"), MENU_PAGE_3}, {filepath.FromSlash("second-section/doc3.md"), menuPage3},
{filepath.FromSlash("Fish and Chips/doc4.md"), MENU_PAGE_4}, {filepath.FromSlash("Fish and Chips/doc4.md"), menuPage4},
} }
func tstCreateMenuPageWithNameTOML(title, menu, name string) []byte { func tstCreateMenuPageWithNameTOML(title, menu, name string) []byte {
@ -265,7 +265,7 @@ func TestPageMenu(t *testing.T) {
viper.Reset() viper.Reset()
defer viper.Reset() defer viper.Reset()
s := setupMenuTests(t, MENU_PAGE_SOURCES) s := setupMenuTests(t, menuPageSources)
if len(s.Pages) != 3 { if len(s.Pages) != 3 {
t.Fatalf("Posts not created, expected 3 got %d", len(s.Pages)) t.Fatalf("Posts not created, expected 3 got %d", len(s.Pages))
@ -312,7 +312,7 @@ func TestMenuURL(t *testing.T) {
viper.Reset() viper.Reset()
defer viper.Reset() defer viper.Reset()
s := setupMenuTests(t, MENU_PAGE_SOURCES) s := setupMenuTests(t, menuPageSources)
for i, this := range []struct { for i, this := range []struct {
me *MenuEntry me *MenuEntry
@ -384,7 +384,7 @@ func doTestMenuWithUnicodeURLs(t *testing.T, canonifyURLs bool) {
viper.Set("CanonifyURLs", canonifyURLs) viper.Set("CanonifyURLs", canonifyURLs)
s := setupMenuTests(t, MENU_PAGE_SOURCES) s := setupMenuTests(t, menuPageSources)
unicodeRussian := findTestMenuEntryByID(s, "unicode", "unicode-russian") unicodeRussian := findTestMenuEntryByID(s, "unicode", "unicode-russian")
@ -411,7 +411,7 @@ func doTestSectionPagesMenu(canonifyUrls bool, t *testing.T) {
viper.Set("SectionPagesMenu", "spm") viper.Set("SectionPagesMenu", "spm")
viper.Set("CanonifyURLs", canonifyUrls) viper.Set("CanonifyURLs", canonifyUrls)
s := setupMenuTests(t, MENU_PAGE_SECTIONS_SOURCES) s := setupMenuTests(t, menuPageSectionsSources)
assert.Equal(t, 3, len(s.Sections)) assert.Equal(t, 3, len(s.Sections))
@ -467,7 +467,7 @@ func TestTaxonomyNodeMenu(t *testing.T) {
defer viper.Reset() defer viper.Reset()
viper.Set("CanonifyURLs", true) viper.Set("CanonifyURLs", true)
s := setupMenuTests(t, MENU_PAGE_SOURCES) s := setupMenuTests(t, menuPageSources)
for i, this := range []struct { for i, this := range []struct {
menu string menu string
@ -510,7 +510,7 @@ func TestMenuLimit(t *testing.T) {
viper.Reset() viper.Reset()
defer viper.Reset() defer viper.Reset()
s := setupMenuTests(t, MENU_PAGE_SOURCES) s := setupMenuTests(t, menuPageSources)
m := *s.Menus["main"] m := *s.Menus["main"]
// main menu has 4 entries // main menu has 4 entries
@ -556,7 +556,7 @@ func TestHomeNodeMenu(t *testing.T) {
viper.Set("CanonifyURLs", true) viper.Set("CanonifyURLs", true)
viper.Set("UglyURLs", true) viper.Set("UglyURLs", true)
s := setupMenuTests(t, MENU_PAGE_SOURCES) s := setupMenuTests(t, menuPageSources)
home := s.newHomeNode() home := s.newHomeNode()
homeMenuEntry := &MenuEntry{Name: home.Title, URL: home.URL} homeMenuEntry := &MenuEntry{Name: home.Title, URL: home.URL}
@ -665,7 +665,7 @@ func findDescendantTestMenuEntry(parent *MenuEntry, id string, matcher func(me *
} }
func setupTestMenuState(s *Site, t *testing.T) { func setupTestMenuState(s *Site, t *testing.T) {
menus, err := tomlToMap(CONF_MENU1) menus, err := tomlToMap(confMenu1)
if err != nil { if err != nil {
t.Fatalf("Unable to Read menus: %v", err) t.Fatalf("Unable to Read menus: %v", err)

View file

@ -24,7 +24,7 @@ import (
func TestEncodePage(t *testing.T) { func TestEncodePage(t *testing.T) {
// borrowed from menu_test.go // borrowed from menu_test.go
s := createTestSite(MENU_PAGE_SOURCES) s := createTestSite(menuPageSources)
testSiteSetup(s, t) testSiteSetup(s, t)
_, err := json.Marshal(s) _, err := json.Marshal(s)

View file

@ -26,16 +26,16 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
) )
const SLUG_DOC_1 = "---\ntitle: slug doc 1\nslug: slug-doc-1\naliases:\n - sd1/foo/\n - sd2\n - sd3/\n - sd4.html\n---\nslug doc 1 content\n" const slugDoc1 = "---\ntitle: slug doc 1\nslug: slug-doc-1\naliases:\n - sd1/foo/\n - sd2\n - sd3/\n - sd4.html\n---\nslug doc 1 content\n"
const SLUG_DOC_2 = `--- const slugDoc2 = `---
title: slug doc 2 title: slug doc 2
slug: slug-doc-2 slug: slug-doc-2
--- ---
slug doc 2 content slug doc 2 content
` `
const INDEX_TEMPLATE = "{{ range .Data.Pages }}.{{ end }}" const indexTemplate = "{{ range .Data.Pages }}.{{ end }}"
func must(err error) { func must(err error) {
if err != nil { if err != nil {
@ -55,8 +55,8 @@ func (t *InMemoryAliasTarget) Publish(label string, permalink template.HTML) (er
} }
var urlFakeSource = []source.ByteSource{ var urlFakeSource = []source.ByteSource{
{filepath.FromSlash("content/blue/doc1.md"), []byte(SLUG_DOC_1)}, {filepath.FromSlash("content/blue/doc1.md"), []byte(slugDoc1)},
{filepath.FromSlash("content/blue/doc2.md"), []byte(SLUG_DOC_2)}, {filepath.FromSlash("content/blue/doc2.md"), []byte(slugDoc2)},
} }
// Issue #1105 // Issue #1105
@ -96,7 +96,7 @@ func TestPageCount(t *testing.T) {
Source: &source.InMemorySource{ByteSource: urlFakeSource}, Source: &source.InMemorySource{ByteSource: urlFakeSource},
} }
s.initializeSiteInfo() s.initializeSiteInfo()
s.prepTemplates("indexes/blue.html", INDEX_TEMPLATE) s.prepTemplates("indexes/blue.html", indexTemplate)
if err := s.CreatePages(); err != nil { if err := s.CreatePages(); err != nil {
t.Errorf("Unable to create pages: %s", err) t.Errorf("Unable to create pages: %s", err)