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/. - *} - - -
- - -
-
- - 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. -
-This is a test. -This is only a test. -If this had been an actual emergency, we would all be -dead by now.-