diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-25 19:36:50 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-27 15:43:56 +0200 |
commit | 09c88e84d196e6c0943b220cd6526d3473c530b6 (patch) | |
tree | 6bc3c0e7abe4c1d8d47b02a72e6dc855a2ad5d45 /hugolib | |
parent | 24c1770288803bd7a344f5903dd4f03cccc6a8f0 (diff) |
output: Rename HTMLType etc. to HTMLFormat
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/page.go | 2 | ||||
-rw-r--r-- | hugolib/page_paths_test.go | 36 | ||||
-rw-r--r-- | hugolib/pagination_test.go | 34 | ||||
-rw-r--r-- | hugolib/site_output.go | 7 | ||||
-rw-r--r-- | hugolib/site_output_test.go | 6 |
5 files changed, 41 insertions, 44 deletions
diff --git a/hugolib/page.go b/hugolib/page.go index f32f1ac0b..7dfc49faa 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -212,7 +212,7 @@ type Page struct { } func (p *Page) RSSLink() template.URL { - f, found := p.outputFormats.GetByName(output.RSSType.Name) + f, found := p.outputFormats.GetByName(output.RSSFormat.Name) if !found { return "" } diff --git a/hugolib/page_paths_test.go b/hugolib/page_paths_test.go index ac322d19c..ded8e6997 100644 --- a/hugolib/page_paths_test.go +++ b/hugolib/page_paths_test.go @@ -37,88 +37,88 @@ func TestPageTargetPath(t *testing.T) { d targetPathDescriptor expected string }{ - {"JSON home", targetPathDescriptor{Kind: KindHome, Type: output.JSONType}, "/index.json"}, - {"AMP home", targetPathDescriptor{Kind: KindHome, Type: output.AMPType}, "/amp/index.html"}, - {"HTML home", targetPathDescriptor{Kind: KindHome, BaseName: "_index", Type: output.HTMLType}, "/index.html"}, + {"JSON home", targetPathDescriptor{Kind: KindHome, Type: output.JSONFormat}, "/index.json"}, + {"AMP home", targetPathDescriptor{Kind: KindHome, Type: output.AMPFormat}, "/amp/index.html"}, + {"HTML home", targetPathDescriptor{Kind: KindHome, BaseName: "_index", Type: output.HTMLFormat}, "/index.html"}, {"HTML section list", targetPathDescriptor{ Kind: KindSection, Sections: []string{"sect1"}, BaseName: "_index", - Type: output.HTMLType}, "/sect1/index.html"}, + Type: output.HTMLFormat}, "/sect1/index.html"}, {"HTML taxonomy list", targetPathDescriptor{ Kind: KindTaxonomy, Sections: []string{"tags", "hugo"}, BaseName: "_index", - Type: output.HTMLType}, "/tags/hugo/index.html"}, + Type: output.HTMLFormat}, "/tags/hugo/index.html"}, {"HTML taxonomy term", targetPathDescriptor{ Kind: KindTaxonomy, Sections: []string{"tags"}, BaseName: "_index", - Type: output.HTMLType}, "/tags/index.html"}, + Type: output.HTMLFormat}, "/tags/index.html"}, { "HTML page", targetPathDescriptor{ Kind: KindPage, Dir: "/a/b", BaseName: "mypage", Sections: []string{"a"}, - Type: output.HTMLType}, "/a/b/mypage/index.html"}, + Type: output.HTMLFormat}, "/a/b/mypage/index.html"}, { "HTML page with special chars", targetPathDescriptor{ Kind: KindPage, Dir: "/a/b", BaseName: "My Page!", - Type: output.HTMLType}, "/a/b/My-Page/index.html"}, - {"RSS home", targetPathDescriptor{Kind: kindRSS, Type: output.RSSType}, "/index.xml"}, + Type: output.HTMLFormat}, "/a/b/My-Page/index.html"}, + {"RSS home", targetPathDescriptor{Kind: kindRSS, Type: output.RSSFormat}, "/index.xml"}, {"RSS section list", targetPathDescriptor{ Kind: kindRSS, Sections: []string{"sect1"}, - Type: output.RSSType}, "/sect1/index.xml"}, + Type: output.RSSFormat}, "/sect1/index.xml"}, { "AMP page", targetPathDescriptor{ Kind: KindPage, Dir: "/a/b/c", BaseName: "myamp", - Type: output.AMPType}, "/amp/a/b/c/myamp/index.html"}, + Type: output.AMPFormat}, "/amp/a/b/c/myamp/index.html"}, { "AMP page with URL with suffix", targetPathDescriptor{ Kind: KindPage, Dir: "/sect/", BaseName: "mypage", URL: "/some/other/url.xhtml", - Type: output.HTMLType}, "/some/other/url.xhtml"}, + Type: output.HTMLFormat}, "/some/other/url.xhtml"}, { "JSON page with URL without suffix", targetPathDescriptor{ Kind: KindPage, Dir: "/sect/", BaseName: "mypage", URL: "/some/other/path/", - Type: output.JSONType}, "/some/other/path/index.json"}, + Type: output.JSONFormat}, "/some/other/path/index.json"}, { "JSON page with URL without suffix and no trailing slash", targetPathDescriptor{ Kind: KindPage, Dir: "/sect/", BaseName: "mypage", URL: "/some/other/path", - Type: output.JSONType}, "/some/other/path/index.json"}, + Type: output.JSONFormat}, "/some/other/path/index.json"}, { "HTML page with expanded permalink", targetPathDescriptor{ Kind: KindPage, Dir: "/a/b", BaseName: "mypage", ExpandedPermalink: "/2017/10/my-title", - Type: output.HTMLType}, "/2017/10/my-title/index.html"}, + Type: output.HTMLFormat}, "/2017/10/my-title/index.html"}, { "Paginated HTML home", targetPathDescriptor{ Kind: KindHome, BaseName: "_index", - Type: output.HTMLType, + Type: output.HTMLFormat, Addends: "page/3"}, "/page/3/index.html"}, { "Paginated Taxonomy list", targetPathDescriptor{ Kind: KindTaxonomy, BaseName: "_index", Sections: []string{"tags", "hugo"}, - Type: output.HTMLType, + Type: output.HTMLFormat, Addends: "page/3"}, "/tags/hugo/page/3/index.html"}, { "Regular page with addend", targetPathDescriptor{ @@ -126,7 +126,7 @@ func TestPageTargetPath(t *testing.T) { Dir: "/a/b", BaseName: "mypage", Addends: "c/d/e", - Type: output.HTMLType}, "/a/b/mypage/c/d/e/index.html"}, + Type: output.HTMLFormat}, "/a/b/mypage/c/d/e/index.html"}, } for i, test := range tests { diff --git a/hugolib/pagination_test.go b/hugolib/pagination_test.go index 2f64c6c18..bd459e9d2 100644 --- a/hugolib/pagination_test.go +++ b/hugolib/pagination_test.go @@ -218,12 +218,12 @@ func TestPaginationURLFactory(t *testing.T) { expected string }{ {"HTML home page 32", - targetPathDescriptor{Kind: KindHome, Type: output.HTMLType}, "http://example.com/", 32, "/zoo/32/"}, + targetPathDescriptor{Kind: KindHome, Type: output.HTMLFormat}, "http://example.com/", 32, "/zoo/32/"}, {"JSON home page 42", - targetPathDescriptor{Kind: KindHome, Type: output.JSONType}, "http://example.com/", 42, "/zoo/42/"}, + targetPathDescriptor{Kind: KindHome, Type: output.JSONFormat}, "http://example.com/", 42, "/zoo/42/"}, // Issue #1252 {"BaseURL with sub path", - targetPathDescriptor{Kind: KindHome, Type: output.HTMLType}, "http://example.com/sub/", 999, "/sub/zoo/999/"}, + targetPathDescriptor{Kind: KindHome, Type: output.HTMLFormat}, "http://example.com/sub/", 999, "/sub/zoo/999/"}, } for _, test := range tests { @@ -282,8 +282,8 @@ func doTestPaginator(t *testing.T, useViper bool) { require.NoError(t, err) pages := createTestPages(s, 12) - n1, _ := newPageOutput(s.newHomePage(), false, output.HTMLType) - n2, _ := newPageOutput(s.newHomePage(), false, output.HTMLType) + n1, _ := newPageOutput(s.newHomePage(), false, output.HTMLFormat) + n2, _ := newPageOutput(s.newHomePage(), false, output.HTMLFormat) n1.Data["Pages"] = pages var paginator1 *Pager @@ -309,7 +309,7 @@ func doTestPaginator(t *testing.T, useViper bool) { require.Equal(t, paginator1, samePaginator) pp, _ := s.NewPage("test") - p, _ := newPageOutput(pp, false, output.HTMLType) + p, _ := newPageOutput(pp, false, output.HTMLFormat) _, err = p.Paginator() require.NotNil(t, err) @@ -318,7 +318,7 @@ func doTestPaginator(t *testing.T, useViper bool) { func TestPaginatorWithNegativePaginate(t *testing.T) { t.Parallel() s := newTestSite(t, "paginate", -1) - n1, _ := newPageOutput(s.newHomePage(), false, output.HTMLType) + n1, _ := newPageOutput(s.newHomePage(), false, output.HTMLFormat) _, err := n1.Paginator() require.Error(t, err) } @@ -381,8 +381,8 @@ func doTestPaginate(t *testing.T, useViper bool) { } pages := createTestPages(s, 6) - n1, _ := newPageOutput(s.newHomePage(), false, output.HTMLType) - n2, _ := newPageOutput(s.newHomePage(), false, output.HTMLType) + n1, _ := newPageOutput(s.newHomePage(), false, output.HTMLFormat) + n2, _ := newPageOutput(s.newHomePage(), false, output.HTMLFormat) var paginator1, paginator2 *Pager @@ -407,7 +407,7 @@ func doTestPaginate(t *testing.T, useViper bool) { require.Equal(t, paginator2, paginator1.Next()) pp, err := s.NewPage("test") - p, _ := newPageOutput(pp, false, output.HTMLType) + p, _ := newPageOutput(pp, false, output.HTMLFormat) _, err = p.Paginate(pages) require.NotNil(t, err) @@ -416,7 +416,7 @@ func doTestPaginate(t *testing.T, useViper bool) { func TestInvalidOptions(t *testing.T) { t.Parallel() s := newTestSite(t) - n1, _ := newPageOutput(s.newHomePage(), false, output.HTMLType) + n1, _ := newPageOutput(s.newHomePage(), false, output.HTMLFormat) _, err := n1.Paginate(createTestPages(s, 1), 1, 2) require.NotNil(t, err) @@ -434,7 +434,7 @@ func TestPaginateWithNegativePaginate(t *testing.T) { s, err := NewSiteForCfg(deps.DepsCfg{Cfg: cfg, Fs: fs}) require.NoError(t, err) - n, _ := newPageOutput(s.newHomePage(), false, output.HTMLType) + n, _ := newPageOutput(s.newHomePage(), false, output.HTMLFormat) _, err = n.Paginate(createTestPages(s, 2)) require.NotNil(t, err) @@ -445,7 +445,7 @@ func TestPaginatePages(t *testing.T) { s := newTestSite(t) groups, _ := createTestPages(s, 31).GroupBy("Weight", "desc") - pd := targetPathDescriptor{Kind: KindHome, Type: output.HTMLType, PathSpec: s.PathSpec, Addends: "t"} + pd := targetPathDescriptor{Kind: KindHome, Type: output.HTMLFormat, PathSpec: s.PathSpec, Addends: "t"} for i, seq := range []interface{}{createTestPages(s, 11), groups, WeightedPages{}, PageGroup{}, &Pages{}} { v, err := paginatePages(pd, seq, 11) @@ -461,8 +461,8 @@ func TestPaginatePages(t *testing.T) { func TestPaginatorFollowedByPaginateShouldFail(t *testing.T) { t.Parallel() s := newTestSite(t, "paginate", 10) - n1, _ := newPageOutput(s.newHomePage(), false, output.HTMLType) - n2, _ := newPageOutput(s.newHomePage(), false, output.HTMLType) + n1, _ := newPageOutput(s.newHomePage(), false, output.HTMLFormat) + n2, _ := newPageOutput(s.newHomePage(), false, output.HTMLFormat) _, err := n1.Paginator() require.Nil(t, err) @@ -478,8 +478,8 @@ func TestPaginateFollowedByDifferentPaginateShouldFail(t *testing.T) { t.Parallel() s := newTestSite(t, "paginate", 10) - n1, _ := newPageOutput(s.newHomePage(), false, output.HTMLType) - n2, _ := newPageOutput(s.newHomePage(), false, output.HTMLType) + n1, _ := newPageOutput(s.newHomePage(), false, output.HTMLFormat) + n2, _ := newPageOutput(s.newHomePage(), false, output.HTMLFormat) p1 := createTestPages(s, 2) p2 := createTestPages(s, 10) diff --git a/hugolib/site_output.go b/hugolib/site_output.go index 8b0dd7d63..69e68ff9b 100644 --- a/hugolib/site_output.go +++ b/hugolib/site_output.go @@ -33,7 +33,6 @@ func createSiteOutputFormats(cfg config.Provider) (map[string]output.Formats, er outputs := cfg.GetStringMap("outputs") if outputs == nil || len(outputs) == 0 { - // TODO(bep) outputs log a warning? return outFormats, nil } @@ -56,7 +55,7 @@ func createSiteOutputFormats(cfg config.Provider) (map[string]output.Formats, er // Make sure every kind has at least one output format for _, kind := range allKinds { if _, found := outFormats[kind]; !found { - outFormats[kind] = output.Formats{output.HTMLType} + outFormats[kind] = output.Formats{output.HTMLFormat} } } @@ -69,7 +68,7 @@ func createDefaultOutputFormats(cfg config.Provider) (map[string]output.Formats, for _, kind := range allKinds { var formats output.Formats // All have HTML - formats = append(formats, output.HTMLType) + formats = append(formats, output.HTMLFormat) // All but page have RSS if kind != KindPage { @@ -81,7 +80,7 @@ func createDefaultOutputFormats(cfg config.Provider) (map[string]output.Formats, // RSS has now a well defined media type, so strip any suffix provided rssBase = strings.TrimSuffix(rssBase, path.Ext(rssBase)) - rssType := output.RSSType + rssType := output.RSSFormat rssType.BaseName = rssBase formats = append(formats, rssType) diff --git a/hugolib/site_output_test.go b/hugolib/site_output_test.go index 006f3bad0..86e1a55ca 100644 --- a/hugolib/site_output_test.go +++ b/hugolib/site_output_test.go @@ -38,8 +38,8 @@ func TestDefaultOutputFormats(t *testing.T) { kind string want output.Formats }{ - {"RSS not for regular pages", KindPage, output.Formats{output.HTMLType}}, - {"Home Sweet Home", KindHome, output.Formats{output.HTMLType, output.RSSType}}, + {"RSS not for regular pages", KindPage, output.Formats{output.HTMLFormat}}, + {"Home Sweet Home", KindHome, output.Formats{output.HTMLFormat, output.RSSFormat}}, } for _, tt := range tests { @@ -59,7 +59,6 @@ func TestSiteWithPageOutputs(t *testing.T) { } } -// TODO(bep) output add test for site outputs config func doTestSiteWithPageOutputs(t *testing.T, outputs []string) { t.Parallel() @@ -147,7 +146,6 @@ Output/Rel: {{ .Name -}}/{{ .Rel }}| require.Equal(t, "http://example.com/blog/index.json", json.Permalink()) if helpers.InStringArray(outputs, "cal") { - // TODO(bep) output have do some protocil handling for the default too if set. cal := of.Get("calendar") require.NotNil(t, cal) require.Equal(t, "/blog/index.ics", cal.RelPermalink()) |