make use of template engine, add footer
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Philipp 2021-10-01 22:49:47 +02:00
parent 4fd2f099b8
commit 48d9621adf
6 changed files with 278 additions and 259 deletions

View file

@ -1,6 +1,7 @@
package main package main
import ( import (
"time"
"log" "log"
"net/http" "net/http"
@ -24,20 +25,49 @@ func main() {
log.Fatal("There is an issue with the databse: %w", err) log.Fatal("There is an issue with the databse: %w", err)
} }
var addedServers []string
for _, server := range addedServers {
println(server)
}
for _, s := range ss { for _, s := range ss {
serverString := s.ServerIP serverString := s.ServerIP
c := cron.New() if !stringInSlice(s.ServerIP, addedServers) {
c.AddFunc("*/1 * * * *", func() { updateServers(serverString, store) }) addedServers = append(addedServers, s.ServerIP)
c.Start() c := cron.New()
c.AddFunc("*/1 * * * *", func() { updateServers(serverString, store) })
c.Start()
}
} }
cronjob := cron.New()
cronjob.AddFunc("*/5 * * * *", func() {
for _, s := range ss {
serverString := s.ServerIP
if !stringInSlice(s.ServerIP, addedServers) {
addedServers = append(addedServers, s.ServerIP)
c := cron.New()
c.AddFunc("*/1 * * * *", func() { updateServers(serverString, store) })
c.Start()
}
}
})
cronjob.Start()
h := web.NewHandler(store) h := web.NewHandler(store)
http.ListenAndServe(":3000", h) http.ListenAndServe(":3000", h)
} }
func stringInSlice(a string, list []string) bool {
for _, b := range list {
if b == a {
return true
}
}
return false
}
func updateServers(host string, store steamServer.Store) { func updateServers(host string, store steamServer.Store) {
client, err := a2s.NewClient(host) client, err := a2s.NewClient(host, a2s.TimeoutOption(time.Second * 10))
if err != nil { if err != nil {
log.Fatal("Creation of client failed: %w", err) log.Fatal("Creation of client failed: %w", err)
@ -50,6 +80,13 @@ func updateServers(host string, store steamServer.Store) {
if err != nil { if err != nil {
log.Printf("Querying failed: %s", err) log.Printf("Querying failed: %s", err)
server := steamServer.Server {
Name: host,
Map: "Server didn't reply.",
Players: 0,
}
store.UpdateServerByQuery(&server, host)
return return
} }

View file

@ -22,7 +22,7 @@ func (s *GamemodeStore) Gamemode(name string) (steamServer.Gamemode, error) {
func (s *GamemodeStore) Gamemodes() ([]steamServer.Gamemode, error) { func (s *GamemodeStore) Gamemodes() ([]steamServer.Gamemode, error) {
var gg []steamServer.Gamemode var gg []steamServer.Gamemode
var query = `SELECT * FROM gamemodes ORDER BY name ASC` var query = `SELECT * FROM public.gamemodes ORDER BY CASE name WHEN 'Deathmatch' THEN 1 WHEN 'MGE' THEN 2 WHEN 'Jumpserver' THEN 3 WHEN 'Casual' THEN 4 END`
if err := s.Select(&gg, query); err != nil { if err := s.Select(&gg, query); err != nil {
return []steamServer.Gamemode{}, fmt.Errorf("error gettings servers: %w", err) return []steamServer.Gamemode{}, fmt.Errorf("error gettings servers: %w", err)
} }

View file

@ -1,125 +1,70 @@
<!DOCTYPE html> {{define "title"}}
<html lang="en"><head> <title>Serverlist :: {{.Region}}</title>
<title>Serverlist :: {{.Region}}</title> {{end}}
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" type="image/x-icon" href="https://spenny.tf/favicon.ico"/>
<link href="https://unpkg.com/tailwindcss@1.0.4/dist/tailwind.min.css" rel="stylesheet">
<script async defer data-website-id="084ca01d-5337-4f12-8932-3033addbc175" src="https://a.v0v.de/t.js"></script>
<script defer data-domain="serverlist.tf" src="https://t.v0v.de/js/t.js"></script>
<style>
tr#content {
line-height: 0;
}
td#flag {
padding-right: 0;
}
td#name {
padding-left: 0;
}
</style>
</head>
<body class="flex justify-center" style="background: #edf2f7;">
<section class="container mx-auto px-8 my-1 flex flex-wrap -m-4">
<div class="p-2 md:w-40">
<a href="/" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
<div>
<p class=" text-xs font-medium ">All Regions</p>
</div>
</a>
</div>
<div class="p-2 md:w-40">
<a href="/america" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
<div>
<p class=" text-xs font-medium ">North America</p>
</div>
</a>
</div>
<div class="p-2 md:w-40">
<a href="/europe" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
<div>
<p class=" text-xs font-medium ">Europe</p>
</div>
</a>
</div>
<div class="p-2 md:w-40">
<a href="/australia" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
<div>
<p class=" text-xs font-medium ">Australia</p>
</div>
</a>
</div>
<div class="p-2 md:w-40">
<a href="/asia" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
<div>
<p class=" text-xs font-medium ">Asia</p>
</div>
</a>
</div>
{{ $gamemodes := .Gamemodes}} {{define "content"}}
{{ $servers := .Servers}} {{ $gamemodes := .Gamemodes}}
{{ $flags := .Flags}} {{ $servers := .Servers}}
<div class="container mx-auto px-4 sm:px-8"> {{ $flags := .Flags}}
<div class="py-8"> <div class="container mx-auto px-4 sm:px-8">
<div> <div class="py-8">
<h2 class="text-2xl font-semibold leading-tight">{{.Region}}</h2> <div>
</div> <h2 class="text-2xl font-semibold leading-tight">{{.Region}}</h2>
{{range $gamemode := $gamemodes}}
<div class="-mx-4 sm:-mx-8 px-4 sm:px-8 py-4 overflow-x-auto">
<div class="inline-block min-w-full shadow rounded-lg overflow-hidden">
<table class="min-w-full leading-normal">
<thead>
<tr>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
</th>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
{{$gamemode.Name}}
</th>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
Map
</th>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
Players
</th>
</tr>
</thead>
<tbody>
{{range $server := $servers}}
{{if eq $gamemode.ID $server.GamemodeID}}
<tr id="content">
<td class="px-5 border-b border-gray-200 bg-white" id="flag">
{{range $flag := $flags}}
{{if eq $server.ServerIP $flag.ServerIP}}
<img src="https://flagcdn.com/16x12/{{$flag.Flag}}.png" srcset="https://flagcdn.com/32x24/{{$flag.Flag}}.png 2x, https://flagcdn.com/48x36/{{$flag.Flag}}.png 3x" width="16" height="12">
{{end}}
{{end}}
</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm" id="name">
<div class="flex items-center">
<div class="ml-3">
<a href="steam://connect/{{$server.ServerIP}}" class="text-gray-900 whitespace-no-wrap">{{$server.Name}}</a>
</div>
</div>
</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
<p class="text-gray-900 whitespace-no-wrap">{{$server.Map}}</p>
</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
<p class="text-gray-900 whitespace-no-wrap">{{$server.Players}}/{{$server.MaxPlayers}}</p>
</td>
</tr>
{{end}}
{{end}}
</tbody>
</table>
</div>
</div>
{{end}}
</div> </div>
{{range $gamemode := $gamemodes}}
<div class="-mx-4 sm:-mx-8 px-4 sm:px-8 py-4 overflow-x-auto">
<div class="inline-block min-w-full shadow rounded-lg overflow-hidden">
<table class="min-w-full leading-normal">
<thead>
<tr>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
</th>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
{{$gamemode.Name}}
</th>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
Map
</th>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
Players
</th>
</tr>
</thead>
<tbody>
{{range $server := $servers}}
{{if eq $gamemode.ID $server.GamemodeID}}
<tr id="content">
<td class="px-5 border-b border-gray-200 bg-white" id="flag">
{{range $flag := $flags}}
{{if eq $server.ServerIP $flag.ServerIP}}
<img src="https://flagcdn.com/16x12/{{$flag.Flag}}.png" srcset="https://flagcdn.com/32x24/{{$flag.Flag}}.png 2x, https://flagcdn.com/48x36/{{$flag.Flag}}.png 3x" width="16" height="12">
{{end}}
{{end}}
</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm" id="name">
<div class="flex items-center">
<div class="ml-3">
<a href="steam://connect/{{$server.ServerIP}}" class="text-gray-900 whitespace-no-wrap">{{$server.Name}}</a>
</div>
</div>
</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
<p class="text-gray-900 whitespace-no-wrap">{{$server.Map}}</p>
</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
<p class="text-gray-900 whitespace-no-wrap">{{$server.Players}}/{{$server.MaxPlayers}}</p>
</td>
</tr>
{{end}}
{{end}}
</tbody>
</table>
</div>
</div>
{{end}}
</div> </div>
</body> </div>
</html> </section>
{{end}}

92
templates/layout.html Normal file
View file

@ -0,0 +1,92 @@
<!DOCTYPE html>
<html lang="en"><head>
{{block "title" .}}{{end}}
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" type="image/x-icon" href="https://spenny.tf/favicon.ico"/>
<link href="https://unpkg.com/tailwindcss@1.0.4/dist/tailwind.min.css" rel="stylesheet">
<script async defer data-website-id="084ca01d-5337-4f12-8932-3033addbc175" src="https://a.v0v.de/t.js"></script>
<script defer data-domain="serverlist.tf" src="https://t.v0v.de/js/t.js"></script>
<style>
tr#content {
line-height: 0;
}
td#flag {
padding-right: 0;
}
td#name {
padding-left: 0;
}
</style>
</head>
<body class="max-w-screen-xl px-4 py-12 mx-auto space-y-8 sm:px-6 lg:px-8" style="background: #edf2f7;">
<section class="container mx-auto px-8 my-1 flex flex-wrap -m-4">
<div class="p-2 md:w-40">
<a href="/" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
<div>
<p class=" text-xs font-medium ">All Regions</p>
</div>
</a>
</div>
<div class="p-2 md:w-40">
<a href="/america" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
<div>
<p class=" text-xs font-medium ">North America</p>
</div>
</a>
</div>
<div class="p-2 md:w-40">
<a href="/europe" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
<div>
<p class=" text-xs font-medium ">Europe</p>
</div>
</a>
</div>
<div class="p-2 md:w-40">
<a href="/australia" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
<div>
<p class=" text-xs font-medium ">Australia</p>
</div>
</a>
</div>
<div class="p-2 md:w-40">
<a href="/asia" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
<div>
<p class=" text-xs font-medium ">Asia</p>
</div>
</a>
</div>
{{block "content" .}}{{end}}
</body>
<!-- Foooter -->
<section class="bg-white rounded-lg">
<div class="max-w-screen-xl px-4 py-12 mx-auto space-y-8 overflow-hidden sm:px-6 lg:px-8">
<nav class="flex flex-wrap justify-center -mx-5 -my-2">
<div class="px-5 py-2">
<a href="https://spenny.tf/discord" class="text-base leading-6 text-gray-500 hover:text-gray-900">
Get added
</a>
</div>
<div class="px-5 py-2">
<a href="https://spenny.tf/discord" class="text-base leading-6 text-gray-500 hover:text-gray-900">
Discord
</a>
</div>
<div class="px-5 py-2">
<a href="https://spenny.tf" class="text-base leading-6 text-gray-500 hover:text-gray-900">
spenny.tf
</a>
</div>
<div class="px-5 py-2">
<a href="https://www.teamfortress.tv/60348" class="text-base leading-6 text-gray-500 hover:text-gray-900">
teamfortress.tv
</a>
</div>
</nav>
<p class="mt-8 text-base leading-6 text-center text-gray-400">
© 2021 Serverlist.tf
</p>
</div>
</section>
</html>

View file

@ -1,130 +1,75 @@
<!DOCTYPE html> {{define "title"}}
<html lang="en"><head> <title>Serverlist :: {{.Region}}</title>
<title>Serverlist :: {{.Region}}</title> {{end}}
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" type="image/x-icon" href="https://spenny.tf/favicon.ico"/>
<link href="https://unpkg.com/tailwindcss@1.0.4/dist/tailwind.min.css" rel="stylesheet">
<script async defer data-website-id="084ca01d-5337-4f12-8932-3033addbc175" src="https://a.v0v.de/t.js"></script>
<script defer data-domain="serverlist.tf" src="https://t.v0v.de/js/t.js"></script>
<style>
tr#content {
line-height: 0;
}
td#flag {
padding-right: 0;
}
td#name {
padding-left: 0;
}
</style>
</head>
<body class="flex justify-center" style="background: #edf2f7;">
<section class="container mx-auto px-8 my-1 flex flex-wrap -m-4">
<div class="p-2 md:w-40">
<a href="/" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
<div>
<p class=" text-xs font-medium ">All Regions</p>
</div>
</a>
</div>
<div class="p-2 md:w-40">
<a href="/america" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
<div>
<p class=" text-xs font-medium ">North America</p>
</div>
</a>
</div>
<div class="p-2 md:w-40">
<a href="/europe" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
<div>
<p class=" text-xs font-medium ">Europe</p>
</div>
</a>
</div>
<div class="p-2 md:w-40">
<a href="/australia" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
<div>
<p class=" text-xs font-medium ">Australia</p>
</div>
</a>
</div>
<div class="p-2 md:w-40">
<a href="/asia" class="flex items-center p-4 bg-blue-200 rounded-lg shadow-xs cursor-pointer hover:bg-blue-500 hover:text-gray-100">
<div>
<p class=" text-xs font-medium ">Asia</p>
</div>
</a>
</div>
{{ $gamemodes := .Gamemodes}} {{define "content"}}
{{ $gamemodesCount := .GamemodeCount}} {{ $gamemodes := .Gamemodes}}
{{ $servers := .Servers}} {{ $gamemodesCount := .GamemodeCount}}
{{ $flags := .Flags}} {{ $servers := .Servers}}
<div class="container mx-auto px-4 sm:px-8"> {{ $flags := .Flags}}
<div class="py-8"> <div class="container mx-auto px-4 sm:px-8">
<div> <div class="py-8">
<h2 class="text-2xl font-semibold leading-tight">{{.Region}}</h2> <div>
</div> <h2 class="text-2xl font-semibold leading-tight">{{.Region}}</h2>
{{range $gamemode := $gamemodes}}
{{range $gamemodeCount := $gamemodesCount}}
{{if eq $gamemode.ID $gamemodeCount.ID}}
<div class="-mx-4 sm:-mx-8 px-4 sm:px-8 py-4 overflow-x-auto">
<div class="inline-block min-w-full shadow rounded-lg overflow-hidden">
<table class="min-w-full leading-normal">
<thead>
<tr>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
</th>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
{{$gamemode.Name}}
</th>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
Map
</th>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
Players
</th>
</tr>
</thead>
<tbody>
{{range $server := $servers}}
{{if eq $gamemode.ID $server.GamemodeID}}
<tr id="content">
<td class="px-5 border-b border-gray-200 bg-white" id="flag">
{{range $flag := $flags}}
{{if eq $server.ServerIP $flag.ServerIP}}
<img src="https://flagcdn.com/16x12/{{$flag.Flag}}.png" srcset="https://flagcdn.com/32x24/{{$flag.Flag}}.png 2x, https://flagcdn.com/48x36/{{$flag.Flag}}.png 3x" width="16" height="12">
{{end}}
{{end}}
</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm" id="name">
<div class="flex items-center">
<div class="ml-3">
<a href="steam://connect/{{$server.ServerIP}}" class="text-gray-900 whitespace-no-wrap">{{$server.Name}}</a>
</div>
</div>
</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
<p class="text-gray-900 whitespace-no-wrap">{{$server.Map}}</p>
</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
<p class="text-gray-900 whitespace-no-wrap">{{$server.Players}}/{{$server.MaxPlayers}}</p>
</td>
</tr>
{{end}}
{{end}}
</tbody>
</table>
</div>
</div>
{{end}}
{{end}}
{{end}}
</div> </div>
{{range $gamemode := $gamemodes}}
{{range $gamemodeCount := $gamemodesCount}}
{{if eq $gamemode.ID $gamemodeCount.ID}}
<div class="-mx-4 sm:-mx-8 px-4 sm:px-8 py-4 overflow-x-auto">
<div class="inline-block min-w-full shadow rounded-lg overflow-hidden">
<table class="min-w-full leading-normal">
<thead>
<tr>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
</th>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
{{$gamemode.Name}}
</th>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
Map
</th>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
Players
</th>
</tr>
</thead>
<tbody>
{{range $server := $servers}}
{{if eq $gamemode.ID $server.GamemodeID}}
<tr id="content">
<td class="px-5 border-b border-gray-200 bg-white" id="flag">
{{range $flag := $flags}}
{{if eq $server.ServerIP $flag.ServerIP}}
<img src="https://flagcdn.com/16x12/{{$flag.Flag}}.png" srcset="https://flagcdn.com/32x24/{{$flag.Flag}}.png 2x, https://flagcdn.com/48x36/{{$flag.Flag}}.png 3x" width="16" height="12">
{{end}}
{{end}}
</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm" id="name">
<div class="flex items-center">
<div class="ml-3">
<a href="steam://connect/{{$server.ServerIP}}" class="text-gray-900 whitespace-no-wrap">{{$server.Name}}</a>
</div>
</div>
</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
<p class="text-gray-900 whitespace-no-wrap">{{$server.Map}}</p>
</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
<p class="text-gray-900 whitespace-no-wrap">{{$server.Players}}/{{$server.MaxPlayers}}</p>
</td>
</tr>
{{end}}
{{end}}
</tbody>
</table>
</div>
</div>
{{end}}
{{end}}
{{end}}
</div> </div>
</body> </div>
</html> </section>
{{end}}

View file

@ -40,7 +40,7 @@ func (h *Handler) Home() http.HandlerFunc {
Flags []steamServer.Flag Flags []steamServer.Flag
} }
tmpl := template.Must(template.ParseFiles("templates/home.html")) tmpl := template.Must(template.ParseFiles("templates/layout.html", "templates/home.html"))
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
ss, err := h.store.Servers() ss, err := h.store.Servers()
if err != nil { if err != nil {
@ -77,7 +77,7 @@ func (h *Handler) Europe() http.HandlerFunc {
Flags []steamServer.Flag Flags []steamServer.Flag
} }
tmpl := template.Must(template.ParseFiles("templates/region.html")) tmpl := template.Must(template.ParseFiles("templates/layout.html", "templates/region.html"))
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
reg, err := h.store.Region("Europe") reg, err := h.store.Region("Europe")
if err != nil { if err != nil {
@ -125,7 +125,7 @@ func (h *Handler) America() http.HandlerFunc {
Flags []steamServer.Flag Flags []steamServer.Flag
} }
tmpl := template.Must(template.ParseFiles("templates/region.html")) tmpl := template.Must(template.ParseFiles("templates/layout.html", "templates/region.html"))
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
reg, err := h.store.Region("North America") reg, err := h.store.Region("North America")
if err != nil { if err != nil {
@ -173,7 +173,7 @@ func (h *Handler) Asia() http.HandlerFunc {
Flags []steamServer.Flag Flags []steamServer.Flag
} }
tmpl := template.Must(template.ParseFiles("templates/region.html")) tmpl := template.Must(template.ParseFiles("templates/layout.html", "templates/region.html"))
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
reg, err := h.store.Region("Asia") reg, err := h.store.Region("Asia")
if err != nil { if err != nil {
@ -221,7 +221,7 @@ func (h *Handler) Australia() http.HandlerFunc {
Flags []steamServer.Flag Flags []steamServer.Flag
} }
tmpl := template.Must(template.ParseFiles("templates/region.html")) tmpl := template.Must(template.ParseFiles("templates/layout.html", "templates/region.html"))
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
reg, err := h.store.Region("Australia") reg, err := h.store.Region("Australia")
if err != nil { if err != nil {