nuke/web/index.go
fucksophie 02b9aebbe5
Some checks failed
Docker image builds / build (push) Failing after 4m22s
NUKE
2026-02-07 14:27:38 +02:00

42 lines
1.3 KiB
Go

package web
import (
"context"
"fmt"
"io"
"github.com/a-h/templ"
"git.sad.ovh/sophie/nuke/lib/challenge"
"git.sad.ovh/sophie/nuke/lib/config"
"git.sad.ovh/sophie/nuke/lib/localization"
)
func Base(title string, body templ.Component, impressum *config.Impressum, localizer *localization.SimpleLocalizer) templ.Component {
return base(title, body, impressum, nil, nil, localizer)
}
func BaseWithChallengeAndOGTags(title string, body templ.Component, impressum *config.Impressum, challenge *challenge.Challenge, rules *config.ChallengeRules, ogTags map[string]string, localizer *localization.SimpleLocalizer) templ.Component {
return base(title, body, impressum, struct {
Rules *config.ChallengeRules `json:"rules"`
Challenge any `json:"challenge"`
}{
Challenge: challenge,
Rules: rules,
}, ogTags, localizer)
}
func ErrorPage(msg, mail, code string, localizer *localization.SimpleLocalizer) templ.Component {
return errorPage(msg, mail, code, localizer)
}
func Bench(localizer *localization.SimpleLocalizer) templ.Component {
return bench(localizer)
}
func honeypotLink(href string) templ.Component {
return templ.ComponentFunc(func(ctx context.Context, w io.Writer) error {
fmt.Fprintf(w, `<script type="ignore"><a href="%s">Don't click me</a></script>`, href)
return nil
})
}