mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
output: Rename HTMLType etc. to HTMLFormat
This commit is contained in:
parent
24c1770288
commit
09c88e84d1
11 changed files with 86 additions and 91 deletions
|
@ -317,7 +317,6 @@ func (p *PathSpec) PrependBasePath(rel string) string {
|
|||
|
||||
// URLizeAndPrep applies misc sanitation to the given URL to get it in line
|
||||
// with the Hugo standard.
|
||||
// TODO(bep) output check usage
|
||||
func (p *PathSpec) URLizeAndPrep(in string) string {
|
||||
return p.URLPrep(p.URLize(in))
|
||||
}
|
||||
|
|
|
@ -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 ""
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -102,7 +102,7 @@ func (l *LayoutHandler) For(d LayoutDescriptor, layoutOverride string, f Format)
|
|||
layout = layoutOverride
|
||||
}
|
||||
|
||||
isRSS := f.Name == RSSType.Name
|
||||
isRSS := f.Name == RSSFormat.Name
|
||||
|
||||
if d.Kind == "page" {
|
||||
if isRSS {
|
||||
|
|
|
@ -34,7 +34,6 @@ type TemplateNames struct {
|
|||
MasterFilename string
|
||||
}
|
||||
|
||||
// TODO(bep) output this is refactoring in progress.
|
||||
type TemplateLookupDescriptor struct {
|
||||
// The full path to the site or theme root.
|
||||
WorkingDir string
|
||||
|
|
|
@ -56,13 +56,13 @@ func TestLayout(t *testing.T) {
|
|||
{"Page with overridden layout", LayoutDescriptor{Kind: "page", Layout: "mylayout", Type: "myttype"}, false, "myotherlayout", ampType,
|
||||
[]string{"myttype/myotherlayout.amp.html", "myttype/myotherlayout.html"}},
|
||||
// RSS
|
||||
{"RSS Home with theme", LayoutDescriptor{Kind: "home"}, true, "", RSSType,
|
||||
{"RSS Home with theme", LayoutDescriptor{Kind: "home"}, true, "", RSSFormat,
|
||||
[]string{"rss.xml", "_default/rss.xml", "theme/rss.xml", "theme/_default/rss.xml", "_internal/_default/rss.xml"}},
|
||||
{"RSS Section", LayoutDescriptor{Kind: "section", Section: "sect1"}, false, "", RSSType,
|
||||
{"RSS Section", LayoutDescriptor{Kind: "section", Section: "sect1"}, false, "", RSSFormat,
|
||||
[]string{"section/sect1.rss.xml", "_default/rss.xml", "rss.xml", "_internal/_default/rss.xml"}},
|
||||
{"RSS Taxonomy", LayoutDescriptor{Kind: "taxonomy", Section: "tag"}, false, "", RSSType,
|
||||
{"RSS Taxonomy", LayoutDescriptor{Kind: "taxonomy", Section: "tag"}, false, "", RSSFormat,
|
||||
[]string{"taxonomy/tag.rss.xml", "_default/rss.xml", "rss.xml", "_internal/_default/rss.xml"}},
|
||||
{"RSS Taxonomy term", LayoutDescriptor{Kind: "taxonomyTerm", Section: "tag"}, false, "", RSSType,
|
||||
{"RSS Taxonomy term", LayoutDescriptor{Kind: "taxonomyTerm", Section: "tag"}, false, "", RSSFormat,
|
||||
[]string{"taxonomy/tag.terms.rss.xml", "_default/rss.xml", "rss.xml", "_internal/_default/rss.xml"}},
|
||||
} {
|
||||
t.Run(this.name, func(t *testing.T) {
|
||||
|
@ -90,7 +90,7 @@ func BenchmarkLayout(b *testing.B) {
|
|||
l := NewLayoutHandler(false)
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
layouts := l.For(descriptor, "", HTMLType)
|
||||
layouts := l.For(descriptor, "", HTMLFormat)
|
||||
require.NotEmpty(b, layouts)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@ import (
|
|||
|
||||
var (
|
||||
// An ordered list of built-in output formats
|
||||
//
|
||||
// See https://www.ampproject.org/learn/overview/
|
||||
// TODO(bep) output rename to AMPFormat etc.
|
||||
AMPType = Format{
|
||||
AMPFormat = Format{
|
||||
Name: "AMP",
|
||||
MediaType: media.HTMLType,
|
||||
BaseName: "index",
|
||||
|
@ -33,7 +33,7 @@ var (
|
|||
IsHTML: true,
|
||||
}
|
||||
|
||||
CalendarType = Format{
|
||||
CalendarFormat = Format{
|
||||
Name: "Calendar",
|
||||
MediaType: media.CalendarType,
|
||||
IsPlainText: true,
|
||||
|
@ -42,14 +42,14 @@ var (
|
|||
Rel: "alternate",
|
||||
}
|
||||
|
||||
CSSType = Format{
|
||||
CSSFormat = Format{
|
||||
Name: "CSS",
|
||||
MediaType: media.CSSType,
|
||||
BaseName: "styles",
|
||||
Rel: "stylesheet",
|
||||
}
|
||||
|
||||
HTMLType = Format{
|
||||
HTMLFormat = Format{
|
||||
Name: "HTML",
|
||||
MediaType: media.HTMLType,
|
||||
BaseName: "index",
|
||||
|
@ -57,7 +57,7 @@ var (
|
|||
IsHTML: true,
|
||||
}
|
||||
|
||||
JSONType = Format{
|
||||
JSONFormat = Format{
|
||||
Name: "JSON",
|
||||
MediaType: media.JSONType,
|
||||
BaseName: "index",
|
||||
|
@ -65,7 +65,7 @@ var (
|
|||
Rel: "alternate",
|
||||
}
|
||||
|
||||
RSSType = Format{
|
||||
RSSFormat = Format{
|
||||
Name: "RSS",
|
||||
MediaType: media.RSSType,
|
||||
BaseName: "index",
|
||||
|
@ -75,12 +75,12 @@ var (
|
|||
)
|
||||
|
||||
var builtInTypes = map[string]Format{
|
||||
strings.ToLower(AMPType.Name): AMPType,
|
||||
strings.ToLower(CalendarType.Name): CalendarType,
|
||||
strings.ToLower(CSSType.Name): CSSType,
|
||||
strings.ToLower(HTMLType.Name): HTMLType,
|
||||
strings.ToLower(JSONType.Name): JSONType,
|
||||
strings.ToLower(RSSType.Name): RSSType,
|
||||
strings.ToLower(AMPFormat.Name): AMPFormat,
|
||||
strings.ToLower(CalendarFormat.Name): CalendarFormat,
|
||||
strings.ToLower(CSSFormat.Name): CSSFormat,
|
||||
strings.ToLower(HTMLFormat.Name): HTMLFormat,
|
||||
strings.ToLower(JSONFormat.Name): JSONFormat,
|
||||
strings.ToLower(RSSFormat.Name): RSSFormat,
|
||||
}
|
||||
|
||||
type Formats []Format
|
||||
|
|
|
@ -21,41 +21,41 @@ import (
|
|||
)
|
||||
|
||||
func TestDefaultTypes(t *testing.T) {
|
||||
require.Equal(t, "Calendar", CalendarType.Name)
|
||||
require.Equal(t, media.CalendarType, CalendarType.MediaType)
|
||||
require.Equal(t, "webcal://", CalendarType.Protocol)
|
||||
require.Empty(t, CalendarType.Path)
|
||||
require.True(t, CalendarType.IsPlainText)
|
||||
require.False(t, CalendarType.IsHTML)
|
||||
require.Equal(t, "Calendar", CalendarFormat.Name)
|
||||
require.Equal(t, media.CalendarType, CalendarFormat.MediaType)
|
||||
require.Equal(t, "webcal://", CalendarFormat.Protocol)
|
||||
require.Empty(t, CalendarFormat.Path)
|
||||
require.True(t, CalendarFormat.IsPlainText)
|
||||
require.False(t, CalendarFormat.IsHTML)
|
||||
|
||||
require.Equal(t, "HTML", HTMLType.Name)
|
||||
require.Equal(t, media.HTMLType, HTMLType.MediaType)
|
||||
require.Empty(t, HTMLType.Path)
|
||||
require.Empty(t, HTMLType.Protocol) // Will inherit the BaseURL protocol.
|
||||
require.False(t, HTMLType.IsPlainText)
|
||||
require.True(t, HTMLType.IsHTML)
|
||||
require.Equal(t, "HTML", HTMLFormat.Name)
|
||||
require.Equal(t, media.HTMLType, HTMLFormat.MediaType)
|
||||
require.Empty(t, HTMLFormat.Path)
|
||||
require.Empty(t, HTMLFormat.Protocol) // Will inherit the BaseURL protocol.
|
||||
require.False(t, HTMLFormat.IsPlainText)
|
||||
require.True(t, HTMLFormat.IsHTML)
|
||||
|
||||
require.Equal(t, "AMP", AMPType.Name)
|
||||
require.Equal(t, media.HTMLType, AMPType.MediaType)
|
||||
require.Equal(t, "amp", AMPType.Path)
|
||||
require.Empty(t, AMPType.Protocol) // Will inherit the BaseURL protocol.
|
||||
require.False(t, AMPType.IsPlainText)
|
||||
require.True(t, AMPType.IsHTML)
|
||||
require.Equal(t, "AMP", AMPFormat.Name)
|
||||
require.Equal(t, media.HTMLType, AMPFormat.MediaType)
|
||||
require.Equal(t, "amp", AMPFormat.Path)
|
||||
require.Empty(t, AMPFormat.Protocol) // Will inherit the BaseURL protocol.
|
||||
require.False(t, AMPFormat.IsPlainText)
|
||||
require.True(t, AMPFormat.IsHTML)
|
||||
|
||||
require.Equal(t, "RSS", RSSType.Name)
|
||||
require.Equal(t, media.RSSType, RSSType.MediaType)
|
||||
require.Empty(t, RSSType.Path)
|
||||
require.False(t, RSSType.IsPlainText)
|
||||
require.True(t, RSSType.NoUgly)
|
||||
require.False(t, CalendarType.IsHTML)
|
||||
require.Equal(t, "RSS", RSSFormat.Name)
|
||||
require.Equal(t, media.RSSType, RSSFormat.MediaType)
|
||||
require.Empty(t, RSSFormat.Path)
|
||||
require.False(t, RSSFormat.IsPlainText)
|
||||
require.True(t, RSSFormat.NoUgly)
|
||||
require.False(t, CalendarFormat.IsHTML)
|
||||
|
||||
}
|
||||
|
||||
func TestGetType(t *testing.T) {
|
||||
tp, _ := GetFormat("html")
|
||||
require.Equal(t, HTMLType, tp)
|
||||
require.Equal(t, HTMLFormat, tp)
|
||||
tp, _ = GetFormat("HTML")
|
||||
require.Equal(t, HTMLType, tp)
|
||||
require.Equal(t, HTMLFormat, tp)
|
||||
_, found := GetFormat("FOO")
|
||||
require.False(t, found)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue