fix
Helius
2022-07-07 08e5cfa5651c15a79bcbcff2b04a1dda6c5c961b
fix
4 files modified
33 ■■■■■ changed files
src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java 18 ●●●●● 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
@@ -71,6 +71,16 @@
        return false;
    }
    public void staticPath() {
        // 设置img的链接访问
        if ("img".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() {
        // 判断是否为最小节点,如果是且没有特殊标签,则跳过清空
        if (!isNeedEmpty()) {
@@ -79,13 +89,7 @@
        this.element.empty();
        // 设置img的链接访问
        if ("img".equals(this.element.tagName())) {
            String src = this.element.attr("src");
            if (StrUtil.isNotBlank(STATIC_URL)) {
                this.element.attr("src", STATIC_URL + src);
            }
        }
        staticPath();
        Attributes attributes = this.element.attributes();
        if (attributes.isEmpty()) {
            return;
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