diff --git a/internal/interfaces/api/handlers.go b/internal/interfaces/api/handlers.go index d57b12e..3609a82 100644 --- a/internal/interfaces/api/handlers.go +++ b/internal/interfaces/api/handlers.go @@ -56,10 +56,9 @@ func (s *Server) registerAdminHandler() { s.mux.HandleFunc("/admin/init", s.handler.InitHandler) - staticDir := adminStaticDir() s.mux.Handle("/admin/static/", s.cache.Control( http.StripPrefix("/admin/static", - http.FileServer(restrict(http.Dir(staticDir)))))) + http.FileServer(adminStaticDir())))) uploadsDir := application.UploadDir() s.mux.Handle("/api/uploads/", s.record.Collect(s.cors.Handle(s.cache.Control( diff --git a/internal/interfaces/api/path.go b/internal/interfaces/api/path.go index 8c78724..cb434c2 100644 --- a/internal/interfaces/api/path.go +++ b/internal/interfaces/api/path.go @@ -1,17 +1,21 @@ package api import ( + "embed" "log" + "net/http" "os" - "path/filepath" ) -func adminStaticDir() string { +//go:embed admin/static/* +var staticFiles embed.FS + +func adminStaticDir() http.FileSystem { staticDir := os.Getenv("HUGOVERSE_ADMIN_STATIC_DIR") if staticDir == "" { - staticDir = filepath.Join(getWd(), "internal", "interfaces", "api", "admin", "static") + return http.FS(staticFiles) } - return staticDir + return http.Dir(staticDir) } func getWd() string { diff --git a/internal/interfaces/cli/vercurr.go b/internal/interfaces/cli/vercurr.go index 854f222..6d4a3e7 100644 --- a/internal/interfaces/cli/vercurr.go +++ b/internal/interfaces/cli/vercurr.go @@ -3,6 +3,6 @@ package cli var CurrentVersion = Version{ Major: 0, Minor: 0, - PatchLevel: 6, + PatchLevel: 7, Suffix: "", } diff --git a/manifest.json b/manifest.json index a855b9c..c2fb1fc 100644 --- a/manifest.json +++ b/manifest.json @@ -1,5 +1,5 @@ { - "version": "0.0.6", + "version": "0.0.7", "name": "Hugoverse", "description": "Headless CMS for Hugo", "author": "sunwei",