-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
138 lines (125 loc) · 2.53 KB
/
main.go
File metadata and controls
138 lines (125 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package main
import (
"embed"
"flag"
"fmt"
"github.com/anhgelus/golatt"
"os"
)
type HeroData struct {
Title string
Description string
Image string
Dark bool
Min bool
}
type SeasonData struct {
Left bool
Title string
Description []string
Image string
ImageAlt string
Href string
}
type PersonData struct {
Name string
Image string
Description string
Link string
}
type CommonData struct {
HasFooter bool
HasNav bool
Hero *HeroData
Team []*PersonData
}
//go:embed templates dist public
var templates embed.FS
var g *golatt.Golatt
var (
dev bool = false
port int = 80
)
func init() {
flag.BoolVar(&dev, "dev", dev, "development mode")
flag.IntVar(&port, "port", port, "port")
}
func main() {
flag.Parse()
if dev {
g = golatt.New(os.DirFS("templates"), os.DirFS("public"), os.DirFS("dist"))
} else {
g = golatt.New(
golatt.UsableEmbedFS("templates", templates),
golatt.UsableEmbedFS("public", templates),
golatt.UsableEmbedFS("dist", templates),
)
}
g.NotFoundHandler = handleNotFound
g.DefaultSeoData = &golatt.SeoData{
Image: "",
Description: "",
Domain: "architects-land.anhgelus.world",
}
g.FormatTitle = func(t string) string {
if t == "Architects Land" {
return t
}
return t + " - Architects Land"
}
g.Templates = append(g.Templates,
"organisms/*.gohtml",
"molecules/*.gohtml",
"atoms/*.gohtml",
"base/*.gohtml",
)
g.TemplateFuncMap["getSkin"] = GetSkin
g.HandleFunc("/", handleHome)
g.NewTemplate("rules",
"/rules",
"Règles",
"purgatory.webp",
"Les Règles d'Architects Land",
CommonData{
HasFooter: true,
HasNav: true,
Hero: &HeroData{
Title: "Règles",
Description: "",
Image: "purgatory.jpg",
Dark: false,
Min: true,
},
}).
Handle()
g.NewTemplate("team",
"/team",
"Équipe",
"supernoob-field.jpg",
"L'équipe derrière Architects Land",
CommonData{
HasFooter: true,
HasNav: true,
Hero: &HeroData{
Title: "Équipe",
Description: "",
Image: "supernoob-field.jpg",
Dark: true,
Min: true,
},
Team: team,
}).
Handle()
g.HandleFunc("/season/{id:[a-z-]+}", handleSeason)
g.HandleFunc("/season/{id:[a-z-]+}/player/{player}", handlePlayer)
g.HandleFunc("/season/{id:[a-z-]+}/skins/3d/{player}.png", handleSkin)
s := fmt.Sprintf(":%d", port)
if dev {
if port == 80 {
s = ":8000"
}
g.StartServer(s)
} else {
g.StartServer(s)
}
}