Compare commits

..
1 Commits
Author SHA1 Message Date
Sebastian UnterschützandClaude Opus 5.5 1f90fe8470 feat(statuspages): error page linking a home page set by admins
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 6m52s
ci / test (pull_request) Successful in 15m30s
ci / build (pull_request) Successful in 16m56s
ci / image (pull_request) Successful in 6m1s
The bare status page domain and pages that do not exist answered with a
plain "404 page not found". They now show an error page with a button to
the platform's home page, which platform admins set under Admin. The
status page servers receive it with the page index and keep it across
restarts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-26 20:37:59 +01:00
17 changed files with 902 additions and 395 deletions

No files matched your search

+11 -5
View File
@@ -362,14 +362,20 @@ type PageRef struct {
Host string `json:"host,omitempty"`
}
// PageIndex lists the pages a status page server serves.
type PageIndex struct {
Pages []PageRef `json:"pages"`
// HomeURL is the platform's home page, which the server links from
// its error page; empty for none.
HomeURL string `json:"home_url,omitempty"`
}
// Pages lists every page this status page server serves, so it can keep
// them all cached before anyone visits.
func (c *Client) Pages(ctx context.Context) ([]PageRef, error) {
var out struct {
Pages []PageRef `json:"pages"`
}
func (c *Client) Pages(ctx context.Context) (PageIndex, error) {
var out PageIndex
err := c.do(ctx, http.MethodGet, "/pages/index", nil, &out)
return out.Pages, err
return out, err
}
// ErrNotFound means no published page matches.
+5
View File
@@ -318,6 +318,11 @@ var endpoints = []endpoint{
{method: "PUT", path: "/api/v1/admin/checker-network", tag: "Platform", summary: "Let platform checkers check private addresses or not",
description: "Unset, they may on self-hosted installations and may not in the cloud edition. Applies from each checker's next poll.",
perm: "platform admin", req: checkerNetwork{}, status: http.StatusNoContent},
{method: "GET", path: "/api/v1/admin/statuspage-home", tag: "Platform", summary: "The home page linked from the status page servers' error page", perm: "platform admin",
resp: statusPageHome{}},
{method: "PUT", path: "/api/v1/admin/statuspage-home", tag: "Platform", summary: "Set the home page linked from the status page servers' error page",
description: "Visitors of the bare status page domain and of pages that do not exist see an error page with a link to this URL. Empty links none.",
perm: "platform admin", req: statusPageHome{}, status: http.StatusNoContent},
{method: "GET", path: "/api/v1/admin/identity-providers", tag: "Platform", summary: "Identity providers for signing up and in",
description: "With the callback URL to register at each provider. Secrets are never returned.", perm: "platform admin",
resp: obj{"providers": []idpView{}, "callback_url": ""}},
+1
View File
@@ -111,6 +111,7 @@ var auditActions = map[string]string{
"PUT /api/v1/org/legal/:kind": "org.legal_update",
"PUT /api/v1/admin/check-types": "platform.check_types_update",
"PUT /api/v1/admin/checker-network": "platform.checker_network_update",
"PUT /api/v1/admin/statuspage-home": "platform.statuspage_home_update",
"PUT /api/v1/admin/limits": "platform.limits_update",
"POST /api/v1/admin/identity-providers": "platform.idp_create",
"PUT /api/v1/admin/identity-providers/:id": "platform.idp_update",
+1 -1
View File
@@ -625,7 +625,7 @@ func (s *Server) adminPage(c *gin.Context) {
for _, t := range check.Types {
types = append(types, web.CheckTypeOption{Type: string(t), Enabled: !off[string(t)]})
}
web.Render(c, http.StatusOK, web.AdminPage(s.pageFor(c, "admin.title"), me, v, storageView(c, stats), types, s.platformPrivate(ctx), webLimits(s.platformLimits(ctx)), s.idpAdminView(ctx)))
web.Render(c, http.StatusOK, web.AdminPage(s.pageFor(c, "admin.title"), me, v, storageView(c, stats), types, s.platformPrivate(ctx), s.statusPageHome(ctx), webLimits(s.platformLimits(ctx)), s.idpAdminView(ctx)))
}
func (s *Server) adminStatusPagesPage(c *gin.Context) {
+5
View File
@@ -56,6 +56,8 @@ type Server struct {
limits *versioned[Limits]
// support caches how the platform runs support tickets.
support *versioned[supportSettings]
// pageHome caches the home page the status page servers link.
pageHome *versioned[string]
// draining, once closed, ends the long polls of checkers.
draining <-chan struct{}
// handler serves the requests agents send over their streams.
@@ -99,6 +101,7 @@ func New(cfg config.API, d Deps) *Server {
checkerNet: newVersioned[bool]("checker-network"),
limits: newVersioned[Limits]("limits"),
support: newVersioned[supportSettings]("support"),
pageHome: newVersioned[string]("statuspage-home"),
}
}
@@ -224,6 +227,8 @@ func (s *Server) Mount(r gin.IRouter) {
admin.PUT("/users/:id/suspension", s.adminSuspendUser)
admin.DELETE("/users/:id", s.adminDeleteUser)
admin.PUT("/checker-network", s.adminSetCheckerNetwork)
admin.GET("/statuspage-home", s.adminGetStatusPageHome)
admin.PUT("/statuspage-home", s.adminSetStatusPageHome)
admin.GET("/legal", s.adminListLegal)
admin.PUT("/legal/:kind", s.adminSaveLegal)
admin.GET("/regions", s.adminListRegions)
+77
View File
@@ -0,0 +1,77 @@
package api
import (
"context"
"encoding/json"
"errors"
"net/http"
"strings"
"github.com/gin-gonic/gin"
"github.com/jackc/pgx/v5"
"git.zb-server.de/ZB-Server/uptimesebi/internal/store"
"git.zb-server.de/ZB-Server/uptimesebi/internal/tenant"
)
// The status page servers answer visitors of pages that do not exist, and
// of their bare domain, with a page linking the platform's home page.
const settingStatusPageHome = "statuspage_home"
type statusPageHome struct {
// URL is the home page linked from the status page servers' error
// page; empty links none.
URL string `json:"url" binding:"max=2000"`
}
func (s *Server) statusPageHome(ctx context.Context) string {
v, err := s.pageHome.get(ctx, s.rdb, func(ctx context.Context) (string, error) {
var v statusPageHome
err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error {
raw, err := q.GetPlatformSetting(ctx, settingStatusPageHome)
if errors.Is(err, pgx.ErrNoRows) {
return nil
}
if err != nil {
return err
}
return json.Unmarshal(raw, &v)
})
return v.URL, err
})
if err != nil {
s.log.WarnContext(ctx, "loading the status page home failed", "error", err)
return ""
}
return v
}
func (s *Server) adminGetStatusPageHome(c *gin.Context) {
c.JSON(http.StatusOK, statusPageHome{URL: s.statusPageHome(c.Request.Context())})
}
func (s *Server) adminSetStatusPageHome(c *gin.Context) {
var req statusPageHome
if !bind(c, &req) {
return
}
req.URL = strings.TrimSpace(req.URL)
if req.URL != "" && !validLegalURL(req.URL) {
fail(c, http.StatusUnprocessableEntity, "invalid_legal_url")
return
}
ctx := c.Request.Context()
raw, _ := json.Marshal(req)
auditDetail(c, "url", req.URL)
if err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error {
return q.SetPlatformSetting(ctx, store.SetPlatformSettingParams{Key: settingStatusPageHome, Value: raw})
}); err != nil {
internalError(c, err)
return
}
if err := s.pageHome.bump(ctx, s.rdb); err != nil {
s.log.ErrorContext(ctx, "announcing the status page home failed", "error", err)
}
c.Status(http.StatusNoContent)
}
+46
View File
@@ -0,0 +1,46 @@
package api_test
import (
"context"
"net/http"
"strings"
"testing"
"git.zb-server.de/ZB-Server/uptimesebi/internal/store"
"git.zb-server.de/ZB-Server/uptimesebi/internal/tenant"
)
func TestStatusPageHome(t *testing.T) {
e := newEnv(t)
admin := e.browser(t)
admin.signup("a@"+uniq("home")+".test", uniq("home-"))
if err := tenant.New(e.dbPool).Tx(context.Background(), tenant.Global(), func(q *store.Queries) error {
return q.MakeAdmin(context.Background(), admin.userIDSelf())
}); err != nil {
t.Fatal(err)
}
t.Cleanup(func() { admin.do("PUT", "/api/v1/admin/statuspage-home", map[string]any{"url": ""}) })
pages := e.statuspageClient(t, nil)
st, body := admin.do("PUT", "/api/v1/admin/statuspage-home", map[string]any{"url": "javascript:alert(1)"})
expect(t, "script link", st, body, http.StatusUnprocessableEntity, "invalid_legal_url")
if st, body := admin.do("PUT", "/api/v1/admin/statuspage-home", map[string]any{"url": " https://example.test/ "}); st != http.StatusNoContent {
t.Fatalf("set home = %d %v", st, body)
}
if _, body := admin.do("GET", "/api/v1/admin/statuspage-home", nil); body["url"] != "https://example.test/" {
t.Errorf("home = %v", body)
}
index, err := pages.Pages(context.Background())
if err != nil || index.HomeURL != "https://example.test/" {
t.Errorf("page index home = %q %v", index.HomeURL, err)
}
if _, _, html := admin.page("/admin"); !strings.Contains(html, `value="https://example.test/"`) {
t.Error("the admin page does not show the home page")
}
owner := e.browser(t)
owner.signup("o@"+uniq("home")+".test", uniq("home-"))
if st, _ := owner.do("PUT", "/api/v1/admin/statuspage-home", map[string]any{"url": "https://evil.test/"}); st != http.StatusForbidden {
t.Errorf("non-admin sets the home page = %d, want 403", st)
}
}
+1 -1
View File
@@ -461,7 +461,7 @@ func (s *Server) agentPageIndex(c *gin.Context) {
for i, r := range rows {
out[i] = agentapi.PageRef{Slug: r.Slug, Host: r.Host}
}
c.JSON(http.StatusOK, gin.H{"pages": out})
c.JSON(http.StatusOK, agentapi.PageIndex{Pages: out, HomeURL: s.statusPageHome(ctx)})
}
type statusPageRequest struct {
+2 -1
View File
@@ -205,7 +205,8 @@ func TestStatusPages(t *testing.T) {
own := e.statuspageClient(t, &org)
lists := func(c *agentapi.Client) bool {
t.Helper()
refs, err := c.Pages(context.Background())
index, err := c.Pages(context.Background())
refs := index.Pages
if err != nil {
t.Fatal(err)
}
+8 -1
View File
@@ -1612,5 +1612,12 @@
"pages.subscribers_limit": "Neue Abos pro Woche für die Organisation: {{.Max}}",
"pages.feeds": "Feed und API",
"pages.feeds_hint": "Jede veröffentlichte Seite hat einen RSS-Feed und eine JSON-API zum Lesen, pro Besucher begrenzt:",
"audit.action.statuspage.subscriber_delete": "Abonnent einer Statusseite entfernt"
"audit.action.statuspage.subscriber_delete": "Abonnent einer Statusseite entfernt",
"page.not_found_title": "Seite nicht gefunden",
"page.not_found": "Unter dieser Adresse gibt es keine Statusseite, oder sie ist nicht veröffentlicht.",
"page.not_found_home": "Zur Hauptseite",
"admin.statuspage_home": "Hauptseite der Statusseiten",
"admin.statuspage_home_hint": "Wer die Statusseiten-Domain ohne Pfad oder eine Seite aufruft, die es nicht gibt, sieht eine Fehlerseite. Sie verlinkt diese Adresse, z. B. eure Website. Leer: kein Link.",
"admin.statuspage_home_url": "Adresse der Hauptseite",
"audit.action.platform.statuspage_home_update": "Hauptseite der Statusseiten geändert"
}
+8 -1
View File
@@ -1612,5 +1612,12 @@
"pages.subscribers_limit": "New subscriptions per week for the organization: {{.Max}}",
"pages.feeds": "Feed and API",
"pages.feeds_hint": "Every published page has an RSS feed and a read-only JSON API, rate limited per visitor:",
"audit.action.statuspage.subscriber_delete": "Status page subscriber removed"
"audit.action.statuspage.subscriber_delete": "Status page subscriber removed",
"page.not_found_title": "Page not found",
"page.not_found": "There is no status page at this address, or it is not published.",
"page.not_found_home": "Go to the home page",
"admin.statuspage_home": "Status page home",
"admin.statuspage_home_hint": "Visitors of the bare status page domain and of pages that do not exist see an error page. It links this address, e.g. your website. Empty: no link.",
"admin.statuspage_home_url": "Home page URL",
"audit.action.platform.statuspage_home_update": "Status page home changed"
}
+43 -5
View File
@@ -63,7 +63,7 @@ type Source interface {
// PageIfChanged answers agentapi.ErrNotModified when the page still
// has checksum.
PageIfChanged(ctx context.Context, host, slug, checksum string) (agentapi.PageSnapshot, error)
Pages(ctx context.Context) ([]agentapi.PageRef, error)
Pages(ctx context.Context) (agentapi.PageIndex, error)
}
// Server renders pages for one status page agent.
@@ -78,7 +78,9 @@ type Server struct {
dir string
now func() time.Time
mu sync.Mutex
mu sync.Mutex
// home is the platform's home page, linked from the error page.
home string
cache map[string]entry
refreshing map[string]bool
// again holds pages that changed while being refreshed, which are
@@ -161,9 +163,39 @@ func (s *Server) loadDisk() error {
if len(s.cache) > 0 {
s.log.Info("loaded cached status pages", "count", len(s.cache))
}
if raw, err := os.ReadFile(filepath.Join(s.dir, homeFile)); err == nil {
s.home = string(raw)
}
return nil
}
// homeFile keeps the home page across restarts; not .json, which are pages.
const homeFile = "home.url"
// setHome records the home page the error page links.
func (s *Server) setHome(url string) {
s.mu.Lock()
changed := s.home != url
s.home = url
s.mu.Unlock()
if changed && s.dir != "" {
if err := os.WriteFile(filepath.Join(s.dir, homeFile), []byte(url), 0o600); err != nil {
s.log.Warn("saving the home page failed", "error", err)
}
}
}
// notFound answers visitors of a page that does not exist with a page
// leading to the platform's home page.
func (s *Server) notFound(c *gin.Context) {
s.localizeRequest(c)
s.mu.Lock()
home := s.home
s.mu.Unlock()
c.Header("Cache-Control", "no-store")
web.Render(c, http.StatusNotFound, web.PublicNotFoundPage("/static/dist/app.css", home))
}
func (s *Server) fileFor(key string) string {
sum := sha256.Sum256([]byte(key))
return filepath.Join(s.dir, hex.EncodeToString(sum[:16])+".json")
@@ -237,7 +269,7 @@ func (s *Server) serve(c *gin.Context) {
key, base = "host:"+host, "/"
} else {
if len(parts) == 0 {
c.Status(http.StatusNotFound)
s.notFound(c)
return
}
slug, parts = parts[0], parts[1:]
@@ -261,7 +293,11 @@ func (s *Server) serve(c *gin.Context) {
}
e, ok := s.lookup(c.Request.Context(), key, host, slug)
if !ok {
c.Status(http.StatusNotFound)
if rt.kind == routeFeed || rt.kind == routeAPI {
c.Status(http.StatusNotFound)
} else {
s.notFound(c)
}
return
}
if rt.kind == routeLegal {
@@ -523,11 +559,13 @@ func (s *Server) Run(ctx context.Context) {
func (s *Server) Sync(ctx context.Context) {
ctx, cancel := context.WithTimeout(ctx, syncInterval)
defer cancel()
refs, err := s.src.Pages(ctx)
index, err := s.src.Pages(ctx)
if err != nil {
s.log.WarnContext(ctx, "listing status pages failed", "error", err)
return
}
s.setHome(index.HomeURL)
refs := index.Pages
todo := map[string]entry{}
s.mu.Lock()
for key, e := range s.cache {
+27 -6
View File
@@ -25,6 +25,7 @@ type fakeSource struct {
err error
delay time.Duration
pages map[string]agentapi.PageSnapshot
home string
}
// PageIfChanged counts calls and answers like the API, sending pages
@@ -65,16 +66,16 @@ func (f *fakeSource) page(ctx context.Context, host, slug string) (agentapi.Page
}
// Pages lists the fake's pages by their keys: "host|" or "|slug".
func (f *fakeSource) Pages(context.Context) ([]agentapi.PageRef, error) {
func (f *fakeSource) Pages(context.Context) (agentapi.PageIndex, error) {
f.mu.Lock()
defer f.mu.Unlock()
if f.err != nil {
return nil, f.err
return agentapi.PageIndex{}, f.err
}
var out []agentapi.PageRef
out := agentapi.PageIndex{HomeURL: f.home}
for k := range f.pages {
host, slug, _ := strings.Cut(k, "|")
out = append(out, agentapi.PageRef{Host: host, Slug: slug})
out.Pages = append(out.Pages, agentapi.PageRef{Host: host, Slug: slug})
}
return out, nil
}
@@ -128,6 +129,26 @@ func (h harness) get(host, path string) (int, string) {
return w.Code, w.Body.String()
}
// The error page links the platform's home page, also after a restart
// while the API is down.
func TestNotFoundLinksHome(t *testing.T) {
dir := t.TempDir()
now := time.Now()
src := newSource()
h := newHarness(t, src, dir, &now)
if code, body := h.get("status.example.test", "/"); code != 404 || strings.Contains(body, "Zur Hauptseite") {
t.Errorf("error page without a home page = %d, links one: %t", code, strings.Contains(body, "Zur Hauptseite"))
}
src.home = "https://example.test/"
h.srv.Sync(context.Background())
restarted := newHarness(t, &fakeSource{err: errors.New("connection refused")}, dir, &now)
for _, hs := range []harness{h, restarted} {
if code, body := hs.get("status.example.test", "/gone"); code != 404 || !strings.Contains(body, `href="https://example.test/"`) {
t.Errorf("error page = %d, lacks the link to the home page", code)
}
}
}
func TestRouting(t *testing.T) {
now := time.Now()
h := newHarness(t, newSource(), t.TempDir(), &now)
@@ -138,8 +159,8 @@ func TestRouting(t *testing.T) {
}{
{"status.example.test", "/acme", 200, "Acme status"},
{"status.example.test:8082", "/acme", 200, "Alle Systeme funktionieren"},
{"status.example.test", "/missing", 404, ""},
{"status.example.test", "/", 404, ""},
{"status.example.test", "/missing", 404, "Seite nicht gefunden"},
{"status.example.test", "/", 404, "Seite nicht gefunden"},
{"status.acme.test", "/", 200, "Acme on own domain"},
{"status.acme.test", "/acme", 404, ""},
{"other.test", "/", 404, ""},
+32
View File
@@ -446,3 +446,35 @@ templ pageMaintenance(heading string, items []agentapi.PageMaintenance) {
</section>
}
}
// PublicNotFoundPage answers visitors of a status page that does not exist,
// and of the bare status page domain, with a link to the home page if set.
templ PublicNotFoundPage(cssHref, home string) {
<!DOCTYPE html>
<html lang={ i18n.Lang(ctx) }>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="robots" content="noindex"/>
<title>{ i18n.T(ctx, "page.not_found_title") }</title>
@faviconLinks()
<link rel="stylesheet" href={ cssHref }/>
</head>
<body class="min-h-screen">
<main class="mx-auto flex min-h-screen max-w-xl flex-col justify-center px-4 py-14 sm:px-6">
<p class="mb-3 font-mono text-xs text-muted">404</p>
<h1 class="mb-3 text-2xl font-semibold">{ i18n.T(ctx, "page.not_found_title") }</h1>
<p class="mb-8 text-muted">{ i18n.T(ctx, "page.not_found") }</p>
if home != "" {
<p>
<a href={ templ.SafeURL(home) } class="inline-block border border-ink px-4 py-2 text-sm hover:bg-ink hover:text-paper">{ i18n.T(ctx, "page.not_found_home") }</a>
</p>
}
<p class="mt-14 flex items-center gap-1 font-mono text-xs text-muted">
@brandMark("h-3.5 w-3.5")
UptimeSebi
</p>
</main>
</body>
</html>
}
+144
View File
@@ -2251,4 +2251,148 @@ func pageMaintenance(heading string, items []agentapi.PageMaintenance) templ.Com
})
}
// PublicNotFoundPage answers visitors of a status page that does not exist,
// and of the bare status page domain, with a link to the home page if set.
func PublicNotFoundPage(cssHref, home string) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
return templ_7745c5c3_CtxErr
}
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 186, "<!doctype html><html lang=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var109 string
templ_7745c5c3_Var109, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.Lang(ctx)).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 454, Col: 28}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var109)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 187, "\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><meta name=\"robots\" content=\"noindex\"><title>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var110 string
templ_7745c5c3_Var110, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.not_found_title"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 459, Col: 47}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var110))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 188, "</title>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = faviconLinks().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 189, "<link rel=\"stylesheet\" href=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var111 string
templ_7745c5c3_Var111, templ_7745c5c3_Err = templruntime.NewAttributeExpression(cssHref).ResolveURL(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 461, Col: 40}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var111)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 190, "\"></head><body class=\"min-h-screen\"><main class=\"mx-auto flex min-h-screen max-w-xl flex-col justify-center px-4 py-14 sm:px-6\"><p class=\"mb-3 font-mono text-xs text-muted\">404</p><h1 class=\"mb-3 text-2xl font-semibold\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var112 string
templ_7745c5c3_Var112, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.not_found_title"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 466, Col: 81}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var112))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 191, "</h1><p class=\"mb-8 text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var113 string
templ_7745c5c3_Var113, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.not_found"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 467, Col: 62}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var113))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 192, "</p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if home != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 193, "<p><a href=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var114 string
templ_7745c5c3_Var114, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL(home)).ResolveURL(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 470, Col: 35}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var114)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 194, "\" class=\"inline-block border border-ink px-4 py-2 text-sm hover:bg-ink hover:text-paper\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var115 string
templ_7745c5c3_Var115, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.not_found_home"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 470, Col: 161}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var115))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 195, "</a></p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 196, "<p class=\"mt-14 flex items-center gap-1 font-mono text-xs text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = brandMark("h-3.5 w-3.5").Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 197, " UptimeSebi</p></main></body></html>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate
+19 -1
View File
@@ -195,7 +195,7 @@ templ RegionsPage(p Page, me Me, v RegionsView) {
}
}
templ AdminPage(p Page, me Me, v RegionsView, storage StorageView, checkTypes []CheckTypeOption, platformPrivate bool, limits LimitsView, idps IDPAdminView) {
templ AdminPage(p Page, me Me, v RegionsView, storage StorageView, checkTypes []CheckTypeOption, platformPrivate bool, pageHome string, limits LimitsView, idps IDPAdminView) {
@consoleShell(p, me) {
@settingsHeading("admin.title", "admin.intro")
@adminLinks()
@@ -203,6 +203,7 @@ templ AdminPage(p Page, me Me, v RegionsView, storage StorageView, checkTypes []
@limitsSection(limits)
@regionsBody(v)
@checkerNetworkSection(platformPrivate)
@statusPageHomeSection(pageHome)
@checkTypesSection(checkTypes, "/admin/check-types", "/admin", "admin.check_types_intro")
@storageSection(storage)
}
@@ -228,6 +229,23 @@ templ checkerNetworkSection(allow bool) {
</section>
}
// statusPageHomeSection sets the home page the status page servers link
// from their error page.
templ statusPageHomeSection(url string) {
<section class="mt-12 max-w-3xl">
@sectionHeading("admin.statuspage_home")
<p class="mb-4 text-sm text-muted">{ i18n.T(ctx, "admin.statuspage_home_hint") }</p>
<form data-api="/admin/statuspage-home" data-method="put" data-next="/admin">
@formError()
<label class="mb-4 block">
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "admin.statuspage_home_url") }</span>
<input class="w-full border border-rule bg-transparent px-2.5 py-1.5 outline-none focus:border-ink" type="url" name="url" value={ url } maxlength="2000" placeholder="https://example.com"/>
</label>
<button type="submit" class="border border-ink px-3 py-1.5 text-sm hover:bg-ink hover:text-paper">{ i18n.T(ctx, "common.save") }</button>
</form>
</section>
}
// checkTypesSection lets the platform or an organization choose the
// check types it offers.
templ checkTypesSection(types []CheckTypeOption, api, next, introID string) {
File diff suppressed because it is too large. Load diff