From 9e5a24e03d25d8c1c11f1755c4460fbfce12daf9 Mon Sep 17 00:00:00 2001 From: Amy Gale Ruth Bowersox Date: Tue, 16 Sep 2025 08:08:11 -0600 Subject: [PATCH] changed so that templates are embedded in the app --- ui/templates.go | 39 ++++++++++++++- views/frame.jet | 126 ------------------------------------------------ views/top.jet | 93 ----------------------------------- 3 files changed, 38 insertions(+), 220 deletions(-) delete mode 100644 views/frame.jet delete mode 100644 views/top.jet diff --git a/ui/templates.go b/ui/templates.go index ac31412..4ccede7 100644 --- a/ui/templates.go +++ b/ui/templates.go @@ -11,6 +11,8 @@ package ui import ( + "embed" + "fmt" "io" "git.erbosoft.com/amy/amsterdam/config" @@ -18,9 +20,44 @@ import ( "github.com/labstack/echo/v4" ) +//go:embed views/* +var static_views embed.FS + +// EmbeddedLoader is our implementation of Loader that references an embedded filesystem. +type EmbeddedLoader struct { + efs embed.FS + prefix string +} + +/* Exists (implements Loader) tests if a particular template exists. + * Parameters: + * templatePath - Path of the template to be tested. + * Returns: + * true if the template exists, false if not. + */ +func (l *EmbeddedLoader) Exists(templatePath string) bool { + file, err := l.efs.Open(fmt.Sprintf("%s%s", l.prefix, templatePath)) + if err == nil { + file.Close() + return true + } + return false +} + +/* Open (implements Loader) opens a template file. + * Parameters: + * templatePath - Path of the template to open. + * Returns: + * Handle to the opened template file + *. Standard Go error status. + */ +func (l *EmbeddedLoader) Open(templatePath string) (io.ReadCloser, error) { + return l.efs.Open((fmt.Sprintf("%s%s", l.prefix, templatePath))) +} + // views is the main Jet template repository. var views = jet.NewSet( - jet.NewOSFileSystemLoader("./views"), + &EmbeddedLoader{efs: static_views, prefix: "views"}, jet.DevelopmentMode(true), ) diff --git a/views/frame.jet b/views/frame.jet deleted file mode 100644 index e0ff981..0000000 --- a/views/frame.jet +++ /dev/null @@ -1,126 +0,0 @@ -{* - * 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_pageTitle }} - {{ GlobalConfig.Site.Title }} - - - - - - - - -
-
- -
- - Amsterdam Test - -
- - -
- -
- Help - | - Find -
-
- - -
- -
-
- - -
- - You are not logged in - - - Log In - | - Create Account - -
-
- - -
- -
-
-
-
Front Page
-
Calendar
-
Chat
-
-
- -
-
-
About This Site
-
Documentation
- About Venice -
-
-
- - -
-
- {{ .SubRender(amsterdam_innerPage) | raw }} -
-
-
- - -
-
 
-
-
-
-
- All trademarks and copyrights on this page are owned by their respective companies.
- All messages posted by users on this page are owned by those users.
- The rest: Copyright © 2001-2006 - Silverwrist Design Studios, - All Rights Reserved.
- See our Policy Page - for our copyright and privacy policies. -
-
- - Powered By Amsterdam - -
-
-
-
- - \ No newline at end of file diff --git a/views/top.jet b/views/top.jet deleted file mode 100644 index a0cd017..0000000 --- a/views/top.jet +++ /dev/null @@ -1,93 +0,0 @@ -{* - * 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/. - *} - -
- -
-

Welcome to Venice

-
-

- Welcome to the Venice Web Communities System. To get the most out of this site, you should log in or create an account, using one of the links above. -

-
- - -
-

Venice Currents

-
- -
-
- Amy, formerly Eric - ( - Administrator, - Sep 8, 2025 5:17:02 PM - ) -
-
This is a test.
-This is only a test.
-If this had been an actual emergency, we would all be 
-dead by now.
-
- (From the topic: It Works Again!) -
-
-
-
- - -
- -
-
-

Featured Communities:

-
-
-
- 🟣 - La Piazza -
-
-
- - -
-
-

Featured Conferences:

-
-
-
- 🟣 -
- General Discussion - (La Piazza) -
-
-
-
- - -
-
-

Users Online:

-
-
-
1 total (max 1)
-
- 🟣 - Not logged in (1) -
-
-
-