generated from annihilatorrrr/gotemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtmpl.go
177 lines (175 loc) · 5.01 KB
/
tmpl.go
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
package main
const templateFile = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Go TinyStatus</title>
<style>
body {
font-family: sans-serif;
line-height: 1.6;
color: #e0e0e0;
max-width: 1200px;
margin: 0 auto;
padding: 20px;
background: #181818;
transition: background 0.3s ease, color 0.3s ease;
}
h1, h2 {
color: #e0e0e0;
text-align: center;
}
.status-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 15px;
margin-bottom: 40px;
}
.status-item {
background: #242424;
border-radius: 8px;
padding: 15px;
box-shadow: 0 2px 4px rgba(255,255,255,0.1);
text-align: center;
transition: transform .2s, background 0.3s ease;
}
.status-item:hover {
transform: translateY(-5px);
}
.status-item h3 {
margin: 0 0 10px;
}
.status-up { color: #27ae60; }
.status-down { color: #e74c3c; }
.incidents {
background: #242424;
border-radius: 8px;
padding: 20px;
box-shadow: 0 2px 4px rgba(255,255,255,0.1);
margin-bottom: 40px;
}
.footer {
text-align: center;
font-size: .9em;
color: #a0a0a0;
margin-top: 40px;
}
.footer a {
color: #9b59b6;
text-decoration: none;
}
.footer a:hover { text-decoration: underline; }
</style>
</head>
<body>
<h1>Go TinyStatus</h1>
<h2>Current Status:</h2>
{{range $group := .groups}}
<h3>{{$group.Title}} Status</h3>
<div class="status-grid">
{{range $result := $group.CheckResults}}
<div class="status-item">
<h3>{{$result.Name}}</h3>
<p class="{{if $result.Status}}status-up{{else}}status-down{{end}}">
{{if $result.Status}}Operational{{else}}Down{{end}}
</p>
</div>
{{end}}
</div>
{{end}}
<h2>Incident History</h2>
<div class="incidents">
{{.incidents}}
</div>
<div class="footer">
<p>Last updated: {{.last_updated}}</p>
<p><a href="history.html">View Status History</a></p>
<p>Powered by <a href="https://github.com/annihilatorrrr/gotinystatus">GoTinyStatus</a></p>
</div>
</body>
</html>`
const historyTemplateFile = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Go TinyStatus History</title>
<style>
body {
font-family: sans-serif;
line-height: 1.6;
color: #e0e0e0;
max-width: 1200px;
margin: auto;
padding: 20px;
background: #181818;
transition: background 0.3s ease, color 0.3s ease;
}
h1, h2 {
color: #e0e0e0;
text-align: center;
}
.history-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: 20px;
margin-bottom: 40px;
}
.history-item {
background: #242424;
border-radius: 8px;
padding: 15px;
box-shadow: 0 2px 4px rgba(255,255,255,0.1);
max-height: 300px;
overflow: auto;
}
.history-item h2 {
font-size: 1.2rem;
margin: 0;
}
.history-entry {
margin-bottom: 5px;
font-size: 0.9rem;
display: flex;
justify-content: space-between;
}
.status-up { color: #27ae60; }
.status-down { color: #e74c3c; }
.footer {
text-align: center;
font-size: .9em;
color: #a0a0a0;
margin-top: 40px;
}
.footer a {
color: #9b59b6;
text-decoration: none;
}
.footer a:hover { text-decoration: underline; }
</style>
</head>
<body>
<h1>Go TinyStatus History</h1>
<div class="history-grid">
{{ range $service, $entries := .history }}
<div class="history-item">
<h2>{{ $service }}</h2>
{{ range $entry := $entries }}
<div class="history-entry">
<span>{{ index (split $entry.Timestamp "T") 0 }} {{ slice (index (split $entry.Timestamp "T") 1) 0 8 }}</span>
<span class="{{ if $entry.Status }}status-up{{ else }}status-down{{ end }}">
{{ if $entry.Status }}Up{{ else }}Down{{ end }}
</span>
</div>
{{ end }}
</div>
{{ end }}
</div>
<div class="footer">
<p>Last updated: {{.last_updated}}</p>
<p><a href="/">Back to Current Status</a></p>
<p>Powered by <a href="https://github.com/annihilatorrrr/gotinystatus">GoTinyStatus</a></p>
</div>
</body>
</html>`