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
This commit is contained in:
@@ -37,7 +37,7 @@ public class IndexServlet extends HttpServlet {
|
|||||||
private final byte[] indexSource;
|
private final byte[] indexSource;
|
||||||
|
|
||||||
IndexServlet(String canonicalURL, @Nullable String cdnPath) throws URISyntaxException {
|
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();
|
SoyFileSet.Builder builder = SoyFileSet.builder();
|
||||||
builder.add(Resources.getResource(resourcePath));
|
builder.add(Resources.getResource(resourcePath));
|
||||||
SoyTofu.Renderer renderer =
|
SoyTofu.Renderer renderer =
|
||||||
|
|||||||
@@ -27,7 +27,9 @@
|
|||||||
<meta name="description" content="Gerrit Code Review">{\n}
|
<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}
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">{\n}
|
||||||
|
|
||||||
|
{if $canonicalPath != ''}
|
||||||
<script>window.CANONICAL_PATH = '{$canonicalPath}';</script>{\n}
|
<script>window.CANONICAL_PATH = '{$canonicalPath}';</script>{\n}
|
||||||
|
{/if}
|
||||||
|
|
||||||
// SourceCodePro fonts are used in styles/fonts.css
|
// SourceCodePro fonts are used in styles/fonts.css
|
||||||
// @see https://github.com/w3c/preload/issues/32 regarding crossorigin
|
// @see https://github.com/w3c/preload/issues/32 regarding crossorigin
|
||||||
@@ -40,5 +42,5 @@
|
|||||||
<link rel="import" href="{$staticResourcePath}/elements/gr-app.html">{\n}
|
<link rel="import" href="{$staticResourcePath}/elements/gr-app.html">{\n}
|
||||||
|
|
||||||
<body unresolved>{\n}
|
<body unresolved>{\n}
|
||||||
<gr-app id="app" canonical-path="{$canonicalPath}"></gr-app>{\n}
|
<gr-app id="app"></gr-app>{\n}
|
||||||
{/template}
|
{/template}
|
||||||
@@ -37,12 +37,6 @@
|
|||||||
value: function() { return document.body; },
|
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: {
|
_account: {
|
||||||
type: Object,
|
type: Object,
|
||||||
observer: '_accountChanged',
|
observer: '_accountChanged',
|
||||||
@@ -80,8 +74,6 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
ready: function() {
|
ready: function() {
|
||||||
Gerrit.CANONICAL_PATH = this.canonicalPath;
|
|
||||||
|
|
||||||
this.$.router.start();
|
this.$.router.start();
|
||||||
|
|
||||||
this.$.restAPI.getAccount().then(function(account) {
|
this.$.restAPI.getAccount().then(function(account) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ limitations under the License.
|
|||||||
|
|
||||||
<test-fixture id="basic">
|
<test-fixture id="basic">
|
||||||
<template>
|
<template>
|
||||||
<gr-app id="app" canonical-path="/abc/def/ghi"></gr-app>
|
<gr-app id="app"></gr-app>
|
||||||
</template>
|
</template>
|
||||||
</test-fixture>
|
</test-fixture>
|
||||||
|
|
||||||
@@ -107,9 +107,5 @@ limitations under the License.
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('canonical-path', function() {
|
|
||||||
assert.equal(Gerrit.CANONICAL_PATH, '/abc/def/ghi');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user