rolling back revision 7393

This commit is contained in:
tlw72 2011-02-08 14:28:52 +00:00
parent a8d353dab1
commit 6314a2d00d

View file

@ -58,10 +58,11 @@ public class FreemarkerConfigurationLoader {
String themeDir = getThemeDir(vreq.getPortal()); String themeDir = getThemeDir(vreq.getPortal());
return getConfigForTheme(themeDir); return getConfigForTheme(themeDir);
} }
protected String getThemeDir(Portal portal) { protected String getThemeDir(Portal portal) {
return portal.getThemeDir().replaceAll("/$", ""); return portal.getThemeDir().replaceAll("/$", "");
} }
protected Configuration getConfigForTheme(String themeDir) { protected Configuration getConfigForTheme(String themeDir) {
@ -95,10 +96,10 @@ public class FreemarkerConfigurationLoader {
config.setTemplateUpdateDelay(0); // no template caching in development config.setTemplateUpdateDelay(0); // no template caching in development
} else { } else {
int delay = 60; int delay = 60;
log.debug("Setting Freemarker template cache update delay to " + delay + "."); log.debug("Setting Freemarker template cache update delay to " + delay + ".");
config.setTemplateUpdateDelay(delay); // in seconds; Freemarker default is 5 config.setTemplateUpdateDelay(delay); // in seconds; Freemarker default is 5
} }
// Specify how templates will see the data model. // Specify how templates will see the data model.
// The default wrapper exposes set methods unless exposure level is set. // The default wrapper exposes set methods unless exposure level is set.
// By default we want to block exposure of set methods. // By default we want to block exposure of set methods.
@ -125,19 +126,15 @@ public class FreemarkerConfigurationLoader {
log.error("Error setting value for url_escaping_charset."); log.error("Error setting value for url_escaping_charset.");
} }
// auto include setup.ftl which allows for globals to be easily defined in a template that's always included config.setTemplateLoader(getTemplateLoader(config, themeDir));
// used primarily to setup ${bodyClasses} for now
config.addAutoInclude("pageSetup.ftl");
config.setTemplateLoader(getTemplateLoader(config, themeDir));
return config; return config;
} }
// Define template locations. Template loader will look first in the theme-specific // Define template locations. Template loader will look first in the theme-specific
// location, then in the vitro location. // location, then in the vitro location.
protected final TemplateLoader getTemplateLoader(Configuration config, String themeDir) { protected final TemplateLoader getTemplateLoader(Configuration config, String themeDir) {
List<TemplateLoader> loaders = new ArrayList<TemplateLoader>(); List<TemplateLoader> loaders = new ArrayList<TemplateLoader>();
MultiTemplateLoader mtl = null; MultiTemplateLoader mtl = null;
try { try {
@ -148,7 +145,7 @@ public class FreemarkerConfigurationLoader {
if (themeTemplateDir.exists()) { if (themeTemplateDir.exists()) {
FileTemplateLoader themeFtl = new FileTemplateLoader(themeTemplateDir); FileTemplateLoader themeFtl = new FileTemplateLoader(themeTemplateDir);
loaders.add(themeFtl); loaders.add(themeFtl);
} }
// Vitro template loader // Vitro template loader
String vitroTemplatePath = context.getRealPath("/templates/freemarker"); String vitroTemplatePath = context.getRealPath("/templates/freemarker");
@ -162,6 +159,8 @@ public class FreemarkerConfigurationLoader {
} catch (IOException e) { } catch (IOException e) {
log.error("Error creating template loaders"); log.error("Error creating template loaders");
} }
return mtl; return mtl;
} }
} }