mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
use templates
This commit is contained in:
parent
65e760454c
commit
3ace231495
|
@ -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
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<meta property="og:description" content="nourybot">
|
||||
</head>
|
||||
<header>
|
||||
{{ template "header" .}}
|
||||
{{ template "header" . }}
|
||||
</header>
|
||||
<body>
|
||||
{{ template "body" . }}
|
||||
|
|
|
@ -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 }}
|
||||
|
|
|
@ -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 }}
|
||||
|
|
|
@ -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 }}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{{define "footer"}}
|
||||
Powered by <a href="https://go.dev/">Go</a>
|
||||
{{end}}
|
||||
{{ define "footer" }}
|
||||
Source: <a href="https://github.com/lyx0/nourybot">github</a>
|
||||
{{ end }}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{{define "header"}}
|
||||
{{ define "header" }}
|
||||
<h1><a href='/'>nourybot</a></h1>
|
||||
{{end}}
|
||||
{{ end }}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{{define "title"}}nourybot{{end}}
|
||||
{{define "body"}}
|
||||
{{ define "title" }}nourybot{{ end }}
|
||||
{{ define "body" }}
|
||||
<p>Channels connected to:</hp>
|
||||
<table>
|
||||
<tr>
|
||||
|
@ -15,4 +15,4 @@
|
|||
{{ end }}
|
||||
{{ end }}
|
||||
</table>
|
||||
{{end}}
|
||||
{{ end }}
|
||||
|
|
|
@ -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 }}
|
||||
|
|
Loading…
Reference in a new issue