package de.uni_koeln.spinfo.upcase.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.thymeleaf.spring4.SpringTemplateEngine;
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
import org.thymeleaf.templateresolver.ServletContextTemplateResolver;

@Configuration
@EnableWebMvc
public class ThymeLeafConfig extends WebMvcConfigurerAdapter {

	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler("/assets/**").addResourceLocations("/assets/");
		registry.addResourceHandler("/bootstrap/**").addResourceLocations("/bootstrap/");
		registry.addResourceHandler("/favicon.ico").addResourceLocations("/");
		registry.addResourceHandler("/images/**").addResourceLocations("/images/");
		registry.addResourceHandler("/static/**").addResourceLocations("/static/");
	}

	@Override
	public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
		configurer.enable();
	}

	@Bean
	public ServletContextTemplateResolver templateResolver() {
		ServletContextTemplateResolver resolver = new ServletContextTemplateResolver();
		resolver.setPrefix("/WEB-INF/views/");
		resolver.setSuffix(".html");
		resolver.setTemplateMode("HTML5");
		resolver.setCacheable(false);
		return resolver;
	}

	@Bean
	public SpringTemplateEngine templateEngine() {
		SpringTemplateEngine engine = new SpringTemplateEngine();
		engine.setTemplateResolver(templateResolver());
		return engine;
	}

	@Bean
	public ThymeleafViewResolver thymeleafViewResolver() {
		ThymeleafViewResolver resolver = new ThymeleafViewResolver();
		resolver.setTemplateEngine(templateEngine());
		return resolver;
	}
}

@@ -37,16 +37,115 @@
 onfig;%0A%0A
+import java.util.HashSet;%0Aimport java.util.Set;%0A%0Aimport org.springframework.context.MessageSource;%0A
 import o
@@ -249,16 +249,163 @@
 ration;%0A
+import org.springframework.context.support.ResourceBundleMessageSource;%0Aimport org.springframework.web.multipart.commons.CommonsMultipartResolver;%0A
 import o
@@ -746,36 +746,210 @@
 eaf.
-spring4.SpringTemplateEngine
+dialect.IDialect;%0Aimport org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect;%0Aimport org.thymeleaf.spring4.SpringTemplateEngine;%0Aimport org.thymeleaf.spring4.dialect.SpringStandardDialect
 ;%0Aim
@@ -2134,24 +2134,25 @@
 teEngine() %7B
+%09
 %0A%09%09SpringTem
@@ -2246,24 +2246,190 @@
 esolver());%0A
+%09%09Set%3CIDialect%3E dialetcs = new HashSet%3C%3E();%0A%09%09dialetcs.add(new SpringSecurityDialect());%0A%09%09dialetcs.add(new SpringStandardDialect());%0A%09%09engine.setDialects(dialetcs);%0A
 %09%09return eng
@@ -2633,11 +2633,498 @@
 lver;%0A%09%7D
+%0A%0A%09@Bean%0A%09public MessageSource messageSource() %7B%0A%09%09ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();%0A%09%09messageSource.setDefaultEncoding(%22UTF-8%22);%0A%09%09messageSource.setBasename(%22locale/messages%22);%0A%09%09return messageSource;%0A%09%7D%0A%09%0A%09@Bean%0A%09public CommonsMultipartResolver multipartResolver() %7B%0A%09%09CommonsMultipartResolver resolver = new CommonsMultipartResolver();%0A%09%09resolver.setMaxUploadSize(104857600);%0A%09%09resolver.setDefaultEncoding(%22UTF-8%22);%0A%09%09return resolver;%0A%09%7D%0A%09
 %0A%7D%0A

Add message source, multipart resolver and thymeleaf spring sec dialect