Update page contents

This commit is contained in:
2026-06-24 08:17:35 -04:00
parent cb53a00e27
commit 9b5cd0c611
2 changed files with 22 additions and 6 deletions

View File

@@ -171,8 +171,8 @@
<nav aria-label="quick links"> <nav aria-label="quick links">
<a href="https://youtube.com">youtube <kbd>y</kbd></a> <a href="https://youtube.com">youtube <kbd>y</kbd></a>
<a href="https://git.fsdproject.org">Fsd Git <kbd>f</kbd></a> <a href="https://git.fsdproject.org">fsd git <kbd>f</kbd></a>
<a href="https://git.vxserver.dev">Personal Git <kbd>g</kbd></a> <a href="https://git.vxserver.dev">my git <kbd>g</kbd></a>
</nav> </nav>
<footer> <footer>
@@ -194,6 +194,7 @@
function tick() { function tick() {
const now = new Date(); const now = new Date();
clock.textContent = now.toLocaleTimeString([], { clock.textContent = now.toLocaleTimeString([], {
timeZone: "{{.Timezone}}",
hour: "2-digit", hour: "2-digit",
minute: "2-digit", minute: "2-digit",
hour12: true hour12: true

15
main.go
View File

@@ -21,6 +21,7 @@ var port = flag.Int("p", 1437, "set the port for hjem to use")
type HjemData struct { type HjemData struct {
OS string OS string
Email string Email string
Timezone string
} }
func main() { func main() {
@@ -67,12 +68,26 @@ func main() {
} }
} }
user_tz := "UTC"
if tz := os.Getenv("TZ"); tz != "" {
user_tz = tz
} else if data, err := os.ReadFile("/etc/timezone"); err == nil {
if tz := strings.TrimSpace(string(data)); tz != "" {
user_tz = tz
}
} else if path, err := os.Readlink("/etc/localtime"); err == nil {
user_tz = filepath.Join(
filepath.Base(filepath.Dir(path)),
filepath.Base(path))
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8") w.Header().Set("Content-Type", "text/html; charset=utf-8")
err := t.ExecuteTemplate(w, "hjem", HjemData{ err := t.ExecuteTemplate(w, "hjem", HjemData{
OS: user_os, OS: user_os,
Email: user_email, Email: user_email,
Timezone: user_tz,
}) })
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)