use of org.ambraproject.wombat.config.site.SiteTemplateLoader in project wombat by PLOS.
the class SpringConfiguration method freeMarkerConfig.
@Bean
public FreeMarkerConfig freeMarkerConfig(ServletContext servletContext, SiteSet siteSet, IsDevFeatureEnabledDirective isDevFeatureEnabledDirective, SiteLinkDirective siteLinkDirective, RenderCssLinksDirective renderCssLinksDirective, RenderJsDirective renderJsDirective, BuildInfoDirective buildInfoDirective, FetchHtmlDirective fetchHtmlDirective, ThemeConfigDirective themeConfigDirective, AppLinkDirective appLinkDirective, ArticleExcerptTransformDirective articleExcerptTransformDirective, GlobalConfigDirective globalConfigDirective) throws IOException {
SiteTemplateLoader loader = new SiteTemplateLoader(servletContext, siteSet);
FreeMarkerConfigurer config = new FreeMarkerConfigurer();
config.setPreTemplateLoaders(loader);
// Freemarker custom directives used throughout the app.
// TODO: should all of these be their own @Beans? I'm only doing that now for
// ones that have dependencies on spring-injection.
ImmutableMap.Builder<String, Object> variables = ImmutableMap.builder();
variables.put("formatJsonDate", new Iso8601DateDirective());
variables.put("replaceParams", new ReplaceParametersDirective());
variables.put("siteLink", siteLinkDirective);
variables.put("isDevFeatureEnabled", isDevFeatureEnabledDirective);
variables.put("cssLink", new CssLinkDirective());
variables.put("renderCssLinks", renderCssLinksDirective);
variables.put("js", new JsDirective());
variables.put("renderJs", renderJsDirective);
variables.put("buildInfo", buildInfoDirective);
variables.put("fetchHtml", fetchHtmlDirective);
variables.put("themeConfig", themeConfigDirective);
variables.put("appLink", appLinkDirective);
variables.put("abbreviatedName", new AbbreviatedNameDirective());
variables.put("xform", articleExcerptTransformDirective);
variables.put("globalConfig", globalConfigDirective);
config.setFreemarkerVariables(variables.build());
return config;
}
Aggregations