diff --git a/src/main/java/com/commafeed/backend/DatabaseUpdater.java b/src/main/java/com/commafeed/backend/DatabaseUpdater.java index a27cb9f3..a4240b69 100644 --- a/src/main/java/com/commafeed/backend/DatabaseUpdater.java +++ b/src/main/java/com/commafeed/backend/DatabaseUpdater.java @@ -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; diff --git a/src/main/java/com/commafeed/backend/feeds/FeedRefreshUpdater.java b/src/main/java/com/commafeed/backend/feeds/FeedRefreshUpdater.java index 7450a619..e212e33a 100644 --- a/src/main/java/com/commafeed/backend/feeds/FeedRefreshUpdater.java +++ b/src/main/java/com/commafeed/backend/feeds/FeedRefreshUpdater.java @@ -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); } diff --git a/src/main/java/com/commafeed/backend/feeds/FeedRefreshWorker.java b/src/main/java/com/commafeed/backend/feeds/FeedRefreshWorker.java index a5393d9f..fa6fc857 100644 --- a/src/main/java/com/commafeed/backend/feeds/FeedRefreshWorker.java +++ b/src/main/java/com/commafeed/backend/feeds/FeedRefreshWorker.java @@ -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); } diff --git a/src/main/java/com/commafeed/backend/services/ApplicationPropertiesService.java b/src/main/java/com/commafeed/backend/services/ApplicationPropertiesService.java new file mode 100644 index 00000000..fc24b8f2 --- /dev/null +++ b/src/main/java/com/commafeed/backend/services/ApplicationPropertiesService.java @@ -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")); + } +} diff --git a/src/main/java/com/commafeed/frontend/model/ServerInfo.java b/src/main/java/com/commafeed/frontend/model/ServerInfo.java index 2c20d74d..889c870b 100644 --- a/src/main/java/com/commafeed/frontend/model/ServerInfo.java +++ b/src/main/java/com/commafeed/frontend/model/ServerInfo.java @@ -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 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; + } + } diff --git a/src/main/java/com/commafeed/frontend/resources/WroListener.java b/src/main/java/com/commafeed/frontend/resources/WroListener.java index a5ef0834..36ea5a7c 100644 --- a/src/main/java/com/commafeed/frontend/resources/WroListener.java +++ b/src/main/java/com/commafeed/frontend/resources/WroListener.java @@ -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); diff --git a/src/main/java/com/commafeed/frontend/rest/resources/ServerREST.java b/src/main/java/com/commafeed/frontend/rest/resources/ServerREST.java index 0094148b..44ea0a6e 100644 --- a/src/main/java/com/commafeed/frontend/rest/resources/ServerREST.java +++ b/src/main/java/com/commafeed/frontend/rest/resources/ServerREST.java @@ -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(); } diff --git a/src/main/java/com/commafeed/frontend/utils/InternationalizationDevelopmentFilter.java b/src/main/java/com/commafeed/frontend/utils/InternationalizationDevelopmentFilter.java index 23603889..de5cbb1e 100644 --- a/src/main/java/com/commafeed/frontend/utils/InternationalizationDevelopmentFilter.java +++ b/src/main/java/com/commafeed/frontend/utils/InternationalizationDevelopmentFilter.java @@ -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(); diff --git a/src/main/resources/i18n/en.properties b/src/main/resources/i18n/en.properties index eb5f9b16..73fe3859 100644 --- a/src/main/resources/i18n/en.properties +++ b/src/main/resources/i18n/en.properties @@ -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 diff --git a/src/main/webapp/js/controllers.js b/src/main/webapp/js/controllers.js index 196f67d5..3c0170b5 100644 --- a/src/main/webapp/js/controllers.js +++ b/src/main/webapp/js/controllers.js @@ -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'; diff --git a/src/main/webapp/templates/feeds.help.html b/src/main/webapp/templates/feeds.help.html index bca538c1..45147dbd 100644 --- a/src/main/webapp/templates/feeds.help.html +++ b/src/main/webapp/templates/feeds.help.html @@ -9,6 +9,7 @@

${about.line2_prefix}GitHub${about.line2_suffix}

+ ${about.version} {{infos.version}} ({{infos.gitCommit}})