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.
This commit is contained in:
Anthony Fok
2015-03-11 11:34:57 -06:00
committed by bep
parent 00f07c5374
commit 67df33f500
33 changed files with 310 additions and 303 deletions

View File

@@ -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()
return helpers.MakePermalink(string(viper.GetString("BaseURL")), helpers.URLizeAndPrep(plink)).String()
}
func (s *Site) NewNode() *Node {
@@ -1348,7 +1348,7 @@ func (s *Site) renderAndWriteXML(name string, dest string, d interface{}, layout
err := s.render(name, d, renderBuffer, layouts...)
absURLInXML, err := transform.AbsURLInXML(viper.GetString("BaseUrl"))
absURLInXML, err := transform.AbsURLInXML(viper.GetString("BaseURL"))
if err != nil {
return err
}
@@ -1377,8 +1377,8 @@ func (s *Site) renderAndWritePage(name string, dest string, d interface{}, layou
transformLinks := transform.NewEmptyTransforms()
if viper.GetBool("CanonifyUrls") {
absURL, err := transform.AbsURL(viper.GetString("BaseUrl"))
if viper.GetBool("CanonifyURLs") {
absURL, err := transform.AbsURL(viper.GetString("BaseURL"))
if err != nil {
return err
}
@@ -1460,7 +1460,7 @@ func (s *Site) initTargetList() {
if s.Targets.Page == nil {
s.Targets.Page = &target.PagePub{
PublishDir: s.absPublishDir(),
UglyUrls: viper.GetBool("UglyUrls"),
UglyURLs: viper.GetBool("UglyURLs"),
}
}
if s.Targets.File == nil {