Update seasonal background patterns

This commit is contained in:
2021-09-15 22:58:03 +02:00
parent 721abbdf78
commit 63c5bd5e45
4 changed files with 18 additions and 11 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

View File

Before

Width:  |  Height:  |  Size: 865 B

After

Width:  |  Height:  |  Size: 865 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

View File

@@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"html/template" "html/template"
"io/ioutil" "io/ioutil"
"math/rand"
"net/http" "net/http"
"net/url" "net/url"
"os" "os"
@@ -206,20 +207,22 @@ func (tm *TemplateManager) Get() *template.Template {
// Template functions. These can be called from within the template to execute // Template functions. These can be called from within the template to execute
// more specialized actions // more specialized actions
const (
electionStart = 1615935600
electionEnd = 1616022000
)
func (tm *TemplateManager) bgPattern() template.URL { func (tm *TemplateManager) bgPattern() template.URL {
var now = time.Now() var (
var epoch = now.Unix() now = time.Now()
var file string month = now.Month()
day = now.Day()
file string
)
if epoch > electionStart && epoch < electionEnd { if now.Weekday() == time.Wednesday && rand.Intn(20) == 0 {
file = "checker_vote.png"
} else if now.Weekday() == time.Wednesday && now.UnixNano()%10 == 0 {
file = "checker_wednesday.png" file = "checker_wednesday.png"
} else if month == time.August && day == 24 {
file = "checker_developers.png"
} else if month == time.October && day == 31 {
file = "checker_halloween.png"
} else if month == time.December && day == 25 || day == 26 || day == 27 {
file = "checker_christmas.png"
} else { } else {
file = fmt.Sprintf("checker%d.png", now.UnixNano()%17) file = fmt.Sprintf("checker%d.png", now.UnixNano()%17)
} }
@@ -310,6 +313,10 @@ func detectInt(i interface{}) int {
return int(v) return int(v)
case uint64: case uint64:
return int(v) return int(v)
case float32:
return int(v)
case float64:
return int(v)
} }
panic(fmt.Sprintf("%v is not an int", i)) panic(fmt.Sprintf("%v is not an int", i))
} }