| | |
| | | @Bean |
| | | public TemplateConfiguration templateConfiguration() { |
| | | log.info("CMS管理系统"); |
| | | TemplateConfiguration cfg = new TemplateConfiguration(cmsProperties.getTemplatePath(), cmsProperties.getStaticPath(), cmsProperties.getOutputPath()); |
| | | TemplateConfiguration cfg = new TemplateConfiguration(cmsProperties.getTemplatePath(), cmsProperties.getStaticPath(), cmsProperties.getOutputPath(), cmsProperties.getBaseUrl(), cmsProperties.getStaticUrl()); |
| | | TemplateLoader loader = new TemplateLoader(cfg); |
| | | cfg.templateLoader(loader); |
| | | return cfg; |
| | |
| | | |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.xcong.farmer.cms.core.handler.DataParserHandler; |
| | | import com.xcong.farmer.cms.core.tag.TagsEnum; |
| | |
| | | } |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | Attributes attributes = this.element.attributes(); |
| | | if (attributes.isEmpty()) { |
| | | return; |
| | |
| | | |
| | | public abstract class Configuration { |
| | | |
| | | public String staticPath; |
| | | public String templatePath; |
| | | public String outputPath; |
| | | protected static String BASE_URL; |
| | | protected static String STATIC_URL; |
| | | protected static String staticPath; |
| | | protected static String templatePath; |
| | | protected static String outputPath; |
| | | |
| | | public Configuration() { |
| | | } |
| | | |
| | | public Configuration(String templatePath, String staticPath, String outputPath) { |
| | | this.staticPath = staticPath; |
| | | this.templatePath = templatePath; |
| | | this.outputPath = outputPath; |
| | | public Configuration(String templatePath, String staticPath, String outputPath, String baseUrl, String staticUrl) { |
| | | Configuration.staticPath = staticPath; |
| | | Configuration.templatePath = templatePath; |
| | | Configuration.outputPath = outputPath; |
| | | Configuration.BASE_URL = baseUrl; |
| | | } |
| | | |
| | | public static Map<String, String> templateCode = new HashMap<>(); |
| | |
| | | |
| | | private TemplateLoader templateLoader; |
| | | |
| | | public TemplateConfiguration(String templatePath, String staticPath, String outputPath) { |
| | | super(templatePath, staticPath, outputPath); |
| | | public TemplateConfiguration(String templatePath, String staticPath, String outputPath, String baseUrl, String staticUrl) { |
| | | super(templatePath, staticPath, outputPath, baseUrl, staticUrl); |
| | | } |
| | | |
| | | public void templateLoader(TemplateLoader templateLoader) { |
| | |
| | | public class CmsTemplateServiceImpl extends ServiceImpl<CmsTemplateMapper, CmsTemplateEntity> implements ICmsTemplateService { |
| | | |
| | | @Autowired |
| | | private TemplateConfiguration cfg; |
| | | private CmsProperties properties; |
| | | |
| | | private List<String> fileSuffix = Arrays.asList(".zip", ".html"); |
| | | |
| | | @Override |
| | | public void updateTemplate(MultipartFile upload) { |
| | | String templatePath = cfg.templatePath; |
| | | String staticPath = cfg.staticPath; |
| | | String templatePath = properties.getTemplatePath(); |
| | | String staticPath = properties.getStaticPath(); |
| | | |
| | | String filename = upload.getOriginalFilename(); |
| | | String suffix = filename.substring(filename.lastIndexOf(".")); |
| | |
| | | |
| | | for (File templateFile : files) { |
| | | if (!templateFile.isFile()) { |
| | | FileUtil.move(templateFile, new File(FileUtils.path(staticPath, templateFile.getName())), true); |
| | | continue; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | String name = templateFile.getName(); |
| | | if (!name.endsWith(".list.html") && !name.endsWith(".article.html") && !name.endsWith(".index.html")) { |
| | | if (!name.endsWith(".list.html") && !name.endsWith(".article.html") && !name.endsWith("index.html")) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | path: /home/javaweb/webresource/uploadeFile/image/ |
| | | |
| | | cms: |
| | | base-url: http://localhost |
| | | static-url: http://localhost |
| | | template-path: /Users/helius/Desktop/template |
| | | static-path: |
| | | output-path: /Users/helius/Desktop/web/output |
| | | base-url: http://120.27.238.55:8000/cms/output |
| | | static-url: http://120.27.238.55:8000/cms/static |
| | | template-path: /home/javaweb/webresource/cms/template |
| | | static-path: /home/javaweb/webresource/cms/static |
| | | output-path: /home/javaweb/webresource/cms/output |
| | | |
| | |
| | | cms: |
| | | base-url: http://localhost |
| | | static-url: http://localhost |
| | | template-path: /Users/helius/Desktop/template |
| | | static-path: |
| | | template-path: /Users/helius/Desktop/template/upload |
| | | static-path: /Users/helius/Desktop/static |
| | | output-path: /Users/helius/Desktop/web/output |
| | | |