Add video link and custom video thumbnail support.
Some checks are pending
ci/woodpecker/push/build Pipeline is pending

This commit is contained in:
Captain ALM 2023-09-16 16:16:29 +01:00
parent 4da16c32ae
commit c12fc92f71
Signed by: alfred
GPG Key ID: 4E4ADD02609997B1
2 changed files with 31 additions and 11 deletions

View File

@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"/> <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="description" content="Captain ALM's City University Portfolio"> <meta name="description" content="Captain ALM's City University Portfolio">
<meta name="keywords" content="CaptainALM Captain_ALM Captain ALM portfolio Alfred Manville projects programming hacking cracking"> <meta name="keywords" content="CaptainALM Captain_ALM Captain ALM portfolio Alfred Manville projects programming hacking cracking city uni cityuni cuol City University of London mycityuni">
<title>City University Portfolio</title> <title>City University Portfolio</title>
<link rel="stylesheet" href="{{ .Data.CSSBaseURL }}"/> <link rel="stylesheet" href="{{ .Data.CSSBaseURL }}"/>
{{ if .Light }} {{ if .Light }}
@ -155,8 +155,13 @@
<div class="item-table-360"> <div class="item-table-360">
<div id="video-{{ $c }}"> <div id="video-{{ $c }}">
{{ if eq .VideoLocation "" }} {{ if eq .VideoLocation "" }}
<img src="{{ $.Data.NoVideoImageLocation }}" alt="No Video" width="360px"> <img src="{{.GetVideoThumbnail $.Data.NoVideoImageLocation }}" alt="No Video" width="360px">
{{ else }} {{ else }}
{{ if .IsVideoLink }}
<a href="{{ .VideoLocation }}">
<img src="{{ .GetVideoThumbnail $.Data.PlayVideoImageLocation }}" alt="Play Video" title="Play" width="360px">
</a>
{{ else }}
<script type="application/javascript"> <script type="application/javascript">
CreateVideoPlaceholder({{ $c }}) CreateVideoPlaceholder({{ $c }})
</script> </script>
@ -166,6 +171,7 @@
<a href="{{ .VideoLocation }}">The Video</a> <a href="{{ .VideoLocation }}">The Video</a>
</video> </video>
</noscript> </noscript>
{{ end }}
{{ end }} {{ end }}
</div> </div>
</div> </div>

View File

@ -5,21 +5,23 @@ import (
"html/template" "html/template"
"math" "math"
"net/http" "net/http"
"strings"
"time" "time"
) )
const dateFormat = "01/2006" const dateFormat = "01/2006"
type EntryYaml struct { type EntryYaml struct {
Name string `yaml:"name"` Name string `yaml:"name"`
Content string `yaml:"content"` Content string `yaml:"content"`
StartDate yaml.DateType `yaml:"startDate"` StartDate yaml.DateType `yaml:"startDate"`
EndDate yaml.DateType `yaml:"endDate"` EndDate yaml.DateType `yaml:"endDate"`
VideoLocation template.URL `yaml:"videoLocation"` VideoLocation template.URL `yaml:"videoLocation"`
VideoContentType string `yaml:"videoContentType"` VideoContentType string `yaml:"videoContentType"`
ThumbnailLocations []template.URL `yaml:"thumbnailLocations"` ThumbnailLocations []template.URL `yaml:"thumbnailLocations"`
ImageLocations []template.URL `yaml:"imageLocations"` ImageLocations []template.URL `yaml:"imageLocations"`
ImageAltTexts []string `yaml:"imageAltTexts"` ImageAltTexts []string `yaml:"imageAltTexts"`
VideoThumbnailLocation template.URL `yaml:"videoThumbnailLocation"`
} }
type ImageReference struct { type ImageReference struct {
@ -28,6 +30,18 @@ type ImageReference struct {
ImageAltText string 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 { func (ey EntryYaml) GetStartDate() string {
return ey.StartDate.Format(dateFormat) return ey.StartDate.Format(dateFormat)
} }