aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2025-04-27 13:28:24 -0400
committerXe Iaso <me@xeiaso.net>2025-04-27 14:05:04 -0400
commit10e176a023ee1a4955160c86f0dc71a435bdf866 (patch)
tree35dc8d55e84af44f8d9a874c5fc7f6c4786c5912
parent80a9c44410aa8e6d5116a9231f3947326efab76d (diff)
downloadx-10e176a023ee1a4955160c86f0dc71a435bdf866.tar.xz
x-10e176a023ee1a4955160c86f0dc71a435bdf866.zip
feat(xess): add fancy 404 page
Signed-off-by: Xe Iaso <me@xeiaso.net>
-rw-r--r--xess/xess.go8
-rw-r--r--xess/xess.templ5
-rw-r--r--xess/xess_templ.go42
3 files changed, 55 insertions, 0 deletions
diff --git a/xess/xess.go b/xess/xess.go
index 07d1ade..38b5b90 100644
--- a/xess/xess.go
+++ b/xess/xess.go
@@ -7,6 +7,7 @@ import (
"embed"
"net/http"
+ "github.com/a-h/templ"
"within.website/x"
"within.website/x/internal"
)
@@ -29,3 +30,10 @@ func init() {
func Mount(mux *http.ServeMux) {
mux.Handle("/.within.website/x/xess/", internal.UnchangingCache(http.StripPrefix("/.within.website/x/xess/", http.FileServerFS(Static))))
}
+
+func NotFound(w http.ResponseWriter, r *http.Request) {
+ templ.Handler(
+ Simple("Not found: "+r.URL.Path, fourohfour(r.URL.Path)),
+ templ.WithStatus(http.StatusNotFound),
+ )
+}
diff --git a/xess/xess.templ b/xess/xess.templ
index 4c010b7..84eff14 100644
--- a/xess/xess.templ
+++ b/xess/xess.templ
@@ -39,3 +39,8 @@ templ Simple(title string, body templ.Component) {
nil,
)
}
+
+templ fourohfour(path string) {
+ <p>404: <code>{ path }</code></p>
+ <p>Sorry but the number you have reached is either not available or out of service. If you are reaching this message in error, please hang up and try your call again.</p>
+}
diff --git a/xess/xess_templ.go b/xess/xess_templ.go
index c1fa412..99607ac 100644
--- a/xess/xess_templ.go
+++ b/xess/xess_templ.go
@@ -161,4 +161,46 @@ func Simple(title string, body templ.Component) templ.Component {
})
}
+func fourohfour(path 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)
+ templ_7745c5c3_Var6 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var6 == nil {
+ templ_7745c5c3_Var6 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "<p>404: <code>")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var7 string
+ templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(path)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `xess.templ`, Line: 44, Col: 21}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "</code></p><p>Sorry but the number you have reached is either not available or out of service. If you are reaching this message in error, please hang up and try your call again.</p>")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ return nil
+ })
+}
+
var _ = templruntime.GeneratedTemplate