diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-04-01 15:12:31 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-04-01 15:12:31 +0200 |
commit | f911b107ef32c1c4369aa252a790e3c933660135 (patch) | |
tree | e1ac6996be0cc65eff325fb2ff12723fc73605a3 | |
parent | 05949c903817b93dd7fd71211260db625180eed6 (diff) |
media, output: Add CSV type and format
And make CSS correclty behave as plain text.
-rw-r--r-- | media/mediaType.go | 1 | ||||
-rw-r--r-- | media/mediaType_test.go | 1 | ||||
-rw-r--r-- | output/outputFormat.go | 16 | ||||
-rw-r--r-- | output/outputFormat_test.go | 18 |
4 files changed, 30 insertions, 6 deletions
diff --git a/media/mediaType.go b/media/mediaType.go index f6597fdb6..a6ba873eb 100644 --- a/media/mediaType.go +++ b/media/mediaType.go @@ -49,6 +49,7 @@ func (m Type) String() string { var ( CalendarType = Type{"text", "calendar", "ics"} CSSType = Type{"text", "css", "css"} + CSVType = Type{"text", "csv", "csv"} HTMLType = Type{"text", "html", "html"} JavascriptType = Type{"application", "javascript", "js"} JSONType = Type{"application", "json", "json"} diff --git a/media/mediaType_test.go b/media/mediaType_test.go index 7636af59c..e918b9393 100644 --- a/media/mediaType_test.go +++ b/media/mediaType_test.go @@ -30,6 +30,7 @@ func TestDefaultTypes(t *testing.T) { }{ {CalendarType, "text", "calendar", "ics", "text/calendar", "text/calendar+ics"}, {CSSType, "text", "css", "css", "text/css", "text/css+css"}, + {CSVType, "text", "csv", "csv", "text/csv", "text/csv+csv"}, {HTMLType, "text", "html", "html", "text/html", "text/html+html"}, {JavascriptType, "application", "javascript", "js", "application/javascript", "application/javascript+js"}, {JSONType, "application", "json", "json", "application/json", "application/json+json"}, diff --git a/output/outputFormat.go b/output/outputFormat.go index 797c7ae2d..76329a936 100644 --- a/output/outputFormat.go +++ b/output/outputFormat.go @@ -43,10 +43,18 @@ var ( } CSSFormat = Format{ - Name: "CSS", - MediaType: media.CSSType, - BaseName: "styles", - Rel: "stylesheet", + Name: "CSS", + MediaType: media.CSSType, + BaseName: "styles", + IsPlainText: true, + Rel: "stylesheet", + } + CSVFormat = Format{ + Name: "CSV", + MediaType: media.CSVType, + BaseName: "index", + IsPlainText: true, + Rel: "alternate", } HTMLFormat = Format{ diff --git a/output/outputFormat_test.go b/output/outputFormat_test.go index 1d3700f4b..e742012ba 100644 --- a/output/outputFormat_test.go +++ b/output/outputFormat_test.go @@ -28,17 +28,31 @@ func TestDefaultTypes(t *testing.T) { require.True(t, CalendarFormat.IsPlainText) require.False(t, CalendarFormat.IsHTML) + require.Equal(t, "CSS", CSSFormat.Name) + require.Equal(t, media.CSSType, CSSFormat.MediaType) + require.Empty(t, CSSFormat.Path) + require.Empty(t, CSSFormat.Protocol) // Will inherit the BaseURL protocol. + require.True(t, CSSFormat.IsPlainText) + require.False(t, CSSFormat.IsHTML) + + require.Equal(t, "CSV", CSVFormat.Name) + require.Equal(t, media.CSVType, CSVFormat.MediaType) + require.Empty(t, CSVFormat.Path) + require.Empty(t, CSVFormat.Protocol) + require.True(t, CSVFormat.IsPlainText) + require.False(t, CSVFormat.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.Empty(t, HTMLFormat.Protocol) require.False(t, HTMLFormat.IsPlainText) require.True(t, HTMLFormat.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.Empty(t, AMPFormat.Protocol) require.False(t, AMPFormat.IsPlainText) require.True(t, AMPFormat.IsHTML) |