diff options
author | Anthony Fok <foka@debian.org> | 2015-03-11 11:34:57 -0600 |
---|---|---|
committer | bep <bjorn.erik.pedersen@gmail.com> | 2015-03-11 21:55:00 +0100 |
commit | 67df33f50069445d53d373790e8c636e47013a72 (patch) | |
tree | c4e9d646f32aa2a7a40e6c5597b904647bc85e3f /hugolib | |
parent | 00f07c5374d859057c6e7c4731000b5978364819 (diff) |
Correct initialisms as suggested by golint
First step to use initialisms that golint suggests,
for example:
Line 116: func GetHtmlRenderer should be GetHTMLRenderer
as see on http://goreportcard.com/report/spf13/hugo
Thanks to @bep for the idea!
Note that command-line flags (cobra and pflag)
as well as struct fields like .BaseUrl and .Url
that are used in Go HTML templates need more work
to maintain backward-compatibility, and thus
are NOT yet dealt with in this commit.
First step in fixing #959.
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/menu_test.go | 88 | ||||
-rw-r--r-- | hugolib/node.go | 6 | ||||
-rw-r--r-- | hugolib/page.go | 28 | ||||
-rw-r--r-- | hugolib/page_permalink_test.go | 8 | ||||
-rw-r--r-- | hugolib/pagesPrevNext.go | 4 | ||||
-rw-r--r-- | hugolib/pagination.go | 16 | ||||
-rw-r--r-- | hugolib/pagination_test.go | 4 | ||||
-rw-r--r-- | hugolib/path_separators_windows_test.go | 2 | ||||
-rw-r--r-- | hugolib/permalinks.go | 4 | ||||
-rw-r--r-- | hugolib/shortcode.go | 2 | ||||
-rw-r--r-- | hugolib/site.go | 58 | ||||
-rw-r--r-- | hugolib/site_show_plan_test.go | 2 | ||||
-rw-r--r-- | hugolib/site_test.go | 34 | ||||
-rw-r--r-- | hugolib/taxonomy.go | 4 |
14 files changed, 130 insertions, 130 deletions
diff --git a/hugolib/menu_test.go b/hugolib/menu_test.go index c92222adc..bea5a84e4 100644 --- a/hugolib/menu_test.go +++ b/hugolib/menu_test.go @@ -95,7 +95,7 @@ var MENU_PAGE_SOURCES = []source.ByteSource{ {"sect/doc3.md", MENU_PAGE_3}, } -func tstCreateMenuPageWithNameToml(title, menu, name string) []byte { +func tstCreateMenuPageWithNameTOML(title, menu, name string) []byte { return []byte(fmt.Sprintf(`+++ title = "%s" weight = 1 @@ -106,7 +106,7 @@ weight = 1 Front Matter with Menu with Name`, title, menu, name)) } -func tstCreateMenuPageWithIdentifierToml(title, menu, identifier string) []byte { +func tstCreateMenuPageWithIdentifierTOML(title, menu, identifier string) []byte { return []byte(fmt.Sprintf(`+++ title = "%s" weight = 1 @@ -118,7 +118,7 @@ weight = 1 Front Matter with Menu with Identifier`, title, menu, identifier)) } -func tstCreateMenuPageWithNameYaml(title, menu, name string) []byte { +func tstCreateMenuPageWithNameYAML(title, menu, name string) []byte { return []byte(fmt.Sprintf(`--- title: "%s" weight: 1 @@ -129,7 +129,7 @@ menu: Front Matter with Menu with Name`, title, menu, name)) } -func tstCreateMenuPageWithIdentifierYaml(title, menu, identifier string) []byte { +func tstCreateMenuPageWithIdentifierYAML(title, menu, identifier string) []byte { return []byte(fmt.Sprintf(`--- title: "%s" weight: 1 @@ -144,22 +144,22 @@ Front Matter with Menu with Identifier`, title, menu, identifier)) type testMenuState struct { site *Site oldMenu interface{} - oldBaseUrl interface{} + oldBaseURL interface{} } // Issue 817 - identifier should trump everything func TestPageMenuWithIdentifier(t *testing.T) { toml := []source.ByteSource{ - {"sect/doc1.md", tstCreateMenuPageWithIdentifierToml("t1", "m1", "i1")}, - {"sect/doc2.md", tstCreateMenuPageWithIdentifierToml("t1", "m1", "i2")}, - {"sect/doc3.md", tstCreateMenuPageWithIdentifierToml("t1", "m1", "i2")}, // duplicate + {"sect/doc1.md", tstCreateMenuPageWithIdentifierTOML("t1", "m1", "i1")}, + {"sect/doc2.md", tstCreateMenuPageWithIdentifierTOML("t1", "m1", "i2")}, + {"sect/doc3.md", tstCreateMenuPageWithIdentifierTOML("t1", "m1", "i2")}, // duplicate } yaml := []source.ByteSource{ - {"sect/doc1.md", tstCreateMenuPageWithIdentifierYaml("t1", "m1", "i1")}, - {"sect/doc2.md", tstCreateMenuPageWithIdentifierYaml("t1", "m1", "i2")}, - {"sect/doc3.md", tstCreateMenuPageWithIdentifierYaml("t1", "m1", "i2")}, // duplicate + {"sect/doc1.md", tstCreateMenuPageWithIdentifierYAML("t1", "m1", "i1")}, + {"sect/doc2.md", tstCreateMenuPageWithIdentifierYAML("t1", "m1", "i2")}, + {"sect/doc3.md", tstCreateMenuPageWithIdentifierYAML("t1", "m1", "i2")}, // duplicate } doTestPageMenuWithIdentifier(t, toml) @@ -174,8 +174,8 @@ func doTestPageMenuWithIdentifier(t *testing.T, menuPageSources []source.ByteSou assert.Equal(t, 3, len(ts.site.Pages), "Not enough pages") - me1 := ts.findTestMenuEntryById("m1", "i1") - me2 := ts.findTestMenuEntryById("m1", "i2") + me1 := ts.findTestMenuEntryByID("m1", "i1") + me2 := ts.findTestMenuEntryByID("m1", "i2") assert.NotNil(t, me1) assert.NotNil(t, me2) @@ -188,15 +188,15 @@ func doTestPageMenuWithIdentifier(t *testing.T, menuPageSources []source.ByteSou // Issue 817 contd - name should be second identifier in func TestPageMenuWithDuplicateName(t *testing.T) { toml := []source.ByteSource{ - {"sect/doc1.md", tstCreateMenuPageWithNameToml("t1", "m1", "n1")}, - {"sect/doc2.md", tstCreateMenuPageWithNameToml("t1", "m1", "n2")}, - {"sect/doc3.md", tstCreateMenuPageWithNameToml("t1", "m1", "n2")}, // duplicate + {"sect/doc1.md", tstCreateMenuPageWithNameTOML("t1", "m1", "n1")}, + {"sect/doc2.md", tstCreateMenuPageWithNameTOML("t1", "m1", "n2")}, + {"sect/doc3.md", tstCreateMenuPageWithNameTOML("t1", "m1", "n2")}, // duplicate } yaml := []source.ByteSource{ - {"sect/doc1.md", tstCreateMenuPageWithNameYaml("t1", "m1", "n1")}, - {"sect/doc2.md", tstCreateMenuPageWithNameYaml("t1", "m1", "n2")}, - {"sect/doc3.md", tstCreateMenuPageWithNameYaml("t1", "m1", "n2")}, // duplicate + {"sect/doc1.md", tstCreateMenuPageWithNameYAML("t1", "m1", "n1")}, + {"sect/doc2.md", tstCreateMenuPageWithNameYAML("t1", "m1", "n2")}, + {"sect/doc3.md", tstCreateMenuPageWithNameYAML("t1", "m1", "n2")}, // duplicate } doTestPageMenuWithDuplicateName(t, toml) @@ -234,7 +234,7 @@ func TestPageMenu(t *testing.T) { third := ts.site.Pages[2] pOne := ts.findTestMenuEntryByName("p_one", "One") - pTwo := ts.findTestMenuEntryById("p_two", "Two") + pTwo := ts.findTestMenuEntryByID("p_two", "Two") for i, this := range []struct { menu string @@ -267,11 +267,11 @@ func TestPageMenu(t *testing.T) { } // issue #888 -func TestMenuWithHashInUrl(t *testing.T) { +func TestMenuWithHashInURL(t *testing.T) { ts := setupMenuTests(t, MENU_PAGE_SOURCES) defer resetMenuTestState(ts) - me := ts.findTestMenuEntryById("hash", "hash") + me := ts.findTestMenuEntryByID("hash", "hash") assert.NotNil(t, me) @@ -279,41 +279,41 @@ func TestMenuWithHashInUrl(t *testing.T) { } // issue #719 -func TestMenuWithUnicodeUrls(t *testing.T) { - for _, uglyUrls := range []bool{true, false} { - for _, canonifyUrls := range []bool{true, false} { - doTestMenuWithUnicodeUrls(t, canonifyUrls, uglyUrls) +func TestMenuWithUnicodeURLs(t *testing.T) { + for _, uglyURLs := range []bool{true, false} { + for _, canonifyURLs := range []bool{true, false} { + doTestMenuWithUnicodeURLs(t, canonifyURLs, uglyURLs) } } } -func doTestMenuWithUnicodeUrls(t *testing.T, canonifyUrls, uglyUrls bool) { - viper.Set("CanonifyUrls", canonifyUrls) - viper.Set("UglyUrls", uglyUrls) +func doTestMenuWithUnicodeURLs(t *testing.T, canonifyURLs, uglyURLs bool) { + viper.Set("CanonifyURLs", canonifyURLs) + viper.Set("UglyURLs", uglyURLs) ts := setupMenuTests(t, MENU_PAGE_SOURCES) defer resetMenuTestState(ts) - unicodeRussian := ts.findTestMenuEntryById("unicode", "unicode-russian") + unicodeRussian := ts.findTestMenuEntryByID("unicode", "unicode-russian") expectedBase := "/%D0%BD%D0%BE%D0%B2%D0%BE%D1%81%D1%82%D0%B8-%D0%BF%D1%80%D0%BE%D0%B5%D0%BA%D1%82%D0%B0" - if !canonifyUrls { + if !canonifyURLs { expectedBase = "/Zoo" + expectedBase } var expected string - if uglyUrls { + if uglyURLs { expected = expectedBase + ".html" } else { expected = expectedBase + "/" } - assert.Equal(t, expected, unicodeRussian.Url, "uglyUrls[%t]", uglyUrls) + assert.Equal(t, expected, unicodeRussian.Url, "uglyURLs[%t]", uglyURLs) } func TestTaxonomyNodeMenu(t *testing.T) { - viper.Set("CanonifyUrls", true) + viper.Set("CanonifyURLs", true) ts := setupMenuTests(t, MENU_PAGE_SOURCES) defer resetMenuTestState(ts) @@ -325,9 +325,9 @@ func TestTaxonomyNodeMenu(t *testing.T) { hasMenuCurrent bool }{ {"tax", taxRenderInfo{key: "key", singular: "one", plural: "two"}, - ts.findTestMenuEntryById("tax", "1"), true, false}, + ts.findTestMenuEntryByID("tax", "1"), true, false}, {"tax", taxRenderInfo{key: "key", singular: "one", plural: "two"}, - ts.findTestMenuEntryById("tax", "2"), true, false}, + ts.findTestMenuEntryByID("tax", "2"), true, false}, {"tax", taxRenderInfo{key: "key", singular: "one", plural: "two"}, &MenuEntry{Name: "Somewhere else", Url: "/somewhereelse"}, false, false}, } { @@ -347,9 +347,9 @@ func TestTaxonomyNodeMenu(t *testing.T) { } - menuEntryXml := ts.findTestMenuEntryById("tax", "xml") + menuEntryXML := ts.findTestMenuEntryByID("tax", "xml") - if strings.HasSuffix(menuEntryXml.Url, "/") { + if strings.HasSuffix(menuEntryXML.Url, "/") { t.Error("RSS menu item should not be padded with trailing slash") } } @@ -370,9 +370,9 @@ func TestHomeNodeMenu(t *testing.T) { {"main", homeMenuEntry, true, false}, {"doesnotexist", homeMenuEntry, false, false}, {"main", &MenuEntry{Name: "Somewhere else", Url: "/somewhereelse"}, false, false}, - {"grandparent", ts.findTestMenuEntryById("grandparent", "grandparentId"), false, false}, - {"grandparent", ts.findTestMenuEntryById("grandparent", "parentId"), false, true}, - {"grandparent", ts.findTestMenuEntryById("grandparent", "grandchildId"), true, false}, + {"grandparent", ts.findTestMenuEntryByID("grandparent", "grandparentId"), false, false}, + {"grandparent", ts.findTestMenuEntryByID("grandparent", "parentId"), false, true}, + {"grandparent", ts.findTestMenuEntryByID("grandparent", "grandchildId"), true, false}, } { isMenuCurrent := home.IsMenuCurrent(this.menu, this.menuItem) @@ -391,7 +391,7 @@ func TestHomeNodeMenu(t *testing.T) { var testMenuIdentityMatcher = func(me *MenuEntry, id string) bool { return me.Identifier == id } var testMenuNameMatcher = func(me *MenuEntry, id string) bool { return me.Name == id } -func (ts testMenuState) findTestMenuEntryById(mn string, id string) *MenuEntry { +func (ts testMenuState) findTestMenuEntryByID(mn string, id string) *MenuEntry { return ts.findTestMenuEntry(mn, id, testMenuIdentityMatcher) } func (ts testMenuState) findTestMenuEntryByName(mn string, id string) *MenuEntry { @@ -447,7 +447,7 @@ func (ts testMenuState) findDescendantTestMenuEntry(parent *MenuEntry, id string } func getTestMenuState(s *Site, t *testing.T) *testMenuState { - menuState := &testMenuState{site: s, oldBaseUrl: viper.Get("baseurl"), oldMenu: viper.Get("menu")} + menuState := &testMenuState{site: s, oldBaseURL: viper.Get("baseurl"), oldMenu: viper.Get("menu")} menus, err := tomlToMap(CONF_MENU1) @@ -471,7 +471,7 @@ func setupMenuTests(t *testing.T, pageSources []source.ByteSource) *testMenuStat func resetMenuTestState(state *testMenuState) { viper.Set("menu", state.oldMenu) - viper.Set("baseurl", state.oldBaseUrl) + viper.Set("baseurl", state.oldBaseURL) } func createTestSite(pageSources []source.ByteSource) *Site { diff --git a/hugolib/node.go b/hugolib/node.go index 604b5475a..aa9a46d99 100644 --- a/hugolib/node.go +++ b/hugolib/node.go @@ -40,7 +40,7 @@ func (n *Node) Now() time.Time { return time.Now() } -func (n *Node) HasMenuCurrent(menuId string, inme *MenuEntry) bool { +func (n *Node) HasMenuCurrent(menuID string, inme *MenuEntry) bool { if inme.HasChildren() { me := MenuEntry{Name: n.Title, Url: n.Url} @@ -54,7 +54,7 @@ func (n *Node) HasMenuCurrent(menuId string, inme *MenuEntry) bool { return false } -func (n *Node) IsMenuCurrent(menuId string, inme *MenuEntry) bool { +func (n *Node) IsMenuCurrent(menuID string, inme *MenuEntry) bool { me := MenuEntry{Name: n.Title, Url: n.Url} if !me.IsSameResource(inme) { @@ -63,7 +63,7 @@ func (n *Node) IsMenuCurrent(menuId string, inme *MenuEntry) bool { // this resource may be included in several menus // search for it to make sure that it is in the menu with the given menuId - if menu, ok := (*n.Site.Menus)[menuId]; ok { + if menu, ok := (*n.Site.Menus)[menuID]; ok { for _, menuEntry := range *menu { if menuEntry.IsSameResource(inme) { return true diff --git a/hugolib/page.go b/hugolib/page.go index a32774891..9aa301037 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -149,8 +149,8 @@ func (p *Page) Authors() AuthorList { return al } -func (p *Page) UniqueId() string { - return p.Source.UniqueId() +func (p *Page) UniqueID() string { + return p.Source.UniqueID() } func (p *Page) Ref(ref string) (string, error) { @@ -200,12 +200,12 @@ func (p *Page) setSummary() { func (p *Page) renderBytes(content []byte) []byte { return helpers.RenderBytes( &helpers.RenderingContext{Content: content, PageFmt: p.guessMarkupType(), - DocumentId: p.UniqueId(), Config: p.getRenderingConfig()}) + DocumentID: p.UniqueID(), Config: p.getRenderingConfig()}) } func (p *Page) renderContent(content []byte) []byte { return helpers.RenderBytesWithTOC(&helpers.RenderingContext{Content: content, PageFmt: p.guessMarkupType(), - DocumentId: p.UniqueId(), Config: p.getRenderingConfig()}) + DocumentID: p.UniqueID(), Config: p.getRenderingConfig()}) } func (p *Page) getRenderingConfig() *helpers.Blackfriday { @@ -341,15 +341,15 @@ func (p *Page) analyzePage() { } func (p *Page) permalink() (*url.URL, error) { - baseUrl := string(p.Site.BaseUrl) + baseURL := string(p.Site.BaseUrl) dir := strings.TrimSpace(filepath.ToSlash(p.Source.Dir())) pSlug := strings.TrimSpace(p.Slug) - pUrl := strings.TrimSpace(p.Url) + pURL := strings.TrimSpace(p.Url) var permalink string var err error - if len(pUrl) > 0 { - return helpers.MakePermalink(baseUrl, pUrl), nil + if len(pURL) > 0 { + return helpers.MakePermalink(baseURL, pURL), nil } if override, ok := p.Site.Permalinks[p.Section()]; ok { @@ -361,14 +361,14 @@ func (p *Page) permalink() (*url.URL, error) { // fmt.Printf("have a section override for %q in section %s → %s\n", p.Title, p.Section, permalink) } else { if len(pSlug) > 0 { - permalink = helpers.UrlPrep(viper.GetBool("UglyUrls"), path.Join(dir, p.Slug+"."+p.Extension())) + permalink = helpers.URLPrep(viper.GetBool("UglyURLs"), path.Join(dir, p.Slug+"."+p.Extension())) } else { _, t := filepath.Split(p.Source.LogicalName()) - permalink = helpers.UrlPrep(viper.GetBool("UglyUrls"), path.Join(dir, helpers.ReplaceExtension(strings.TrimSpace(t), p.Extension()))) + permalink = helpers.URLPrep(viper.GetBool("UglyURLs"), path.Join(dir, helpers.ReplaceExtension(strings.TrimSpace(t), p.Extension()))) } } - return helpers.MakePermalink(baseUrl, permalink), nil + return helpers.MakePermalink(baseURL, permalink), nil } func (p *Page) Extension() string { @@ -419,7 +419,7 @@ func (p *Page) RelPermalink() (string, error) { return "", err } - if viper.GetBool("CanonifyUrls") { + if viper.GetBool("CanonifyURLs") { // replacements for relpermalink with baseUrl on the form http://myhost.com/sub/ will fail later on // have to return the Url relative from baseUrl relpath, err := helpers.GetRelativePath(link.String(), string(p.Site.BaseUrl)) @@ -452,12 +452,12 @@ func (p *Page) update(f interface{}) error { case "description": p.Description = cast.ToString(v) case "slug": - p.Slug = helpers.Urlize(cast.ToString(v)) + p.Slug = helpers.URLize(cast.ToString(v)) case "url": if url := cast.ToString(v); strings.HasPrefix(url, "http://") || strings.HasPrefix(url, "https://") { return fmt.Errorf("Only relative urls are supported, %v provided", url) } - p.Url = helpers.Urlize(cast.ToString(v)) + p.Url = helpers.URLize(cast.ToString(v)) case "type": p.contentType = cast.ToString(v) case "extension", "ext": diff --git a/hugolib/page_permalink_test.go b/hugolib/page_permalink_test.go index b73e08721..dc4dc8371 100644 --- a/hugolib/page_permalink_test.go +++ b/hugolib/page_permalink_test.go @@ -16,8 +16,8 @@ func TestPermalink(t *testing.T) { base template.URL slug string url string - uglyUrls bool - canonifyUrls bool + uglyURLs bool + canonifyURLs bool expectedAbs string expectedRel string }{ @@ -42,8 +42,8 @@ func TestPermalink(t *testing.T) { viper.Set("DefaultExtension", "html") for i, test := range tests { - viper.Set("uglyurls", test.uglyUrls) - viper.Set("canonifyurls", test.canonifyUrls) + viper.Set("uglyurls", test.uglyURLs) + viper.Set("canonifyurls", test.canonifyURLs) p := &Page{ Node: Node{ UrlPath: UrlPath{ diff --git a/hugolib/pagesPrevNext.go b/hugolib/pagesPrevNext.go index 5a7bc3809..4ffc11653 100644 --- a/hugolib/pagesPrevNext.go +++ b/hugolib/pagesPrevNext.go @@ -15,7 +15,7 @@ package hugolib func (p Pages) Prev(cur *Page) *Page { for x, c := range p { - if c.UniqueId() == cur.UniqueId() { + if c.UniqueID() == cur.UniqueID() { if x == 0 { return p[len(p)-1] } @@ -27,7 +27,7 @@ func (p Pages) Prev(cur *Page) *Page { func (p Pages) Next(cur *Page) *Page { for x, c := range p { - if c.UniqueId() == cur.UniqueId() { + if c.UniqueID() == cur.UniqueID() { if x < len(p)-1 { return p[x+1] } diff --git a/hugolib/pagination.go b/hugolib/pagination.go index 55d7104b6..b56e64f7f 100644 --- a/hugolib/pagination.go +++ b/hugolib/pagination.go @@ -35,12 +35,12 @@ var paginatorEmptyPages Pages type paginator struct { paginatedPages []Pages pagers - paginationUrlFactory + paginationURLFactory total int size int } -type paginationUrlFactory func(int) string +type paginationURLFactory func(int) string // PageNumber returns the current page's number in the pager sequence. func (p *pager) PageNumber() int { @@ -49,7 +49,7 @@ func (p *pager) PageNumber() int { // Url returns the url to the current page. func (p *pager) Url() template.HTML { - return template.HTML(p.paginationUrlFactory(p.PageNumber())) + return template.HTML(p.paginationURLFactory(p.PageNumber())) } // Pages returns the elements on this page. @@ -225,14 +225,14 @@ func paginatePages(seq interface{}, section string) (pagers, error) { return nil, errors.New(fmt.Sprintf("unsupported type in paginate, got %T", seq)) } - urlFactory := newPaginationUrlFactory(section) + urlFactory := newPaginationURLFactory(section) paginator, _ := newPaginator(pages, paginateSize, urlFactory) pagers := paginator.Pagers() return pagers, nil } -func newPaginator(pages Pages, size int, urlFactory paginationUrlFactory) (*paginator, error) { +func newPaginator(pages Pages, size int, urlFactory paginationURLFactory) (*paginator, error) { if size <= 0 { return nil, errors.New("Paginator size must be positive") @@ -240,7 +240,7 @@ func newPaginator(pages Pages, size int, urlFactory paginationUrlFactory) (*pagi split := splitPages(pages, size) - p := &paginator{total: len(pages), paginatedPages: split, size: size, paginationUrlFactory: urlFactory} + p := &paginator{total: len(pages), paginatedPages: split, size: size, paginationURLFactory: urlFactory} var ps pagers @@ -259,7 +259,7 @@ func newPaginator(pages Pages, size int, urlFactory paginationUrlFactory) (*pagi return p, nil } -func newPaginationUrlFactory(pathElements ...string) paginationUrlFactory { +func newPaginationURLFactory(pathElements ...string) paginationURLFactory { paginatePath := viper.GetString("paginatePath") return func(page int) string { @@ -270,6 +270,6 @@ func newPaginationUrlFactory(pathElements ...string) paginationUrlFactory { rel = fmt.Sprintf("/%s/%s/%d/", path.Join(pathElements...), paginatePath, page) } - return helpers.UrlizeAndPrep(rel) + return helpers.URLizeAndPrep(rel) } } diff --git a/hugolib/pagination_test.go b/hugolib/pagination_test.go index 5d4612867..7d3b2ae72 100644 --- a/hugolib/pagination_test.go +++ b/hugolib/pagination_test.go @@ -99,8 +99,8 @@ func TestPagerNoPages(t *testing.T) { func TestPaginationUrlFactory(t *testing.T) { viper.Set("PaginatePath", "zoo") - unicode := newPaginationUrlFactory("новости проекта") - fooBar := newPaginationUrlFactory("foo", "bar") + unicode := newPaginationURLFactory("новости проекта") + fooBar := newPaginationURLFactory("foo", "bar") assert.Equal(t, "/%D0%BD%D0%BE%D0%B2%D0%BE%D1%81%D1%82%D0%B8-%D0%BF%D1%80%D0%BE%D0%B5%D0%BA%D1%82%D0%B0/", unicode(1)) assert.Equal(t, "/foo/bar/", fooBar(1)) diff --git a/hugolib/path_separators_windows_test.go b/hugolib/path_separators_windows_test.go index f9af74dcb..4d8e0c48b 100644 --- a/hugolib/path_separators_windows_test.go +++ b/hugolib/path_separators_windows_test.go @@ -11,7 +11,7 @@ const ( ) func TestTemplatePathSeparator(t *testing.T) { - tmpl := new(tpl.GoHtmlTemplate) + tmpl := new(tpl.GoHTMLTemplate) if name := tmpl.GenerateTemplateNameFrom(win_base, win_path); name != "sub1/index.html" { t.Fatalf("Template name incorrect. Expected: %s, Got: %s", "sub1/index.html", name) } diff --git a/hugolib/permalinks.go b/hugolib/permalinks.go index 642de8378..fdae2b856 100644 --- a/hugolib/permalinks.go +++ b/hugolib/permalinks.go @@ -139,14 +139,14 @@ func pageToPermalinkDate(p *Page, dateField string) (string, error) { func pageToPermalinkTitle(p *Page, _ string) (string, error) { // Page contains Node which has Title // (also contains UrlPath which has Slug, sometimes) - return helpers.Urlize(p.Title), nil + return helpers.URLize(p.Title), nil } // pageToPermalinkFilename returns the URL-safe form of the filename func pageToPermalinkFilename(p *Page, _ string) (string, error) { //var extension = p.Source.Ext //var name = p.Source.Path()[0 : len(p.Source.Path())-len(extension)] - return helpers.Urlize(p.Source.BaseFileName()), nil + return helpers.URLize(p.Source.BaseFileName()), nil } // if the page has a slug, return the slug, else return the title diff --git a/hugolib/shortcode.go b/hugolib/shortcode.go index ca310d6b0..f1db1dc19 100644 --- a/hugolib/shortcode.go +++ b/hugolib/shortcode.go @@ -203,7 +203,7 @@ func renderShortcode(sc shortcode, p *Page, t tpl.Template) string { if sc.doMarkup { newInner := helpers.RenderBytes(&helpers.RenderingContext{ Content: []byte(inner), PageFmt: p.guessMarkupType(), - DocumentId: p.UniqueId(), Config: p.getRenderingConfig()}) + DocumentID: p.UniqueID(), Config: p.getRenderingConfig()}) // If the type is “unknown” or “markdown”, we assume the markdown // generation has been performed. Given the input: `a line`, markdown diff --git a/hugolib/site.go b/hugolib/site.go index bde869265..83e097e6e 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -113,7 +113,7 @@ type SiteInfo struct { Permalinks PermalinkOverrides Params map[string]interface{} BuildDrafts bool - canonifyUrls bool + canonifyURLs bool paginationPageCount uint64 Data *map[string]interface{} } @@ -158,10 +158,10 @@ func (s *SiteInfo) GetParam(key string) interface{} { } func (s *SiteInfo) refLink(ref string, page *Page, relative bool) (string, error) { - var refUrl *url.URL + var refURL *url.URL var err error - refUrl, err = url.Parse(ref) + refURL, err = url.Parse(ref) if err != nil { return "", err @@ -170,16 +170,16 @@ func (s *SiteInfo) refLink(ref string, page *Page, relative bool) (string, error var target *Page var link string - if refUrl.Path != "" { + if refURL.Path != "" { for _, page := range []*Page(*s.Pages) { - if page.Source.Path() == refUrl.Path || page.Source.LogicalName() == refUrl.Path { + if page.Source.Path() == refURL.Path || page.Source.LogicalName() == refURL.Path { target = page break } } if target == nil { - return "", fmt.Errorf("No page found with path or logical name \"%s\".\n", refUrl.Path) + return "", fmt.Errorf("No page found with path or logical name \"%s\".\n", refURL.Path) } if relative { @@ -193,13 +193,13 @@ func (s *SiteInfo) refLink(ref string, page *Page, relative bool) (string, error } } - if refUrl.Fragment != "" { - link = link + "#" + refUrl.Fragment + if refURL.Fragment != "" { + link = link + "#" + refURL.Fragment - if refUrl.Path != "" && target != nil && !target.getRenderingConfig().PlainIdAnchors { - link = link + ":" + target.UniqueId() - } else if page != nil && !page.getRenderingConfig().PlainIdAnchors { - link = link + ":" + page.UniqueId() + if refURL.Path != "" && target != nil && !target.getRenderingConfig().PlainIDAnchors { + link = link + ":" + target.UniqueID() + } else if page != nil && !page.getRenderingConfig().PlainIDAnchors { + link = link + ":" + page.UniqueID() } } @@ -316,11 +316,11 @@ func (s *Site) loadData(sources []source.Input) (err error) { func readData(f *source.File) (interface{}, error) { switch f.Extension() { case "yaml", "yml": - return parser.HandleYamlMetaData(f.Bytes()) + return parser.HandleYAMLMetaData(f.Bytes()) case "json": - return parser.HandleJsonMetaData(f.Bytes()) + return parser.HandleJSONMetaData(f.Bytes()) case "toml": - return parser.HandleTomlMetaData(f.Bytes()) + return parser.HandleTOMLMetaData(f.Bytes()) default: return nil, fmt.Errorf("Data not supported for extension '%s'", f.Extension()) } @@ -444,14 +444,14 @@ func (s *Site) initializeSiteInfo() { } s.Info = SiteInfo{ - BaseUrl: template.URL(helpers.SanitizeUrlKeepTrailingSlash(viper.GetString("BaseUrl"))), + BaseUrl: template.URL(helpers.SanitizeURLKeepTrailingSlash(viper.GetString("BaseURL"))), Title: viper.GetString("Title"), Author: viper.GetStringMap("author"), LanguageCode: viper.GetString("languagecode"), Copyright: viper.GetString("copyright"), DisqusShortname: viper.GetString("DisqusShortname"), BuildDrafts: viper.GetBool("BuildDrafts"), - canonifyUrls: viper.GetBool("CanonifyUrls"), + canonifyURLs: viper.GetBool("CanonifyURLs"), Pages: &s.Pages, Recent: &s.Pages, Menus: &s.Menus, @@ -706,12 +706,12 @@ func (s *Site) getMenusFromConfig() Menus { if strings.HasPrefix(menuEntry.Url, "/") { // make it match the nodes - menuEntryUrl := menuEntry.Url - menuEntryUrl = helpers.UrlizeAndPrep(menuEntryUrl) - if !s.Info.canonifyUrls { - menuEntryUrl = helpers.AddContextRoot(string(s.Info.BaseUrl), menuEntryUrl) + menuEntryURL := menuEntry.Url + menuEntryURL = helpers.URLizeAndPrep(menuEntryURL) + if !s.Info.canonifyURLs { + menuEntryURL = helpers.AddContextRoot(string(s.Info.BaseUrl), menuEntryURL) } - menuEntry.Url = menuEntryUrl + menuEntry.Url = menuEntryURL } if ret[name] == nil { @@ -1249,7 +1249,7 @@ func (s *Site) RenderHomePage() error { } } - n.Url = helpers.Urlize("404.html") + n.Url = helpers.URLize("404.html") n.Title = "404 Page not found" n.Permalink = s.permalink("404.html") @@ -1315,7 +1315,7 @@ func (s *Site) Stats() { } func (s *Site) setUrls(n *Node, in string) { - n.Url = helpers.UrlizeAndPrep(in) + n.Url = helpers.URLizeAndPrep(in) n.Permalink = s.permalink(n.Url) n.RSSLink = s.permalink(in + ".xml") } @@ -1325,7 +1325,7 @@ func (s *Site) permalink(plink string) template.HTML { } func (s *Site) permalinkStr(plink string) string { - return helpers.MakePermalink(string(viper.GetString("BaseUrl")), helpers.UrlizeAndPrep(plink)).String()< |