Add theme switch.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Captain ALM 2022-07-27 00:34:40 +01:00
parent 9be55ab6dc
commit eecf2e9a70
Signed by: alfred
GPG Key ID: 4E4ADD02609997B1
3 changed files with 26 additions and 6 deletions

View File

@ -15,7 +15,17 @@
</head>
<body>
<header class="header">
{{ if .Light }}
<a href="?light" class="home-button no-dec"><b>&#8962;</b></a>
<a href="?{{ .Parameters }}" class="home-button no-dec"><b>&#9790;</b></a>
{{ else }}
<a href="?" class="home-button no-dec"><b>&#8962;</b></a>
{{ if eq .Parameters "" }}
<a href="?light" class="home-button no-dec"><b>&#9737;</b></a>
{{ else }}
<a href="?light&{{ .Parameters }}" class="home-button no-dec"><b>&#9737;</b></a>
{{ end }}
{{ end }}
<input class="nav-menu" type="checkbox" id="nav-menu"/>
<label class="hmb" for="nav-menu"><span class="hmb-line"></span></label>
<nav class="nav">

View File

@ -53,6 +53,17 @@ func (p *Page) GetLastModified() time.Time {
}
func (p *Page) GetCacheIDExtension(urlParameters url.Values) string {
toReturn := p.getNonThemedCleanQuery(urlParameters)
if toReturn != "" {
toReturn += "&"
}
if urlParameters.Has("light") {
toReturn += "light"
}
return strings.TrimRight(toReturn, "&")
}
func (p *Page) getNonThemedCleanQuery(urlParameters url.Values) string {
toReturn := ""
if urlParameters.Has("order") {
if theParameter := strings.ToLower(urlParameters.Get("order")); theParameter == "start" || theParameter == "end" || theParameter == "name" || theParameter == "duration" {
@ -61,12 +72,9 @@ func (p *Page) GetCacheIDExtension(urlParameters url.Values) string {
}
if urlParameters.Has("sort") {
if theParameter := strings.ToLower(urlParameters.Get("sort")); theParameter == "asc" || theParameter == "ascending" || theParameter == "desc" || theParameter == "descending" {
toReturn += "sort=" + theParameter + "&"
toReturn += "sort=" + theParameter
}
}
if urlParameters.Has("light") {
toReturn += "light"
}
return strings.TrimRight(toReturn, "&")
}
@ -82,6 +90,7 @@ func (p *Page) GetContents(urlParameters url.Values) (contentType string, conten
theMarshal := &Marshal{
Data: *theData,
Light: urlParameters.Has("light"),
Parameters: p.getNonThemedCleanQuery(urlParameters),
}
switch strings.ToLower(urlParameters.Get("order")) {
case "end":

View File

@ -4,6 +4,7 @@ import "sort"
type Marshal struct {
Data DataYaml
Parameters string
OrderStartDate int8
OrderEndDate int8
OrderName int8