Brave advertisement
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
type TemplateData struct {
|
||||
Authenticated bool
|
||||
Username string
|
||||
UserAgent string
|
||||
UserStyle template.CSS
|
||||
APIEndpoint template.URL
|
||||
PixelAPI *pixelapi.PixelAPI
|
||||
@@ -35,6 +36,7 @@ func (wc *WebController) newTemplateData(w http.ResponseWriter, r *http.Request)
|
||||
var t = &TemplateData{
|
||||
Authenticated: false,
|
||||
Username: "",
|
||||
UserAgent: r.UserAgent(),
|
||||
UserStyle: userStyle(r),
|
||||
APIEndpoint: template.URL(wc.conf.APIURLExternal),
|
||||
URLQuery: r.URL.Query(),
|
||||
|
@@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Fornaxian/log"
|
||||
@@ -75,6 +76,7 @@ func (tm *TemplateManager) Get() *template.Template {
|
||||
func (tm *TemplateManager) funcMap() template.FuncMap {
|
||||
return template.FuncMap{
|
||||
"bgPattern": tm.bgPattern,
|
||||
"isBrave": tm.isBrave,
|
||||
"debugMode": tm.debugMode,
|
||||
"apiUrl": tm.apiURL,
|
||||
"pageNr": tm.pageNr,
|
||||
@@ -90,6 +92,9 @@ func (tm *TemplateManager) bgPattern() string {
|
||||
}
|
||||
return fmt.Sprintf("checker%d.png", now.UnixNano()%17)
|
||||
}
|
||||
func (tm *TemplateManager) isBrave(useragent string) bool {
|
||||
return strings.Contains(useragent, "Brave")
|
||||
}
|
||||
func (tm *TemplateManager) debugMode() bool {
|
||||
return tm.debugModeEnabled
|
||||
}
|
||||
|
Reference in New Issue
Block a user