| | |
| | | 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()) { |
| | |
| | | |
| | | 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; |
| | |
| | | |
| | | this.templateLoader.data(map); |
| | | Template template = template(templateName); |
| | | template.output(this.outputPath); |
| | | template.output(outputPath); |
| | | |
| | | // 判断是否有分页,有则执行。从第二页开始 |
| | | int i = 2; |
| | |
| | | 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) { |
| | |
| | | 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(".")); |
| | |
| | | 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")) { |
| | |
| | | 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")) { |
| | |
| | | |
| | | 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 |
| | | |