xiaoyong931011
2022-07-07 3d7afb3f26718b7c9a19f6926054a514ea6a4500
Merge branch 'master' of http://120.27.238.55:7000/r/farmer-cms
6 files modified
54 ■■■■■ changed files
src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java 34 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/core/node/Template.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/core/template/Configuration.java 1 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/core/template/TemplateConfiguration.java 6 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/CmsTemplateServiceImpl.java 5 ●●●●● patch | view | raw | blame | history
src/main/resources/application.yml 4 ●●●● patch | view | raw | blame | history
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;
@@ -71,14 +72,7 @@
        return false;
    }
    public void parser() {
        // 判断是否为最小节点,如果是且没有特殊标签,则跳过清空
        if (!isNeedEmpty()) {
            return;
        }
        this.element.empty();
    public void staticPath() {
        // 设置img的链接访问
        if ("img".equals(this.element.tagName())) {
            String src = this.element.attr("src");
@@ -86,6 +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();
        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<>();
src/main/java/com/xcong/farmer/cms/core/template/TemplateConfiguration.java
@@ -33,7 +33,7 @@
        this.templateLoader.data(map);
        Template template = template(templateName);
        template.output(this.outputPath);
        template.output(outputPath);
        // 判断是否有分页,有则执行。从第二页开始
        int i = 2;
@@ -41,13 +41,13 @@
            map.put("page", i);
            this.templateLoader.data(map);
            Template pageTemplate = template(templateName);
            pageTemplate.output(this.outputPath);
            pageTemplate.output(outputPath);
            i++;
        }
    }
    public Template template(String templateName) {
        return template(new File(path(this.templatePath) + templateName));
        return template(new File(path(templatePath) + templateName));
    }
    public Template template(File file) {
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/CmsTemplateServiceImpl.java
@@ -53,6 +53,7 @@
    public void updateTemplate(MultipartFile upload) {
        String templatePath = properties.getTemplatePath();
        String staticPath = properties.getStaticPath();
        Long companyId = LoginUserUtil.getCompanyId();
        String filename = upload.getOriginalFilename();
        String suffix = filename.substring(filename.lastIndexOf("."));
@@ -94,7 +95,7 @@
                    Document parse = Jsoup.parse(templateFile, null);
                    String attr = parse.head().attr("name");
                    CmsTemplateEntity cmsTemplate = new CmsTemplateEntity();
                    cmsTemplate.setCompanyId(10L);
                    cmsTemplate.setCompanyId(companyId);
                    if (name.endsWith(".list.html")) {
                        cmsTemplate.setType(2);
                    } else if (name.endsWith(".article.html")) {
@@ -116,7 +117,7 @@
                Document parse = Jsoup.parse(file, null);
                String attr = parse.head().attr("name");
                CmsTemplateEntity cmsTemplate = new CmsTemplateEntity();
                cmsTemplate.setCompanyId(LoginUserUtil.getCompanyId());
                cmsTemplate.setCompanyId(companyId);
                if (file.getName().endsWith(".list.html")) {
                    cmsTemplate.setType(2);
                } else if (file.getName().endsWith(".article.html")) {
src/main/resources/application.yml
@@ -98,8 +98,8 @@
cms:
  base-url: http://localhost
  static-url: http://localhost
  template-path: /Users/helius/Desktop/template/upload
  static-url: http://localhost/
  template-path: /Users/helius/Desktop/template
  static-path: /Users/helius/Desktop/static
  output-path: /Users/helius/Desktop/web/output