use templates

This commit is contained in:
lyx0 2024-02-12 20:04:02 +01:00
parent 65e760454c
commit 3ace231495
9 changed files with 45 additions and 54 deletions

View file

@ -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

View file

@ -1,13 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="width=device-width,initial-scale=1" name="viewport">
<title>nourybot - lidl twitch bot</title>
<meta property="og:title" content="nourybot - commands in {{ .Channel }}">
<meta property="og:description" content="nourybot">
</head>
<h1>Commands in {{ .Channel }}</h1>
{{ define "title" }}nourybot - commands in {{ .Channel }}{{ end }}
{{ define "body" }}
{{ with .Commands }}
{{ range . }}
<p>
@ -18,3 +10,4 @@
</p>
{{ end }}
{{ end }}
{{ end }}

View file

@ -1,13 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="width=device-width,initial-scale=1" name="viewport">
<title>nourybot - lidl twitch bot</title>
<meta property="og:title" content="nourybot - timers in {{ .Channel }}">
<meta property="og:description" content="nourybot">
</head>
<h1>Timers in {{ .Channel }}</h1>
{{ define "title" }}nourybot - timers in {{ .Channel }}{{ end }}
{{ define "body" }}
{{ with .Timers }}
{{ range . }}
<p>
@ -17,3 +9,4 @@
</p>
{{ end }}
{{ end }}
{{ end }}

View file

@ -1,13 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="width=device-width,initial-scale=1" name="viewport">
<title>nourybot - lidl twitch bot</title>
<meta property="og:title" content="nourybot - commands">
<meta property="og:description" content="nourybot">
</head>
<h1>Commands</h1>
{{ define "title" }}nourybot - commands{{ end }}
{{ define "body" }}
<p>General commands:</p>
{{ with .Commands }}
{{ range . }}
@ -23,3 +15,4 @@
</p>
{{ end }}
{{ end }}
{{ end }}

View file

@ -1,3 +1,3 @@
{{ define "footer" }}
Powered by <a href="https://go.dev/">Go</a>
Source: <a href="https://github.com/lyx0/nourybot">github</a>
{{ end }}

View file

@ -1,14 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="width=device-width,initial-scale=1" name="viewport">
<title>nourybot - lidl twitch bot</title>
<meta property="og:title" content="nourybot - timers">
<meta property="og:description" content="nourybot">
</head>
<h1>Timers</h1>
<p>General commands:</p>
{{ define "title" }}nourybot - timer {{ end }}
{{ define "body" }}
{{ with .Timers }}
{{ range . }}
<p>
@ -18,3 +9,4 @@
</p>
{{ end }}
{{ end }}
{{ end }}