reformatted IP Ban page and shifted specific rendering to AmSendPageData

This commit is contained in:
2026-02-10 18:16:43 -07:00
parent 38c4b3f71e
commit 975265af58
5 changed files with 32 additions and 28 deletions
+2 -13
View File
@@ -57,20 +57,9 @@ func AmErrorHandler(err error, c echo.Context) {
if c.Response().Committed { if c.Response().Committed {
return return
} }
errCode := http.StatusInternalServerError
if he, ok := err.(*echo.HTTPError); ok {
errCode = he.Code
}
amctxt := ui.AmContextFromEchoContext(c) amctxt := ui.AmContextFromEchoContext(c)
amctxt.SetLeftMenu("top") cerr := ui.AmSendPageData(c, amctxt, "error", err)
amctxt.SetRC(errCode)
amctxt.VarMap().Set("error", err.Error())
// TODO: come up with a way to shift templates and titles for different error codes
amctxt.VarMap().Set("amsterdam_pageTitle", "Amsterdam Internal Server Error")
cerr := ui.AmSendPageData(c, amctxt, "framed", "error.jet")
if cerr != nil { if cerr != nil {
log.Errorf("Error rendering error %d (%v): %v", errCode, err, cerr) log.Errorf("Error rendering error (%v): %v", err, cerr)
} }
} }
-1
View File
@@ -299,7 +299,6 @@ func JumpToShortcut(ctxt ui.AmContext) (string, any) {
} }
scope, target := link.Classify() scope, target := link.Classify()
if scope != "global" { if scope != "global" {
ctxt.SetRC(http.StatusNotFound)
return "error", echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("not found: %s", ctxt.URLParam("postlink"))) return "error", echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("not found: %s", ctxt.URLParam("postlink")))
} }
if err = link.VerifyNames(ctxt.Ctx()); err != nil { if err = link.VerifyNames(ctxt.Ctx()); err != nil {
+1 -4
View File
@@ -32,10 +32,7 @@ func IPBanTest(next echo.HandlerFunc) echo.HandlerFunc {
// but let the request pass anyway // but let the request pass anyway
} else if banmsg != "" { } else if banmsg != "" {
amctxt := AmContextFromEchoContext(c) amctxt := AmContextFromEchoContext(c)
amctxt.VarMap().Set("amsterdam_pageTitle", "IP Address Banned") return AmSendPageData(c, amctxt, "ipban", banmsg)
amctxt.VarMap().Set("message", banmsg)
amctxt.SetRC(http.StatusForbidden)
return AmSendPageData(c, amctxt, "framed", "ipban.jet")
} }
return next(c) return next(c)
} }
+11 -3
View File
@@ -36,9 +36,9 @@ import (
* Standard Go error status. * Standard Go error status.
*/ */
func AmSendPageData(ctxt echo.Context, amctxt AmContext, command string, data any) error { func AmSendPageData(ctxt echo.Context, amctxt AmContext, command string, data any) error {
var err error // Preprocess certain commands into different ones.
switch command {
if command == "error" { case "error":
httprc := amctxt.RC() httprc := amctxt.RC()
message := "" message := ""
if data == nil { if data == nil {
@@ -73,8 +73,16 @@ func AmSendPageData(ctxt echo.Context, amctxt AmContext, command string, data an
amctxt.SetRC(httprc) amctxt.SetRC(httprc)
command = "framed" command = "framed"
data = "error.jet" data = "error.jet"
case "ipban":
amctxt.VarMap().Set("amsterdam_pageTitle", "IP Address Banned")
amctxt.VarMap().Set("message", data)
amctxt.SetRC(http.StatusForbidden)
command = "framed"
data = "ipban.jet"
} }
// Process commands.
var err error
switch command { switch command {
case "bytes": case "bytes":
err = ctxt.Blob(amctxt.RC(), amctxt.OutputType(), data.([]byte)) err = ctxt.Blob(amctxt.RC(), amctxt.OutputType(), data.([]byte))
+18 -7
View File
@@ -1,17 +1,28 @@
{* {*
* Amsterdam Web Communities System * Amsterdam Web Communities System
* Copyright (c) 2025 Erbosoft Metaverse Design Solutions, All Rights Reserved * Copyright (c) 2025-2026 Erbosoft Metaverse Design Solutions, All Rights Reserved
* *
* This Source Code Form is subject to the terms of the Mozilla Public * This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
*} *}
<div class="flex"> <div class="p-4">
<div class="flex-1 p-4"> <!-- IP Ban Dialog -->
<div class="mb-8"> <div class="max-w-2xl w-full">
<h1 class="text-blue-800 text-4xl font-bold mb-2">This IP Address Has Been Banned</h1> <div class="bg-white border-2 border-gray-600 rounded-lg shadow-2xl overflow-hidden">
<hr class="border-2 border-gray-400 w-4/5 mb-4"> <!-- Dialog Header -->
<p class="text-black text-sm mb-4"><strong>{{ message }}</strong></p> <div class="bg-gray-600 px-6 py-4">
<h1 class="text-white text-2xl font-bold text-center flex items-center justify-center gap-3">
<span class="text-3xl">⛔</span>This IP Address Has Been Banned<span class="text-3xl">⛔</span>
</h1>
</div>
<!-- Dialog Body -->
<div class="px-8 py-8">
<div class="text-center mb-8">
<p class="text-black-800 text-lg leading-relaxed"><b>{{ message }}</b></p>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>