feat: legal notice and privacy policy (Markdown or link) #70
No files matched your search
@@ -16,6 +16,7 @@ require (
|
|||||||
github.com/pquerna/otp v1.5.0
|
github.com/pquerna/otp v1.5.0
|
||||||
github.com/pressly/goose/v3 v3.30.1
|
github.com/pressly/goose/v3 v3.30.1
|
||||||
github.com/redis/go-redis/v9 v9.23.0
|
github.com/redis/go-redis/v9 v9.23.0
|
||||||
|
github.com/yuin/goldmark v1.7.13
|
||||||
go.uber.org/zap v1.28.0
|
go.uber.org/zap v1.28.0
|
||||||
golang.org/x/crypto v0.59.0
|
golang.org/x/crypto v0.59.0
|
||||||
golang.org/x/net v0.63.0
|
golang.org/x/net v0.63.0
|
||||||
|
|||||||
@@ -146,6 +146,8 @@ github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY
|
|||||||
github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
||||||
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
|
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
|
||||||
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
|
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
|
||||||
|
github.com/yuin/goldmark v1.7.13 h1:GPddIs617DnBLFFVJFgpo1aBfe/4xcvMc3SB5t/D0pA=
|
||||||
|
github.com/yuin/goldmark v1.7.13/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=
|
||||||
github.com/zeebo/assert v1.1.0 h1:hU1L1vLTHsnO8x8c9KAR5GmM5QscxHg5RNU5z5qbUWY=
|
github.com/zeebo/assert v1.1.0 h1:hU1L1vLTHsnO8x8c9KAR5GmM5QscxHg5RNU5z5qbUWY=
|
||||||
github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
|
github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
|
||||||
github.com/zeebo/blake3 v0.2.4 h1:KYQPkhpRtcqh0ssGYcKLG1JYvddkEA8QwCM/yBqhaZI=
|
github.com/zeebo/blake3 v0.2.4 h1:KYQPkhpRtcqh0ssGYcKLG1JYvddkEA8QwCM/yBqhaZI=
|
||||||
|
|||||||
@@ -63,6 +63,28 @@ type PageSnapshot struct {
|
|||||||
Sections []Section `json:"sections"`
|
Sections []Section `json:"sections"`
|
||||||
Incidents []PageIncident `json:"incidents"`
|
Incidents []PageIncident `json:"incidents"`
|
||||||
GeneratedAt time.Time `json:"generated_at"`
|
GeneratedAt time.Time `json:"generated_at"`
|
||||||
|
// Legal holds the legal notice and privacy policy shown on the page.
|
||||||
|
// They travel with the snapshot so they stay available during an API
|
||||||
|
// outage, which some jurisdictions require.
|
||||||
|
Legal []LegalDoc `json:"legal,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LegalDoc is a legal notice ("imprint") or privacy policy ("privacy"):
|
||||||
|
// a link to a page elsewhere or Markdown to render.
|
||||||
|
type LegalDoc struct {
|
||||||
|
Kind string `json:"kind"`
|
||||||
|
URL string `json:"url,omitempty"`
|
||||||
|
Markdown string `json:"markdown,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LegalDocByKind returns the document of kind, if any.
|
||||||
|
func (s PageSnapshot) LegalDocByKind(kind string) (LegalDoc, bool) {
|
||||||
|
for _, d := range s.Legal {
|
||||||
|
if d.Kind == kind {
|
||||||
|
return d, true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return LegalDoc{}, false
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrNotFound means no published page matches.
|
// ErrNotFound means no published page matches.
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ var auditActions = map[string]string{
|
|||||||
"POST /api/v1/org/tokens": "token.create",
|
"POST /api/v1/org/tokens": "token.create",
|
||||||
"DELETE /api/v1/org/tokens/:id": "token.delete",
|
"DELETE /api/v1/org/tokens/:id": "token.delete",
|
||||||
|
|
||||||
|
"PUT /api/v1/admin/legal/:kind": "platform.legal_update",
|
||||||
|
"PUT /api/v1/org/legal/:kind": "org.legal_update",
|
||||||
"POST /api/v1/admin/regions": "platform.region_create",
|
"POST /api/v1/admin/regions": "platform.region_create",
|
||||||
"DELETE /api/v1/admin/regions/:id": "platform.region_delete",
|
"DELETE /api/v1/admin/regions/:id": "platform.region_delete",
|
||||||
"POST /api/v1/admin/agents": "platform.agent_create",
|
"POST /api/v1/admin/agents": "platform.agent_create",
|
||||||
@@ -131,7 +133,7 @@ func (w *captureWriter) Write(b []byte) (int, error) {
|
|||||||
|
|
||||||
// Response fields worth keeping; anything else may be a secret, such as a
|
// Response fields worth keeping; anything else may be a secret, such as a
|
||||||
// freshly created token.
|
// freshly created token.
|
||||||
var auditFields = []string{"name", "key", "slug", "email", "type", "target", "domain"}
|
var auditFields = []string{"name", "key", "slug", "email", "type", "target", "domain", "kind"}
|
||||||
|
|
||||||
// audit records state-changing requests after they ran.
|
// audit records state-changing requests after they ran.
|
||||||
func (s *Server) audit() gin.HandlerFunc {
|
func (s *Server) audit() gin.HandlerFunc {
|
||||||
@@ -170,6 +172,10 @@ func (s *Server) audit() gin.HandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if status < 400 && strings.HasPrefix(action, "auth.") {
|
||||||
|
// The address only identifies attempts on unknown accounts.
|
||||||
|
delete(details, "email")
|
||||||
|
}
|
||||||
for _, param := range []string{"id", "user"} {
|
for _, param := range []string{"id", "user"} {
|
||||||
if id, err := uuid.Parse(c.Param(param)); err == nil {
|
if id, err := uuid.Parse(c.Param(param)); err == nil {
|
||||||
e.TargetID = &id
|
e.TargetID = &id
|
||||||
|
|||||||
@@ -0,0 +1,210 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"slices"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/a-h/templ"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
|
||||||
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/agentapi"
|
||||||
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/store"
|
||||||
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/tenant"
|
||||||
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/web"
|
||||||
|
)
|
||||||
|
|
||||||
|
// mergeLegal picks one document per kind, the organization's over the
|
||||||
|
// platform's. rows come organization first.
|
||||||
|
func mergeLegal(rows []store.LegalDocument) []agentapi.LegalDoc {
|
||||||
|
out := []agentapi.LegalDoc{}
|
||||||
|
seen := map[string]bool{}
|
||||||
|
for _, r := range rows {
|
||||||
|
if seen[r.Kind] || (r.Url == "" && r.Markdown == "") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
seen[r.Kind] = true
|
||||||
|
out = append(out, agentapi.LegalDoc{Kind: r.Kind, URL: r.Url, Markdown: r.Markdown})
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// platformLegalDocs returns the platform's documents, which every console
|
||||||
|
// page links in its footer.
|
||||||
|
func (s *Server) platformLegalDocs(ctx context.Context) []agentapi.LegalDoc {
|
||||||
|
docs, err := s.legal.get(ctx, s.rdb, func(ctx context.Context) ([]agentapi.LegalDoc, error) {
|
||||||
|
var rows []store.LegalDocument
|
||||||
|
err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error {
|
||||||
|
var err error
|
||||||
|
rows, err = q.LegalDocuments(ctx, nil)
|
||||||
|
return err
|
||||||
|
})
|
||||||
|
return mergeLegal(rows), err
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
s.log.WarnContext(ctx, "loading legal documents failed", "error", err)
|
||||||
|
}
|
||||||
|
return docs
|
||||||
|
}
|
||||||
|
|
||||||
|
func validLegalKind(kind string) bool { return slices.Contains(web.LegalKinds, kind) }
|
||||||
|
|
||||||
|
type legalRequest struct {
|
||||||
|
URL string `json:"url" binding:"max=2000"`
|
||||||
|
Markdown string `json:"markdown" binding:"max=100000"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// validLegalURL accepts absolute http and https URLs only, so a stored link
|
||||||
|
// cannot run script when clicked.
|
||||||
|
func validLegalURL(raw string) bool {
|
||||||
|
u, err := url.Parse(raw)
|
||||||
|
return err == nil && (u.Scheme == "https" || u.Scheme == "http") && u.Host != ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// saveLegal stores or, with both fields empty, removes a document of org,
|
||||||
|
// nil for the platform.
|
||||||
|
func (s *Server) saveLegal(c *gin.Context, scope tenant.Scope, org *uuid.UUID) bool {
|
||||||
|
kind := c.Param("kind")
|
||||||
|
if !validLegalKind(kind) {
|
||||||
|
fail(c, http.StatusNotFound, "not_found")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
var req legalRequest
|
||||||
|
if !bind(c, &req) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
req.URL, req.Markdown = strings.TrimSpace(req.URL), strings.TrimSpace(req.Markdown)
|
||||||
|
if req.URL != "" && !validLegalURL(req.URL) {
|
||||||
|
fail(c, http.StatusUnprocessableEntity, "invalid_legal_url")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
auditDetail(c, "kind", kind)
|
||||||
|
ctx := c.Request.Context()
|
||||||
|
err := s.db.Tx(ctx, scope, func(q *store.Queries) error {
|
||||||
|
if req.URL == "" && req.Markdown == "" {
|
||||||
|
return q.DeleteLegalDocument(ctx, store.DeleteLegalDocumentParams{OrgID: org, Kind: kind})
|
||||||
|
}
|
||||||
|
return q.UpsertLegalDocument(ctx, store.UpsertLegalDocumentParams{OrgID: org, Kind: kind, Url: req.URL, Markdown: req.Markdown})
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
internalError(c, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
c.Status(http.StatusNoContent)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) adminSaveLegal(c *gin.Context) {
|
||||||
|
if s.saveLegal(c, tenant.System(), nil) {
|
||||||
|
if err := s.legal.bump(c.Request.Context(), s.rdb); err != nil {
|
||||||
|
s.log.ErrorContext(c.Request.Context(), "announcing legal document change failed", "error", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) orgSaveLegal(c *gin.Context) {
|
||||||
|
p := current(c)
|
||||||
|
s.saveLegal(c, p.scope(), &p.Org.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
type legalView struct {
|
||||||
|
Kind string `json:"kind"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
Markdown string `json:"markdown"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ownLegal returns the documents stored for org (nil: the platform),
|
||||||
|
// without fallbacks.
|
||||||
|
func (s *Server) ownLegal(ctx context.Context, scope tenant.Scope, org *uuid.UUID) ([]legalView, error) {
|
||||||
|
var rows []store.LegalDocument
|
||||||
|
err := s.db.Tx(ctx, scope, func(q *store.Queries) error {
|
||||||
|
var err error
|
||||||
|
rows, err = q.LegalDocuments(ctx, org)
|
||||||
|
return err
|
||||||
|
})
|
||||||
|
out := make([]legalView, 0, len(web.LegalKinds))
|
||||||
|
for _, kind := range web.LegalKinds {
|
||||||
|
v := legalView{Kind: kind}
|
||||||
|
for _, r := range rows {
|
||||||
|
if r.Kind == kind && (r.OrgID == nil) == (org == nil) {
|
||||||
|
v.URL, v.Markdown = r.Url, r.Markdown
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out = append(out, v)
|
||||||
|
}
|
||||||
|
return out, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) adminListLegal(c *gin.Context) {
|
||||||
|
docs, err := s.ownLegal(c.Request.Context(), tenant.System(), nil)
|
||||||
|
if err != nil {
|
||||||
|
internalError(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusOK, gin.H{"documents": docs})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) orgListLegal(c *gin.Context) {
|
||||||
|
p := current(c)
|
||||||
|
docs, err := s.ownLegal(c.Request.Context(), p.scope(), &p.Org.ID)
|
||||||
|
if err != nil {
|
||||||
|
internalError(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusOK, gin.H{"documents": docs})
|
||||||
|
}
|
||||||
|
|
||||||
|
// legalPage serves a platform document to anyone: Markdown rendered here,
|
||||||
|
// links redirected.
|
||||||
|
func (s *Server) legalPage(c *gin.Context) {
|
||||||
|
kind := c.Param("kind")
|
||||||
|
for _, d := range s.platformLegalDocs(c.Request.Context()) {
|
||||||
|
if d.Kind != kind {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if d.URL != "" {
|
||||||
|
c.Redirect(http.StatusFound, d.URL)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
html, err := web.RenderMarkdown(d.Markdown)
|
||||||
|
if err != nil {
|
||||||
|
internalError(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
web.Render(c, http.StatusOK, web.LegalPage(s.pageFor(c, web.LegalTitleID(kind)), html))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.Status(http.StatusNotFound)
|
||||||
|
}
|
||||||
|
|
||||||
|
func toLegalForms(docs []legalView) []web.LegalForm {
|
||||||
|
out := make([]web.LegalForm, len(docs))
|
||||||
|
for i, d := range docs {
|
||||||
|
out[i] = web.LegalForm{Kind: d.Kind, URL: d.URL, Markdown: d.Markdown}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) orgLegalView(c *gin.Context, p *principal, page web.Page, me web.Me) (templ.Component, error) {
|
||||||
|
docs, err := s.ownLegal(c.Request.Context(), p.scope(), &p.Org.ID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return web.LegalSettingsPage(page, me, "legal.org_title", "legal.org_intro", "/org/legal/", "/settings/legal", toLegalForms(docs)), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) adminLegalPage(c *gin.Context) {
|
||||||
|
me, ok := s.adminMe(c)
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
docs, err := s.ownLegal(c.Request.Context(), tenant.System(), nil)
|
||||||
|
if err != nil {
|
||||||
|
internalError(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
web.Render(c, http.StatusOK, web.LegalSettingsPage(s.pageFor(c, "legal.platform_title"), me, "legal.platform_title", "legal.platform_intro", "/admin/legal/", "/admin/legal", toLegalForms(docs)))
|
||||||
|
}
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
package api_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/agentapi"
|
||||||
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/store"
|
||||||
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/tenant"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestLegalDocuments(t *testing.T) {
|
||||||
|
e := newEnv(t)
|
||||||
|
admin := e.browser(t)
|
||||||
|
admin.signup("a@"+uniq("lg")+".test", uniq("lg-"))
|
||||||
|
err := tenant.New(e.dbPool).Tx(context.Background(), tenant.Global(), func(q *store.Queries) error {
|
||||||
|
return q.MakeAdmin(context.Background(), admin.userIDSelf())
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Cleanup(func() {
|
||||||
|
for _, kind := range []string{"imprint", "privacy"} {
|
||||||
|
admin.do("PUT", "/api/v1/admin/legal/"+kind, map[string]any{})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
imprint := "# Impressum\n\nBetreiber GmbH <script>alert(1)</script>"
|
||||||
|
st, body := admin.do("PUT", "/api/v1/admin/legal/imprint", map[string]any{"markdown": imprint})
|
||||||
|
expect(t, "admin sets imprint", st, body, http.StatusNoContent, "")
|
||||||
|
st, body = admin.do("PUT", "/api/v1/admin/legal/privacy", map[string]any{"url": "javascript:alert(1)"})
|
||||||
|
expect(t, "javascript link", st, body, http.StatusUnprocessableEntity, "invalid_legal_url")
|
||||||
|
st, body = admin.do("PUT", "/api/v1/admin/legal/privacy", map[string]any{"url": "https://operator.example/privacy"})
|
||||||
|
expect(t, "admin sets privacy link", st, body, http.StatusNoContent, "")
|
||||||
|
st, body = admin.do("PUT", "/api/v1/admin/legal/terms", map[string]any{"markdown": "x"})
|
||||||
|
expect(t, "unknown kind", st, body, http.StatusNotFound, "not_found")
|
||||||
|
|
||||||
|
// The console footer links them, also before signing in.
|
||||||
|
_, _, login := e.browser(t).page("/login")
|
||||||
|
if !strings.Contains(login, `href="/legal/imprint"`) || !strings.Contains(login, `href="https://operator.example/privacy"`) {
|
||||||
|
t.Error("login page footer lacks the legal links")
|
||||||
|
}
|
||||||
|
st, _, html := e.browser(t).page("/legal/imprint")
|
||||||
|
if st != http.StatusOK || !strings.Contains(html, "<h1>Impressum</h1>") || strings.Contains(html, "<script>alert") {
|
||||||
|
t.Errorf("GET /legal/imprint = %d, rendered %q", st, html)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Status pages fall back to the platform's documents.
|
||||||
|
owner := e.browser(t)
|
||||||
|
owner.signup("o@"+uniq("lg")+".test", uniq("lg-"))
|
||||||
|
slug := uniq("lgp-")
|
||||||
|
_, page := owner.do("POST", "/api/v1/org/statuspages", map[string]any{"slug": slug, "title": "Acme"})
|
||||||
|
owner.do("PUT", "/api/v1/org/statuspages/"+page["id"].(string), map[string]any{"slug": slug, "title": "Acme", "published": true})
|
||||||
|
client := e.statuspageClient(t, nil)
|
||||||
|
legalOf := func() map[string]agentapi.LegalDoc {
|
||||||
|
snap, err := client.Page(context.Background(), "", slug)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
out := map[string]agentapi.LegalDoc{}
|
||||||
|
for _, d := range snap.Legal {
|
||||||
|
out[d.Kind] = d
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
if got := legalOf(); got["imprint"].Markdown != imprint || got["privacy"].URL != "https://operator.example/privacy" {
|
||||||
|
t.Errorf("snapshot legal = %+v, want the platform's", got)
|
||||||
|
}
|
||||||
|
|
||||||
|
// An organization's own documents win.
|
||||||
|
st, body = owner.do("PUT", "/api/v1/org/legal/imprint", map[string]any{"markdown": "# Acme GmbH"})
|
||||||
|
expect(t, "org sets imprint", st, body, http.StatusNoContent, "")
|
||||||
|
if got := legalOf(); got["imprint"].Markdown != "# Acme GmbH" || got["privacy"].URL != "https://operator.example/privacy" {
|
||||||
|
t.Errorf("snapshot legal = %+v, want own imprint and platform privacy", got)
|
||||||
|
}
|
||||||
|
_, list := owner.do("GET", "/api/v1/org/legal", nil)
|
||||||
|
if !strings.Contains(mustJSON(list), "Acme GmbH") || strings.Contains(mustJSON(list), "operator.example") {
|
||||||
|
t.Errorf("org legal list = %v, want only its own documents", list)
|
||||||
|
}
|
||||||
|
st, _ = owner.do("PUT", "/api/v1/org/legal/imprint", map[string]any{})
|
||||||
|
if got := legalOf(); st != http.StatusNoContent || got["imprint"].Markdown != imprint {
|
||||||
|
t.Errorf("after removing the own imprint snapshot = %+v", got)
|
||||||
|
}
|
||||||
|
|
||||||
|
viewer := e.joinVia(t, owner.invite("v@"+uniq("lg")+".test", owner.roleID("viewer")))
|
||||||
|
if st, _ := viewer.do("PUT", "/api/v1/org/legal/imprint", map[string]any{"markdown": "x"}); st != http.StatusForbidden {
|
||||||
|
t.Errorf("viewer sets imprint = %d, want 403", st)
|
||||||
|
}
|
||||||
|
if st, _ := owner.do("PUT", "/api/v1/admin/legal/imprint", map[string]any{"markdown": "x"}); st != http.StatusForbidden {
|
||||||
|
t.Errorf("non-admin sets platform imprint = %d, want 403", st)
|
||||||
|
}
|
||||||
|
for path, want := range map[string]string{"/admin/legal": "Platform legal notice", "/settings/legal": "Legal notice & privacy"} {
|
||||||
|
b := admin
|
||||||
|
if path == "/settings/legal" {
|
||||||
|
b = owner
|
||||||
|
}
|
||||||
|
if st, _, html := b.page(path); st != http.StatusOK || !strings.Contains(html, want) {
|
||||||
|
t.Errorf("GET %s = %d, lacks %q", path, st, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A change on one replica shows on another with the next request.
|
||||||
|
func TestLegalChangeReachesOtherReplicas(t *testing.T) {
|
||||||
|
a := newEnv(t)
|
||||||
|
b := newEnv(t)
|
||||||
|
admin := a.browser(t)
|
||||||
|
admin.signup("a@"+uniq("lr")+".test", uniq("lr-"))
|
||||||
|
err := tenant.New(a.dbPool).Tx(context.Background(), tenant.Global(), func(q *store.Queries) error {
|
||||||
|
return q.MakeAdmin(context.Background(), admin.userIDSelf())
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Cleanup(func() { admin.do("PUT", "/api/v1/admin/legal/imprint", map[string]any{}) })
|
||||||
|
admin.do("PUT", "/api/v1/admin/legal/imprint", map[string]any{})
|
||||||
|
|
||||||
|
visitor := b.browser(t)
|
||||||
|
if _, _, html := visitor.page("/login"); strings.Contains(html, `href="/legal/imprint"`) {
|
||||||
|
t.Fatal("imprint linked before it exists")
|
||||||
|
}
|
||||||
|
admin.do("PUT", "/api/v1/admin/legal/imprint", map[string]any{"markdown": "# Impressum"})
|
||||||
|
if _, _, html := visitor.page("/login"); !strings.Contains(html, `href="/legal/imprint"`) {
|
||||||
|
t.Error("the other replica still serves the old footer")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -38,6 +38,9 @@ func (s *Server) registerPages(r gin.IRouter) {
|
|||||||
r.GET("/settings/audit", s.orgPage("audit.title", authz.AuditRead, s.auditView))
|
r.GET("/settings/audit", s.orgPage("audit.title", authz.AuditRead, s.auditView))
|
||||||
r.GET("/admin", s.adminPage)
|
r.GET("/admin", s.adminPage)
|
||||||
r.GET("/admin/audit", s.adminAuditPage)
|
r.GET("/admin/audit", s.adminAuditPage)
|
||||||
|
r.GET("/admin/legal", s.adminLegalPage)
|
||||||
|
r.GET("/settings/legal", s.orgPage("legal.org_title", authz.OrgManage, s.orgLegalView))
|
||||||
|
r.GET("/legal/:kind", s.legalPage)
|
||||||
}
|
}
|
||||||
|
|
||||||
// flashErrors lists the codes a redirect may ask a page to display. Anything
|
// flashErrors lists the codes a redirect may ask a page to display. Anything
|
||||||
@@ -50,7 +53,7 @@ var flashErrors = map[ssoError]bool{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) pageFor(c *gin.Context, titleID string) web.Page {
|
func (s *Server) pageFor(c *gin.Context, titleID string) web.Page {
|
||||||
p := web.Page{TitleID: titleID, Languages: s.catalog.Supported()}
|
p := web.Page{TitleID: titleID, Languages: s.catalog.Supported(), Legal: web.LegalLinks(s.platformLegalDocs(c.Request.Context()), "/legal/")}
|
||||||
if sess := auth.Current(c); sess != nil {
|
if sess := auth.Current(c); sess != nil {
|
||||||
p.CSRF = sess.CSRF
|
p.CSRF = sess.CSRF
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/go-playground/validator/v10"
|
"github.com/go-playground/validator/v10"
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
|
|
||||||
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/agentapi"
|
||||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/auth"
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/auth"
|
||||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/authz"
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/authz"
|
||||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/config"
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/config"
|
||||||
@@ -42,6 +43,7 @@ type Server struct {
|
|||||||
sched *schedule.Scheduler
|
sched *schedule.Scheduler
|
||||||
eval *evaluate.Evaluator
|
eval *evaluate.Evaluator
|
||||||
smtp *notify.SMTP
|
smtp *notify.SMTP
|
||||||
|
legal *versioned[[]agentapi.LegalDoc]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deps are the external resources a Server needs.
|
// Deps are the external resources a Server needs.
|
||||||
@@ -72,6 +74,7 @@ func New(cfg config.API, d Deps) *Server {
|
|||||||
totp: auth.NewTOTPVerifier(d.Redis),
|
totp: auth.NewTOTPVerifier(d.Redis),
|
||||||
sso: sso.New(sso.SafeHTTPClient(allowPrivate), cfg.PublicURL+"/sso/callback", allowPrivate),
|
sso: sso.New(sso.SafeHTTPClient(allowPrivate), cfg.PublicURL+"/sso/callback", allowPrivate),
|
||||||
sched: schedule.New(d.Redis),
|
sched: schedule.New(d.Redis),
|
||||||
|
legal: newVersioned[[]agentapi.LegalDoc]("legal"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,6 +113,8 @@ func (s *Server) Mount(r gin.IRouter) {
|
|||||||
org := v1.Group("/org", s.orgAccess())
|
org := v1.Group("/org", s.orgAccess())
|
||||||
org.PUT("/policy", sessionOnly(), can(authz.OrgManage), s.updatePolicy)
|
org.PUT("/policy", sessionOnly(), can(authz.OrgManage), s.updatePolicy)
|
||||||
org.GET("/export", sessionOnly(), can(authz.OrgManage), s.exportOrg)
|
org.GET("/export", sessionOnly(), can(authz.OrgManage), s.exportOrg)
|
||||||
|
org.GET("/legal", can(authz.OrgManage), s.orgListLegal)
|
||||||
|
org.PUT("/legal/:kind", can(authz.OrgManage), s.orgSaveLegal)
|
||||||
org.POST("/delete", sessionOnly(), s.deleteOrg)
|
org.POST("/delete", sessionOnly(), s.deleteOrg)
|
||||||
|
|
||||||
// Monitor and group handlers check permissions themselves: assignments
|
// Monitor and group handlers check permissions themselves: assignments
|
||||||
@@ -132,6 +137,8 @@ func (s *Server) Mount(r gin.IRouter) {
|
|||||||
|
|
||||||
admin := v1.Group("/admin", s.requireAdmin())
|
admin := v1.Group("/admin", s.requireAdmin())
|
||||||
admin.GET("/audit", s.listPlatformAudit)
|
admin.GET("/audit", s.listPlatformAudit)
|
||||||
|
admin.GET("/legal", s.adminListLegal)
|
||||||
|
admin.PUT("/legal/:kind", s.adminSaveLegal)
|
||||||
admin.GET("/regions", s.adminListRegions)
|
admin.GET("/regions", s.adminListRegions)
|
||||||
admin.POST("/regions", s.adminCreateRegion)
|
admin.POST("/regions", s.adminCreateRegion)
|
||||||
admin.DELETE("/regions/:id", s.adminDeleteRegion)
|
admin.DELETE("/regions/:id", s.adminDeleteRegion)
|
||||||
|
|||||||
@@ -74,7 +74,11 @@ func (s *Server) buildSnapshot(ctx context.Context, page store.StatusPage) (agen
|
|||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
incidents, err = q.IncidentsForMonitors(ctx, store.IncidentsForMonitorsParams{Ids: ids, Since: ptr(now.Add(-incidentLookback))})
|
if incidents, err = q.IncidentsForMonitors(ctx, store.IncidentsForMonitorsParams{Ids: ids, Since: ptr(now.Add(-incidentLookback))}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
docs, err := q.LegalDocuments(ctx, &page.OrgID)
|
||||||
|
snap.Legal = mergeLegal(docs)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/redis/go-redis/v9"
|
||||||
|
)
|
||||||
|
|
||||||
|
// versioned caches a value derived from the database on every replica. A
|
||||||
|
// counter in Redis names the current version; writers bump it after their
|
||||||
|
// change committed, and readers reload when it moved. A change is thus
|
||||||
|
// visible on every replica with the next request, at the cost of one Redis
|
||||||
|
// GET per read.
|
||||||
|
type versioned[T any] struct {
|
||||||
|
key string
|
||||||
|
|
||||||
|
mu sync.Mutex
|
||||||
|
loaded bool
|
||||||
|
version int64
|
||||||
|
value T
|
||||||
|
}
|
||||||
|
|
||||||
|
func newVersioned[T any](name string) *versioned[T] {
|
||||||
|
return &versioned[T]{key: "version:" + name}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get returns the cached value, loading it when the version changed. If
|
||||||
|
// Redis is unreachable it keeps serving what it has.
|
||||||
|
func (v *versioned[T]) get(ctx context.Context, rdb redis.UniversalClient, load func(context.Context) (T, error)) (T, error) {
|
||||||
|
current, err := rdb.Get(ctx, v.key).Int64()
|
||||||
|
if errors.Is(err, redis.Nil) {
|
||||||
|
current, err = 0, nil
|
||||||
|
}
|
||||||
|
v.mu.Lock()
|
||||||
|
defer v.mu.Unlock()
|
||||||
|
if v.loaded && (err != nil || current == v.version) {
|
||||||
|
return v.value, nil
|
||||||
|
}
|
||||||
|
value, lerr := load(ctx)
|
||||||
|
if lerr != nil {
|
||||||
|
return v.value, lerr
|
||||||
|
}
|
||||||
|
// Remembering the version read before loading errs on the side of one
|
||||||
|
// extra reload, never of missing a change.
|
||||||
|
v.value, v.version, v.loaded = value, current, err == nil
|
||||||
|
return value, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// bump announces a committed change to every replica.
|
||||||
|
func (v *versioned[T]) bump(ctx context.Context, rdb redis.UniversalClient) error {
|
||||||
|
return rdb.Incr(ctx, v.key).Err()
|
||||||
|
}
|
||||||
@@ -156,6 +156,7 @@ func TestDynamicFamilies(t *testing.T) {
|
|||||||
"page.status.": {"operational", "degraded", "outage", "unknown"},
|
"page.status.": {"operational", "degraded", "outage", "unknown"},
|
||||||
"page.component.": {"operational", "degraded", "outage", "unknown"},
|
"page.component.": {"operational", "degraded", "outage", "unknown"},
|
||||||
"storage.level_": {"raw", "1h", "1d"},
|
"storage.level_": {"raw", "1h", "1d"},
|
||||||
|
"legal.": {"imprint", "privacy"},
|
||||||
"storage.job_": {"compression", "retention", "refresh_continuous_aggregate", "job_stat_history_retention"},
|
"storage.job_": {"compression", "retention", "refresh_continuous_aggregate", "job_stat_history_retention"},
|
||||||
}
|
}
|
||||||
for prefix, values := range families {
|
for prefix, values := range families {
|
||||||
|
|||||||
@@ -41,9 +41,11 @@
|
|||||||
"audit.action.monitor.update": "Monitor geändert",
|
"audit.action.monitor.update": "Monitor geändert",
|
||||||
"audit.action.org.delete": "Organisation gelöscht",
|
"audit.action.org.delete": "Organisation gelöscht",
|
||||||
"audit.action.org.export": "Daten der Organisation exportiert",
|
"audit.action.org.export": "Daten der Organisation exportiert",
|
||||||
|
"audit.action.org.legal_update": "Rechtstext geändert",
|
||||||
"audit.action.org.policy_update": "Sicherheitsrichtlinie geändert",
|
"audit.action.org.policy_update": "Sicherheitsrichtlinie geändert",
|
||||||
"audit.action.platform.agent_create": "Plattform-Agent erstellt",
|
"audit.action.platform.agent_create": "Plattform-Agent erstellt",
|
||||||
"audit.action.platform.agent_delete": "Plattform-Agent widerrufen",
|
"audit.action.platform.agent_delete": "Plattform-Agent widerrufen",
|
||||||
|
"audit.action.platform.legal_update": "Rechtstext der Plattform geändert",
|
||||||
"audit.action.platform.region_create": "Plattform-Region erstellt",
|
"audit.action.platform.region_create": "Plattform-Region erstellt",
|
||||||
"audit.action.platform.region_delete": "Plattform-Region gelöscht",
|
"audit.action.platform.region_delete": "Plattform-Region gelöscht",
|
||||||
"audit.action.region.create": "Region erstellt",
|
"audit.action.region.create": "Region erstellt",
|
||||||
@@ -149,6 +151,7 @@
|
|||||||
"error.invalid_header": "Ein Request-Header ist ungültig.",
|
"error.invalid_header": "Ein Request-Header ist ungültig.",
|
||||||
"error.invalid_input": "Eingaben prüfen.",
|
"error.invalid_input": "Eingaben prüfen.",
|
||||||
"error.invalid_interval": "Das Intervall muss mindestens {{.Min}} Sekunden und höchstens einen Tag betragen.",
|
"error.invalid_interval": "Das Intervall muss mindestens {{.Min}} Sekunden und höchstens einen Tag betragen.",
|
||||||
|
"error.invalid_legal_url": "Der Link muss eine http- oder https-URL sein.",
|
||||||
"error.invalid_method": "Nur GET- und HEAD-Anfragen werden unterstützt.",
|
"error.invalid_method": "Nur GET- und HEAD-Anfragen werden unterstützt.",
|
||||||
"error.invalid_monitor": "Einer der Monitore existiert nicht oder ist doppelt aufgeführt.",
|
"error.invalid_monitor": "Einer der Monitore existiert nicht oder ist doppelt aufgeführt.",
|
||||||
"error.invalid_permissions": "Mindestens eine Berechtigung auswählen.",
|
"error.invalid_permissions": "Mindestens eine Berechtigung auswählen.",
|
||||||
@@ -333,6 +336,15 @@
|
|||||||
"invite.title": "Einladung",
|
"invite.title": "Einladung",
|
||||||
"lang.de": "Deutsch",
|
"lang.de": "Deutsch",
|
||||||
"lang.en": "English",
|
"lang.en": "English",
|
||||||
|
"legal.hint": "Ein Link hat Vorrang vor dem Text. Beide Felder leer lassen, um das Dokument zu entfernen. HTML wird nicht dargestellt.",
|
||||||
|
"legal.imprint": "Impressum",
|
||||||
|
"legal.markdown": "Oder Text (Markdown)",
|
||||||
|
"legal.org_intro": "Werden auf den Statusseiten deiner Organisation angezeigt. Ohne eigene Dokumente werden die der Plattform verwendet.",
|
||||||
|
"legal.org_title": "Impressum & Datenschutz",
|
||||||
|
"legal.platform_intro": "Im Footer der Konsole und der Anmeldeseiten verlinkt sowie auf Statusseiten von Organisationen ohne eigene Dokumente.",
|
||||||
|
"legal.platform_title": "Impressum & Datenschutz der Plattform",
|
||||||
|
"legal.privacy": "Datenschutz",
|
||||||
|
"legal.url": "Link auf eine bestehende Seite",
|
||||||
"members.assign": "Rolle hinzufügen",
|
"members.assign": "Rolle hinzufügen",
|
||||||
"members.intro": "Rollen bestimmen, was ein Mitglied darf. Niemand kann Berechtigungen vergeben, die er selbst nicht hat.",
|
"members.intro": "Rollen bestimmen, was ein Mitglied darf. Niemand kann Berechtigungen vergeben, die er selbst nicht hat.",
|
||||||
"members.invite": "Einladen",
|
"members.invite": "Einladen",
|
||||||
@@ -507,6 +519,7 @@
|
|||||||
"settings.audit": "Wer wann was geändert hat.",
|
"settings.audit": "Wer wann was geändert hat.",
|
||||||
"settings.channels": "Webhooks und E-Mail für Incidents",
|
"settings.channels": "Webhooks und E-Mail für Incidents",
|
||||||
"settings.groups": "Monitore in verschachtelten Gruppen ordnen",
|
"settings.groups": "Monitore in verschachtelten Gruppen ordnen",
|
||||||
|
"settings.legal": "Impressum und Datenschutzerklärung für deine Statusseiten.",
|
||||||
"settings.members": "Personen einladen und Rollen vergeben",
|
"settings.members": "Personen einladen und Rollen vergeben",
|
||||||
"settings.org": "Anmelderichtlinien und Token-Laufzeit",
|
"settings.org": "Anmelderichtlinien und Token-Laufzeit",
|
||||||
"settings.regions": "Eigene Regionen, Checker und Statuspage-Server",
|
"settings.regions": "Eigene Regionen, Checker und Statuspage-Server",
|
||||||
|
|||||||
@@ -41,9 +41,11 @@
|
|||||||
"audit.action.monitor.update": "Monitor changed",
|
"audit.action.monitor.update": "Monitor changed",
|
||||||
"audit.action.org.delete": "Organization deleted",
|
"audit.action.org.delete": "Organization deleted",
|
||||||
"audit.action.org.export": "Organization data exported",
|
"audit.action.org.export": "Organization data exported",
|
||||||
|
"audit.action.org.legal_update": "Legal document changed",
|
||||||
"audit.action.org.policy_update": "Security policy changed",
|
"audit.action.org.policy_update": "Security policy changed",
|
||||||
"audit.action.platform.agent_create": "Platform agent created",
|
"audit.action.platform.agent_create": "Platform agent created",
|
||||||
"audit.action.platform.agent_delete": "Platform agent revoked",
|
"audit.action.platform.agent_delete": "Platform agent revoked",
|
||||||
|
"audit.action.platform.legal_update": "Platform legal document changed",
|
||||||
"audit.action.platform.region_create": "Platform region created",
|
"audit.action.platform.region_create": "Platform region created",
|
||||||
"audit.action.platform.region_delete": "Platform region deleted",
|
"audit.action.platform.region_delete": "Platform region deleted",
|
||||||
"audit.action.region.create": "Region created",
|
"audit.action.region.create": "Region created",
|
||||||
@@ -149,6 +151,7 @@
|
|||||||
"error.invalid_header": "A request header is not valid.",
|
"error.invalid_header": "A request header is not valid.",
|
||||||
"error.invalid_input": "Please check your input.",
|
"error.invalid_input": "Please check your input.",
|
||||||
"error.invalid_interval": "The interval must be at least {{.Min}} seconds and at most one day.",
|
"error.invalid_interval": "The interval must be at least {{.Min}} seconds and at most one day.",
|
||||||
|
"error.invalid_legal_url": "The link must be an http or https URL.",
|
||||||
"error.invalid_method": "Only GET and HEAD requests are supported.",
|
"error.invalid_method": "Only GET and HEAD requests are supported.",
|
||||||
"error.invalid_monitor": "One of the monitors does not exist or is listed twice.",
|
"error.invalid_monitor": "One of the monitors does not exist or is listed twice.",
|
||||||
"error.invalid_permissions": "Choose at least one permission.",
|
"error.invalid_permissions": "Choose at least one permission.",
|
||||||
@@ -333,6 +336,15 @@
|
|||||||
"invite.title": "Invitation",
|
"invite.title": "Invitation",
|
||||||
"lang.de": "Deutsch",
|
"lang.de": "Deutsch",
|
||||||
"lang.en": "English",
|
"lang.en": "English",
|
||||||
|
"legal.hint": "A link takes precedence over the text. Leave both empty to remove the document. HTML is not rendered.",
|
||||||
|
"legal.imprint": "Legal notice",
|
||||||
|
"legal.markdown": "Or text (Markdown)",
|
||||||
|
"legal.org_intro": "Shown on your organization's status pages. Without your own documents, the platform's are shown.",
|
||||||
|
"legal.org_title": "Legal notice & privacy",
|
||||||
|
"legal.platform_intro": "Linked in the footer of the console and sign-in pages, and on status pages of organizations without their own documents.",
|
||||||
|
"legal.platform_title": "Platform legal notice & privacy",
|
||||||
|
"legal.privacy": "Privacy policy",
|
||||||
|
"legal.url": "Link to an existing page",
|
||||||
"members.assign": "Add role",
|
"members.assign": "Add role",
|
||||||
"members.intro": "Roles decide what each member may do. Nobody can grant permissions they do not hold themselves.",
|
"members.intro": "Roles decide what each member may do. Nobody can grant permissions they do not hold themselves.",
|
||||||
"members.invite": "Invite",
|
"members.invite": "Invite",
|
||||||
@@ -507,6 +519,7 @@
|
|||||||
"settings.audit": "Who changed what and when.",
|
"settings.audit": "Who changed what and when.",
|
||||||
"settings.channels": "Webhooks and email for incidents",
|
"settings.channels": "Webhooks and email for incidents",
|
||||||
"settings.groups": "Organize monitors in nested groups",
|
"settings.groups": "Organize monitors in nested groups",
|
||||||
|
"settings.legal": "Legal notice and privacy policy for your status pages.",
|
||||||
"settings.members": "Invite people and assign roles",
|
"settings.members": "Invite people and assign roles",
|
||||||
"settings.org": "Sign-in policies and token lifetime",
|
"settings.org": "Sign-in policies and token lifetime",
|
||||||
"settings.regions": "Your own regions, checkers and status page servers",
|
"settings.regions": "Your own regions, checkers and status page servers",
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
-- +goose Up
|
||||||
|
-- Legal notice and privacy policy, either as Markdown served by us or as a
|
||||||
|
-- link to a page elsewhere; a link wins when both are set. Rows without an
|
||||||
|
-- organization belong to the platform: the console and status pages of
|
||||||
|
-- organizations without their own.
|
||||||
|
CREATE TABLE legal_documents (
|
||||||
|
org_id uuid REFERENCES orgs (id) ON DELETE CASCADE,
|
||||||
|
kind text NOT NULL CHECK (kind IN ('imprint', 'privacy')),
|
||||||
|
url text NOT NULL DEFAULT '' CHECK (length(url) <= 2000),
|
||||||
|
markdown text NOT NULL DEFAULT '' CHECK (length(markdown) <= 100000),
|
||||||
|
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||||
|
UNIQUE NULLS NOT DISTINCT (org_id, kind)
|
||||||
|
);
|
||||||
|
|
||||||
|
ALTER TABLE legal_documents ENABLE ROW LEVEL SECURITY;
|
||||||
|
ALTER TABLE legal_documents FORCE ROW LEVEL SECURITY;
|
||||||
|
-- Platform documents are public.
|
||||||
|
CREATE POLICY legal_documents_read ON legal_documents FOR SELECT
|
||||||
|
USING (app_scope_system() OR org_id IS NULL OR org_id = app_org_id());
|
||||||
|
CREATE POLICY legal_documents_write ON legal_documents FOR ALL
|
||||||
|
USING (app_scope_system() OR org_id = app_org_id())
|
||||||
|
WITH CHECK (app_scope_system() OR org_id = app_org_id());
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
DROP TABLE legal_documents;
|
||||||
@@ -192,36 +192,73 @@ func (s *Server) serve(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
host := hostOnly(c.Request.Host)
|
host := hostOnly(c.Request.Host)
|
||||||
var key, slug string
|
parts := strings.Split(strings.Trim(c.Request.URL.Path, "/"), "/")
|
||||||
|
var key, slug, base, legal string
|
||||||
|
custom := s.IsCustomDomain(host)
|
||||||
switch {
|
switch {
|
||||||
case s.IsCustomDomain(host):
|
case custom:
|
||||||
if c.Request.URL.Path != "/" {
|
key, base = "host:"+host, "/"
|
||||||
|
if len(parts) > 1 {
|
||||||
c.Status(http.StatusNotFound)
|
c.Status(http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
key = "host:" + host
|
|
||||||
default:
|
default:
|
||||||
slug = strings.Trim(c.Request.URL.Path, "/")
|
slug = parts[0]
|
||||||
if slug == "" || strings.Contains(slug, "/") {
|
if len(parts) == 2 {
|
||||||
|
legal = parts[1]
|
||||||
|
}
|
||||||
|
if slug == "" || len(parts) > 2 {
|
||||||
c.Status(http.StatusNotFound)
|
c.Status(http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
key, host = "slug:"+slug, ""
|
key, host, base = "slug:"+slug, "", "/"+slug+"/"
|
||||||
|
}
|
||||||
|
if custom {
|
||||||
|
legal = parts[0]
|
||||||
}
|
}
|
||||||
e, ok := s.lookup(c.Request.Context(), key, host, slug)
|
e, ok := s.lookup(c.Request.Context(), key, host, slug)
|
||||||
if !ok {
|
if !ok {
|
||||||
c.Status(http.StatusNotFound)
|
c.Status(http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if legal != "" {
|
||||||
|
s.serveLegal(c, e, legal, base)
|
||||||
|
return
|
||||||
|
}
|
||||||
var staleSince time.Time
|
var staleSince time.Time
|
||||||
if s.now().Sub(e.Fetched) > staleNoticeAfter {
|
if s.now().Sub(e.Fetched) > staleNoticeAfter {
|
||||||
staleSince = e.Fetched
|
staleSince = e.Fetched
|
||||||
}
|
}
|
||||||
|
s.localizeRequest(c)
|
||||||
|
c.Header("Cache-Control", "public, max-age=30")
|
||||||
|
web.Render(c, http.StatusOK, web.PublicStatusPage(e.Snap, web.PublicAssets{CSSHref: "/static/dist/app.css", StaleSince: staleSince, LegalBase: base}))
|
||||||
|
}
|
||||||
|
|
||||||
|
// serveLegal shows a legal document of the page from the cached snapshot,
|
||||||
|
// so it stays reachable while the API is down.
|
||||||
|
func (s *Server) serveLegal(c *gin.Context, e entry, kind, base string) {
|
||||||
|
d, ok := e.Snap.LegalDocByKind(kind)
|
||||||
|
switch {
|
||||||
|
case !ok:
|
||||||
|
c.Status(http.StatusNotFound)
|
||||||
|
case d.URL != "":
|
||||||
|
c.Redirect(http.StatusFound, d.URL)
|
||||||
|
default:
|
||||||
|
html, err := web.RenderMarkdown(d.Markdown)
|
||||||
|
if err != nil {
|
||||||
|
c.Status(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
s.localizeRequest(c)
|
||||||
|
c.Header("Cache-Control", "public, max-age=300")
|
||||||
|
web.Render(c, http.StatusOK, web.PublicLegalPage(e.Snap, web.PublicAssets{CSSHref: "/static/dist/app.css"}, kind, html, base))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) localizeRequest(c *gin.Context) {
|
||||||
l := s.catalog.Match(c.GetHeader("Accept-Language"))
|
l := s.catalog.Match(c.GetHeader("Accept-Language"))
|
||||||
c.Request = c.Request.WithContext(i18n.NewContext(c.Request.Context(), l))
|
c.Request = c.Request.WithContext(i18n.NewContext(c.Request.Context(), l))
|
||||||
c.Header("Cache-Control", "public, max-age=30")
|
|
||||||
c.Header("Content-Language", l.Lang())
|
c.Header("Content-Language", l.Lang())
|
||||||
web.Render(c, http.StatusOK, web.PublicStatusPage(e.Snap, web.PublicAssets{CSSHref: "/static/dist/app.css", StaleSince: staleSince}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// lookup answers from the cache whenever possible and refreshes in the
|
// lookup answers from the cache whenever possible and refreshes in the
|
||||||
|
|||||||
@@ -218,3 +218,49 @@ func TestDeletedPageDisappears(t *testing.T) {
|
|||||||
t.Errorf("GET after restart = %d, want 404 (removed from disk too)", code)
|
t.Errorf("GET after restart = %d, want 404 (removed from disk too)", code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLegalDocuments(t *testing.T) {
|
||||||
|
now := time.Now()
|
||||||
|
src := newSource()
|
||||||
|
legal := []agentapi.LegalDoc{
|
||||||
|
{Kind: "imprint", Markdown: "# Impressum\n\nAcme GmbH <script>alert(1)</script> [x](javascript:alert(1))"},
|
||||||
|
{Kind: "privacy", URL: "https://acme.example/privacy"},
|
||||||
|
}
|
||||||
|
src.pages["|acme"] = agentapi.PageSnapshot{Title: "Acme status", Status: agentapi.PageOperational, Legal: legal}
|
||||||
|
src.pages["status.acme.test|"] = agentapi.PageSnapshot{Title: "Acme on own domain", Status: agentapi.PageOperational, Legal: legal}
|
||||||
|
h := newHarness(t, src, t.TempDir(), &now)
|
||||||
|
|
||||||
|
_, page := h.get("status.example.test", "/acme")
|
||||||
|
if !strings.Contains(page, `href="/acme/imprint"`) || !strings.Contains(page, `href="https://acme.example/privacy"`) {
|
||||||
|
t.Error("status page does not link its legal documents")
|
||||||
|
}
|
||||||
|
if _, page := h.get("status.acme.test", "/"); !strings.Contains(page, `href="/imprint"`) {
|
||||||
|
t.Error("custom domain page does not link /imprint")
|
||||||
|
}
|
||||||
|
|
||||||
|
// The API goes away; the documents stay reachable from the cache.
|
||||||
|
src.mu.Lock()
|
||||||
|
src.err = errors.New("connection refused")
|
||||||
|
src.mu.Unlock()
|
||||||
|
now = now.Add(time.Hour)
|
||||||
|
|
||||||
|
for _, tc := range []struct{ host, path string }{{"status.example.test", "/acme/imprint"}, {"status.acme.test", "/imprint"}} {
|
||||||
|
code, body := h.get(tc.host, tc.path)
|
||||||
|
if code != http.StatusOK || !strings.Contains(body, "<h1>Impressum</h1>") || !strings.Contains(body, "Acme GmbH") {
|
||||||
|
t.Errorf("GET %s%s = %d, lacks the rendered imprint", tc.host, tc.path, code)
|
||||||
|
}
|
||||||
|
if strings.Contains(body, "<script>alert") || strings.Contains(body, "javascript:") {
|
||||||
|
t.Errorf("GET %s%s renders unsafe markup", tc.host, tc.path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
req := httptest.NewRequest(http.MethodGet, "/acme/privacy", nil)
|
||||||
|
req.Host = "status.example.test"
|
||||||
|
w := httptest.NewRecorder()
|
||||||
|
h.r.ServeHTTP(w, req)
|
||||||
|
if w.Code != http.StatusFound || w.Header().Get("Location") != "https://acme.example/privacy" {
|
||||||
|
t.Errorf("privacy link = %d %s, want redirect", w.Code, w.Header().Get("Location"))
|
||||||
|
}
|
||||||
|
if code, _ := h.get("status.example.test", "/acme/other"); code != http.StatusNotFound {
|
||||||
|
t.Errorf("unknown document = %d, want 404", code)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
// Code generated by sqlc. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// sqlc v1.31.1
|
||||||
|
// source: legal.sql
|
||||||
|
|
||||||
|
package store
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
const deleteLegalDocument = `-- name: DeleteLegalDocument :exec
|
||||||
|
DELETE FROM legal_documents WHERE org_id IS NOT DISTINCT FROM $1 AND kind = $2
|
||||||
|
`
|
||||||
|
|
||||||
|
type DeleteLegalDocumentParams struct {
|
||||||
|
OrgID *uuid.UUID
|
||||||
|
Kind string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) DeleteLegalDocument(ctx context.Context, arg DeleteLegalDocumentParams) error {
|
||||||
|
_, err := q.db.Exec(ctx, deleteLegalDocument, arg.OrgID, arg.Kind)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
const legalDocuments = `-- name: LegalDocuments :many
|
||||||
|
SELECT org_id, kind, url, markdown, updated_at FROM legal_documents
|
||||||
|
WHERE org_id IS NULL OR org_id = $1
|
||||||
|
ORDER BY org_id NULLS LAST, kind
|
||||||
|
`
|
||||||
|
|
||||||
|
// The organization's documents and the platform's, organization first.
|
||||||
|
func (q *Queries) LegalDocuments(ctx context.Context, orgID *uuid.UUID) ([]LegalDocument, error) {
|
||||||
|
rows, err := q.db.Query(ctx, legalDocuments, orgID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
items := []LegalDocument{}
|
||||||
|
for rows.Next() {
|
||||||
|
var i LegalDocument
|
||||||
|
if err := rows.Scan(
|
||||||
|
&i.OrgID,
|
||||||
|
&i.Kind,
|
||||||
|
&i.Url,
|
||||||
|
&i.Markdown,
|
||||||
|
&i.UpdatedAt,
|
||||||
|
); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
items = append(items, i)
|
||||||
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return items, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
const upsertLegalDocument = `-- name: UpsertLegalDocument :exec
|
||||||
|
INSERT INTO legal_documents (org_id, kind, url, markdown)
|
||||||
|
VALUES ($1, $2, $3, $4)
|
||||||
|
ON CONFLICT (org_id, kind) DO UPDATE SET url = EXCLUDED.url, markdown = EXCLUDED.markdown, updated_at = now()
|
||||||
|
`
|
||||||
|
|
||||||
|
type UpsertLegalDocumentParams struct {
|
||||||
|
OrgID *uuid.UUID
|
||||||
|
Kind string
|
||||||
|
Url string
|
||||||
|
Markdown string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) UpsertLegalDocument(ctx context.Context, arg UpsertLegalDocumentParams) error {
|
||||||
|
_, err := q.db.Exec(ctx, upsertLegalDocument,
|
||||||
|
arg.OrgID,
|
||||||
|
arg.Kind,
|
||||||
|
arg.Url,
|
||||||
|
arg.Markdown,
|
||||||
|
)
|
||||||
|
return err
|
||||||
|
}
|
||||||
@@ -115,6 +115,14 @@ type Invitation struct {
|
|||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type LegalDocument struct {
|
||||||
|
OrgID *uuid.UUID
|
||||||
|
Kind string
|
||||||
|
Url string
|
||||||
|
Markdown string
|
||||||
|
UpdatedAt time.Time
|
||||||
|
}
|
||||||
|
|
||||||
type Membership struct {
|
type Membership struct {
|
||||||
OrgID uuid.UUID
|
OrgID uuid.UUID
|
||||||
UserID uuid.UUID
|
UserID uuid.UUID
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ type Querier interface {
|
|||||||
DeleteGroup(ctx context.Context, id uuid.UUID) (int64, error)
|
DeleteGroup(ctx context.Context, id uuid.UUID) (int64, error)
|
||||||
DeleteInvitation(ctx context.Context, id uuid.UUID) (int64, error)
|
DeleteInvitation(ctx context.Context, id uuid.UUID) (int64, error)
|
||||||
DeleteInvitationsForEmail(ctx context.Context, email string) error
|
DeleteInvitationsForEmail(ctx context.Context, email string) error
|
||||||
|
DeleteLegalDocument(ctx context.Context, arg DeleteLegalDocumentParams) error
|
||||||
DeleteMonitor(ctx context.Context, id uuid.UUID) (int64, error)
|
DeleteMonitor(ctx context.Context, id uuid.UUID) (int64, error)
|
||||||
DeleteMonitorRegions(ctx context.Context, monitorID uuid.UUID) error
|
DeleteMonitorRegions(ctx context.Context, monitorID uuid.UUID) error
|
||||||
DeleteOrg(ctx context.Context, id uuid.UUID) (int64, error)
|
DeleteOrg(ctx context.Context, id uuid.UUID) (int64, error)
|
||||||
@@ -112,6 +113,8 @@ type Querier interface {
|
|||||||
// Newest result per monitor and region in the org.
|
// Newest result per monitor and region in the org.
|
||||||
LatestResults(ctx context.Context, orgID uuid.UUID) ([]LatestResultsRow, error)
|
LatestResults(ctx context.Context, orgID uuid.UUID) ([]LatestResultsRow, error)
|
||||||
LatestResultsForMonitor(ctx context.Context, arg LatestResultsForMonitorParams) ([]LatestResultsForMonitorRow, error)
|
LatestResultsForMonitor(ctx context.Context, arg LatestResultsForMonitorParams) ([]LatestResultsForMonitorRow, error)
|
||||||
|
// The organization's documents and the platform's, organization first.
|
||||||
|
LegalDocuments(ctx context.Context, orgID *uuid.UUID) ([]LegalDocument, error)
|
||||||
ListAPITokens(ctx context.Context, arg ListAPITokensParams) ([]ListAPITokensRow, error)
|
ListAPITokens(ctx context.Context, arg ListAPITokensParams) ([]ListAPITokensRow, error)
|
||||||
// Agents owned by org, or platform agents when org is NULL.
|
// Agents owned by org, or platform agents when org is NULL.
|
||||||
ListAgents(ctx context.Context, orgID *uuid.UUID) ([]ListAgentsRow, error)
|
ListAgents(ctx context.Context, orgID *uuid.UUID) ([]ListAgentsRow, error)
|
||||||
@@ -214,6 +217,7 @@ type Querier interface {
|
|||||||
UpdateRole(ctx context.Context, arg UpdateRoleParams) (Role, error)
|
UpdateRole(ctx context.Context, arg UpdateRoleParams) (Role, error)
|
||||||
UpdateSSOProvider(ctx context.Context, arg UpdateSSOProviderParams) (SsoProvider, error)
|
UpdateSSOProvider(ctx context.Context, arg UpdateSSOProviderParams) (SsoProvider, error)
|
||||||
UpdateStatusPage(ctx context.Context, arg UpdateStatusPageParams) (StatusPage, error)
|
UpdateStatusPage(ctx context.Context, arg UpdateStatusPageParams) (StatusPage, error)
|
||||||
|
UpsertLegalDocument(ctx context.Context, arg UpsertLegalDocumentParams) error
|
||||||
// Uptime per monitor from the hourly aggregate, including the not yet
|
// Uptime per monitor from the hourly aggregate, including the not yet
|
||||||
// materialized most recent hours (real-time aggregation).
|
// materialized most recent hours (real-time aggregation).
|
||||||
UptimeSince(ctx context.Context, arg UptimeSinceParams) ([]UptimeSinceRow, error)
|
UptimeSince(ctx context.Context, arg UptimeSinceParams) ([]UptimeSinceRow, error)
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
-- name: UpsertLegalDocument :exec
|
||||||
|
INSERT INTO legal_documents (org_id, kind, url, markdown)
|
||||||
|
VALUES ($1, $2, $3, $4)
|
||||||
|
ON CONFLICT (org_id, kind) DO UPDATE SET url = EXCLUDED.url, markdown = EXCLUDED.markdown, updated_at = now();
|
||||||
|
|
||||||
|
-- name: DeleteLegalDocument :exec
|
||||||
|
DELETE FROM legal_documents WHERE org_id IS NOT DISTINCT FROM $1 AND kind = $2;
|
||||||
|
|
||||||
|
-- name: LegalDocuments :many
|
||||||
|
-- The organization's documents and the platform's, organization first.
|
||||||
|
SELECT org_id, kind, url, markdown, updated_at FROM legal_documents
|
||||||
|
WHERE org_id IS NULL OR org_id = sqlc.narg(org_id)
|
||||||
|
ORDER BY org_id NULLS LAST, kind;
|
||||||
@@ -72,3 +72,23 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Markdown of legal documents, written by operators and organizations. */
|
||||||
|
@layer components {
|
||||||
|
.legal-text {
|
||||||
|
@apply text-sm leading-relaxed;
|
||||||
|
}
|
||||||
|
.legal-text h1 { @apply mb-6 text-xl font-semibold; }
|
||||||
|
.legal-text h2 { @apply mb-3 mt-8 text-base font-semibold; }
|
||||||
|
.legal-text h3 { @apply mb-2 mt-6 text-sm font-semibold; }
|
||||||
|
.legal-text p,
|
||||||
|
.legal-text ul,
|
||||||
|
.legal-text ol,
|
||||||
|
.legal-text table { @apply mb-4; }
|
||||||
|
.legal-text ul { @apply list-disc pl-5; }
|
||||||
|
.legal-text ol { @apply list-decimal pl-5; }
|
||||||
|
.legal-text a { @apply underline underline-offset-2; }
|
||||||
|
.legal-text th,
|
||||||
|
.legal-text td { @apply border border-rule px-2 py-1 text-left; }
|
||||||
|
.legal-text code { @apply font-mono text-xs; }
|
||||||
|
}
|
||||||
@@ -201,6 +201,7 @@ templ SettingsIndex(p Page, me Me) {
|
|||||||
@settingsLink("/settings/regions", "console.nav.regions", "settings.regions")
|
@settingsLink("/settings/regions", "console.nav.regions", "settings.regions")
|
||||||
@settingsLink("/settings/org", "console.nav.org", "settings.org")
|
@settingsLink("/settings/org", "console.nav.org", "settings.org")
|
||||||
@settingsLink("/settings/sso", "console.nav.sso", "settings.sso")
|
@settingsLink("/settings/sso", "console.nav.sso", "settings.sso")
|
||||||
|
@settingsLink("/settings/legal", "legal.org_title", "settings.legal")
|
||||||
}
|
}
|
||||||
if me.Can["audit.read"] {
|
if me.Can["audit.read"] {
|
||||||
@settingsLink("/settings/audit", "audit.title", "settings.audit")
|
@settingsLink("/settings/audit", "audit.title", "settings.audit")
|
||||||
|
|||||||
@@ -985,6 +985,10 @@ func SettingsIndex(p Page, me Me) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
templ_7745c5c3_Err = settingsLink("/settings/legal", "legal.org_title", "settings.legal").Render(ctx, templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if me.Can["audit.read"] {
|
if me.Can["audit.read"] {
|
||||||
templ_7745c5c3_Err = settingsLink("/settings/audit", "audit.title", "settings.audit").Render(ctx, templ_7745c5c3_Buffer)
|
templ_7745c5c3_Err = settingsLink("/settings/audit", "audit.title", "settings.audit").Render(ctx, templ_7745c5c3_Buffer)
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ type Page struct {
|
|||||||
// typically after a redirect back from an SSO flow.
|
// typically after a redirect back from an SSO flow.
|
||||||
ErrorID string
|
ErrorID string
|
||||||
NoticeID string
|
NoticeID string
|
||||||
|
// Legal links the platform's legal notice and privacy policy.
|
||||||
|
Legal []LegalLink
|
||||||
}
|
}
|
||||||
|
|
||||||
templ Layout(p Page) {
|
templ Layout(p Page) {
|
||||||
@@ -27,8 +29,11 @@ templ Layout(p Page) {
|
|||||||
<script src="/static/dist/axios.min.js" defer></script>
|
<script src="/static/dist/axios.min.js" defer></script>
|
||||||
<script src="/static/dist/app.js" defer></script>
|
<script src="/static/dist/app.js" defer></script>
|
||||||
</head>
|
</head>
|
||||||
<body class="min-h-screen" data-msg-network={ i18n.T(ctx, "app.network_error") }>
|
<body class="flex min-h-screen flex-col" data-msg-network={ i18n.T(ctx, "app.network_error") }>
|
||||||
{ children... }
|
<div class="flex-1">
|
||||||
|
{ children... }
|
||||||
|
</div>
|
||||||
|
@legalFooter(p.Legal)
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ type Page struct {
|
|||||||
// typically after a redirect back from an SSO flow.
|
// typically after a redirect back from an SSO flow.
|
||||||
ErrorID string
|
ErrorID string
|
||||||
NoticeID string
|
NoticeID string
|
||||||
|
// Legal links the platform's legal notice and privacy policy.
|
||||||
|
Legal []LegalLink
|
||||||
}
|
}
|
||||||
|
|
||||||
func Layout(p Page) templ.Component {
|
func Layout(p Page) templ.Component {
|
||||||
@@ -47,7 +49,7 @@ func Layout(p Page) templ.Component {
|
|||||||
var templ_7745c5c3_Var2 string
|
var templ_7745c5c3_Var2 string
|
||||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.Lang(ctx)).Resolve(ctx)
|
templ_7745c5c3_Var2, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.Lang(ctx)).Resolve(ctx)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 18, Col: 28}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 20, Col: 28}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var2)
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var2)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
@@ -65,7 +67,7 @@ func Layout(p Page) templ.Component {
|
|||||||
var templ_7745c5c3_Var3 string
|
var templ_7745c5c3_Var3 string
|
||||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templruntime.NewAttributeExpression(p.CSRF).Resolve(ctx)
|
templ_7745c5c3_Var3, templ_7745c5c3_Err = templruntime.NewAttributeExpression(p.CSRF).Resolve(ctx)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 23, Col: 44}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 25, Col: 44}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var3)
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var3)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
@@ -83,26 +85,26 @@ func Layout(p Page) templ.Component {
|
|||||||
var templ_7745c5c3_Var4 string
|
var templ_7745c5c3_Var4 string
|
||||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, p.TitleID))
|
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, p.TitleID))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 25, Col: 34}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 27, Col: 34}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " · uptimesebi</title><link rel=\"stylesheet\" href=\"/static/dist/app.css\"><script src=\"/static/dist/axios.min.js\" defer></script><script src=\"/static/dist/app.js\" defer></script></head><body class=\"min-h-screen\" data-msg-network=\"")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " · uptimesebi</title><link rel=\"stylesheet\" href=\"/static/dist/app.css\"><script src=\"/static/dist/axios.min.js\" defer></script><script src=\"/static/dist/app.js\" defer></script></head><body class=\"flex min-h-screen flex-col\" data-msg-network=\"")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var5 string
|
var templ_7745c5c3_Var5 string
|
||||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "app.network_error")).Resolve(ctx)
|
templ_7745c5c3_Var5, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "app.network_error")).Resolve(ctx)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 30, Col: 80}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 32, Col: 94}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var5)
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var5)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "\">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "\"><div class=\"flex-1\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -110,7 +112,15 @@ func Layout(p Page) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "</body></html>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "</div>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = legalFooter(p.Legal).Render(ctx, templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "</body></html>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -135,76 +145,76 @@ func languageSwitch(langs []string) templ.Component {
|
|||||||
}
|
}
|
||||||
ctx = templ.InitializeContext(ctx)
|
ctx = templ.InitializeContext(ctx)
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "<span class=\"flex gap-2 font-mono text-xs\">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "<span class=\"flex gap-2 font-mono text-xs\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
for _, l := range langs {
|
for _, l := range langs {
|
||||||
if l == i18n.Lang(ctx) {
|
if l == i18n.Lang(ctx) {
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "<span class=\"text-ink\" aria-current=\"true\">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "<span class=\"text-ink\" aria-current=\"true\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var7 string
|
var templ_7745c5c3_Var7 string
|
||||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(l)
|
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(l)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 40, Col: 50}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 45, Col: 50}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "</span>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "</span>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "<button type=\"button\" data-locale=\"")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "<button type=\"button\" data-locale=\"")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var8 string
|
var templ_7745c5c3_Var8 string
|
||||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templruntime.NewAttributeExpression(l).Resolve(ctx)
|
templ_7745c5c3_Var8, templ_7745c5c3_Err = templruntime.NewAttributeExpression(l).Resolve(ctx)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 42, Col: 41}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 47, Col: 41}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var8)
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var8)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "\" class=\"text-muted hover:text-ink\" title=\"")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "\" class=\"text-muted hover:text-ink\" title=\"")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var9 string
|
var templ_7745c5c3_Var9 string
|
||||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "lang."+l)).Resolve(ctx)
|
templ_7745c5c3_Var9, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "lang."+l)).Resolve(ctx)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 42, Col: 108}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 47, Col: 108}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var9)
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var9)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "\">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var10 string
|
var templ_7745c5c3_Var10 string
|
||||||
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(l)
|
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(l)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 42, Col: 114}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 47, Col: 114}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "</button>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "</button>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "</span>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</span>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -242,7 +252,7 @@ func authShell(p Page) templ.Component {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
ctx = templ.InitializeContext(ctx)
|
ctx = templ.InitializeContext(ctx)
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "<main class=\"mx-auto mt-[12vh] w-full max-w-sm px-6\"><div class=\"mb-10 flex items-baseline justify-between\"><p class=\"font-mono text-xs tracking-wide text-muted\">uptimesebi</p>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "<main class=\"mx-auto mt-[12vh] w-full max-w-sm px-6\"><div class=\"mb-10 flex items-baseline justify-between\"><p class=\"font-mono text-xs tracking-wide text-muted\">uptimesebi</p>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -250,20 +260,20 @@ func authShell(p Page) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "</div><h1 class=\"mb-6 text-xl font-semibold\">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "</div><h1 class=\"mb-6 text-xl font-semibold\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var13 string
|
var templ_7745c5c3_Var13 string
|
||||||
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, p.TitleID))
|
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, p.TitleID))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 55, Col: 66}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 60, Col: 66}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "</h1>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "</h1>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -275,7 +285,7 @@ func authShell(p Page) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "</main>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "</main>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -306,69 +316,69 @@ func field(label, name, typ, autocomplete string, required bool) templ.Component
|
|||||||
}
|
}
|
||||||
ctx = templ.InitializeContext(ctx)
|
ctx = templ.InitializeContext(ctx)
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "<label class=\"mb-4 block\"><span class=\"mb-1 block text-xs font-medium uppercase tracking-wider text-muted\">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "<label class=\"mb-4 block\"><span class=\"mb-1 block text-xs font-medium uppercase tracking-wider text-muted\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var15 string
|
var templ_7745c5c3_Var15 string
|
||||||
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(label)
|
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(label)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 64, Col: 90}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 69, Col: 90}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "</span> <input class=\"w-full border border-rule bg-transparent px-2.5 py-1.5 outline-none focus:border-ink\" type=\"")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "</span> <input class=\"w-full border border-rule bg-transparent px-2.5 py-1.5 outline-none focus:border-ink\" type=\"")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var16 string
|
var templ_7745c5c3_Var16 string
|
||||||
templ_7745c5c3_Var16, templ_7745c5c3_Err = templruntime.NewAttributeExpression(typ).Resolve(ctx)
|
templ_7745c5c3_Var16, templ_7745c5c3_Err = templruntime.NewAttributeExpression(typ).Resolve(ctx)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 67, Col: 13}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 72, Col: 13}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var16)
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var16)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "\" name=\"")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "\" name=\"")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var17 string
|
var templ_7745c5c3_Var17 string
|
||||||
templ_7745c5c3_Var17, templ_7745c5c3_Err = templruntime.NewAttributeExpression(name).Resolve(ctx)
|
templ_7745c5c3_Var17, templ_7745c5c3_Err = templruntime.NewAttributeExpression(name).Resolve(ctx)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 68, Col: 14}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 73, Col: 14}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var17)
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var17)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "\" autocomplete=\"")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "\" autocomplete=\"")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var18 string
|
var templ_7745c5c3_Var18 string
|
||||||
templ_7745c5c3_Var18, templ_7745c5c3_Err = templruntime.NewAttributeExpression(autocomplete).Resolve(ctx)
|
templ_7745c5c3_Var18, templ_7745c5c3_Err = templruntime.NewAttributeExpression(autocomplete).Resolve(ctx)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 69, Col: 30}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 74, Col: 30}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var18)
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var18)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "\"")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "\"")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
if required {
|
if required {
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, " required")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, " required")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "></label>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "></label>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -393,20 +403,20 @@ func submit(label string) templ.Component {
|
|||||||
}
|
}
|
||||||
ctx = templ.InitializeContext(ctx)
|
ctx = templ.InitializeContext(ctx)
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "<button type=\"submit\" class=\"mt-2 w-full bg-ink px-3 py-2 text-sm font-medium text-paper hover:opacity-90 disabled:opacity-50\">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "<button type=\"submit\" class=\"mt-2 w-full bg-ink px-3 py-2 text-sm font-medium text-paper hover:opacity-90 disabled:opacity-50\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var20 string
|
var templ_7745c5c3_Var20 string
|
||||||
templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(label)
|
templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(label)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 77, Col: 9}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 82, Col: 9}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "</button>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "</button>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -432,39 +442,39 @@ func flash(p Page) templ.Component {
|
|||||||
ctx = templ.InitializeContext(ctx)
|
ctx = templ.InitializeContext(ctx)
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
if p.ErrorID != "" {
|
if p.ErrorID != "" {
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "<p class=\"mb-6 border-l-2 border-down pl-2 text-sm text-down\">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "<p class=\"mb-6 border-l-2 border-down pl-2 text-sm text-down\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var22 string
|
var templ_7745c5c3_Var22 string
|
||||||
templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, p.ErrorID))
|
templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, p.ErrorID))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 83, Col: 88}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 88, Col: 88}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "</p>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "</p>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if p.NoticeID != "" {
|
if p.NoticeID != "" {
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "<p class=\"mb-6 border-l-2 border-up pl-2 text-sm\">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "<p class=\"mb-6 border-l-2 border-up pl-2 text-sm\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var23 string
|
var templ_7745c5c3_Var23 string
|
||||||
templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, p.NoticeID))
|
templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, p.NoticeID))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 86, Col: 77}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/layout.templ`, Line: 91, Col: 77}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "</p>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "</p>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -490,7 +500,7 @@ func formError() templ.Component {
|
|||||||
}
|
}
|
||||||
ctx = templ.InitializeContext(ctx)
|
ctx = templ.InitializeContext(ctx)
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "<p data-error class=\"mb-4 hidden border-l-2 border-down pl-2 text-sm text-down\"></p>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "<p data-error class=\"mb-4 hidden border-l-2 border-down pl-2 text-sm text-down\"></p>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package web
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
|
||||||
|
"github.com/yuin/goldmark"
|
||||||
|
"github.com/yuin/goldmark/extension"
|
||||||
|
|
||||||
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/agentapi"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LegalKinds are the legal documents, in footer order.
|
||||||
|
var LegalKinds = []string{"imprint", "privacy"}
|
||||||
|
|
||||||
|
// LegalTitleID names the catalog message of a document kind.
|
||||||
|
func LegalTitleID(kind string) string { return "legal." + kind }
|
||||||
|
|
||||||
|
// LegalLink points to a legal document, ours or elsewhere.
|
||||||
|
type LegalLink struct {
|
||||||
|
Kind string
|
||||||
|
Href string
|
||||||
|
External bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// markdown renders untrusted input: goldmark drops raw HTML and links with
|
||||||
|
// dangerous schemes such as javascript: unless told otherwise.
|
||||||
|
var markdown = goldmark.New(goldmark.WithExtensions(extension.Table, extension.Linkify, extension.Strikethrough))
|
||||||
|
|
||||||
|
// RenderMarkdown converts src to HTML that is safe to embed.
|
||||||
|
func RenderMarkdown(src string) (string, error) {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
if err := markdown.Convert([]byte(src), &buf); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return buf.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// LegalLinks turns documents into links: external URLs as they are,
|
||||||
|
// Markdown documents to base+kind.
|
||||||
|
func LegalLinks(docs []agentapi.LegalDoc, base string) []LegalLink {
|
||||||
|
var out []LegalLink
|
||||||
|
for _, kind := range LegalKinds {
|
||||||
|
for _, d := range docs {
|
||||||
|
if d.Kind != kind {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
switch {
|
||||||
|
case d.URL != "":
|
||||||
|
out = append(out, LegalLink{Kind: kind, Href: d.URL, External: true})
|
||||||
|
case d.Markdown != "" && base != "":
|
||||||
|
out = append(out, LegalLink{Kind: kind, Href: base + kind})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// PageLegalLinks returns the legal links of a status page.
|
||||||
|
func PageLegalLinks(s agentapi.PageSnapshot, base string) []LegalLink {
|
||||||
|
return LegalLinks(s.Legal, base)
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
package web
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/agentapi"
|
||||||
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
|
||||||
|
)
|
||||||
|
|
||||||
|
templ legalLink(l LegalLink) {
|
||||||
|
if l.External {
|
||||||
|
<a href={ templ.SafeURL(l.Href) } rel="noopener" class="hover:text-ink">{ i18n.T(ctx, LegalTitleID(l.Kind)) }</a>
|
||||||
|
} else {
|
||||||
|
<a href={ templ.SafeURL(l.Href) } class="hover:text-ink">{ i18n.T(ctx, LegalTitleID(l.Kind)) }</a>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
templ legalFooter(links []LegalLink) {
|
||||||
|
if len(links) > 0 {
|
||||||
|
<footer class="mx-auto flex w-full max-w-5xl justify-end gap-4 px-6 py-6 font-mono text-xs text-muted">
|
||||||
|
for _, l := range links {
|
||||||
|
@legalLink(l)
|
||||||
|
}
|
||||||
|
</footer>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
templ legalBody(html string) {
|
||||||
|
<article class="legal-text max-w-2xl">
|
||||||
|
@templ.Raw(html)
|
||||||
|
</article>
|
||||||
|
}
|
||||||
|
|
||||||
|
// LegalPage shows a platform legal document.
|
||||||
|
templ LegalPage(p Page, html string) {
|
||||||
|
@Layout(p) {
|
||||||
|
<main class="mx-auto max-w-3xl px-6 py-14">
|
||||||
|
<p class="mb-10"><a href="/" class="font-mono text-xs tracking-wide text-muted hover:text-ink">uptimesebi</a></p>
|
||||||
|
@legalBody(html)
|
||||||
|
</main>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PublicLegalPage shows a legal document of a status page.
|
||||||
|
templ PublicLegalPage(s agentapi.PageSnapshot, a PublicAssets, kind, html, back string) {
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang={ i18n.Lang(ctx) }>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8"/>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||||
|
<title>{ i18n.T(ctx, LegalTitleID(kind)) } · { s.Title }</title>
|
||||||
|
<link rel="stylesheet" href={ a.CSSHref }/>
|
||||||
|
</head>
|
||||||
|
<body class="min-h-screen">
|
||||||
|
<main class="mx-auto max-w-3xl px-6 py-14">
|
||||||
|
<p class="mb-10"><a href={ templ.SafeURL(back) } class="text-sm text-muted hover:text-ink">{ "← " + s.Title }</a></p>
|
||||||
|
@legalBody(html)
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
}
|
||||||
|
|
||||||
|
// LegalForm is the stored state of one legal document.
|
||||||
|
type LegalForm struct {
|
||||||
|
Kind string
|
||||||
|
URL string
|
||||||
|
Markdown string
|
||||||
|
}
|
||||||
|
|
||||||
|
// LegalSettingsPage edits legal documents. apiBase plus the kind is the
|
||||||
|
// endpoint each form saves to.
|
||||||
|
templ LegalSettingsPage(p Page, me Me, titleID, introID, apiBase, next string, docs []LegalForm) {
|
||||||
|
@consoleShell(p, me) {
|
||||||
|
@settingsHeading(titleID, introID)
|
||||||
|
for _, d := range docs {
|
||||||
|
<section class="mb-12 max-w-2xl">
|
||||||
|
@sectionHeading(LegalTitleID(d.Kind))
|
||||||
|
<form data-api={ apiBase + d.Kind } data-method="put" data-next={ next }>
|
||||||
|
@formError()
|
||||||
|
<label class="mb-4 block">
|
||||||
|
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "legal.url") }</span>
|
||||||
|
<input type="url" name="url" value={ d.URL } placeholder="https://" class="w-full border border-rule bg-transparent px-2.5 py-1.5 text-sm outline-none focus:border-ink"/>
|
||||||
|
</label>
|
||||||
|
<label class="mb-1 block">
|
||||||
|
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "legal.markdown") }</span>
|
||||||
|
<textarea name="markdown" rows="12" class="w-full border border-rule bg-transparent px-2.5 py-1.5 font-mono text-xs outline-none focus:border-ink">{ d.Markdown }</textarea>
|
||||||
|
</label>
|
||||||
|
<p class="mb-4 text-xs text-muted">{ i18n.T(ctx, "legal.hint") }</p>
|
||||||
|
@submit(i18n.T(ctx, "common.save"))
|
||||||
|
</form>
|
||||||
|
</section>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,508 @@
|
|||||||
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
|
// templ: version: v0.3.1118
|
||||||
|
|
||||||
|
package web
|
||||||
|
|
||||||
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
|
||||||
|
import "github.com/a-h/templ"
|
||||||
|
import templruntime "github.com/a-h/templ/runtime"
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/agentapi"
|
||||||
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
|
||||||
|
)
|
||||||
|
|
||||||
|
func legalLink(l LegalLink) 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)
|
||||||
|
if l.External {
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<a href=\"")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var2 string
|
||||||
|
templ_7745c5c3_Var2, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL(l.Href)).ResolveURL(ctx)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/legal.templ`, Line: 10, Col: 33}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var2)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "\" rel=\"noopener\" class=\"hover:text-ink\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var3 string
|
||||||
|
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, LegalTitleID(l.Kind)))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/legal.templ`, Line: 10, Col: 109}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</a>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "<a href=\"")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var4 string
|
||||||
|
templ_7745c5c3_Var4, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL(l.Href)).ResolveURL(ctx)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/legal.templ`, Line: 12, Col: 33}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var4)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "\" class=\"hover:text-ink\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var5 string
|
||||||
|
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, LegalTitleID(l.Kind)))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/legal.templ`, Line: 12, Col: 94}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "</a>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func legalFooter(links []LegalLink) 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)
|
||||||
|
if len(links) > 0 {
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<footer class=\"mx-auto flex w-full max-w-5xl justify-end gap-4 px-6 py-6 font-mono text-xs text-muted\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
for _, l := range links {
|
||||||
|
templ_7745c5c3_Err = legalLink(l).Render(ctx, templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "</footer>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func legalBody(html 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, 9, "<article class=\"legal-text max-w-2xl\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templ.Raw(html).Render(ctx, templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "</article>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// LegalPage shows a platform legal document.
|
||||||
|
func LegalPage(p Page, html 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_Var9 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||||
|
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||||
|
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)
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "<main class=\"mx-auto max-w-3xl px-6 py-14\"><p class=\"mb-10\"><a href=\"/\" class=\"font-mono text-xs tracking-wide text-muted hover:text-ink\">uptimesebi</a></p>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = legalBody(html).Render(ctx, templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "</main>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
templ_7745c5c3_Err = Layout(p).Render(templ.WithChildren(ctx, templ_7745c5c3_Var9), templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// PublicLegalPage shows a legal document of a status page.
|
||||||
|
func PublicLegalPage(s agentapi.PageSnapshot, a PublicAssets, kind, html, back 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, 13, "<!doctype html><html lang=\"")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var11 string
|
||||||
|
templ_7745c5c3_Var11, 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/legal.templ`, Line: 45, Col: 28}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var11)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><title>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var12 string
|
||||||
|
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, LegalTitleID(kind)))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/legal.templ`, Line: 49, Col: 43}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, " · ")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var13 string
|
||||||
|
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(s.Title)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/legal.templ`, Line: 49, Col: 58}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "</title><link rel=\"stylesheet\" href=\"")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var14 string
|
||||||
|
templ_7745c5c3_Var14, templ_7745c5c3_Err = templruntime.NewAttributeExpression(a.CSSHref).ResolveURL(ctx)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/legal.templ`, Line: 50, Col: 42}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var14)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "\"></head><body class=\"min-h-screen\"><main class=\"mx-auto max-w-3xl px-6 py-14\"><p class=\"mb-10\"><a href=\"")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var15 string
|
||||||
|
templ_7745c5c3_Var15, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL(back)).ResolveURL(ctx)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/legal.templ`, Line: 54, Col: 50}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var15)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "\" class=\"text-sm text-muted hover:text-ink\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var16 string
|
||||||
|
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs("← " + s.Title)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/legal.templ`, Line: 54, Col: 113}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "</a></p>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = legalBody(html).Render(ctx, templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "</main></body></html>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// LegalForm is the stored state of one legal document.
|
||||||
|
type LegalForm struct {
|
||||||
|
Kind string
|
||||||
|
URL string
|
||||||
|
Markdown string
|
||||||
|
}
|
||||||
|
|
||||||
|
// LegalSettingsPage edits legal documents. apiBase plus the kind is the
|
||||||
|
// endpoint each form saves to.
|
||||||
|
func LegalSettingsPage(p Page, me Me, titleID, introID, apiBase, next string, docs []LegalForm) 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_Var18 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||||
|
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||||
|
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)
|
||||||
|
templ_7745c5c3_Err = settingsHeading(titleID, introID).Render(ctx, templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
for _, d := range docs {
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "<section class=\"mb-12 max-w-2xl\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = sectionHeading(LegalTitleID(d.Kind)).Render(ctx, templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "<form data-api=\"")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var19 string
|
||||||
|
templ_7745c5c3_Var19, templ_7745c5c3_Err = templruntime.NewAttributeExpression(apiBase + d.Kind).Resolve(ctx)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/legal.templ`, Line: 76, Col: 37}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var19)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "\" data-method=\"put\" data-next=\"")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var20 string
|
||||||
|
templ_7745c5c3_Var20, templ_7745c5c3_Err = templruntime.NewAttributeExpression(next).Resolve(ctx)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/legal.templ`, Line: 76, Col: 74}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var20)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = formError().Render(ctx, templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "<label class=\"mb-4 block\"><span class=\"mb-1 block text-xs font-medium uppercase tracking-wider text-muted\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var21 string
|
||||||
|
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "legal.url"))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/legal.templ`, Line: 79, Col: 113}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "</span> <input type=\"url\" name=\"url\" value=\"")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var22 string
|
||||||
|
templ_7745c5c3_Var22, templ_7745c5c3_Err = templruntime.NewAttributeExpression(d.URL).Resolve(ctx)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/legal.templ`, Line: 80, Col: 48}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var22)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "\" placeholder=\"https://\" class=\"w-full border border-rule bg-transparent px-2.5 py-1.5 text-sm outline-none focus:border-ink\"></label> <label class=\"mb-1 block\"><span class=\"mb-1 block text-xs font-medium uppercase tracking-wider text-muted\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var23 string
|
||||||
|
templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "legal.markdown"))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/legal.templ`, Line: 83, Col: 118}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "</span> <textarea name=\"markdown\" rows=\"12\" class=\"w-full border border-rule bg-transparent px-2.5 py-1.5 font-mono text-xs outline-none focus:border-ink\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var24 string
|
||||||
|
templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(d.Markdown)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/legal.templ`, Line: 84, Col: 165}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "</textarea></label><p class=\"mb-4 text-xs text-muted\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var25 string
|
||||||
|
templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "legal.hint"))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/legal.templ`, Line: 86, Col: 67}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "</p>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = submit(i18n.T(ctx, "common.save")).Render(ctx, templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "</form></section>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var18), templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ = templruntime.GeneratedTemplate
|
||||||
@@ -15,6 +15,10 @@ type PublicAssets struct {
|
|||||||
// StaleSince, if set, tells visitors that live updates are unavailable
|
// StaleSince, if set, tells visitors that live updates are unavailable
|
||||||
// and the page shows the state of that moment.
|
// and the page shows the state of that moment.
|
||||||
StaleSince time.Time
|
StaleSince time.Time
|
||||||
|
// LegalBase prefixes links to legal documents served as Markdown, e.g.
|
||||||
|
// "/acme/" or "/" on a custom domain. Empty leaves them out, as in a
|
||||||
|
// single-file export, which can only link elsewhere.
|
||||||
|
LegalBase string
|
||||||
}
|
}
|
||||||
|
|
||||||
// StylesheetText returns the built stylesheet for inlining.
|
// StylesheetText returns the built stylesheet for inlining.
|
||||||
|
|||||||
@@ -104,7 +104,12 @@ templ PublicStatusPage(s agentapi.PageSnapshot, a PublicAssets) {
|
|||||||
</section>
|
</section>
|
||||||
<footer class="flex justify-between border-t border-rule pt-4 font-mono text-xs text-muted">
|
<footer class="flex justify-between border-t border-rule pt-4 font-mono text-xs text-muted">
|
||||||
<span>{ i18n.T(ctx, "page.updated", "Time", s.GeneratedAt.UTC().Format(time.DateTime)+" UTC") }</span>
|
<span>{ i18n.T(ctx, "page.updated", "Time", s.GeneratedAt.UTC().Format(time.DateTime)+" UTC") }</span>
|
||||||
<span>uptimesebi</span>
|
<span class="flex gap-4">
|
||||||
|
for _, l := range PageLegalLinks(s, a.LegalBase) {
|
||||||
|
@legalLink(l)
|
||||||
|
}
|
||||||
|
<span>uptimesebi</span>
|
||||||
|
</span>
|
||||||
</footer>
|
</footer>
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -525,7 +525,17 @@ func PublicStatusPage(s agentapi.PageSnapshot, a PublicAssets) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 52, "</span> <span>uptimesebi</span></footer></main></body></html>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 52, "</span> <span class=\"flex gap-4\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
for _, l := range PageLegalLinks(s, a.LegalBase) {
|
||||||
|
templ_7745c5c3_Err = legalLink(l).Render(ctx, templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 53, "<span>uptimesebi</span></span></footer></main></body></html>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,7 +146,10 @@ templ RegionsPage(p Page, me Me, v RegionsView) {
|
|||||||
templ AdminPage(p Page, me Me, v RegionsView, storage StorageView) {
|
templ AdminPage(p Page, me Me, v RegionsView, storage StorageView) {
|
||||||
@consoleShell(p, me) {
|
@consoleShell(p, me) {
|
||||||
@settingsHeading("admin.title", "admin.intro")
|
@settingsHeading("admin.title", "admin.intro")
|
||||||
<p class="-mt-4 mb-8 text-sm"><a href="/admin/audit" class="underline underline-offset-2">{ i18n.T(ctx, "audit.platform_title") }</a></p>
|
<p class="-mt-4 mb-8 flex gap-4 text-sm">
|
||||||
|
<a href="/admin/audit" class="underline underline-offset-2">{ i18n.T(ctx, "audit.platform_title") }</a>
|
||||||
|
<a href="/admin/legal" class="underline underline-offset-2">{ i18n.T(ctx, "legal.platform_title") }</a>
|
||||||
|
</p>
|
||||||
@regionsBody(v)
|
@regionsBody(v)
|
||||||
@storageSection(storage)
|
@storageSection(storage)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -729,20 +729,33 @@ func AdminPage(p Page, me Me, v RegionsView, storage StorageView) templ.Componen
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 55, "<p class=\"-mt-4 mb-8 text-sm\"><a href=\"/admin/audit\" class=\"underline underline-offset-2\">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 55, "<p class=\"-mt-4 mb-8 flex gap-4 text-sm\"><a href=\"/admin/audit\" class=\"underline underline-offset-2\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var39 string
|
var templ_7745c5c3_Var39 string
|
||||||
templ_7745c5c3_Var39, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "audit.platform_title"))
|
templ_7745c5c3_Var39, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "audit.platform_title"))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 149, Col: 129}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 150, Col: 100}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var39))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var39))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 56, "</a></p>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 56, "</a> <a href=\"/admin/legal\" class=\"underline underline-offset-2\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var40 string
|
||||||
|
templ_7745c5c3_Var40, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "legal.platform_title"))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 151, Col: 100}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var40))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 57, "</a></p>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user