From 049b9acbd9635c206f5eeb01074b5d63803c4cd5 Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Wed, 19 Jul 2023 21:13:34 +0200 Subject: ref: Remove static fs on root Go embed does allow to load parent folder, so I move static fs to static folder as I think it fits better there than in the root of the project. --- .gitignore | 2 +- cmd/server/main.go | 4 +- static.go | 10 --- static/square.svg | 199 +++++++++++++++++++++++++++++++++++++++++++++++++++++ static/static.go | 6 ++ 5 files changed, 208 insertions(+), 13 deletions(-) delete mode 100644 static.go create mode 100644 static/square.svg create mode 100644 static/static.go diff --git a/.gitignore b/.gitignore index 8c71f01..4b42cf2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ vendor/ -static/ +static/main.css bin/ media_cache/ templates/*.qtpl.go diff --git a/cmd/server/main.go b/cmd/server/main.go index 8f163df..1591102 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -16,7 +16,6 @@ import ( "gorm.io/driver/sqlite" "gorm.io/gorm" - "git.sr.ht/~gabrielgio/img" "git.sr.ht/~gabrielgio/img/pkg/database/localfs" "git.sr.ht/~gabrielgio/img/pkg/database/repository" "git.sr.ht/~gabrielgio/img/pkg/database/sql" @@ -25,6 +24,7 @@ import ( "git.sr.ht/~gabrielgio/img/pkg/view" "git.sr.ht/~gabrielgio/img/pkg/worker" "git.sr.ht/~gabrielgio/img/pkg/worker/scanner" + "git.sr.ht/~gabrielgio/img/static" ) func main() { @@ -72,7 +72,7 @@ func main() { } r := router.New() - r.GET("/static/{filepath:*}", ext.FileServer(img.StaticFS, "static/")) + r.GET("/static/{filepath:*}", ext.FileServer(static.Static, "static/")) // repository var ( diff --git a/static.go b/static.go deleted file mode 100644 index 06f1459..0000000 --- a/static.go +++ /dev/null @@ -1,10 +0,0 @@ -package img - -import ( - "embed" -) - -var ( - //go:embed static/* - StaticFS embed.FS -) diff --git a/static/square.svg b/static/square.svg new file mode 100644 index 0000000..31c56cc --- /dev/null +++ b/static/square.svg @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/static.go b/static/static.go new file mode 100644 index 0000000..ada0434 --- /dev/null +++ b/static/static.go @@ -0,0 +1,6 @@ +package static + +import "embed" + +//go:embed * +var Static embed.FS -- cgit v1.2.3