diff --git a/cmd/nourybot/router.go b/cmd/nourybot/router.go index 61652f6..5c96094 100644 --- a/cmd/nourybot/router.go +++ b/cmd/nourybot/router.go @@ -34,7 +34,12 @@ type timersRouteData struct { } func (app *application) timersRoute(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { - t, err := template.ParseFiles("./web/templates/timers.page.gohtml") + t, err := template.ParseFiles( + "./web/templates/base.template.gohtml", + "./web/templates/header.partial.gohtml", + "./web/templates/footer.partial.gohtml", + "./web/templates/timers.page.gohtml", + ) if err != nil { app.Log.Error(err) return @@ -79,7 +84,12 @@ type channelTimersRouteData struct { func (app *application) channelTimersRoute(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { channel := ps.ByName("channel") - t, err := template.ParseFiles("./web/templates/channeltimers.page.gohtml") + t, err := template.ParseFiles( + "./web/templates/base.template.gohtml", + "./web/templates/header.partial.gohtml", + "./web/templates/footer.partial.gohtml", + "./web/templates/channeltimers.page.gohtml", + ) if err != nil { app.Log.Error(err) return @@ -122,7 +132,12 @@ type commandsRouteData struct { } func (app *application) commandsRoute(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { - t, err := template.ParseFiles("./web/templates/commands.page.gohtml") + t, err := template.ParseFiles( + "./web/templates/base.template.gohtml", + "./web/templates/header.partial.gohtml", + "./web/templates/footer.partial.gohtml", + "./web/templates/commands.page.gohtml", + ) if err != nil { app.Log.Error(err) return @@ -203,7 +218,12 @@ type channelCommandsRouteData struct { func (app *application) channelCommandsRoute(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { channel := ps.ByName("channel") - t, err := template.ParseFiles("./web/templates/channelcommands.page.gohtml") + t, err := template.ParseFiles( + "./web/templates/base.template.gohtml", + "./web/templates/header.partial.gohtml", + "./web/templates/footer.partial.gohtml", + "./web/templates/channelcommands.page.gohtml", + ) if err != nil { app.Log.Error(err) return diff --git a/web/templates/base.template.gohtml b/web/templates/base.template.gohtml index 41ebf93..88af319 100644 --- a/web/templates/base.template.gohtml +++ b/web/templates/base.template.gohtml @@ -8,7 +8,7 @@
- {{ template "header" .}} + {{ template "header" . }}
{{ template "body" . }} diff --git a/web/templates/channelcommands.page.gohtml b/web/templates/channelcommands.page.gohtml index 7e567ed..3c76731 100644 --- a/web/templates/channelcommands.page.gohtml +++ b/web/templates/channelcommands.page.gohtml @@ -1,13 +1,5 @@ - - - - - - nourybot - lidl twitch bot - - - -

Commands in {{ .Channel }}

+{{ define "title" }}nourybot - commands in {{ .Channel }}{{ end }} +{{ define "body" }} {{ with .Commands }} {{ range . }}

@@ -18,3 +10,4 @@

{{ end }} {{ end }} +{{ end }} diff --git a/web/templates/channeltimers.page.gohtml b/web/templates/channeltimers.page.gohtml index 4bfae84..e9174b4 100644 --- a/web/templates/channeltimers.page.gohtml +++ b/web/templates/channeltimers.page.gohtml @@ -1,13 +1,5 @@ - - - - - - nourybot - lidl twitch bot - - - -

Timers in {{ .Channel }}

+{{ define "title" }}nourybot - timers in {{ .Channel }}{{ end }} +{{ define "body" }} {{ with .Timers }} {{ range . }}

@@ -17,3 +9,4 @@

{{ end }} {{ end }} +{{ end }} diff --git a/web/templates/commands.page.gohtml b/web/templates/commands.page.gohtml index 3ef1d99..ac6c814 100644 --- a/web/templates/commands.page.gohtml +++ b/web/templates/commands.page.gohtml @@ -1,13 +1,5 @@ - - - - - - nourybot - lidl twitch bot - - - -

Commands

+{{ define "title" }}nourybot - commands{{ end }} +{{ define "body" }}

General commands:

{{ with .Commands }} {{ range . }} @@ -23,3 +15,4 @@

{{ end }} {{ end }} +{{ end }} diff --git a/web/templates/footer.partial.gohtml b/web/templates/footer.partial.gohtml index 7d9aa21..0e772f5 100644 --- a/web/templates/footer.partial.gohtml +++ b/web/templates/footer.partial.gohtml @@ -1,3 +1,3 @@ -{{define "footer"}} -Powered by Go -{{end}} +{{ define "footer" }} +Source: github +{{ end }} diff --git a/web/templates/header.partial.gohtml b/web/templates/header.partial.gohtml index 09c7a13..537071b 100644 --- a/web/templates/header.partial.gohtml +++ b/web/templates/header.partial.gohtml @@ -1,3 +1,3 @@ -{{define "header"}} +{{ define "header" }}

nourybot

-{{end}} +{{ end }} diff --git a/web/templates/home.page.gohtml b/web/templates/home.page.gohtml index c245e48..ec41b93 100644 --- a/web/templates/home.page.gohtml +++ b/web/templates/home.page.gohtml @@ -1,5 +1,5 @@ -{{define "title"}}nourybot{{end}} -{{define "body"}} +{{ define "title" }}nourybot{{ end }} +{{ define "body" }}

Channels connected to: @@ -15,4 +15,4 @@ {{ end }} {{ end }}
-{{end}} +{{ end }} diff --git a/web/templates/timers.page.gohtml b/web/templates/timers.page.gohtml index 1b7ec77..1c3704d 100644 --- a/web/templates/timers.page.gohtml +++ b/web/templates/timers.page.gohtml @@ -1,14 +1,5 @@ - - - - - - nourybot - lidl twitch bot - - - -

Timers

-

General commands:

+{{ define "title" }}nourybot - timer {{ end }} +{{ define "body" }} {{ with .Timers }} {{ range . }}

@@ -18,3 +9,4 @@

{{ end }} {{ end }} +{{ end }}