Add PolyGerrit site theme file url to REST API
Change-Id: If25d0850f92f90aa4eabdf9aa74f0d3bc6307392
This commit is contained in:
@@ -1801,6 +1801,9 @@ the first matched group, `$2` for the second matched group, etc.
|
|||||||
Information about the configuration from the
|
Information about the configuration from the
|
||||||
link:config-gerrit.html#user[user] section as link:#user-config-info[
|
link:config-gerrit.html#user[user] section as link:#user-config-info[
|
||||||
UserConfigInfo] entity.
|
UserConfigInfo] entity.
|
||||||
|
|`default_theme` |optional|
|
||||||
|
URL to a default PolyGerrit UI theme plugin, if available.
|
||||||
|
Located in `/static/gerrit-theme.html` by default.
|
||||||
|=======================================
|
|=======================================
|
||||||
|
|
||||||
[[sshd-info]]
|
[[sshd-info]]
|
||||||
|
|||||||
@@ -28,4 +28,5 @@ public class ServerInfo {
|
|||||||
public Map<String, String> urlAliases;
|
public Map<String, String> urlAliases;
|
||||||
public UserConfigInfo user;
|
public UserConfigInfo user;
|
||||||
public ReceiveInfo receive;
|
public ReceiveInfo receive;
|
||||||
|
public String defaultTheme;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ import com.google.gerrit.server.notedb.NotesMigration;
|
|||||||
import com.google.gerrit.server.project.ProjectCache;
|
import com.google.gerrit.server.project.ProjectCache;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
@@ -86,6 +87,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
|||||||
private final AgreementJson agreementJson;
|
private final AgreementJson agreementJson;
|
||||||
private final GerritOptions gerritOptions;
|
private final GerritOptions gerritOptions;
|
||||||
private final ChangeIndexCollection indexes;
|
private final ChangeIndexCollection indexes;
|
||||||
|
private final SitePaths sitePaths;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public GetServerInfo(
|
public GetServerInfo(
|
||||||
@@ -107,7 +109,8 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
|||||||
ProjectCache projectCache,
|
ProjectCache projectCache,
|
||||||
AgreementJson agreementJson,
|
AgreementJson agreementJson,
|
||||||
GerritOptions gerritOptions,
|
GerritOptions gerritOptions,
|
||||||
ChangeIndexCollection indexes) {
|
ChangeIndexCollection indexes,
|
||||||
|
SitePaths sitePaths) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.authConfig = authConfig;
|
this.authConfig = authConfig;
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
@@ -127,6 +130,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
|||||||
this.agreementJson = agreementJson;
|
this.agreementJson = agreementJson;
|
||||||
this.gerritOptions = gerritOptions;
|
this.gerritOptions = gerritOptions;
|
||||||
this.indexes = indexes;
|
this.indexes = indexes;
|
||||||
|
this.sitePaths = sitePaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -139,6 +143,9 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
|
|||||||
info.gerrit = getGerritInfo(config, allProjectsName, allUsersName);
|
info.gerrit = getGerritInfo(config, allProjectsName, allUsersName);
|
||||||
info.noteDbEnabled = toBoolean(isNoteDbEnabled());
|
info.noteDbEnabled = toBoolean(isNoteDbEnabled());
|
||||||
info.plugin = getPluginInfo();
|
info.plugin = getPluginInfo();
|
||||||
|
if (Files.exists(sitePaths.site_theme)) {
|
||||||
|
info.defaultTheme = "/static/" + SitePaths.THEME_FILENAME;
|
||||||
|
}
|
||||||
info.sshd = getSshdInfo(config);
|
info.sshd = getSshdInfo(config);
|
||||||
info.suggest = getSuggestInfo(config);
|
info.suggest = getSuggestInfo(config);
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ public final class SitePaths {
|
|||||||
public static final String CSS_FILENAME = "GerritSite.css";
|
public static final String CSS_FILENAME = "GerritSite.css";
|
||||||
public static final String HEADER_FILENAME = "GerritSiteHeader.html";
|
public static final String HEADER_FILENAME = "GerritSiteHeader.html";
|
||||||
public static final String FOOTER_FILENAME = "GerritSiteFooter.html";
|
public static final String FOOTER_FILENAME = "GerritSiteFooter.html";
|
||||||
|
public static final String THEME_FILENAME = "gerrit-theme.html";
|
||||||
|
|
||||||
public final Path site_path;
|
public final Path site_path;
|
||||||
public final Path bin_dir;
|
public final Path bin_dir;
|
||||||
@@ -67,6 +68,8 @@ public final class SitePaths {
|
|||||||
public final Path site_css;
|
public final Path site_css;
|
||||||
public final Path site_header;
|
public final Path site_header;
|
||||||
public final Path site_footer;
|
public final Path site_footer;
|
||||||
|
// For PolyGerrit UI only.
|
||||||
|
public final Path site_theme;
|
||||||
public final Path site_gitweb;
|
public final Path site_gitweb;
|
||||||
|
|
||||||
/** {@code true} if {@link #site_path} has not been initialized. */
|
/** {@code true} if {@link #site_path} has not been initialized. */
|
||||||
@@ -115,6 +118,9 @@ public final class SitePaths {
|
|||||||
site_footer = etc_dir.resolve(FOOTER_FILENAME);
|
site_footer = etc_dir.resolve(FOOTER_FILENAME);
|
||||||
site_gitweb = etc_dir.resolve("gitweb_config.perl");
|
site_gitweb = etc_dir.resolve("gitweb_config.perl");
|
||||||
|
|
||||||
|
// For PolyGerrit UI.
|
||||||
|
site_theme = static_dir.resolve(THEME_FILENAME);
|
||||||
|
|
||||||
boolean isNew;
|
boolean isNew;
|
||||||
try (DirectoryStream<Path> files = Files.newDirectoryStream(site_path)) {
|
try (DirectoryStream<Path> files = Files.newDirectoryStream(site_path)) {
|
||||||
isNew = Iterables.isEmpty(files);
|
isNew = Iterables.isEmpty(files);
|
||||||
|
|||||||
Reference in New Issue
Block a user