use of org.ambraproject.wombat.freemarker.Iso8601DateDirective in project wombat by PLOS.
the class WombatControllerTestConfig method freeMarkerConfig.
@Bean
public FreeMarkerConfig freeMarkerConfig(ServletContext servletContext) throws IOException {
String[] templates = getFreeMarkerTemplateDirsForTest();
List<TemplateLoader> loaders = new ArrayList<TemplateLoader>();
for (String template : templates) {
FileTemplateLoader loader = new FileTemplateLoader(new File(servletContext.getRealPath(template)));
loaders.add(loader);
}
MultiTemplateLoader mtl = new MultiTemplateLoader(loaders.toArray(new TemplateLoader[0]));
FreeMarkerConfigurer config = new FreeMarkerConfigurer();
config.setPreTemplateLoaders(mtl);
ImmutableMap.Builder<String, Object> variables = ImmutableMap.builder();
variables.put("formatJsonDate", new Iso8601DateDirective());
variables.put("replaceParams", new ReplaceParametersDirective());
variables.put("siteLink", getEmptyTemplateDirectiveModel());
variables.put("cssLink", getEmptyTemplateDirectiveModel());
variables.put("renderCssLinks", getEmptyTemplateDirectiveModel());
variables.put("js", getEmptyTemplateDirectiveModel());
variables.put("renderJs", getEmptyTemplateDirectiveModel());
variables.put("buildInfo", getEmptyTemplateDirectiveModel());
variables.put("fetchHtml", getEmptyTemplateDirectiveModel());
variables.put("themeConfig", getEmptyTemplateDirectiveModel());
variables.put("appLink", getEmptyTemplateDirectiveModel());
config.setFreemarkerVariables(variables.build());
return config;
}
use of org.ambraproject.wombat.freemarker.Iso8601DateDirective 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