diff --git a/server/bundle/CSSHandler.go b/server/bundle/CSSHandler.go deleted file mode 100644 index bc80040..0000000 --- a/server/bundle/CSSHandler.go +++ /dev/null @@ -1,38 +0,0 @@ -package bundle - -import ( - "net/http" -) - -type CSSHandler struct { - Webdev bool - Cache []byte -} - -func NewCSSHandler(Webdev bool) *CSSHandler { - h := &CSSHandler{Webdev: Webdev} - - if !Webdev { - //populate cache - manifest := getManifest(Webdev) - h.Cache = createBundle(Webdev, manifest.Styles) - } - - return h -} - -func (h *CSSHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) { - resp.Header().Add("content-type", "text/css") - - if h.Cache == nil { - //dev - manifest := getManifest(h.Webdev) - resp.Write(createBundle(h.Webdev, manifest.Styles)) - - } else { - //prod - resp.Header().Add("Cache-Control", "public, max-age=3600") - resp.Write(h.Cache) - - } -} diff --git a/server/bundle/JsHandler.go b/server/bundle/JsHandler.go deleted file mode 100644 index c0f2da1..0000000 --- a/server/bundle/JsHandler.go +++ /dev/null @@ -1,38 +0,0 @@ -package bundle - -import ( - "net/http" -) - -type JsHandler struct { - Webdev bool - Cache []byte -} - -func NewJsHandler(Webdev bool) *JsHandler { - h := &JsHandler{Webdev: Webdev} - - if !Webdev { - //populate cache - manifest := getManifest(Webdev) - h.Cache = createBundle(Webdev, manifest.Scripts) - } - - return h -} - -func (h *JsHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) { - resp.Header().Add("content-type", "text/javascript") - - if h.Cache == nil { - //dev - manifest := getManifest(h.Webdev) - resp.Write(createBundle(h.Webdev, manifest.Scripts)) - - } else { - //prod - resp.Header().Add("Cache-Control", "public, max-age=3600") - resp.Write(h.Cache) - - } -} diff --git a/server/bundle/Manifest.go b/server/bundle/Manifest.go deleted file mode 100644 index 51b6676..0000000 --- a/server/bundle/Manifest.go +++ /dev/null @@ -1,6 +0,0 @@ -package bundle - -type Manifest struct { - Scripts []string `json:"scripts"` - Styles []string `json:"styles"` -} diff --git a/server/bundle/bundle.go b/server/bundle/bundle.go deleted file mode 100644 index 37d58df..0000000 --- a/server/bundle/bundle.go +++ /dev/null @@ -1,33 +0,0 @@ -package bundle - -import ( - "encoding/json" - "mapserver/vfs" -) - -func getManifest(useLocal bool) *Manifest { - manifestBytes := vfs.FSMustByte(useLocal, "/manifest.js") - manifest := &Manifest{} - err := json.Unmarshal(manifestBytes, manifest) - if err != nil { - panic(err) - } - - return manifest -} - -func createBundle(useLocal bool, files []string) []byte { - script := make([]byte, 0) - - for _, name := range files { - script = append(script, []byte("\n/*File: "+name+"*/\n")...) - content, err := vfs.FSByte(useLocal, name) - if err != nil { - panic("vfs-file not found: " + name) - } - - script = append(script, content...) - } - - return script -} diff --git a/server/static/index.html b/server/static/index.html index 7b220f5..1172501 100644 --- a/server/static/index.html +++ b/server/static/index.html @@ -4,12 +4,30 @@ - + + + + + + + +