Update seasonal background patterns
This commit is contained in:
BIN
res/include/img/background_patterns/checker_christmas.png
Normal file
BIN
res/include/img/background_patterns/checker_christmas.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 277 B |
Before Width: | Height: | Size: 865 B After Width: | Height: | Size: 865 B |
BIN
res/include/img/background_patterns/checker_halloween.png
Normal file
BIN
res/include/img/background_patterns/checker_halloween.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 265 B |
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -206,20 +207,22 @@ func (tm *TemplateManager) Get() *template.Template {
|
||||
// Template functions. These can be called from within the template to execute
|
||||
// more specialized actions
|
||||
|
||||
const (
|
||||
electionStart = 1615935600
|
||||
electionEnd = 1616022000
|
||||
func (tm *TemplateManager) bgPattern() template.URL {
|
||||
var (
|
||||
now = time.Now()
|
||||
month = now.Month()
|
||||
day = now.Day()
|
||||
file string
|
||||
)
|
||||
|
||||
func (tm *TemplateManager) bgPattern() template.URL {
|
||||
var now = time.Now()
|
||||
var epoch = now.Unix()
|
||||
var file string
|
||||
|
||||
if epoch > electionStart && epoch < electionEnd {
|
||||
file = "checker_vote.png"
|
||||
} else if now.Weekday() == time.Wednesday && now.UnixNano()%10 == 0 {
|
||||
if now.Weekday() == time.Wednesday && rand.Intn(20) == 0 {
|
||||
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 {
|
||||
file = fmt.Sprintf("checker%d.png", now.UnixNano()%17)
|
||||
}
|
||||
@@ -310,6 +313,10 @@ func detectInt(i interface{}) int {
|
||||
return int(v)
|
||||
case uint64:
|
||||
return int(v)
|
||||
case float32:
|
||||
return int(v)
|
||||
case float64:
|
||||
return int(v)
|
||||
}
|
||||
panic(fmt.Sprintf("%v is not an int", i))
|
||||
}
|
||||
|
Reference in New Issue
Block a user