media, output: Add Calendar type
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 23 Mar 2017 16:31:05 +0000 (17:31 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 27 Mar 2017 13:43:56 +0000 (15:43 +0200)
media/mediaType.go
media/mediaType_test.go
output/outputFormat.go
output/outputFormat_test.go

index 45b850077356ead397e90d9fbcfdb2d8407d3fd1..07dbcc2113cd0e0393bbf1a63a723e3f9bd30300 100644 (file)
@@ -47,11 +47,11 @@ func (m Type) String() string {
 }
 
 var (
-       CSSType  = Type{"text", "css", "css"}
-       HTMLType = Type{"text", "html", "html"}
-       JSONType = Type{"application", "json", "json"}
-       RSSType  = Type{"application", "rss", "xml"}
+       CalendarType = Type{"text", "calendar", "ics"}
+       CSSType      = Type{"text", "css", "css"}
+       HTMLType     = Type{"text", "html", "html"}
+       JSONType     = Type{"application", "json", "json"}
+       RSSType      = Type{"application", "rss", "xml"}
 )
 
 // TODO(bep) output mime.AddExtensionType
-// TODO(bep) text/template vs html/template
index e9de66d0eb9b853791ae50369c91a9f759950636..40efc4f064ddfee9e2d8c5c9bccd12ccb3681e9f 100644 (file)
@@ -20,6 +20,13 @@ import (
 )
 
 func TestDefaultTypes(t *testing.T) {
+       require.Equal(t, "text", CalendarType.MainType)
+       require.Equal(t, "calendar", CalendarType.SubType)
+       require.Equal(t, "ics", CalendarType.Suffix)
+
+       require.Equal(t, "text/calendar+ics", CalendarType.String())
+       require.Equal(t, "text/calendar", CalendarType.Type())
+
        require.Equal(t, "text", HTMLType.MainType)
        require.Equal(t, "html", HTMLType.SubType)
        require.Equal(t, "html", HTMLType.Suffix)
index 3812030d190f74d6f2ffd8dc1c93ee607a8b5727..efc0cd85f6d60c3e02d300c1ea84bc4693ad5aa2 100644 (file)
@@ -31,6 +31,15 @@ var (
                Rel:       "amphtml",
        }
 
+       CalendarType = Format{
+               Name:        "Calendar",
+               MediaType:   media.CalendarType,
+               IsPlainText: true,
+               Protocol:    "webcal://",
+               BaseName:    "index",
+               Rel:         "alternate",
+       }
+
        CSSType = Format{
                Name:      "CSS",
                MediaType: media.CSSType,
index 21375bf561950791c5d1d3a792322cafe49555ca..efc31a223613a43fd7e413e5da1d434c7b28258b 100644 (file)
@@ -21,6 +21,12 @@ 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.Equal(t, "HTML", HTMLType.Name)
        require.Equal(t, media.HTMLType, HTMLType.MediaType)
        require.Empty(t, HTMLType.Path)