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) {
|
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 {
|
if err != nil {
|
||||||
app.Log.Error(err)
|
app.Log.Error(err)
|
||||||
return
|
return
|
||||||
|
@ -79,7 +84,12 @@ type channelTimersRouteData struct {
|
||||||
|
|
||||||
func (app *application) channelTimersRoute(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
func (app *application) channelTimersRoute(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
channel := ps.ByName("channel")
|
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 {
|
if err != nil {
|
||||||
app.Log.Error(err)
|
app.Log.Error(err)
|
||||||
return
|
return
|
||||||
|
@ -122,7 +132,12 @@ type commandsRouteData struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *application) commandsRoute(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
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 {
|
if err != nil {
|
||||||
app.Log.Error(err)
|
app.Log.Error(err)
|
||||||
return
|
return
|
||||||
|
@ -203,7 +218,12 @@ type channelCommandsRouteData struct {
|
||||||
|
|
||||||
func (app *application) channelCommandsRoute(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
func (app *application) channelCommandsRoute(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
channel := ps.ByName("channel")
|
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 {
|
if err != nil {
|
||||||
app.Log.Error(err)
|
app.Log.Error(err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<meta property="og:description" content="nourybot">
|
<meta property="og:description" content="nourybot">
|
||||||
</head>
|
</head>
|
||||||
<header>
|
<header>
|
||||||
{{ template "header" .}}
|
{{ template "header" . }}
|
||||||
</header>
|
</header>
|
||||||
<body>
|
<body>
|
||||||
{{ template "body" . }}
|
{{ template "body" . }}
|
||||||
|
|
|
@ -1,13 +1,5 @@
|
||||||
<!DOCTYPE html>
|
{{ define "title" }}nourybot - commands in {{ .Channel }}{{ end }}
|
||||||
<html lang="en">
|
{{ define "body" }}
|
||||||
<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>
|
|
||||||
{{ with .Commands }}
|
{{ with .Commands }}
|
||||||
{{ range . }}
|
{{ range . }}
|
||||||
<p>
|
<p>
|
||||||
|
@ -18,3 +10,4 @@
|
||||||
</p>
|
</p>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
|
@ -1,13 +1,5 @@
|
||||||
<!DOCTYPE html>
|
{{ define "title" }}nourybot - timers in {{ .Channel }}{{ end }}
|
||||||
<html lang="en">
|
{{ define "body" }}
|
||||||
<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>
|
|
||||||
{{ with .Timers }}
|
{{ with .Timers }}
|
||||||
{{ range . }}
|
{{ range . }}
|
||||||
<p>
|
<p>
|
||||||
|
@ -17,3 +9,4 @@
|
||||||
</p>
|
</p>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
|
@ -1,13 +1,5 @@
|
||||||
<!DOCTYPE html>
|
{{ define "title" }}nourybot - commands{{ end }}
|
||||||
<html lang="en">
|
{{ define "body" }}
|
||||||
<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>
|
|
||||||
<p>General commands:</p>
|
<p>General commands:</p>
|
||||||
{{ with .Commands }}
|
{{ with .Commands }}
|
||||||
{{ range . }}
|
{{ range . }}
|
||||||
|
@ -23,3 +15,4 @@
|
||||||
</p>
|
</p>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
{{define "footer"}}
|
{{ define "footer" }}
|
||||||
Powered by <a href="https://go.dev/">Go</a>
|
Source: <a href="https://github.com/lyx0/nourybot">github</a>
|
||||||
{{end}}
|
{{ end }}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
{{define "header"}}
|
{{ define "header" }}
|
||||||
<h1><a href='/'>nourybot</a></h1>
|
<h1><a href='/'>nourybot</a></h1>
|
||||||
{{end}}
|
{{ end }}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{{define "title"}}nourybot{{end}}
|
{{ define "title" }}nourybot{{ end }}
|
||||||
{{define "body"}}
|
{{ define "body" }}
|
||||||
<p>Channels connected to:</hp>
|
<p>Channels connected to:</hp>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -15,4 +15,4 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</table>
|
</table>
|
||||||
{{end}}
|
{{ end }}
|
||||||
|
|
|
@ -1,14 +1,5 @@
|
||||||
<!DOCTYPE html>
|
{{ define "title" }}nourybot - timer {{ end }}
|
||||||
<html lang="en">
|
{{ define "body" }}
|
||||||
<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>
|
|
||||||
{{ with .Timers }}
|
{{ with .Timers }}
|
||||||
{{ range . }}
|
{{ range . }}
|
||||||
<p>
|
<p>
|
||||||
|
@ -18,3 +9,4 @@
|
||||||
</p>
|
</p>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
Loading…
Reference in a new issue