feat: separate irc page

This commit is contained in:
Lain Iwakura 2026-05-19 23:22:01 +03:00
parent 227226b291
commit 7f05221b1b
Signed by: lain
GPG key ID: 8160466B2E8D1441
4 changed files with 54 additions and 4 deletions

16
main.go
View file

@ -32,14 +32,26 @@ func main() {
os.Exit(1) os.Exit(1)
} }
ircHTML, err := fs.ReadFile(static, "irc.html")
if err != nil {
slog.Error("read irc", "err", err)
os.Exit(1)
}
pages := map[string][]byte{
"/": indexHTML,
"/irc": ircHTML,
}
mux := http.NewServeMux() mux := http.NewServeMux()
mux.HandleFunc("GET /", func(w http.ResponseWriter, r *http.Request) { mux.HandleFunc("GET /", func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" { page, ok := pages[r.URL.Path]
if !ok {
http.NotFound(w, r) http.NotFound(w, r)
return return
} }
uptime := uptimeLine() uptime := uptimeLine()
body := strings.ReplaceAll(string(indexHTML), "{{uptime}}", html.EscapeString(uptime)) body := strings.ReplaceAll(string(page), "{{uptime}}", html.EscapeString(uptime))
w.Header().Set("Content-Type", "text/html; charset=utf-8") w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.Header().Set("Cache-Control", "no-store") w.Header().Set("Cache-Control", "no-store")
_, _ = w.Write([]byte(body)) _, _ = w.Write([]byte(body))

View file

@ -10,8 +10,8 @@
<div class="container"> <div class="container">
<h1>Welcome home. Again.</h1> <h1>Welcome home. Again.</h1>
<div class="links"> <div class="links">
<a href="https://src.cultist.club">src</a> <a href="https://src.cultist.club" target="_blank">src</a>
<a href="ircs://irc.cultist.club:6697">irc</a> <a href="/irc">irc</a>
</div> </div>
<div class="uptime"> <div class="uptime">
<marquee>{{uptime}}</marquee> <marquee>{{uptime}}</marquee>

23
web/irc.html Normal file
View file

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>irc - cultist.club</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>cultist.club</h1>
<div class="info">
<p>server: <span class="hl">cultist.club</span></p>
<p>port: <span class="hl">6697</span> (tls)</p>
<p>channel: <span class="hl">#main</span></p>
</div>
<div class="links">
<a href="ircs://irc.cultist.club:6697">open in client</a>
<a href="/">back</a>
</div>
</div>
</body>
</html>

View file

@ -44,6 +44,21 @@ h1 {
color: var(--muted); color: var(--muted);
} }
.info {
margin-top: 1.5rem;
font-size: 0.85rem;
color: var(--muted);
line-height: 1.8;
}
.info p {
margin: 0;
}
.hl {
color: var(--fg);
}
.uptime { .uptime {
margin-top: 2rem; margin-top: 2rem;
overflow: hidden; overflow: hidden;