Пример #1
0
        public static void SetTemplateHtml(TemplateInfo templateInfo, string html)
        {
            var directoryPath = GetTemplatesDirectoryPath();
            var htmlPath      = ApplicationUtils.PathCombine(directoryPath, templateInfo.Name, templateInfo.Main);

            ApplicationUtils.WriteText(htmlPath, html);
            ClearCache(htmlPath);
        }
Пример #2
0
        public static void Clone(string nameToClone, TemplateInfo templateInfo, List <TemplateInfo> templateInfoList)
        {
            var directoryPath = Context.PluginApi.GetPluginPath(ApplicationUtils.PluginId, "templates");

            ApplicationUtils.CopyDirectory(ApplicationUtils.PathCombine(directoryPath, nameToClone), ApplicationUtils.PathCombine(directoryPath, templateInfo.Name), true);

            var configJson = ApplicationUtils.JsonSerialize(templateInfo);
            var configPath = ApplicationUtils.PathCombine(directoryPath, templateInfo.Name, "config.json");

            ApplicationUtils.WriteText(configPath, configJson);
        }
Пример #3
0
        public static void DeleteTemplate(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            var directoryPath = GetTemplatesDirectoryPath();
            var templatePath  = ApplicationUtils.PathCombine(directoryPath, name);

            ApplicationUtils.DeleteDirectoryIfExists(templatePath);
        }
Пример #4
0
        public static string GetTemplateHtml(TemplateInfo templateInfo)
        {
            var directoryPath = GetTemplatesDirectoryPath();
            var htmlPath      = ApplicationUtils.PathCombine(directoryPath, templateInfo.Name, templateInfo.Main);
            var html          = CacheUtils.Get <string>(htmlPath);

            if (html != null)
            {
                return(html);
            }

            html = ApplicationUtils.ReadText(htmlPath);

            CacheUtils.InsertHours(htmlPath, html, 1);
            return(html);
        }
Пример #5
0
        private static TemplateInfo GetTemplateInfo(string templatesDirectoryPath, string name)
        {
            TemplateInfo templateInfo;

            var configPath = ApplicationUtils.PathCombine(templatesDirectoryPath, name, "config.json");

            if (ApplicationUtils.IsFileExists(configPath))
            {
                templateInfo      = ApplicationUtils.JsonDeserialize <TemplateInfo>(ApplicationUtils.ReadText(configPath));
                templateInfo.Name = name;
            }
            else
            {
                templateInfo = new TemplateInfo
                {
                    Name = name
                };
            }

            return(templateInfo);
        }