Преглед изворни кода

allow icon js debug loading. only load debug template if newer than jar

pull/44/head
Jonathan Cobb пре 4 година
родитељ
комит
628df3bf35
2 измењених фајлова са 10 додато и 5 уклоњено
  1. +8
    -4
      bubble-server/src/main/java/bubble/rule/AbstractAppRuleDriver.java
  2. +2
    -1
      bubble-server/src/main/java/bubble/rule/RequestModifierRule.java

+ 8
- 4
bubble-server/src/main/java/bubble/rule/AbstractAppRuleDriver.java Прегледај датотеку

@@ -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);
}


+ 2
- 1
bubble-server/src/main/java/bubble/rule/RequestModifierRule.java Прегледај датотеку

@@ -12,6 +12,7 @@ public interface RequestModifierRule {
RequestModifierConfig getRequestModifierConfig ();

Class<RequestModifierRule> RMR = RequestModifierRule.class;
String ICON_JS_TEMPLATE = stream2string(getPackagePath(RMR)+"/"+ RMR.getSimpleName()+"_icon.js.hbs");
String ICON_JS_TEMPLATE_NAME = RMR.getSimpleName() + "_icon.js.hbs";
String ICON_JS_TEMPLATE = stream2string(getPackagePath(RMR) + "/" + ICON_JS_TEMPLATE_NAME);

}

Loading…
Откажи
Сачувај