2022-07-16 22:20:56 +01:00
|
|
|
package index
|
|
|
|
|
|
|
|
import (
|
2022-07-25 15:39:05 +01:00
|
|
|
"golang.captainalm.com/cityuni-webserver/utils/yaml"
|
2022-07-16 22:20:56 +01:00
|
|
|
"html/template"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
const dateFormat = "2006-01-02"
|
|
|
|
|
|
|
|
type EntryYaml struct {
|
2022-07-25 15:39:05 +01:00
|
|
|
Name string `yaml:"name"`
|
|
|
|
Content string `yaml:"content"`
|
|
|
|
StartDate yaml.DateType `yaml:"startDate"`
|
|
|
|
EndDate yaml.DateType `yaml:"endDate"`
|
|
|
|
VideoLocation string `yaml:"videoLocation"`
|
|
|
|
VideoContentType string `yaml:"videoContentType"`
|
|
|
|
ThumbnailLocations []string `yaml:"thumbnailLocations"`
|
|
|
|
ImageLocations []string `yaml:"imageLocations"`
|
2022-07-16 22:20:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (ey EntryYaml) GetStartDate() string {
|
|
|
|
return ey.StartDate.Format(dateFormat)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ey EntryYaml) GetEndDate() string {
|
|
|
|
if ey.EndDate.IsZero() {
|
|
|
|
return ""
|
|
|
|
} else {
|
|
|
|
return ey.EndDate.Format(dateFormat)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ey EntryYaml) GetEndTime() time.Time {
|
|
|
|
if ey.EndDate.IsZero() {
|
|
|
|
return time.Now()
|
|
|
|
} else {
|
2022-07-25 15:39:05 +01:00
|
|
|
return ey.EndDate.Time
|
2022-07-16 22:20:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ey EntryYaml) GetContent() template.HTML {
|
|
|
|
return template.HTML(ey.Content)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ey EntryYaml) GetDuration() time.Duration {
|
2022-07-25 15:39:05 +01:00
|
|
|
return ey.GetEndTime().Sub(ey.StartDate.Time).Truncate(time.Second)
|
2022-07-16 22:20:56 +01:00
|
|
|
}
|