From a01de27c960b0456e4bbf5b1f35da5580c092f61 Mon Sep 17 00:00:00 2001 From: Amy Gale Ruth Bowersox Date: Sun, 21 Sep 2025 22:58:09 -0600 Subject: [PATCH] added error and not-implemented pages and placeholder ad graphic --- errors.go | 26 +++++++++++++++ main.go | 1 + ui/render_wrap.go | 50 ++++++++++++++++++++-------- ui/static_images/placeholder_ad.gif | Bin 0 -> 2423 bytes ui/views/about.jet | 11 +++++- ui/views/error.jet | 22 ++++++++++++ ui/views/frame.jet | 4 +-- ui/views/notimpl.jet | 22 ++++++++++++ 8 files changed, 119 insertions(+), 17 deletions(-) create mode 100644 errors.go create mode 100644 ui/static_images/placeholder_ad.gif create mode 100644 ui/views/error.jet create mode 100644 ui/views/notimpl.jet diff --git a/errors.go b/errors.go new file mode 100644 index 0000000..235a67e --- /dev/null +++ b/errors.go @@ -0,0 +1,26 @@ +/* + * Amsterdam Web Communities System + * Copyright (c) 2025 Erbosoft Metaverse Design Solutions, All Rights Reserved + * + * 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 + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +// Package main contains the high-level Amsterdam logic. +package main + +import "git.erbosoft.com/amy/amsterdam/ui" + +/* NotImplPage is used for all TODO links, to show that something hasn't yet been implemented. + * Parameters: + * ctxt - The AmContext for the request. + * Returns: + * Command string dictating what to be rendered. + * Data as a parameter for the command string. + * Standard Go error status. + */ +func NotImplPage(ctxt ui.AmContext) (string, any, error) { + ctxt.VarMap().Set("amsterdam_pageTitle", "Function Not Implemented") + ctxt.VarMap().Set("path", ctxt.URLPath()) + return "framed_template", "notimpl.jet", nil +} diff --git a/main.go b/main.go index 56d7ac8..0cc8850 100644 --- a/main.go +++ b/main.go @@ -35,6 +35,7 @@ func setupEcho() *echo.Echo { e.Use(LogrusMiddleware) e.Use(session.Middleware(ui.SessionStore)) + e.GET("/TODO/*", ui.AmWrap(NotImplPage)) e.GET("/img/*", ui.AmWrap(ui.AmServeImage)) e.GET("/about", ui.AmWrap(AboutPage)) e.GET("/", ui.AmWrap(TopPage)) diff --git a/ui/render_wrap.go b/ui/render_wrap.go index a67b010..695eaa5 100644 --- a/ui/render_wrap.go +++ b/ui/render_wrap.go @@ -16,6 +16,39 @@ import ( "github.com/labstack/echo/v4" ) +func sendPageData(ctxt echo.Context, amctxt AmContext, command string, data any) error { + var err error + switch command { + case "bytes": + err = ctxt.Blob(amctxt.RC(), amctxt.OutputType(), data.([]byte)) + case "string": + err = ctxt.String(amctxt.RC(), fmt.Sprintf("%v", data)) + case "template": + err = amctxt.Render(fmt.Sprintf("%v", data)) + case "framed_template": + amctxt.VarMap().Set("amsterdam_innerPage", data) + err = amctxt.Render("frame.jet") + default: + err = fmt.Errorf("unknown rendering type: %s", command) + } + return err +} + +/* ErrorPage renders the Amsterdam page with a server error message. + * Parameters: + * ctxt - The AmContext for the request. + * input_err - The error to be rendered on the page. + * Returns: + * Command string dictating what to be rendered. + * Data as a parameter for the command string. + * Standard Go error status. + */ +func ErrorPage(ctxt AmContext, input_err error) (string, any, error) { + ctxt.VarMap().Set("amsterdam_pageTitle", "Internal Server Error") + ctxt.VarMap().Set("error", input_err.Error()) + return "framed_template", "error.jet", nil +} + /* AmWrap wraps the Amsterdam handler function in a wrapper that implements the spec for * Echo handler functions. * Parameters: @@ -36,24 +69,15 @@ func AmWrap(myfunc func(AmContext) (string, any, error)) echo.HandlerFunc { ctxt.Logger().Errorf("Session save error: %v", err) return err } - switch what { - case "bytes": - err = ctxt.Blob(amctxt.RC(), amctxt.OutputType(), rc.([]byte)) - case "string": - err = ctxt.String(amctxt.RC(), fmt.Sprintf("%v", rc)) - case "template": - err = amctxt.Render(fmt.Sprintf("%v", rc)) - case "framed_template": - amctxt.VarMap().Set("amsterdam_innerPage", rc) - err = amctxt.Render("frame.jet") - default: - err = fmt.Errorf("unknown rendering type: %s", what) - } + err = sendPageData(ctxt, amctxt, what, rc) if err != nil { ctxt.Logger().Errorf("Rendering error: %v", err) } } else { ctxt.Logger().Errorf("Page function error: %v", err) + _, rc, _ = ErrorPage(amctxt, err) + newerr := sendPageData(ctxt, amctxt, "framed_template", rc) + err = newerr } return err } diff --git a/ui/static_images/placeholder_ad.gif b/ui/static_images/placeholder_ad.gif new file mode 100644 index 0000000000000000000000000000000000000000..f7d8482c45c10cc941fd768088f0946a505f3cd6 GIT binary patch literal 2423 zcmV--35fPbNk%v~VblRU0P_F<|Ns90003rYW|^6p%*@O)Gc%cHnP!=005bsp%>QOH zW|_>H%$dwHW;4wH%rgKpEC2ui0Mr3I000F3Fvv-(y*TU5yZ>M)j$~<`XsWJk>r%oH z&vH%Qc8>3Q&;Pz4a40MikH#c&scbTz&M0&$tx~VnEKM>1c)#GVcuX#v&*-#z&2GEj z@VILF$f`f#GhKGoWh67xRj*pO$l9QB`m3#qymYbZNo}ZwhcZ>mD zqNk{-s;jJfeF?3xva__co1~_;y1Tr+zH6A8zr)1E#;Lf+%FE2nhr!O#($myxqy}aK z0}R#O-ru^=V*>>f1q5DvxpL}r?O_sT?{AC>ZS!!9!o2wGrLFz)WvZiZPQftm1ni5G zY)m-;3-}aB_m7T(igC)V^AfL&MgaaD!5kbnkj=%7ZbtHwfv!%#Q!i7NG&ob>LICeV z`m6bc(L^sF)hS#jLqN+g1QZ&jn6$vUrnv|VXekxlI|2%fcGQ-jfr6HdI0g{o^9up5 zrWiHwQWZb~0ZzvVjUh7Y(Wz3s)F?Yuuc@{;6;hqrH!0mQ1PUBxs~F`MrAG}%p6Um1 z;H7%+QiV*hOW(|D5-(1GcOzH9hNCuS`?>1er-I281)FKM+1TT7>$CkBH-OK-(H%^k zb1a>PVSG|0U^PIwJ`^V${qkIb1Dwt$Xu>q1GevIgNM$!Jp*p&x*c*MJkiPuyfn^<3 zHx5Rkb}tBEynhIwI{%Imp#D=100dOf+(-VAMZr(pIX4}F^Xa7@NZDc6MS&D}R#HKU zQPA8}&PjNaTnnPJKz0k2XO493g~$gs*dWs6R_H13J-lfZ77^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ca+Znp7kpg(jP4s?ds}?wa_#!;{U-XTI9F&wz&Po&!z(=(du%(1>PhFu0lM zMjQIGj*hfhmBeUCTRN+UzO<&J3XSW0q0*n;w5V~KX;8am)TnlbnR4rCI+(f;uTHhB z%~0uUD8v8)IDk?NZ~$EEI@b#6^{#JCYysff*t!PGg!i`{RE6MNnmpSHpy-foV2oZTF^c*74q zaf0W2-UOGyxP?7|{Al0-5`cLHT<-GUNucH`z&QnUo&hxk$eiad2)fX3KJ%Sp0O%IL pInb4E^rjQt<{ChH%ZDEIr_-FFK~6JYn|ym4?zR~06Rv`ny~-? literal 0 HcmV?d00001 diff --git a/ui/views/about.jet b/ui/views/about.jet index a85984c..4b85c50 100644 --- a/ui/views/about.jet +++ b/ui/views/about.jet @@ -1,3 +1,12 @@ +{* + * Amsterdam Web Communities System + * Copyright (c) 2025 Erbosoft Metaverse Design Solutions, All Rights Reserved + * + * 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 + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + *} +
-
+ \ No newline at end of file diff --git a/ui/views/error.jet b/ui/views/error.jet new file mode 100644 index 0000000..d165483 --- /dev/null +++ b/ui/views/error.jet @@ -0,0 +1,22 @@ +{* + * Amsterdam Web Communities System + * Copyright (c) 2025 Erbosoft Metaverse Design Solutions, All Rights Reserved + * + * 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 + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + *} +
+
+
+

Amsterdam Internal Server Error

+
+

+ The Amsterdam server encountered an error: {{ error }} +

+

+ Click here to return to the home page. +

+
+
+
diff --git a/ui/views/frame.jet b/ui/views/frame.jet index 6684019..849b309 100644 --- a/ui/views/frame.jet +++ b/ui/views/frame.jet @@ -47,9 +47,7 @@
- +
diff --git a/ui/views/notimpl.jet b/ui/views/notimpl.jet new file mode 100644 index 0000000..80c8103 --- /dev/null +++ b/ui/views/notimpl.jet @@ -0,0 +1,22 @@ +{* + * Amsterdam Web Communities System + * Copyright (c) 2025 Erbosoft Metaverse Design Solutions, All Rights Reserved + * + * 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 + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + *} +
+
+
+

Amsterdam: Function Not Implemented

+
+

+ You've stumbled into a function that's not implemented yet. The function path is {{ path }}. +

+

+ Click here to return to the home page. +

+
+
+