diff --git a/polygerrit-ui/README.md b/polygerrit-ui/README.md
index 713b073823..8f946c55ba 100644
--- a/polygerrit-ui/README.md
+++ b/polygerrit-ui/README.md
@@ -68,6 +68,12 @@ Then add go to your path:
PATH=$PATH:/usr/local/go/bin
```
+Install the go Soy template library:
+
+```
+go get "github.com/robfig/soy"
+```
+
### Running the server
To test the local UI against gerrit-review.googlesource.com:
diff --git a/polygerrit-ui/app/BUILD b/polygerrit-ui/app/BUILD
index 593a34b189..5b3085623c 100644
--- a/polygerrit-ui/app/BUILD
+++ b/polygerrit-ui/app/BUILD
@@ -15,7 +15,6 @@ polygerrit_bundle(
],
exclude = [
"bower_components/**",
- "index.html",
"test/**",
"**/*_test.html",
],
@@ -158,7 +157,6 @@ polygerrit_bundle(
],
exclude = [
"bower_components/**",
- "index.html",
"test/**",
"**/*_test.html",
],
diff --git a/polygerrit-ui/app/index.html b/polygerrit-ui/app/index.html
deleted file mode 100644
index 242c04b6d6..0000000000
--- a/polygerrit-ui/app/index.html
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/polygerrit-ui/app/rules.bzl b/polygerrit-ui/app/rules.bzl
index 0d03910df9..b60aa22622 100644
--- a/polygerrit-ui/app/rules.bzl
+++ b/polygerrit-ui/app/rules.bzl
@@ -65,7 +65,6 @@ def polygerrit_bundle(name, srcs, outs, app):
name = name + "_top_sources",
srcs = [
"favicon.ico",
- "index.html",
],
)
diff --git a/polygerrit-ui/server.go b/polygerrit-ui/server.go
index bc4a4d1f66..2594ff76ca 100644
--- a/polygerrit-ui/server.go
+++ b/polygerrit-ui/server.go
@@ -20,6 +20,7 @@ import (
"encoding/json"
"errors"
"flag"
+ "github.com/robfig/soy"
"io"
"io/ioutil"
"log"
@@ -36,11 +37,17 @@ var (
prod = flag.Bool("prod", false, "Serve production assets")
scheme = flag.String("scheme", "https", "URL scheme")
plugins = flag.String("plugins", "", "comma seperated plugin paths to serve")
+
+ tofu, _ = soy.NewBundle().
+ AddTemplateFile("../resources/com/google/gerrit/httpd/raw/PolyGerritIndexHtml.soy").
+ CompileToTofu()
)
func main() {
flag.Parse()
+ http.HandleFunc("/index.html", handleIndex)
+
if *prod {
http.Handle("/", http.FileServer(http.Dir("dist")))
} else {
@@ -63,6 +70,15 @@ func main() {
log.Fatal(http.ListenAndServe(*port, &server{}))
}
+func handleIndex(w http.ResponseWriter, r *http.Request) {
+ var obj = map[string]interface{}{
+ "canonicalPath": "",
+ "staticResourcePath": "",
+ }
+ w.Header().Set("Content-Type", "text/html")
+ tofu.Render(w, "com.google.gerrit.httpd.raw.Index", obj)
+}
+
func handleRESTProxy(w http.ResponseWriter, r *http.Request) {
if strings.HasSuffix(r.URL.Path, ".html") {
w.Header().Set("Content-Type", "text/html")
@@ -211,13 +227,13 @@ var (
func (_ *server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
log.Printf("%s %s %s %s\n", r.Proto, r.Method, r.RemoteAddr, r.URL)
for _, prefix := range fePaths {
- if strings.HasPrefix(r.URL.Path, prefix) {
- r.URL.Path = "/"
- log.Println("Redirecting to /")
+ if strings.HasPrefix(r.URL.Path, prefix) || r.URL.Path == "/" {
+ r.URL.Path = "/index.html"
+ log.Println("Redirecting to /index.html")
break
} else if match := issueNumRE.Find([]byte(r.URL.Path)); match != nil {
- r.URL.Path = "/"
- log.Println("Redirecting to /")
+ r.URL.Path = "/index.html"
+ log.Println("Redirecting to /index.html")
break
}
}