mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
display app version
This commit is contained in:
@@ -17,6 +17,8 @@ import com.wordnik.swagger.annotations.ApiClass;
|
||||
public class ServerInfo implements Serializable {
|
||||
|
||||
private String announcement;
|
||||
private String version;
|
||||
private String gitCommit;
|
||||
private Map<String, String> supportedLanguages = Maps.newHashMap();
|
||||
|
||||
public String getAnnouncement() {
|
||||
@@ -35,4 +37,20 @@ public class ServerInfo implements Serializable {
|
||||
this.supportedLanguages = supportedLanguages;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getGitCommit() {
|
||||
return gitCommit;
|
||||
}
|
||||
|
||||
public void setGitCommit(String gitCommit) {
|
||||
this.gitCommit = gitCommit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package com.commafeed.frontend.resources;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import ro.isdc.wro.config.jmx.WroConfiguration;
|
||||
import ro.isdc.wro.http.WroServletContextListener;
|
||||
|
||||
import com.commafeed.backend.services.ApplicationPropertiesService;
|
||||
|
||||
public class WroListener extends WroServletContextListener {
|
||||
|
||||
@Override
|
||||
protected WroConfiguration newConfiguration() {
|
||||
WroConfiguration conf = super.newConfiguration();
|
||||
|
||||
boolean prod = Boolean.valueOf(ResourceBundle.getBundle("application")
|
||||
.getString("production"));
|
||||
ApplicationPropertiesService properties = ApplicationPropertiesService.get();
|
||||
boolean prod = properties.isProduction();
|
||||
|
||||
conf.setResourceWatcherUpdatePeriod(prod ? 0 : 1);
|
||||
conf.setDisableCache(!prod);
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.commafeed.backend.HttpGetter;
|
||||
import com.commafeed.backend.HttpGetter.HttpResult;
|
||||
import com.commafeed.backend.StartupBean;
|
||||
import com.commafeed.backend.feeds.FeedUtils;
|
||||
import com.commafeed.backend.services.ApplicationPropertiesService;
|
||||
import com.commafeed.frontend.model.ServerInfo;
|
||||
import com.wordnik.swagger.annotations.Api;
|
||||
import com.wordnik.swagger.annotations.ApiOperation;
|
||||
@@ -30,11 +31,15 @@ public class ServerREST extends AbstractResourceREST {
|
||||
@GET
|
||||
@ApiOperation(value = "Get server infos", notes = "Get server infos", responseClass = "com.commafeed.frontend.model.ServerInfo")
|
||||
public Response get() {
|
||||
ApplicationPropertiesService properties = ApplicationPropertiesService.get();
|
||||
|
||||
ServerInfo infos = new ServerInfo();
|
||||
infos.setAnnouncement(applicationSettingsService.get()
|
||||
.getAnnouncement());
|
||||
infos.getSupportedLanguages().putAll(
|
||||
startupBean.getSupportedLanguages());
|
||||
infos.setVersion(properties.getVersion());
|
||||
infos.setGitCommit(properties.getGitCommit());
|
||||
return Response.ok(infos).build();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Properties;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -26,6 +25,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.commafeed.backend.dao.UserSettingsDAO;
|
||||
import com.commafeed.backend.model.UserSettings;
|
||||
import com.commafeed.backend.services.ApplicationPropertiesService;
|
||||
import com.commafeed.frontend.CommaFeedSession;
|
||||
|
||||
/**
|
||||
@@ -43,6 +43,17 @@ public class InternationalizationDevelopmentFilter implements Filter {
|
||||
|
||||
private boolean production = true;
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
ApplicationPropertiesService properties = ApplicationPropertiesService.get();
|
||||
production = properties.isProduction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response,
|
||||
FilterChain chain) throws IOException, ServletException {
|
||||
@@ -108,18 +119,6 @@ public class InternationalizationDevelopmentFilter implements Filter {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
String prod = ResourceBundle.getBundle("application").getString(
|
||||
"production");
|
||||
production = Boolean.valueOf(prod);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
private static class ServletOutputStreamWrapper extends ServletOutputStream {
|
||||
|
||||
private ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
Reference in New Issue
Block a user