added error and not-implemented pages and placeholder ad graphic

This commit is contained in:
2025-09-21 22:58:09 -06:00
parent e2848ffc37
commit a01de27c96
8 changed files with 119 additions and 17 deletions
+26
View File
@@ -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
}
+1
View File
@@ -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))
+37 -13
View File
@@ -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
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

+10 -1
View File
@@ -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/.
*}
<div class="flex">
<!-- Venice Logo -->
<div class="text-center mb-6">
<img src="/img/builtin/AmsterdamLogo.png"
@@ -48,4 +57,4 @@
class="w-72 h-25 mx-auto">
</a>
</div>
</div>
</div>
+22
View File
@@ -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/.
*}
<div class="flex">
<div class="flex-1 p-4">
<div class="mb-8">
<h1 class="text-blue-800 text-4xl font-bold mb-2">Amsterdam Internal Server Error</h1>
<hr class="border-2 border-gray-400 w-4/5 mb-4">
<p class="text-black text-sm mb-4">
The Amsterdam server encountered an error: {{ error }}
</p>
<p class="text-black text-sm mb-4">
<a href="/">Click here</a> to return to the home page.
</p>
</div>
</div>
</div>
+1 -3
View File
@@ -47,9 +47,7 @@
<!-- Banner Ad -->
<div class="w-2/5 flex justify-end">
<img src="./venice-frontpage_files/midler.gif"
alt=""
class="w-96 h-15 mx-2 my-2">
<img src="/img/builtin/placeholder_ad.gif" alt="" class="w-96 h-15 mx-2 my-2">
</div>
</div>
+22
View File
@@ -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/.
*}
<div class="flex">
<div class="flex-1 p-4">
<div class="mb-8">
<h1 class="text-blue-800 text-4xl font-bold mb-2">Amsterdam: Function Not Implemented</h1>
<hr class="border-2 border-gray-400 w-4/5 mb-4">
<p class="text-black text-sm mb-4">
You've stumbled into a function that's not implemented yet. The function path is <code>{{ path }}</code>.
</p>
<p class="text-black text-sm mb-4">
<a href="/">Click here</a> to return to the home page.
</p>
</div>
</div>
</div>