Merge branch 'stable-2.14'

* stable-2.14:
  config-mail: Make the link to Closure Templates more prominent
  intro-user: Add link to receiveemail configuration
  IndexServlet: Add missing serialVersionUID
  Format Java files with google-java-format
  config-gerrit: Fix default port for IMAPS

Change-Id: I83f273386690bf0449e07915734fa4a9a83b4514
This commit is contained in:
David Pursehouse
2017-04-04 15:24:34 +09:00
6 changed files with 25 additions and 24 deletions

View File

@@ -3542,7 +3542,7 @@ Defaults to an empty string which means that receiving emails is disabled.
The port the email server exposes for receiving emails.
+
Defaults to the industry standard for a given protocol and encryption:
POP3: 110; POP3S: 995; IMAP: 143; IMAPS: 995.
POP3: 110; POP3S: 995; IMAP: 143; IMAPS: 993.
[[receiveemail.username]]receiveemail.username::
+

View File

@@ -1,6 +1,7 @@
= Gerrit Code Review - Mail Templates
Gerrit uses Closure Templates for the bulk of the standard mails it sends out.
Gerrit uses link:https://developers.google.com/closure/templates/[Closure Templates]
(Soy) for the bulk of the standard mails it sends out.
There are builtin default templates which are used if they are not overridden.
These defaults are also provided as examples so that administrators may copy
them and easily modify them to tweak their contents.
@@ -230,10 +231,6 @@ $patchSet.refname::
+
The refname of the patch set.
== SEE ALSO
* link:https://developers.google.com/closure/templates/[Closure Templates]
GERRIT
------
Part of link:index.html[Gerrit Code Review]

View File

@@ -771,7 +771,7 @@ screens, e.g. configured link:#dashboards[dashboards], quick.
== Reply by Email
Gerrit sends out email notifications to users and supports parsing back replies
on some of them.
on some of them (when link:config-gerrit.html#receiveemail[configured]).
Gerrit supports replies on these notification emails:

View File

@@ -22,8 +22,8 @@ import com.google.gerrit.common.Nullable;
import com.google.template.soy.SoyFileSet;
import com.google.template.soy.data.SanitizedContent;
import com.google.template.soy.data.SoyMapData;
import com.google.template.soy.tofu.SoyTofu;
import com.google.template.soy.data.UnsafeSanitizedContentOrdainer;
import com.google.template.soy.tofu.SoyTofu;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
@@ -33,16 +33,20 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class IndexServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private final byte[] indexSource;
IndexServlet(String canonicalURL, @Nullable String cdnPath) throws URISyntaxException {
String resourcePath = "com/google/gerrit/httpd/raw/index.html.soy";
SoyFileSet.Builder builder = SoyFileSet.builder();
builder.add(Resources.getResource(resourcePath));
SoyTofu.Renderer renderer = builder.build().compileToTofu()
.newRenderer("com.google.gerrit.httpd.raw.Index")
.setContentKind(SanitizedContent.ContentKind.HTML)
.setData(getTemplateData(canonicalURL, cdnPath));
SoyTofu.Renderer renderer =
builder
.build()
.compileToTofu()
.newRenderer("com.google.gerrit.httpd.raw.Index")
.setContentKind(SanitizedContent.ContentKind.HTML)
.setData(getTemplateData(canonicalURL, cdnPath));
indexSource = renderer.render().getBytes();
}
@@ -75,8 +79,9 @@ public class IndexServlet extends HttpServlet {
// The resource path must be typed as safe for use in a script src.
// TODO(wyatta): Upgrade this to use an appropriate safe URL type.
SanitizedContent sanitizedStaticPath = UnsafeSanitizedContentOrdainer.ordainAsSafe(staticPath,
SanitizedContent.ContentKind.TRUSTED_RESOURCE_URI);
SanitizedContent sanitizedStaticPath =
UnsafeSanitizedContentOrdainer.ordainAsSafe(
staticPath, SanitizedContent.ContentKind.TRUSTED_RESOURCE_URI);
return new SoyMapData(
"canonicalPath", canonicalPath,

View File

@@ -33,7 +33,6 @@ import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.config.SitePaths;
import com.google.inject.Inject;
import com.google.inject.Key;
import com.google.inject.Provider;
import com.google.inject.Provides;
import com.google.inject.ProvisionException;
import com.google.inject.Singleton;
@@ -252,8 +251,9 @@ public class StaticModule extends ServletModule {
@Provides
@Singleton
@Named(POLYGERRIT_INDEX_SERVLET)
HttpServlet getPolyGerritUiIndexServlet(@CanonicalWebUrl @Nullable String canonicalUrl,
@GerritServerConfig Config cfg) throws URISyntaxException {
HttpServlet getPolyGerritUiIndexServlet(
@CanonicalWebUrl @Nullable String canonicalUrl, @GerritServerConfig Config cfg)
throws URISyntaxException {
String cdnPath = cfg.getString("gerrit", null, "cdnPath");
return new IndexServlet(canonicalUrl, cdnPath);
}

View File

@@ -14,13 +14,12 @@
package com.google.gerrit.httpd.raw;
import com.google.gerrit.common.Nullable;
import static com.google.common.truth.Truth.assertThat;
import com.google.template.soy.data.SoyMapData;
import java.net.URISyntaxException;
import org.junit.Test;
import static com.google.common.truth.Truth.assertThat;
public class IndexServletTest {
@Test
public void noPathAndNoCDN() throws URISyntaxException {
@@ -38,8 +37,8 @@ public class IndexServletTest {
@Test
public void noPathAndCDN() throws URISyntaxException {
SoyMapData data = IndexServlet.getTemplateData("http://example.com/",
"http://my-cdn.com/foo/bar/");
SoyMapData data =
IndexServlet.getTemplateData("http://example.com/", "http://my-cdn.com/foo/bar/");
assertThat(data.getSingle("canonicalPath").stringValue()).isEqualTo("");
assertThat(data.getSingle("staticResourcePath").stringValue())
.isEqualTo("http://my-cdn.com/foo/bar/");
@@ -47,8 +46,8 @@ public class IndexServletTest {
@Test
public void pathAndCDN() throws URISyntaxException {
SoyMapData data = IndexServlet.getTemplateData("http://example.com/gerrit",
"http://my-cdn.com/foo/bar/");
SoyMapData data =
IndexServlet.getTemplateData("http://example.com/gerrit", "http://my-cdn.com/foo/bar/");
assertThat(data.getSingle("canonicalPath").stringValue()).isEqualTo("/gerrit");
assertThat(data.getSingle("staticResourcePath").stringValue())
.isEqualTo("http://my-cdn.com/foo/bar/");