src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java
@@ -7,6 +7,7 @@ import com.xcong.farmer.cms.core.handler.DataParserHandler; import com.xcong.farmer.cms.core.tag.TagsEnum; import com.xcong.farmer.cms.core.template.Configuration; import com.xcong.farmer.cms.core.template.TemplateConfiguration; import groovy.lang.Binding; import groovy.lang.GroovyShell; import org.apache.commons.text.StringSubstitutor; @@ -79,17 +80,30 @@ this.element.attr("src", STATIC_URL + src); } } if ("link".equals(this.element.tagName())) { String src = this.element.attr("href"); if (StrUtil.isNotBlank(STATIC_URL)) { this.element.attr("href", STATIC_URL + src); } } if ("script".equals(this.element.tagName())) { String src = this.element.attr("src"); if (StrUtil.isNotBlank(STATIC_URL)) { this.element.attr("src", STATIC_URL + src); } } } public void parser() { staticPath(); // 判断是否为最小节点,如果是且没有特殊标签,则跳过清空 if (!isNeedEmpty()) { return; } this.element.empty(); staticPath(); Attributes attributes = this.element.attributes(); if (attributes.isEmpty()) { return; src/main/java/com/xcong/farmer/cms/core/node/Template.java
@@ -77,7 +77,7 @@ } public void parser() { Elements children = document.body().children(); Elements children = document.children(); if (CollUtil.isNotEmpty(children)) { for (Element child : children) { PartNode partNode = new PartNode(child, this.system); @@ -96,7 +96,7 @@ for (PartNode partNode : partNodes) { sb.append(partNode.getHtml()); } document.body().empty().html(sb.toString()); document = Jsoup.parse(sb.toString()); String outPath = path(outputPath); String html = document.html(); src/main/java/com/xcong/farmer/cms/core/template/Configuration.java
@@ -20,6 +20,7 @@ Configuration.templatePath = templatePath; Configuration.outputPath = outputPath; Configuration.BASE_URL = baseUrl; Configuration.STATIC_URL = staticUrl; } public static Map<String, String> templateCode = new HashMap<>();