From ae3c9ca748e727b85c21a48d1b6f0fdc93980604 Mon Sep 17 00:00:00 2001 From: Amy Gale Ruth Bowersox Date: Sun, 14 Sep 2025 15:51:27 -0600 Subject: [PATCH] debugged image serving and fixed a couple of images in the frame --- docs/templates/jet-header.txt | 8 ++++++++ server.go | 6 +----- ui/images.go | 6 +++--- views/frame.jet | 16 ++++++++++++---- views/top.jet | 8 ++++++++ 5 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 docs/templates/jet-header.txt diff --git a/docs/templates/jet-header.txt b/docs/templates/jet-header.txt new file mode 100644 index 0000000..10bfaa7 --- /dev/null +++ b/docs/templates/jet-header.txt @@ -0,0 +1,8 @@ +{* + * 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/. + *} diff --git a/server.go b/server.go index 51b6124..a7a45f3 100644 --- a/server.go +++ b/server.go @@ -9,8 +9,6 @@ package main import ( - "fmt" - "git.erbosoft.com/amy/amsterdam/ui" "github.com/labstack/echo/v4" ) @@ -18,9 +16,7 @@ import ( func setupEcho() *echo.Echo { e := echo.New() e.Renderer = &ui.TemplateRenderer{} - e.GET("/img/*", ui.AmWrap(func(ctxt ui.AmContext) (string, any, error) { - return "string", fmt.Sprintf("Path: %s", ctxt.URLPath()), nil - })) + e.GET("/img/*", ui.AmWrap(ui.AmServeImage)) e.GET("/", ui.AmWrap(func(ctxt ui.AmContext) (string, any, error) { ctxt.VarMap().Set("amsterdam_pageTitle", "My Front Page") return "framed_template", "top.jet", nil diff --git a/ui/images.go b/ui/images.go index a8a3863..312e08d 100644 --- a/ui/images.go +++ b/ui/images.go @@ -22,11 +22,11 @@ var static_images embed.FS func AmServeImage(ctxt AmContext) (string, any, error) { components := strings.SplitAfter(ctxt.URLPath(), "/") var err error = nil - if len(components) == 2 && components[0] == "builtin" { + if len(components) == 4 && components[2] == "builtin/" { var b []byte - b, err = static_images.ReadFile(fmt.Sprintf("static_images/%s", components[1])) + b, err = static_images.ReadFile(fmt.Sprintf("static_images/%s", components[3])) if err == nil { - mtype := mime.TypeByExtension(components[1][strings.LastIndex(components[1], "."):]) + mtype := mime.TypeByExtension(components[3][strings.LastIndex(components[3], "."):]) ctxt.SetOutputType(mtype) return "bytes", b, nil } diff --git a/views/frame.jet b/views/frame.jet index 217f0d6..e0ff981 100644 --- a/views/frame.jet +++ b/views/frame.jet @@ -1,3 +1,11 @@ +{* + * 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/. + *} @@ -17,8 +25,8 @@
- Venice Test
@@ -106,8 +114,8 @@
- Powered By Venice
diff --git a/views/top.jet b/views/top.jet index b4654d6..a0cd017 100644 --- a/views/top.jet +++ b/views/top.jet @@ -1,3 +1,11 @@ +{* + * 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/. + *}