stormlight-tracker/index.go

52 lines
1.6 KiB
Go
Raw Normal View History

2024-05-15 01:39:21 +00:00
package main
import (
"html/template"
"net/http"
"time"
)
type IndexPage struct {
BookTitle string
Timestamp string
}
func index(w http.ResponseWriter, r *http.Request) {
page := template.Must(template.New("index").Parse(indexPage))
deadline := time.Date(2024, 12, 1, 0, 0, 0, 0, time.UTC)
timeRemaining := deadline.Sub(time.Now().Round(24 * time.Hour))
book, timestamp := getBookWithTimestamp(timeRemaining)
data := IndexPage{
BookTitle: book,
Timestamp: timestamp.String(),
}
page.Execute(w, data)
}
const indexPage string = `<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, height=device-height, user-scalable=no, initial-scale=1.0"/>
<title>Stormlight Archive Tracker</title>
<meta name="description" content="UwU"/>
<link rel="canonical" href="https://stormlight.scalio.me"/>
<style>
body {margin: 5% auto; background: #f2f2f2; color: #444444; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.8; text-shadow: 0 1px 0 #ffffff; max-width: 73%;}
code {background: white;}
a {border-bottom: 1px solid #444444; color: #444444; text-decoration: none;}
a:hover {border-bottom: 0;}
</style>
</head>
<body>
<h1>Stormlight Archive Tracker</h1>
<p>
2024-06-27 22:17:38 +00:00
You should be reading <strong>{{.BookTitle}}</strong> and be past the <strong>{{.Timestamp}}</strong> mark by the end of the day.
2024-05-15 01:39:21 +00:00
</p>
</body>
</html>`