From 98c98d16b4a14d59a16d1516b0429b49546574e7 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Mon, 11 Sep 2023 21:10:58 +0300 Subject: [PATCH] [WIP] prep for embedded files 2 --- main.go | 7 +++---- resources/resources.go | 7 ------- templates/templates.go | 7 +++++++ 3 files changed, 10 insertions(+), 11 deletions(-) delete mode 100644 resources/resources.go create mode 100644 templates/templates.go diff --git a/main.go b/main.go index 9874443..e751cab 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - "embed" "encoding/json" "fmt" "html/template" @@ -10,7 +9,7 @@ import ( "net/http" "time" - "gitea.hbanafa.com/hesham/viddl/resources" + "gitea.hbanafa.com/hesham/viddl/templates" ) const ( @@ -80,12 +79,12 @@ func writeJSONResponse(w http.ResponseWriter, s string) http.ResponseWriter { } -var templates *template.Template +var views *template.Template func init() { log.Println("[ init ] Starting...") - templates = template.Must(template.ParseFS(resources.TemplatesFS, "templates/*.html")) + views = template.Must(template.ParseFS(templates.TemplatesFS , "*.html")) } func main() { diff --git a/resources/resources.go b/resources/resources.go deleted file mode 100644 index c072981..0000000 --- a/resources/resources.go +++ /dev/null @@ -1,7 +0,0 @@ -package resources - -import "embed" - -//go:embed gitea.hbanafa.com/hesham/viddl/resources -var TemplatesFS embed.FS - diff --git a/templates/templates.go b/templates/templates.go new file mode 100644 index 0000000..e88fa9a --- /dev/null +++ b/templates/templates.go @@ -0,0 +1,7 @@ +package templates + +import "embed" + +//go:embed *.html +var TemplatesFS embed.FS +