diff --git a/index.go.html b/index.go.html index 2a4db27..eb13506 100644 --- a/index.go.html +++ b/index.go.html @@ -5,7 +5,7 @@ - + City University Portfolio {{ if .Light }} @@ -155,8 +155,13 @@
{{ if eq .VideoLocation "" }} - No Video + No Video {{ else }} + {{ if .IsVideoLink }} + + Play Video + + {{ else }} @@ -166,6 +171,7 @@ The Video + {{ end }} {{ end }}
diff --git a/pageHandler/pages/index/entry.go b/pageHandler/pages/index/entry.go index bcf6d7b..5da44d3 100644 --- a/pageHandler/pages/index/entry.go +++ b/pageHandler/pages/index/entry.go @@ -5,21 +5,23 @@ import ( "html/template" "math" "net/http" + "strings" "time" ) const dateFormat = "01/2006" type EntryYaml struct { - Name string `yaml:"name"` - Content string `yaml:"content"` - StartDate yaml.DateType `yaml:"startDate"` - EndDate yaml.DateType `yaml:"endDate"` - VideoLocation template.URL `yaml:"videoLocation"` - VideoContentType string `yaml:"videoContentType"` - ThumbnailLocations []template.URL `yaml:"thumbnailLocations"` - ImageLocations []template.URL `yaml:"imageLocations"` - ImageAltTexts []string `yaml:"imageAltTexts"` + Name string `yaml:"name"` + Content string `yaml:"content"` + StartDate yaml.DateType `yaml:"startDate"` + EndDate yaml.DateType `yaml:"endDate"` + VideoLocation template.URL `yaml:"videoLocation"` + VideoContentType string `yaml:"videoContentType"` + ThumbnailLocations []template.URL `yaml:"thumbnailLocations"` + ImageLocations []template.URL `yaml:"imageLocations"` + ImageAltTexts []string `yaml:"imageAltTexts"` + VideoThumbnailLocation template.URL `yaml:"videoThumbnailLocation"` } type ImageReference struct { @@ -28,6 +30,18 @@ type ImageReference struct { ImageAltText string } +func (ey EntryYaml) GetVideoThumbnail(usual template.URL) template.URL { + if ey.VideoThumbnailLocation == "" { + return usual + } else { + return ey.VideoThumbnailLocation + } +} + +func (ey EntryYaml) IsVideoLink() bool { + return strings.EqualFold(ey.VideoContentType, "text/uri-list") +} + func (ey EntryYaml) GetStartDate() string { return ey.StartDate.Format(dateFormat) }