diff options
33 files changed, 313 insertions, 306 deletions
diff --git a/commands/hugo.go b/commands/hugo.go index 58a84cb14..13eadaa52 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -56,8 +56,8 @@ Complete documentation is available at http://gohugo.io`, var hugoCmdV *cobra.Command //Flags that are to be added to commands. -var BuildWatch, IgnoreCache, Draft, Future, UglyUrls, Verbose, Logging, VerboseLog, DisableRSS, DisableSitemap, PluralizeListTitles, NoTimes bool -var Source, CacheDir, Destination, Theme, BaseUrl, CfgFile, LogFile, Editor string +var BuildWatch, IgnoreCache, Draft, Future, UglyURLs, Verbose, Logging, VerboseLog, DisableRSS, DisableSitemap, PluralizeListTitles, NoTimes bool +var Source, CacheDir, Destination, Theme, BaseURL, CfgFile, LogFile, Editor string //Execute adds all child commands to the root command HugoCmd and sets flags appropriately. func Execute() { @@ -89,8 +89,8 @@ func init() { HugoCmd.PersistentFlags().StringVarP(&Destination, "destination", "d", "", "filesystem path to write files to") HugoCmd.PersistentFlags().StringVarP(&Theme, "theme", "t", "", "theme to use (located in /themes/THEMENAME/)") HugoCmd.PersistentFlags().BoolVarP(&Verbose, "verbose", "v", false, "verbose output") - HugoCmd.PersistentFlags().BoolVar(&UglyUrls, "uglyUrls", false, "if true, use /filename.html instead of /filename/") - HugoCmd.PersistentFlags().StringVarP(&BaseUrl, "baseUrl", "b", "", "hostname (and path) to the root eg. http://spf13.com/") + HugoCmd.PersistentFlags().BoolVar(&UglyURLs, "uglyUrls", false, "if true, use /filename.html instead of /filename/") + HugoCmd.PersistentFlags().StringVarP(&BaseURL, "baseUrl", "b", "", "hostname (and path) to the root eg. http://spf13.com/") HugoCmd.PersistentFlags().StringVar(&CfgFile, "config", "", "config file (default is path/config.yaml|json|toml)") HugoCmd.PersistentFlags().StringVar(&Editor, "editor", "", "edit new content with this editor, if provided") HugoCmd.PersistentFlags().BoolVar(&Logging, "log", false, "Enable Logging") @@ -127,10 +127,10 @@ func InitializeConfig() { viper.SetDefault("DefaultLayout", "post") viper.SetDefault("BuildDrafts", false) viper.SetDefault("BuildFuture", false) - viper.SetDefault("UglyUrls", false) + viper.SetDefault("UglyURLs", false) viper.SetDefault("Verbose", false) viper.SetDefault("IgnoreCache", false) - viper.SetDefault("CanonifyUrls", false) + viper.SetDefault("CanonifyURLs", false) viper.SetDefault("Taxonomies", map[string]string{"tag": "tags", "category": "categories"}) viper.SetDefault("Permalinks", make(hugolib.PermalinkOverrides, 0)) viper.SetDefault("Sitemap", hugolib.Sitemap{Priority: -1}) @@ -155,7 +155,7 @@ func InitializeConfig() { } if hugoCmdV.PersistentFlags().Lookup("uglyUrls").Changed { - viper.Set("UglyUrls", UglyUrls) + viper.Set("UglyURLs", UglyURLs) } if hugoCmdV.PersistentFlags().Lookup("disableRSS").Changed { @@ -181,14 +181,14 @@ func InitializeConfig() { if hugoCmdV.PersistentFlags().Lookup("logFile").Changed { viper.Set("LogFile", LogFile) } - if BaseUrl != "" { - if !strings.HasSuffix(BaseUrl, "/") { - BaseUrl = BaseUrl + "/" + if BaseURL != "" { + if !strings.HasSuffix(BaseURL, "/") { + BaseURL = BaseURL + "/" } - viper.Set("BaseUrl", BaseUrl) + viper.Set("BaseURL", BaseURL) } - if viper.GetString("BaseUrl") == "" { + if viper.GetString("BaseURL") == "" { jww.ERROR.Println("No 'baseurl' set in configuration or as a flag. Features like page menus will not work without one.") } diff --git a/commands/server.go b/commands/server.go index 6b145449d..29900f9ce 100644 --- a/commands/server.go +++ b/commands/server.go @@ -84,11 +84,11 @@ func server(cmd *cobra.Command, args []string) { viper.Set("port", serverPort) - BaseUrl, err := fixUrl(BaseUrl) + BaseURL, err := fixURL(BaseURL) if err != nil { jww.ERROR.Fatal(err) } - viper.Set("BaseUrl", BaseUrl) + viper.Set("BaseURL", BaseURL) if err := memStats(); err != nil { jww.ERROR.Println("memstats error:", err) @@ -114,9 +114,9 @@ func serve(port int) { httpFs := &afero.HttpFs{SourceFs: hugofs.DestinationFS} fileserver := http.FileServer(httpFs.Dir(helpers.AbsPathify(viper.GetString("PublishDir")))) - u, err := url.Parse(viper.GetString("BaseUrl")) + u, err := url.Parse(viper.GetString("BaseURL")) if err != nil { - jww.ERROR.Fatalf("Invalid BaseUrl: %s", err) + jww.ERROR.Fatalf("Invalid BaseURL: %s", err) } if u.Path == "" || u.Path == "/" { http.Handle("/", fileserver) @@ -137,10 +137,10 @@ func serve(port int) { // fixUrl massages the BaseUrl into a form needed for serving // all pages correctly. -func fixUrl(s string) (string, error) { +func fixURL(s string) (string, error) { useLocalhost := false if s == "" { - s = viper.GetString("BaseUrl") + s = viper.GetString("BaseURL") useLocalhost = true } if !strings.HasPrefix(s, "http://") && !strings.HasPrefix(s, "https://") { diff --git a/commands/server_test.go b/commands/server_test.go index 57a500859..ea853e801 100644 --- a/commands/server_test.go +++ b/commands/server_test.go @@ -6,11 +6,11 @@ import ( "github.com/spf13/viper" ) -func TestFixUrl(t *testing.T) { +func TestFixURL(t *testing.T) { type data struct { TestName string - CliBaseUrl string - CfgBaseUrl string + CLIBaseURL string + CfgBaseURL string AppendPort bool Port int Result string @@ -28,11 +28,11 @@ func TestFixUrl(t *testing.T) { } for i, test := range tests { - BaseUrl = test.CliBaseUrl - viper.Set("BaseUrl", test.CfgBaseUrl) + BaseURL = test.CLIBaseURL + viper.Set("BaseURL", test.CfgBaseURL) serverAppend = test.AppendPort serverPort = test.Port - result, err := fixUrl(BaseUrl) + result, err := fixURL(BaseURL) if err != nil { t.Errorf("Test #%d %s: unexpected error %s", i, test.TestName, err) } diff --git a/helpers/content.go b/helpers/content.go index d37d9dd28..a327a1e5f 100644 --- a/helpers/content.go +++ b/helpers/content.go @@ -41,7 +41,7 @@ var SummaryDivider = []byte("<!--more-->") type Blackfriday struct { AngledQuotes bool Fractions bool - PlainIdAnchors bool + PlainIDAnchors bool Extensions []string } @@ -50,7 +50,7 @@ func NewBlackfriday() *Blackfriday { return &Blackfriday{ AngledQuotes: false, Fractions: true, - PlainIdAnchors: false, + PlainIDAnchors: false, } } @@ -113,17 +113,17 @@ func BytesToHTML(b []byte) template.HTML { } // GetHtmlRenderer creates a new Renderer with the given configuration. -func GetHtmlRenderer(defaultFlags int, ctx *RenderingContext) blackfriday.Renderer { +func GetHTMLRenderer(defaultFlags int, ctx *RenderingContext) blackfriday.Renderer { renderParameters := blackfriday.HtmlRendererParameters{ FootnoteAnchorPrefix: viper.GetString("FootnoteAnchorPrefix"), FootnoteReturnLinkContents: viper.GetString("FootnoteReturnLinkContents"), } - b := len(ctx.DocumentId) != 0 + b := len(ctx.DocumentID) != 0 - if b && !ctx.getConfig().PlainIdAnchors { - renderParameters.FootnoteAnchorPrefix = ctx.DocumentId + ":" + renderParameters.FootnoteAnchorPrefix - renderParameters.HeaderIDSuffix = ":" + ctx.DocumentId + if b && !ctx.getConfig().PlainIDAnchors { + renderParameters.FootnoteAnchorPrefix = ctx.DocumentID + ":" + renderParameters.FootnoteAnchorPrefix + renderParameters.HeaderIDSuffix = ":" + ctx.DocumentID } htmlFlags := defaultFlags @@ -158,13 +158,13 @@ func getMarkdownExtensions(ctx *RenderingContext) int { } func markdownRender(ctx *RenderingContext) []byte { - return blackfriday.Markdown(ctx.Content, GetHtmlRenderer(0, ctx), + return blackfriday.Markdown(ctx.Content, GetHTMLRenderer(0, ctx), getMarkdownExtensions(ctx)) } func markdownRenderWithTOC(ctx *RenderingContext) []byte { return blackfriday.Markdown(ctx.Content, - GetHtmlRenderer(blackfriday.HTML_TOC, ctx), + GetHTMLRenderer(blackfriday.HTML_TOC, ctx), getMarkdownExtensions(ctx)) } @@ -209,7 +209,7 @@ func ExtractTOC(content []byte) (newcontent []byte, toc []byte) { type RenderingContext struct { Content []byte PageFmt string - DocumentId string + DocumentID string Config *Blackfriday configInit sync.Once } diff --git a/helpers/content_test.go b/helpers/content_test.go index e2410cedd..602ca3785 100644 --- a/helpers/content_test.go +++ b/helpers/content_test.go @@ -7,7 +7,7 @@ import ( "testing" ) -const tstHtmlContent = "<!DOCTYPE html><html><head><script src=\"http://two/foobar.js\"></script></head><body><nav><ul><li hugo-nav=\"section_0\"></li><li hugo-nav=\"section_1\"></li></ul></nav><article>content <a href=\"http://two/foobar\">foobar</a>. Follow up</article><p>This is some text.<br>And some more.</p></body></html>" +const tstHTMLContent = "<!DOCTYPE html><html><head><script src=\"http://two/foobar.js\"></script></head><body><nav><ul><li hugo-nav=\"section_0\"></li><li hugo-nav=\"section_1\"></li></ul></nav><article>content <a href=\"http://two/foobar\">foobar</a>. Follow up</article><p>This is some text.<br>And some more.</p></body></html>" func TestStripHTML(t *testing.T) { type test struct { @@ -31,7 +31,7 @@ func TestStripHTML(t *testing.T) { func BenchmarkStripHTML(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { - StripHTML(tstHtmlContent) + StripHTML(tstHTMLContent) } } diff --git a/helpers/url.go b/helpers/url.go index b3b9779c3..b9b58d050 100644 --- a/helpers/url.go +++ b/helpers/url.go @@ -52,7 +52,7 @@ func (PathBridge) Separator() string { var pathBridge PathBridge -func sanitizeUrlWithFlags(in string, f purell.NormalizationFlags) string { +func sanitizeURLWithFlags(in string, f purell.NormalizationFlags) string { s, err := purell.NormalizeURLString(in, f) if err != nil { return in @@ -88,20 +88,20 @@ func sanitizeUrlWithFlags(in string, f purell.NormalizationFlags) string { } // SanitizeUrl sanitizes the input URL string. -func SanitizeUrl(in string) string { - return sanitizeUrlWithFlags(in, purell.FlagsSafe|purell.FlagRemoveTrailingSlash|purell.FlagRemoveDotSegments|purell.FlagRemoveDuplicateSlashes|purell.FlagRemoveUnnecessaryHostDots|purell.FlagRemoveEmptyPortSeparator) +func SanitizeURL(in string) string { + return sanitizeURLWithFlags(in, purell.FlagsSafe|purell.FlagRemoveTrailingSlash|purell.FlagRemoveDotSegments|purell.FlagRemoveDuplicateSlashes|purell.FlagRemoveUnnecessaryHostDots|purell.FlagRemoveEmptyPortSeparator) } // SanitizeUrlKeepTrailingSlash is the same as SanitizeUrl, but will keep any trailing slash. -func SanitizeUrlKeepTrailingSlash(in string) string { - return sanitizeUrlWithFlags(in, purell.FlagsSafe|purell.FlagRemoveDotSegments|purell.FlagRemoveDuplicateSlashes|purell.FlagRemoveUnnecessaryHostDots|purell.FlagRemoveEmptyPortSeparator) +func SanitizeURLKeepTrailingSlash(in string) string { + return sanitizeURLWithFlags(in, purell.FlagsSafe|purell.FlagRemoveDotSegments|purell.FlagRemoveDuplicateSlashes|purell.FlagRemoveUnnecessaryHostDots|purell.FlagRemoveEmptyPortSeparator) } // Similar to MakePath, but with Unicode handling // Example: // uri: Vim (text editor) // urlize: vim-text-editor -func Urlize(uri string) string { +func URLize(uri string) string { sanitized := MakePathToLower(uri) // escape unicode letters @@ -148,9 +148,9 @@ func MakePermalink(host, plink string) *url.URL { // AddContextRoot adds the context root to an URL if it's not already set. // For relative URL entries on sites with a base url with a context root set (i.e. http://example.com/mysite), // relative URLs must not include the context root if canonifyUrls is enabled. But if it's disabled, it must be set. -func AddContextRoot(baseUrl, relativePath string) string { +func AddContextRoot(baseURL, relativePath string) string { - url, err := url.Parse(baseUrl) + url, err := url.Parse(baseURL) if err != nil { panic(err) } @@ -164,16 +164,16 @@ func AddContextRoot(baseUrl, relativePath string) string { return newPath } -func UrlizeAndPrep(in string) string { - return UrlPrep(viper.GetBool("UglyUrls"), Urlize(in)) +func URLizeAndPrep(in string) string { + return URLPrep(viper.GetBool("UglyURLs"), URLize(in)) } -func UrlPrep(ugly bool, in string) string { +func URLPrep(ugly bool, in string) string { if ugly { - x := Uglify(SanitizeUrl(in)) + x := Uglify(SanitizeURL(in)) return x } - x := PrettifyUrl(SanitizeUrl(in)) + x := PrettifyURL(SanitizeURL(in)) if path.Ext(x) == ".xml" { return x } @@ -186,8 +186,8 @@ func UrlPrep(ugly bool, in string) string { } // PrettifyUrl takes a URL string and returns a semantic, clean URL. -func PrettifyUrl(in string) string { - x := PrettifyUrlPath(in) +func PrettifyURL(in string) string { + x := PrettifyURLPath(in) if path.Base(x) == "index.html" { return path.Dir(x) @@ -205,7 +205,7 @@ func PrettifyUrl(in string) string { // /section/name.html becomes /section/name/index.html // /section/name/ becomes /section/name/index.html // /section/name/index.html becomes /section/name/index.html -func PrettifyUrlPath(in string) string { +func PrettifyURLPath(in string) string { return PrettiyPath(in, pathBridge) } diff --git a/helpers/url_test.go b/helpers/url_test.go index c38750a63..35ade94e5 100644 --- a/helpers/url_test.go +++ b/helpers/url_test.go @@ -19,7 +19,7 @@ func TestUrlize(t *testing.T) { } for _, test := range tests { - output := Urlize(test.input) + output := URLize(test.input) if output != test.expected { t.Errorf("Expected %#v, got %#v\n", test.expected, output) } @@ -36,8 +36,8 @@ func TestSanitizeUrl(t *testing.T) { } for _, test := range tests { - o1 := SanitizeUrl(test.input) - o2 := SanitizeUrlKeepTrailingSlash(test.input) + o1 := SanitizeURL(test.input) + o2 := SanitizeURLKeepTrailingSlash(test.input) expected2 := test.expected @@ -88,7 +88,7 @@ func TestUrlPrep(t *testing.T) { {true, "/section/name/index.html", "/section/name.html"}, } for i, d := range data { - output := UrlPrep(d.ugly, d.input) + output := URLPrep(d.ugly, d.input) if d.output != output { t.Errorf("Test #%d failed. Expected %q got %q", i, d.output, output) } @@ -98,7 +98,7 @@ func TestUrlPrep(t *testing.T) { func TestAddContextRoot(t *testing.T) { tests := []struct { - baseUrl string + baseURL string url string expected string }{ @@ -114,7 +114,7 @@ func TestAddContextRoot(t *testing.T) { } for _, test := range tests { - output := AddContextRoot(test.baseUrl, test.url) + output := AddContextRoot(test.baseURL, test.url) if output != test.expected { t.Errorf("Expected %#v, got %#v\n", test.expected, output) } @@ -122,22 +122,22 @@ func TestAddContextRoot(t *testing.T) { } func TestPretty(t *testing.T) { - assert.Equal(t, PrettifyUrlPath("/section/name.html"), "/section/name/index.html") - assert.Equal(t, PrettifyUrlPath("/section/sub/name.html"), "/section/sub/name/index.html") - assert.Equal(t, PrettifyUrlPath("/section/name/"), "/section/name/index.html") - assert.Equal(t, PrettifyUrlPath("/section/name/index.html"), "/section/name/index.html") - assert.Equal(t, PrettifyUrlPath("/index.html"), "/index.html") - assert.Equal(t, PrettifyUrlPath("/name.xml"), "/name/index.xml") - assert.Equal(t, PrettifyUrlPath("/"), "/") - assert.Equal(t, PrettifyUrlPath(""), "/") - assert.Equal(t, PrettifyUrl("/section/name.html"), "/section/name") - assert.Equal(t, PrettifyUrl("/section/sub/name.html"), "/section/sub/name") - assert.Equal(t, PrettifyUrl("/section/name/"), "/section/name") - assert.Equal(t, PrettifyUrl("/section/name/index.html"), "/section/name") - assert.Equal(t, PrettifyUrl("/index.html"), "/") - assert.Equal(t, PrettifyUrl("/name.xml"), "/name/index.xml") - assert.Equal(t, PrettifyUrl("/"), "/") - assert.Equal(t, PrettifyUrl(""), "/") + assert.Equal(t, PrettifyURLPath("/section/name.html"), "/section/name/index.html") + assert.Equal(t, PrettifyURLPath("/section/sub/name.html"), "/section/sub/name/index.html") + assert.Equal(t, PrettifyURLPath("/section/name/"), "/section/name/index.html") + assert.Equal(t, PrettifyURLPath("/section/name/index.html"), "/section/name/index.html") + assert.Equal(t, PrettifyURLPath("/index.html"), "/index.html") + assert.Equal(t, PrettifyURLPath("/name.xml"), "/name/index.xml") + assert.Equal(t, PrettifyURLPath("/"), "/") + assert.Equal(t, PrettifyURLPath(""), "/") + assert.Equal(t, PrettifyURL("/section/name.html"), "/section/name") + assert.Equal(t, PrettifyURL("/section/sub/name.html"), "/section/sub/name") + assert.Equal(t, PrettifyURL("/section/name/"), "/section/name") + assert.Equal(t, PrettifyURL("/section/name/index.html"), "/section/name") + assert.Equal(t, PrettifyURL("/index.html"), "/") + assert.Equal(t, PrettifyURL("/name.xml"), "/name/index.xml") + assert.Equal(t, PrettifyURL("/"), "/") + assert.Equal(t, PrettifyURL(""), "/") } func TestUgly(t *testing.T) { 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: "tw |