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:
@@ -1,7 +1,6 @@
|
|||||||
package com.commafeed.backend;
|
package com.commafeed.backend;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.util.ResourceBundle;
|
|
||||||
|
|
||||||
import javax.ejb.Stateless;
|
import javax.ejb.Stateless;
|
||||||
import javax.ejb.TransactionManagement;
|
import javax.ejb.TransactionManagement;
|
||||||
@@ -19,13 +18,15 @@ import liquibase.resource.ClassLoaderResourceAccessor;
|
|||||||
import liquibase.resource.ResourceAccessor;
|
import liquibase.resource.ResourceAccessor;
|
||||||
import liquibase.structure.DatabaseObject;
|
import liquibase.structure.DatabaseObject;
|
||||||
|
|
||||||
|
import com.commafeed.backend.services.ApplicationPropertiesService;
|
||||||
|
|
||||||
@Stateless
|
@Stateless
|
||||||
@TransactionManagement(TransactionManagementType.BEAN)
|
@TransactionManagement(TransactionManagementType.BEAN)
|
||||||
public class DatabaseUpdater {
|
public class DatabaseUpdater {
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
String datasourceName = ResourceBundle.getBundle("application")
|
ApplicationPropertiesService properties = ApplicationPropertiesService.get();
|
||||||
.getString("datasource");
|
String datasourceName = properties.getDatasource();
|
||||||
try {
|
try {
|
||||||
Context context = null;
|
Context context = null;
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ public class FeedRefreshUpdater {
|
|||||||
public void init() {
|
public void init() {
|
||||||
ApplicationSettings settings = applicationSettingsService.get();
|
ApplicationSettings settings = applicationSettingsService.get();
|
||||||
int threads = Math.max(settings.getDatabaseUpdateThreads(), 1);
|
int threads = Math.max(settings.getDatabaseUpdateThreads(), 1);
|
||||||
log.info("Creating database pool with {} threads", threads);
|
|
||||||
pool = new FeedRefreshExecutor("feed-refresh-updater", threads, 500 * threads);
|
pool = new FeedRefreshExecutor("feed-refresh-updater", threads, 500 * threads);
|
||||||
locks = Striped.lazyWeakLock(threads * 100000);
|
locks = Striped.lazyWeakLock(threads * 100000);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ public class FeedRefreshWorker {
|
|||||||
private void init() {
|
private void init() {
|
||||||
ApplicationSettings settings = applicationSettingsService.get();
|
ApplicationSettings settings = applicationSettingsService.get();
|
||||||
int threads = settings.getBackgroundThreads();
|
int threads = settings.getBackgroundThreads();
|
||||||
log.info("Creating refresh worker pool with {} threads", threads);
|
|
||||||
pool = new FeedRefreshExecutor("feed-refresh-worker", threads,
|
pool = new FeedRefreshExecutor("feed-refresh-worker", threads,
|
||||||
20 * 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 {
|
public class ServerInfo implements Serializable {
|
||||||
|
|
||||||
private String announcement;
|
private String announcement;
|
||||||
|
private String version;
|
||||||
|
private String gitCommit;
|
||||||
private Map<String, String> supportedLanguages = Maps.newHashMap();
|
private Map<String, String> supportedLanguages = Maps.newHashMap();
|
||||||
|
|
||||||
public String getAnnouncement() {
|
public String getAnnouncement() {
|
||||||
@@ -35,4 +37,20 @@ public class ServerInfo implements Serializable {
|
|||||||
this.supportedLanguages = supportedLanguages;
|
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;
|
package com.commafeed.frontend.resources;
|
||||||
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
|
|
||||||
import ro.isdc.wro.config.jmx.WroConfiguration;
|
import ro.isdc.wro.config.jmx.WroConfiguration;
|
||||||
import ro.isdc.wro.http.WroServletContextListener;
|
import ro.isdc.wro.http.WroServletContextListener;
|
||||||
|
|
||||||
|
import com.commafeed.backend.services.ApplicationPropertiesService;
|
||||||
|
|
||||||
public class WroListener extends WroServletContextListener {
|
public class WroListener extends WroServletContextListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected WroConfiguration newConfiguration() {
|
protected WroConfiguration newConfiguration() {
|
||||||
WroConfiguration conf = super.newConfiguration();
|
WroConfiguration conf = super.newConfiguration();
|
||||||
|
ApplicationPropertiesService properties = ApplicationPropertiesService.get();
|
||||||
boolean prod = Boolean.valueOf(ResourceBundle.getBundle("application")
|
boolean prod = properties.isProduction();
|
||||||
.getString("production"));
|
|
||||||
|
|
||||||
conf.setResourceWatcherUpdatePeriod(prod ? 0 : 1);
|
conf.setResourceWatcherUpdatePeriod(prod ? 0 : 1);
|
||||||
conf.setDisableCache(!prod);
|
conf.setDisableCache(!prod);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import com.commafeed.backend.HttpGetter;
|
|||||||
import com.commafeed.backend.HttpGetter.HttpResult;
|
import com.commafeed.backend.HttpGetter.HttpResult;
|
||||||
import com.commafeed.backend.StartupBean;
|
import com.commafeed.backend.StartupBean;
|
||||||
import com.commafeed.backend.feeds.FeedUtils;
|
import com.commafeed.backend.feeds.FeedUtils;
|
||||||
|
import com.commafeed.backend.services.ApplicationPropertiesService;
|
||||||
import com.commafeed.frontend.model.ServerInfo;
|
import com.commafeed.frontend.model.ServerInfo;
|
||||||
import com.wordnik.swagger.annotations.Api;
|
import com.wordnik.swagger.annotations.Api;
|
||||||
import com.wordnik.swagger.annotations.ApiOperation;
|
import com.wordnik.swagger.annotations.ApiOperation;
|
||||||
@@ -30,11 +31,15 @@ public class ServerREST extends AbstractResourceREST {
|
|||||||
@GET
|
@GET
|
||||||
@ApiOperation(value = "Get server infos", notes = "Get server infos", responseClass = "com.commafeed.frontend.model.ServerInfo")
|
@ApiOperation(value = "Get server infos", notes = "Get server infos", responseClass = "com.commafeed.frontend.model.ServerInfo")
|
||||||
public Response get() {
|
public Response get() {
|
||||||
|
ApplicationPropertiesService properties = ApplicationPropertiesService.get();
|
||||||
|
|
||||||
ServerInfo infos = new ServerInfo();
|
ServerInfo infos = new ServerInfo();
|
||||||
infos.setAnnouncement(applicationSettingsService.get()
|
infos.setAnnouncement(applicationSettingsService.get()
|
||||||
.getAnnouncement());
|
.getAnnouncement());
|
||||||
infos.getSupportedLanguages().putAll(
|
infos.getSupportedLanguages().putAll(
|
||||||
startupBean.getSupportedLanguages());
|
startupBean.getSupportedLanguages());
|
||||||
|
infos.setVersion(properties.getVersion());
|
||||||
|
infos.setGitCommit(properties.getGitCommit());
|
||||||
return Response.ok(infos).build();
|
return Response.ok(infos).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.ResourceBundle;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@@ -26,6 +25,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import com.commafeed.backend.dao.UserSettingsDAO;
|
import com.commafeed.backend.dao.UserSettingsDAO;
|
||||||
import com.commafeed.backend.model.UserSettings;
|
import com.commafeed.backend.model.UserSettings;
|
||||||
|
import com.commafeed.backend.services.ApplicationPropertiesService;
|
||||||
import com.commafeed.frontend.CommaFeedSession;
|
import com.commafeed.frontend.CommaFeedSession;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,6 +43,17 @@ public class InternationalizationDevelopmentFilter implements Filter {
|
|||||||
|
|
||||||
private boolean production = true;
|
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
|
@Override
|
||||||
public void doFilter(ServletRequest request, ServletResponse response,
|
public void doFilter(ServletRequest request, ServletResponse response,
|
||||||
FilterChain chain) throws IOException, ServletException {
|
FilterChain chain) throws IOException, ServletException {
|
||||||
@@ -108,18 +119,6 @@ public class InternationalizationDevelopmentFilter implements Filter {
|
|||||||
return sb.toString();
|
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 static class ServletOutputStreamWrapper extends ServletOutputStream {
|
||||||
|
|
||||||
private ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
private ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ profile.delete_account=Delete account
|
|||||||
|
|
||||||
about.rest_api=REST API
|
about.rest_api=REST API
|
||||||
about.keyboard_shortcuts=Keyboard shortcuts
|
about.keyboard_shortcuts=Keyboard shortcuts
|
||||||
|
about.version=CommaFeed version
|
||||||
about.line1_prefix=CommaFeed is an open-source project. Sources are hosted on
|
about.line1_prefix=CommaFeed is an open-source project. Sources are hosted on
|
||||||
about.line1_suffix=.
|
about.line1_suffix=.
|
||||||
about.line2_prefix=If you encounter an issue, please report it on the issues page of the
|
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',
|
module.controller('HelpController', [ '$scope', 'CategoryService',
|
||||||
'AnalyticsService',
|
'AnalyticsService', 'ServerService',
|
||||||
function($scope, CategoryService, AnalyticsService) {
|
function($scope, CategoryService, AnalyticsService, ServerService) {
|
||||||
|
|
||||||
AnalyticsService.track();
|
AnalyticsService.track();
|
||||||
$scope.CategoryService = CategoryService;
|
$scope.CategoryService = CategoryService;
|
||||||
|
$scope.infos = ServerService.get();
|
||||||
$scope.categoryId = 'all';
|
$scope.categoryId = 'all';
|
||||||
$scope.order = 'desc';
|
$scope.order = 'desc';
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<p>
|
<p>
|
||||||
${about.line2_prefix}<a href="https://github.com/Athou/commafeed/issues" target="_blank">GitHub</a>${about.line2_suffix}
|
${about.line2_prefix}<a href="https://github.com/Athou/commafeed/issues" target="_blank">GitHub</a>${about.line2_suffix}
|
||||||
</p>
|
</p>
|
||||||
|
${about.version} {{infos.version}} ({{infos.gitCommit}})
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="about-module">
|
<div class="about-module">
|
||||||
|
|||||||
Reference in New Issue
Block a user