shithub: hugo

Download patch

ref: 8bcc08e3b0ddd5762101bb2f061e0be04ecd8d57
parent: dbb83f925a7cb256b69b158e2caf0d99e3c7c5e6
author: Bjørn Erik Pedersen <[email protected]>
date: Thu Mar 23 13:31:05 EDT 2017

media, output: Add Calendar type

--- a/media/mediaType.go
+++ b/media/mediaType.go
@@ -47,11 +47,11 @@
 }
 
 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
--- a/media/mediaType_test.go
+++ b/media/mediaType_test.go
@@ -20,6 +20,13 @@
 )
 
 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)
--- a/output/outputFormat.go
+++ b/output/outputFormat.go
@@ -31,6 +31,15 @@
 		Rel:       "amphtml",
 	}
 
+	CalendarType = Format{
+		Name:        "Calendar",
+		MediaType:   media.CalendarType,
+		IsPlainText: true,
+		Protocol:    "webcal://",
+		BaseName:    "index",
+		Rel:         "alternate",
+	}
+
 	CSSType = Format{
 		Name:      "CSS",
 		MediaType: media.CSSType,
--- a/output/outputFormat_test.go
+++ b/output/outputFormat_test.go
@@ -21,6 +21,12 @@
 )
 
 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)