|
|
@@ -39,6 +39,7 @@ import java.util.Map; |
|
|
|
|
|
|
|
import static bubble.ApiConstants.HOME_DIR; |
|
|
|
import static bubble.rule.RequestModifierRule.ICON_JS_TEMPLATE; |
|
|
|
import static bubble.rule.RequestModifierRule.ICON_JS_TEMPLATE_NAME; |
|
|
|
import static org.cobbzilla.util.daemon.ZillaRuntime.die; |
|
|
|
import static org.cobbzilla.util.daemon.ZillaRuntime.empty; |
|
|
|
import static org.cobbzilla.util.io.FileUtil.abs; |
|
|
@@ -122,14 +123,16 @@ public abstract class AbstractAppRuleDriver implements AppRuleDriver { |
|
|
|
return loadTemplate(defaultSiteTemplate, requestModConfig().getSiteJsTemplate()); |
|
|
|
} |
|
|
|
|
|
|
|
@Getter(lazy=true) private final long jarTime = configuration.getBubbleJar().lastModified(); |
|
|
|
|
|
|
|
protected String loadTemplate(String defaultTemplate, String templatePath) { |
|
|
|
if (configuration.getEnvironment().containsKey("DEBUG_RULE_TEMPLATES")) { |
|
|
|
final File templateFile = new File(HOME_DIR + "/debugTemplates/" + templatePath); |
|
|
|
if (templateFile.exists()) { |
|
|
|
log.error("loadTemplate: debug file found (using it): "+abs(templateFile)); |
|
|
|
if (templateFile.exists() && templateFile.lastModified() > getJarTime()) { |
|
|
|
log.error("loadTemplate: debug file found and newer than bubble jar, using it: "+abs(templateFile)); |
|
|
|
return FileUtil.toStringOrDie(templateFile); |
|
|
|
} else { |
|
|
|
log.error("loadTemplate: debug file not found (using default): "+abs(templateFile)); |
|
|
|
log.error("loadTemplate: debug file not found or older than bubble jar, using default: "+abs(templateFile)); |
|
|
|
} |
|
|
|
} |
|
|
|
return defaultTemplate; |
|
|
@@ -185,7 +188,8 @@ public abstract class AbstractAppRuleDriver implements AppRuleDriver { |
|
|
|
ctx.put(siteJsInsertionVar, siteJs); |
|
|
|
} |
|
|
|
if (showIcon) { |
|
|
|
ctx.put(CTX_ICON_JS, HandlebarsUtil.apply(getHandlebars(), ICON_JS_TEMPLATE, ctx)); |
|
|
|
final String iconJs = loadTemplate(ICON_JS_TEMPLATE, ICON_JS_TEMPLATE_NAME); |
|
|
|
ctx.put(CTX_ICON_JS, HandlebarsUtil.apply(getHandlebars(), iconJs, ctx)); |
|
|
|
} |
|
|
|
return HandlebarsUtil.apply(getHandlebars(), bubbleJsTemplate, ctx); |
|
|
|
} |
|
|
|