Finish index.go page code.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
8a637da36a
commit
0a9775d2a1
@ -81,7 +81,16 @@ func (p *Page) GetContents(urlParameters url.Values) (contentType string, conten
|
|||||||
Data: *theData,
|
Data: *theData,
|
||||||
Light: urlParameters.Has("light"),
|
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{}
|
theBuffer := &io.BufferedWriter{}
|
||||||
err = theTemplate.ExecuteTemplate(theBuffer, templateName, theMarshal)
|
err = theTemplate.ExecuteTemplate(theBuffer, templateName, theMarshal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -173,3 +182,11 @@ func (p *Page) getPageData() (*DataYaml, error) {
|
|||||||
return p.StoredData, nil
|
return p.StoredData, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getSortValue(toCheckIn string) int8 {
|
||||||
|
if toCheckIn == "desc" || toCheckIn == "descending" {
|
||||||
|
return -1
|
||||||
|
} else {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user