From 240392dcaec453427a082a894894df8fad4da5fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ken-H=C3=A5vard=20Lieng?= Date: Wed, 16 Mar 2016 23:23:16 +0100 Subject: [PATCH] Use egon templating for the index page --- client/package.json | 1 - client/src/index.html | 16 ---------------- server/index.egon | 20 ++++++++++++++++++++ server/index.egon.go | 19 +++++++++++++++++++ server/index_template.go | 25 ------------------------- server/serve_files.go | 4 ++-- 6 files changed, 41 insertions(+), 44 deletions(-) delete mode 100644 client/src/index.html create mode 100644 server/index.egon create mode 100644 server/index.egon.go delete mode 100644 server/index_template.go diff --git a/client/package.json b/client/package.json index c8a8d191..c780f076 100644 --- a/client/package.json +++ b/client/package.json @@ -27,7 +27,6 @@ "gulp-concat": "^2.6.0", "gulp-cssnano": "^2.1.1", "gulp-gzip": "1.2.0", - "gulp-htmlmin": "^1.3.0", "gulp-util": "^3.0.7", "ify-loader": "^1.0.3", "react-transform-catch-errors": "^1.0.2", diff --git a/client/src/index.html b/client/src/index.html deleted file mode 100644 index 868c594f..00000000 --- a/client/src/index.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - Dispatch - - - - -
- - - - diff --git a/server/index.egon b/server/index.egon new file mode 100644 index 00000000..a2b6bbdd --- /dev/null +++ b/server/index.egon @@ -0,0 +1,20 @@ +<%! data *indexData, cssPath, jsPath string %> + +<%% import "encoding/json" %%> + + + + + + + + Dispatch + + + + +
+ + + + diff --git a/server/index.egon.go b/server/index.egon.go new file mode 100644 index 00000000..8666c64e --- /dev/null +++ b/server/index.egon.go @@ -0,0 +1,19 @@ +// Generated by egon. +// 🚫Edit at your own risk. + +package server +import ( +"io" +"encoding/json" +) + +func IndexTemplate(w io.Writer, data *indexData, cssPath, jsPath string) error { +io.WriteString(w, "Dispatch
") +return nil +} diff --git a/server/index_template.go b/server/index_template.go deleted file mode 100644 index 39553b6e..00000000 --- a/server/index_template.go +++ /dev/null @@ -1,25 +0,0 @@ -package server - -import ( - "encoding/json" - "io" -) - -var ( - index_0 = []byte(`Dispatch
`) -) - -func renderIndex(w io.Writer, data interface{}) { - w.Write(index_0) - w.Write([]byte(files[1].Path)) - w.Write(index_1) - - json.NewEncoder(w).Encode(data) - - w.Write(index_2) - w.Write([]byte(files[0].Path)) - w.Write(index_3) -} diff --git a/server/serve_files.go b/server/serve_files.go index 60a7abf4..459cdde9 100644 --- a/server/serve_files.go +++ b/server/serve_files.go @@ -159,10 +159,10 @@ func serveIndex(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Encoding", "gzip") gzw := gzip.NewWriter(w) - renderIndex(gzw, getIndexData(r, session)) + IndexTemplate(gzw, getIndexData(r, session), files[1].Path, files[0].Path) gzw.Close() } else { - renderIndex(w, getIndexData(r, session)) + IndexTemplate(w, getIndexData(r, session), files[1].Path, files[0].Path) } }