diff options
author | Wyatt Allen <wyatta@google.com> | 2017-04-17 13:55:52 -0700 |
---|---|---|
committer | David Pursehouse <dpursehouse@collab.net> | 2017-04-19 09:34:39 +0000 |
commit | 4d0fe78d3f7c7a4131da2f54c223db3694fe27f6 (patch) | |
tree | 52cf33878147f26f22120b982b17aca6422fcce1 | |
parent | 363019c9c64c09d76f4b3c75490712d042b16504 (diff) |
Soy index cleanup
Some cleanup on the use of Soy index:
* The canonical-path property of GR-APP is removed because it did not
initialize at the right time and a top-level global is used instead.
* Only set a top-level global for canonical path if it is not the empty
string. In this way, the index document does not include an inline
script when it is not needed.
* Give the index Soy template a more descriptive name. index.html.soy
was too generic, and the intermediate period would cause problems with
some internal build tooling.
Bug: Issue 5919
Change-Id: I0bf5964b17cb4f4f9df150b0c6abe8ae1e49f22b
-rw-r--r-- | gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/IndexServlet.java | 2 | ||||
-rw-r--r-- | gerrit-httpd/src/main/resources/com/google/gerrit/httpd/raw/PolyGerritIndexHtml.soy (renamed from gerrit-httpd/src/main/resources/com/google/gerrit/httpd/raw/index.html.soy) | 6 | ||||
-rw-r--r-- | polygerrit-ui/app/elements/gr-app.js | 8 | ||||
-rw-r--r-- | polygerrit-ui/app/elements/gr-app_test.html | 6 |
4 files changed, 6 insertions, 16 deletions
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/IndexServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/IndexServlet.java index e1c6b29b80..b55cf6cf1c 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/IndexServlet.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/raw/IndexServlet.java @@ -37,7 +37,7 @@ public class IndexServlet extends HttpServlet { private final byte[] indexSource; IndexServlet(String canonicalURL, @Nullable String cdnPath) throws URISyntaxException { - String resourcePath = "com/google/gerrit/httpd/raw/index.html.soy"; + String resourcePath = "com/google/gerrit/httpd/raw/PolyGerritIndexHtml.soy"; SoyFileSet.Builder builder = SoyFileSet.builder(); builder.add(Resources.getResource(resourcePath)); SoyTofu.Renderer renderer = diff --git a/gerrit-httpd/src/main/resources/com/google/gerrit/httpd/raw/index.html.soy b/gerrit-httpd/src/main/resources/com/google/gerrit/httpd/raw/PolyGerritIndexHtml.soy index 4d8c43b761..32f91f1834 100644 --- a/gerrit-httpd/src/main/resources/com/google/gerrit/httpd/raw/index.html.soy +++ b/gerrit-httpd/src/main/resources/com/google/gerrit/httpd/raw/PolyGerritIndexHtml.soy @@ -27,7 +27,9 @@ <meta name="description" content="Gerrit Code Review">{\n} <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">{\n} - <script>window.CANONICAL_PATH = '{$canonicalPath}';</script>{\n} + {if $canonicalPath != ''} + <script>window.CANONICAL_PATH = '{$canonicalPath}';</script>{\n} + {/if} // SourceCodePro fonts are used in styles/fonts.css // @see https://github.com/w3c/preload/issues/32 regarding crossorigin @@ -40,5 +42,5 @@ <link rel="import" href="{$staticResourcePath}/elements/gr-app.html">{\n} <body unresolved>{\n} - <gr-app id="app" canonical-path="{$canonicalPath}"></gr-app>{\n} + <gr-app id="app"></gr-app>{\n} {/template} diff --git a/polygerrit-ui/app/elements/gr-app.js b/polygerrit-ui/app/elements/gr-app.js index c9f498fcd5..d820bc7a07 100644 --- a/polygerrit-ui/app/elements/gr-app.js +++ b/polygerrit-ui/app/elements/gr-app.js @@ -37,12 +37,6 @@ value: function() { return document.body; }, }, - /** - * The path component of the canonicalWebURL. If Gerrit is running from - * the root of the domain, this should be empty. - */ - canonicalPath: String, - _account: { type: Object, observer: '_accountChanged', @@ -81,8 +75,6 @@ }, ready: function() { - Gerrit.CANONICAL_PATH = this.canonicalPath; - this.$.router.start(); this.$.restAPI.getAccount().then(function(account) { diff --git a/polygerrit-ui/app/elements/gr-app_test.html b/polygerrit-ui/app/elements/gr-app_test.html index 5c8a21a64f..28251fe59e 100644 --- a/polygerrit-ui/app/elements/gr-app_test.html +++ b/polygerrit-ui/app/elements/gr-app_test.html @@ -27,7 +27,7 @@ limitations under the License. <test-fixture id="basic"> <template> - <gr-app id="app" canonical-path="/abc/def/ghi"></gr-app> + <gr-app id="app"></gr-app> </template> </test-fixture> @@ -105,9 +105,5 @@ limitations under the License. element._loadPlugins([]); assert.isTrue(Gerrit._setPluginsCount.calledWithExactly(0)); }); - - test('canonical-path', function() { - assert.equal(Gerrit.CANONICAL_PATH, '/abc/def/ghi'); - }); }); </script> |