forked from Archives/Athou_commafeed
display app version
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package com.commafeed.backend;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
import javax.ejb.TransactionManagement;
|
||||
@@ -19,13 +18,15 @@ import liquibase.resource.ClassLoaderResourceAccessor;
|
||||
import liquibase.resource.ResourceAccessor;
|
||||
import liquibase.structure.DatabaseObject;
|
||||
|
||||
import com.commafeed.backend.services.ApplicationPropertiesService;
|
||||
|
||||
@Stateless
|
||||
@TransactionManagement(TransactionManagementType.BEAN)
|
||||
public class DatabaseUpdater {
|
||||
|
||||
public void update() {
|
||||
String datasourceName = ResourceBundle.getBundle("application")
|
||||
.getString("datasource");
|
||||
ApplicationPropertiesService properties = ApplicationPropertiesService.get();
|
||||
String datasourceName = properties.getDatasource();
|
||||
try {
|
||||
Context context = null;
|
||||
Connection connection = null;
|
||||
|
||||
@@ -72,7 +72,6 @@ public class FeedRefreshUpdater {
|
||||
public void init() {
|
||||
ApplicationSettings settings = applicationSettingsService.get();
|
||||
int threads = Math.max(settings.getDatabaseUpdateThreads(), 1);
|
||||
log.info("Creating database pool with {} threads", threads);
|
||||
pool = new FeedRefreshExecutor("feed-refresh-updater", threads, 500 * threads);
|
||||
locks = Striped.lazyWeakLock(threads * 100000);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ public class FeedRefreshWorker {
|
||||
private void init() {
|
||||
ApplicationSettings settings = applicationSettingsService.get();
|
||||
int threads = settings.getBackgroundThreads();
|
||||
log.info("Creating refresh worker pool with {} threads", threads);
|
||||
pool = new FeedRefreshExecutor("feed-refresh-worker", threads,
|
||||
20 * threads);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.commafeed.backend.services;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class ApplicationPropertiesService {
|
||||
|
||||
private ResourceBundle bundle;
|
||||
|
||||
private static ApplicationPropertiesService INSTANCE = new ApplicationPropertiesService();
|
||||
|
||||
public static ApplicationPropertiesService get() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private ApplicationPropertiesService() {
|
||||
bundle = ResourceBundle.getBundle("application");
|
||||
}
|
||||
|
||||
public String getDatasource() {
|
||||
return bundle.getString("datasource");
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return bundle.getString("version");
|
||||
}
|
||||
|
||||
public String getGitCommit() {
|
||||
return bundle.getString("git.commit");
|
||||
}
|
||||
|
||||
public boolean isProduction() {
|
||||
return Boolean.valueOf(bundle.getString("production"));
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -97,6 +97,7 @@ profile.delete_account=Delete account
|
||||
|
||||
about.rest_api=REST API
|
||||
about.keyboard_shortcuts=Keyboard shortcuts
|
||||
about.version=CommaFeed version
|
||||
about.line1_prefix=CommaFeed is an open-source project. Sources are hosted on
|
||||
about.line1_suffix=.
|
||||
about.line2_prefix=If you encounter an issue, please report it on the issues page of the
|
||||
|
||||
@@ -1369,11 +1369,12 @@ function($scope, $location, $state, AdminSettingsService) {
|
||||
}]);
|
||||
|
||||
module.controller('HelpController', [ '$scope', 'CategoryService',
|
||||
'AnalyticsService',
|
||||
function($scope, CategoryService, AnalyticsService) {
|
||||
'AnalyticsService', 'ServerService',
|
||||
function($scope, CategoryService, AnalyticsService, ServerService) {
|
||||
|
||||
AnalyticsService.track();
|
||||
$scope.CategoryService = CategoryService;
|
||||
$scope.infos = ServerService.get();
|
||||
$scope.categoryId = 'all';
|
||||
$scope.order = 'desc';
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<p>
|
||||
${about.line2_prefix}<a href="https://github.com/Athou/commafeed/issues" target="_blank">GitHub</a>${about.line2_suffix}
|
||||
</p>
|
||||
${about.version} {{infos.version}} ({{infos.gitCommit}})
|
||||
</div>
|
||||
|
||||
<div class="about-module">
|
||||
|
||||
Reference in New Issue
Block a user