Search in sources :

Example 1 with AbstractTemplateResolver

use of org.thymeleaf.templateresolver.AbstractTemplateResolver in project cas by apereo.

the class CasCoreViewsConfiguration method chainingTemplateViewResolver.

@Bean
public AbstractTemplateResolver chainingTemplateViewResolver() {
    final ChainingTemplateViewResolver chain = new ChainingTemplateViewResolver();
    casProperties.getView().getTemplatePrefixes().forEach(Unchecked.consumer(prefix -> {
        final String prefixPath = ResourceUtils.getFile(prefix).getCanonicalPath();
        final String viewPath = StringUtils.appendIfMissing(prefixPath, "/");
        final ThemeFileTemplateResolver theme = new ThemeFileTemplateResolver(casProperties);
        configureTemplateViewResolver(theme);
        theme.setPrefix(viewPath + "themes/%s/");
        chain.addResolver(theme);
        final FileTemplateResolver file = new FileTemplateResolver();
        configureTemplateViewResolver(file);
        file.setPrefix(viewPath);
        chain.addResolver(file);
    }));
    return chain;
}
Also used : CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) AbstractConfigurableTemplateResolver(org.thymeleaf.templateresolver.AbstractConfigurableTemplateResolver) Unchecked(org.jooq.lambda.Unchecked) AbstractTemplateResolver(org.thymeleaf.templateresolver.AbstractTemplateResolver) ThymeleafProperties(org.springframework.boot.autoconfigure.thymeleaf.ThymeleafProperties) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) ResourceUtils(org.springframework.util.ResourceUtils) Configuration(org.springframework.context.annotation.Configuration) Slf4j(lombok.extern.slf4j.Slf4j) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) ThemeFileTemplateResolver(org.apereo.cas.web.view.ThemeFileTemplateResolver) Bean(org.springframework.context.annotation.Bean) FileTemplateResolver(org.thymeleaf.templateresolver.FileTemplateResolver) ChainingTemplateViewResolver(org.apereo.cas.web.view.ChainingTemplateViewResolver) ChainingTemplateViewResolver(org.apereo.cas.web.view.ChainingTemplateViewResolver) ThemeFileTemplateResolver(org.apereo.cas.web.view.ThemeFileTemplateResolver) FileTemplateResolver(org.thymeleaf.templateresolver.FileTemplateResolver) ThemeFileTemplateResolver(org.apereo.cas.web.view.ThemeFileTemplateResolver) Bean(org.springframework.context.annotation.Bean)

Aggregations

Slf4j (lombok.extern.slf4j.Slf4j)1 StringUtils (org.apache.commons.lang3.StringUtils)1 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)1 ChainingTemplateViewResolver (org.apereo.cas.web.view.ChainingTemplateViewResolver)1 ThemeFileTemplateResolver (org.apereo.cas.web.view.ThemeFileTemplateResolver)1 Unchecked (org.jooq.lambda.Unchecked)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 ThymeleafProperties (org.springframework.boot.autoconfigure.thymeleaf.ThymeleafProperties)1 EnableConfigurationProperties (org.springframework.boot.context.properties.EnableConfigurationProperties)1 Bean (org.springframework.context.annotation.Bean)1 Configuration (org.springframework.context.annotation.Configuration)1 ResourceUtils (org.springframework.util.ResourceUtils)1 AbstractConfigurableTemplateResolver (org.thymeleaf.templateresolver.AbstractConfigurableTemplateResolver)1 AbstractTemplateResolver (org.thymeleaf.templateresolver.AbstractTemplateResolver)1 FileTemplateResolver (org.thymeleaf.templateresolver.FileTemplateResolver)1