working in configuration data and replacing values in frame template

This commit is contained in:
2025-09-13 22:46:02 -06:00
parent 5a437a0c64
commit 779f15f069
9 changed files with 58 additions and 1 deletions
+8
View File
@@ -0,0 +1,8 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
]
}
+32
View File
@@ -0,0 +1,32 @@
/*
* 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 config
import (
_ "embed"
"gopkg.in/yaml.v3"
)
type AmConfig struct {
Site struct {
Title string `yaml:"title"`
} `yaml:"site"`
}
//go:embed default.yaml
var defaultConfigData []byte
var GlobalConfig AmConfig
func init() {
var defaultConfig AmConfig
yaml.Unmarshal(defaultConfigData, &defaultConfig)
GlobalConfig = defaultConfig
}
+2
View File
@@ -0,0 +1,2 @@
site:
title: "Amsterdam Web Communities System"
+1
View File
@@ -15,4 +15,5 @@ require (
golang.org/x/net v0.40.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/text v0.25.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
+3
View File
@@ -23,3 +23,6 @@ golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+1
View File
@@ -17,6 +17,7 @@ func setupEcho() *echo.Echo {
e := echo.New()
e.Renderer = &ui.TemplateRenderer{}
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
}))
return e
+5
View File
@@ -28,6 +28,11 @@ func AmWrap(myfunc func(AmContext) (string, any, error)) echo.HandlerFunc {
default:
err = fmt.Errorf("unknown rendering type: %s", what)
}
if err != nil {
ctxt.Logger().Error("Rendering error: %v", err)
}
} else {
ctxt.Logger().Error("Page function error: %v", err)
}
return err
}
+5
View File
@@ -11,6 +11,7 @@ package ui
import (
"io"
"git.erbosoft.com/amy/amsterdam/config"
"github.com/CloudyKit/jet/v6"
"github.com/labstack/echo/v4"
)
@@ -20,6 +21,10 @@ var views = jet.NewSet(
jet.DevelopmentMode(true),
)
func init() {
views.AddGlobal("GlobalConfig", config.GlobalConfig)
}
type TemplateRenderer struct {
}
+1 -1
View File
@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Front Page - Venice Test</title>
<title>{{ amsterdam_pageTitle }} - {{ GlobalConfig.Site.Title }}</title>
<link rel="icon" href="http://necrovenice:8080/venice/images/venice-icon.png" type="image/png">
<link rel="shortcut icon" href="http://necrovenice:8080/venice/images/venice-favicon.ico">
<meta http-equiv="refresh" content="300">