Finish index.go page code.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Captain ALM 2022-07-17 14:02:40 +01:00
parent 8a637da36a
commit 0a9775d2a1
Signed by: alfred
GPG Key ID: 4E4ADD02609997B1

View File

@ -81,7 +81,16 @@ func (p *Page) GetContents(urlParameters url.Values) (contentType string, conten
Data: *theData,
Light: urlParameters.Has("light"),
}
//Set up sorting here
switch strings.ToLower(urlParameters.Get("order")) {
case "end":
theMarshal.OrderEndDate = getSortValue(strings.ToLower(urlParameters.Get("sort")))
case "name":
theMarshal.OrderName = getSortValue(strings.ToLower(urlParameters.Get("sort")))
case "duration":
theMarshal.OrderDuration = getSortValue(strings.ToLower(urlParameters.Get("sort")))
default:
theMarshal.OrderStartDate = getSortValue(strings.ToLower(urlParameters.Get("sort")))
}
theBuffer := &io.BufferedWriter{}
err = theTemplate.ExecuteTemplate(theBuffer, templateName, theMarshal)
if err != nil {
@ -173,3 +182,11 @@ func (p *Page) getPageData() (*DataYaml, error) {
return p.StoredData, nil
}
}
func getSortValue(toCheckIn string) int8 {
if toCheckIn == "desc" || toCheckIn == "descending" {
return -1
} else {
return 1
}
}