go.talks/present: move included js files outside of static directory
When deployed to App Engine, directories listed in app.yaml
static_files directives are inaccessible to the running application.
This change allows the /play.js handler to read these JS files.
R=campoy, campoy, dsymonds
CC=golang-dev
https://golang.org/cl/7309054
diff --git a/present/appengine.go b/present/appengine.go
index ef620ed..ccec452 100644
--- a/present/appengine.go
+++ b/present/appengine.go
@@ -23,7 +23,7 @@
var basePath = "./present/"
func init() {
- playScript("/static/jquery.js", "/static/playground.js")
+ playScript(basePath, "jquery.js", "playground.js")
present.PlayEnabled = true
http.HandleFunc("/compile", compile)
}
diff --git a/present/static/jquery.js b/present/js/jquery.js
similarity index 100%
rename from present/static/jquery.js
rename to present/js/jquery.js
diff --git a/present/static/play.js b/present/js/play.js
similarity index 100%
rename from present/static/play.js
rename to present/js/play.js
diff --git a/present/static/playground.js b/present/js/playground.js
similarity index 100%
rename from present/static/playground.js
rename to present/js/playground.js
diff --git a/present/static/socket.js b/present/js/socket.js
similarity index 100%
rename from present/static/socket.js
rename to present/js/socket.js
diff --git a/present/local.go b/present/local.go
index e655352..8674dfd 100644
--- a/present/local.go
+++ b/present/local.go
@@ -15,6 +15,6 @@
// HandleSocket registers the websocket handler with http.DefaultServeMux under
// the given path.
func HandleSocket(path string) {
- playScript("/static/socket.js")
+ playScript(basePath, "socket.js")
http.Handle(path, socket.Handler)
}
diff --git a/present/play.go b/present/play.go
index 9a0682a..fcd361d 100644
--- a/present/play.go
+++ b/present/play.go
@@ -14,11 +14,11 @@
// playScript registers an HTTP handler at /play.js that contains all the
// scripts specified by path, relative to basePath.
-func playScript(path ...string) {
+func playScript(root string, path ...string) {
modTime := time.Now()
var buf bytes.Buffer
- for _, p := range append(path, "/static/play.js") {
- b, err := ioutil.ReadFile(filepath.Join(basePath, p))
+ for _, p := range append(path, "play.js") {
+ b, err := ioutil.ReadFile(filepath.Join(root, "js", p))
if err != nil {
panic(err)
}