aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--frontend/renderer.go6
-rw-r--r--main.go4
-rw-r--r--views/pages/user.html2
3 files changed, 9 insertions, 3 deletions
diff --git a/frontend/renderer.go b/frontend/renderer.go
index 3fb79bf..d529dff 100644
--- a/frontend/renderer.go
+++ b/frontend/renderer.go
@@ -50,7 +50,7 @@ func (r *Renderer) SetDefaultData(data map[string]interface{}) {
50} 50}
51 51
52// New erstellt einen neuen Renderer und sucht alle Templates aus dem gegebenen pfad. 52// New erstellt einen neuen Renderer und sucht alle Templates aus dem gegebenen pfad.
53func New(path string) *Renderer { 53func New(path string, functions map[string]interface{}) *Renderer {
54 // Custom Template Funcs 54 // Custom Template Funcs
55 funcMap := template.FuncMap{ 55 funcMap := template.FuncMap{
56 "html": func(in string) template.HTML { 56 "html": func(in string) template.HTML {
@@ -73,6 +73,10 @@ func New(path string) *Renderer {
73 }, 73 },
74 } 74 }
75 75
76 for k, v := range functions {
77 funcMap[k] = v
78 }
79
76 files := make([]string, 0) 80 files := make([]string, 0)
77 filepath.Walk(path, func(path string, info os.FileInfo, err error) error { 81 filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
78 if info.IsDir() || !strings.HasSuffix(path, ".html") { 82 if info.IsDir() || !strings.HasSuffix(path, ".html") {
diff --git a/main.go b/main.go
index 240ca1a..dd00a9b 100644
--- a/main.go
+++ b/main.go
@@ -63,7 +63,9 @@ func main() {
63 } 63 }
64 } 64 }
65 65
66 renderer := frontend.New("views") 66 functions := charakterin.GetRendererFunctions()
67
68 renderer := frontend.New("views", functions)
67 login := charakterin.New(db) 69 login := charakterin.New(db)
68 login.UseRenderer(renderer) 70 login.UseRenderer(renderer)
69 if config.AnilistAPI.ClientID != "" && config.AnilistAPI.ClientSecret != "" { 71 if config.AnilistAPI.ClientID != "" && config.AnilistAPI.ClientSecret != "" {
diff --git a/views/pages/user.html b/views/pages/user.html
index 3c9d145..66cd62d 100644
--- a/views/pages/user.html
+++ b/views/pages/user.html
@@ -1,5 +1,5 @@
1{{ define "user" }} 1{{ define "user" }}
2{{ $isCurrentUser := (and .user (eq .DisplayUser.ID .user.ID)) }} 2{{ $isCurrentUser := isSameUser .DisplayUser .user }}
3<html> 3<html>
4 <head> 4 <head>
5 {{ template "materialize" }} 5 {{ template "materialize" }}