aboutsummaryrefslogtreecommitdiff
path: root/juick-spring-www/src/main/java/com/juick/www/configuration
diff options
context:
space:
mode:
authorGravatar Alexander Alexeev2016-12-12 19:37:38 +0700
committerGravatar Vitaly Takmazov2016-12-12 22:49:47 +0300
commita100c61ee6786f9149770e21c22ee4adcef689ed (patch)
tree1e08df703c61de00888d0915939c5b8690893c85 /juick-spring-www/src/main/java/com/juick/www/configuration
parentd446ba75acc05ec331540d51348bdc2be5aecb42 (diff)
using thymeleaf static variables for show settings
Diffstat (limited to 'juick-spring-www/src/main/java/com/juick/www/configuration')
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/configuration/WebAppConfiguration.java6
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java13
2 files changed, 13 insertions, 6 deletions
diff --git a/juick-spring-www/src/main/java/com/juick/www/configuration/WebAppConfiguration.java b/juick-spring-www/src/main/java/com/juick/www/configuration/WebAppConfiguration.java
index a6632289..28a0f29a 100644
--- a/juick-spring-www/src/main/java/com/juick/www/configuration/WebAppConfiguration.java
+++ b/juick-spring-www/src/main/java/com/juick/www/configuration/WebAppConfiguration.java
@@ -2,7 +2,6 @@ package com.juick.www.configuration;
import com.juick.www.HelpService;
import com.juick.www.WebApp;
-import com.juick.www.settings.TemplateSettingsHolder;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.guava.GuavaCacheManager;
import org.springframework.cache.interceptor.KeyGenerator;
@@ -38,11 +37,6 @@ public class WebAppConfiguration {
}
@Bean
- public TemplateSettingsHolder settingsHolder() {
- return new TemplateSettingsHolder(env);
- }
-
- @Bean
public WebApp webApp() {
return new WebApp(env);
}
diff --git a/juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java b/juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java
index 8da3321e..15f85c9a 100644
--- a/juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java
+++ b/juick-spring-www/src/main/java/com/juick/www/configuration/WwwServletConfiguration.java
@@ -4,10 +4,12 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.juick.www.formatter.SpringDateFormatter;
import nz.net.ultraq.thymeleaf.LayoutDialect;
+import org.apache.commons.lang3.BooleanUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
+import org.springframework.core.env.Environment;
import org.springframework.format.FormatterRegistry;
import org.springframework.http.CacheControl;
import org.springframework.http.converter.HttpMessageConverter;
@@ -25,6 +27,7 @@ import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver;
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
import org.thymeleaf.templatemode.TemplateMode;
+import javax.annotation.Resource;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -35,6 +38,8 @@ import java.util.concurrent.TimeUnit;
@ComponentScan(basePackages = {"com.juick.www.controllers"})
@PropertySource("classpath:juick.conf")
public class WwwServletConfiguration extends WebMvcConfigurationSupport {
+ @Resource
+ private Environment env;
@Bean
public SpringResourceTemplateResolver templateResolver() {
@@ -79,6 +84,14 @@ public class WwwServletConfiguration extends WebMvcConfigurationSupport {
ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
viewResolver.setTemplateEngine(templateEngine());
viewResolver.setCharacterEncoding("UTF-8");
+
+ viewResolver.addStaticVariable(
+ "showSape", BooleanUtils.toBoolean(env.getProperty("template.showSape", "true")));
+ viewResolver.addStaticVariable(
+ "showAdv", BooleanUtils.toBoolean(env.getProperty("template.showAdv", "true")));
+ viewResolver.addStaticVariable(
+ "showSponsors", BooleanUtils.toBoolean(env.getProperty("template.showSponsors", "false")));
+
return viewResolver;
}