From acce3604a4ccaa13be2ecb148c919f33d4383d5e Mon Sep 17 00:00:00 2001 From: eerielili Date: Mon, 7 Apr 2025 21:44:00 +0200 Subject: Add variable WEBMASTER_EMAIL and if present, display it on error page (#235) * Add variable WEBMASTER_EMAIL and if present, display it on error page - Adresses issue https://github.com/TecharoHQ/anubis/issues/115 * web: regenerate templates Signed-off-by: Xe Iaso * update docs Signed-off-by: Xe Iaso --------- Signed-off-by: Xe Iaso Co-authored-by: Xe Iaso --- web/index.go | 4 ++-- web/index.templ | 10 ++++++-- web/index_templ.go | 69 +++++++++++++++++++++++++++++++++++++++++------------- 3 files changed, 63 insertions(+), 20 deletions(-) (limited to 'web') diff --git a/web/index.go b/web/index.go index 0dc8b7f..5d2957b 100644 --- a/web/index.go +++ b/web/index.go @@ -16,8 +16,8 @@ func Index() templ.Component { return index() } -func ErrorPage(msg string) templ.Component { - return errorPage(msg) +func ErrorPage(msg string, mail string) templ.Component { + return errorPage(msg, mail) } func Bench() templ.Component { diff --git a/web/index.templ b/web/index.templ index 63048e2..01d12b6 100644 --- a/web/index.templ +++ b/web/index.templ @@ -129,7 +129,7 @@ templ index() { } -templ errorPage(message string) { +templ errorPage(message string, mail string) {

{ message }.

-

Go home

+ if mail != "" { +

Go home or if you believe you should not be blocked, please contact the webmaster at + { mail } +

+ } else { +

Go home

+ }
} diff --git a/web/index_templ.go b/web/index_templ.go index 27ab6fe..a3e10fe 100644 --- a/web/index_templ.go +++ b/web/index_templ.go @@ -204,7 +204,7 @@ func index() templ.Component { }) } -func errorPage(message string) templ.Component { +func errorPage(message string, mail 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 { @@ -251,7 +251,44 @@ func errorPage(message string) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, ".

Go home

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, ".

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if mail != "" { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "

Go home or if you believe you should not be blocked, please contact the webmaster at ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var15 string + templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(mail) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `index.templ`, Line: 144, Col: 9} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "

Go home

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -275,40 +312,40 @@ func bench() templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var14 := templ.GetChildren(ctx) - if templ_7745c5c3_Var14 == nil { - templ_7745c5c3_Var14 = templ.NopComponent + templ_7745c5c3_Var16 := templ.GetChildren(ctx) + if templ_7745c5c3_Var16 == nil { + templ_7745c5c3_Var16 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "
TimeIters
Time AIters ATime BIters B
TimeIters
Time AIters ATime BIters B

Loading...

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "\">
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } -- cgit v1.2.3