From acbc5e4bf64e0a76ef09243436b44768b8cbd177 Mon Sep 17 00:00:00 2001 From: mikestefanello <552328+mikestefanello@users.noreply.github.com> Date: Tue, 18 Feb 2025 19:19:09 -0500 Subject: [PATCH] Upgrade to Bulma 1.0.2. --- pkg/funcmap/funcmap.go | 14 -------------- pkg/funcmap/funcmap_test.go | 11 ----------- pkg/handlers/files.go | 3 ++- templates/components/core.gohtml | 2 +- templates/layouts/auth.gohtml | 2 +- templates/layouts/main.gohtml | 4 ++-- templates/pages/contact.gohtml | 28 +++++++++++++++------------- 7 files changed, 21 insertions(+), 43 deletions(-) diff --git a/pkg/funcmap/funcmap.go b/pkg/funcmap/funcmap.go index af7c079..2b5dc83 100644 --- a/pkg/funcmap/funcmap.go +++ b/pkg/funcmap/funcmap.go @@ -3,7 +3,6 @@ package funcmap import ( "fmt" "html/template" - "reflect" "strings" "github.com/Masterminds/sprig" @@ -29,7 +28,6 @@ func NewFuncMap(web *echo.Echo) template.FuncMap { funcs := sprig.FuncMap() // Include all the custom functions - funcs["hasField"] = fm.hasField funcs["file"] = fm.file funcs["link"] = fm.link funcs["url"] = fm.url @@ -37,18 +35,6 @@ func NewFuncMap(web *echo.Echo) template.FuncMap { return funcs } -// hasField checks if an interface contains a given field -func (fm *funcMap) hasField(v any, name string) bool { - rv := reflect.ValueOf(v) - if rv.Kind() == reflect.Ptr { - rv = rv.Elem() - } - if rv.Kind() != reflect.Struct { - return false - } - return rv.FieldByName(name).IsValid() -} - // file appends a cache buster to a given filepath so it can remain cached until the app is restarted func (fm *funcMap) file(filepath string) string { return fmt.Sprintf("/%s/%s?v=%s", config.StaticPrefix, filepath, CacheBuster) diff --git a/pkg/funcmap/funcmap_test.go b/pkg/funcmap/funcmap_test.go index 5ddf3bc..b3b3b2b 100644 --- a/pkg/funcmap/funcmap_test.go +++ b/pkg/funcmap/funcmap_test.go @@ -12,22 +12,11 @@ import ( func TestNewFuncMap(t *testing.T) { f := NewFuncMap(echo.New()) - assert.NotNil(t, f["hasField"]) assert.NotNil(t, f["link"]) assert.NotNil(t, f["file"]) assert.NotNil(t, f["url"]) } -func TestHasField(t *testing.T) { - type example struct { - name string - } - var e example - f := new(funcMap) - assert.True(t, f.hasField(e, "name")) - assert.False(t, f.hasField(e, "abcd")) -} - func TestLink(t *testing.T) { f := new(funcMap) diff --git a/pkg/handlers/files.go b/pkg/handlers/files.go index c325556..1dfe9c5 100644 --- a/pkg/handlers/files.go +++ b/pkg/handlers/files.go @@ -75,7 +75,8 @@ func (h *Files) Page(ctx echo.Context) error { func (h *Files) Submit(ctx echo.Context) error { file, err := ctx.FormFile("file") if err != nil { - return err + msg.Danger(ctx, "A file is required.") + return h.Page(ctx) } src, err := file.Open() diff --git a/templates/components/core.gohtml b/templates/components/core.gohtml index 0eb2f69..ddfc482 100644 --- a/templates/components/core.gohtml +++ b/templates/components/core.gohtml @@ -13,7 +13,7 @@ {{end}} {{define "css"}} - + {{end}} {{define "js"}} diff --git a/templates/layouts/auth.gohtml b/templates/layouts/auth.gohtml index f315402..6bbc9c0 100644 --- a/templates/layouts/auth.gohtml +++ b/templates/layouts/auth.gohtml @@ -1,5 +1,5 @@ - +
{{template "metatags" .}} {{template "css" .}} diff --git a/templates/layouts/main.gohtml b/templates/layouts/main.gohtml index 865c0f2..779dbc8 100644 --- a/templates/layouts/main.gohtml +++ b/templates/layouts/main.gohtml @@ -1,11 +1,11 @@ - + {{template "metatags" .}} {{template "css" .}} {{template "js" .}} - +