Exemple #1
0
        public virtual IEnumerable <ModuleItemPath> AllThemeFiles(string moduleName, string themeName, out string themeRuleBody)
        {
            ModuleItemPath        themePath  = GetThemePath(moduleName, themeName);
            List <ModuleItemPath> themeFiles = new List <ModuleItemPath>();

            themeRuleBody = "";
            if (Directory.Exists(themePath.PhysicalPath))
            {
                var files         = Directory.EnumerateFiles(themePath.PhysicalPath, "*.css").Select(it => Path.GetFileName(it));
                var orderFilePath = Path.Combine(themePath.PhysicalPath, FileOrderHelper.OrderFileName);
                if (File.Exists(orderFilePath))
                {
                    files = FileOrderHelper.OrderFiles(orderFilePath, files);
                }

                foreach (var file in files)
                {
                    themeFiles.Add(new ModuleItemPath(themePath, file));
                }

                string themeBaseUrl = Kooboo.Web.Url.UrlUtility.ResolveUrl(themePath.VirtualPath);

                var themeRuleFiles = ThemeRuleParser.Parser.Parse(ThemeRuleBody(moduleName, themeName),
                                                                  (fileVirtualPath) => Kooboo.Web.Url.UrlUtility.Combine(themeBaseUrl, fileVirtualPath), out themeRuleBody);

                return(themeFiles.Where(it => !themeRuleFiles.Any(cf => cf.EqualsOrNullEmpty(it.EntryName, StringComparison.CurrentCultureIgnoreCase))));
            }
            return(new ModuleItemPath[0]);
        }
Exemple #2
0
        public virtual IEnumerable <StyleFile> AllStylesEnumerable(Site site, string themeName)
        {
            var theme = new Theme(site, themeName);

            var fileNames = EnumerateCssFilesWithPath(site, themeName);

            fileNames = FileOrderHelper.OrderFiles(GetOrderFile(site, themeName), fileNames);

            return(fileNames.Select(it => new StyleFile(theme, it).LastVersion()));
        }
Exemple #3
0
        public virtual IEnumerable <ModuleItemPath> AllScripts(string moduleName)
        {
            ModuleItemPath scriptsPath = new ModuleItemPath(moduleName, "Scripts");

            if (Directory.Exists(scriptsPath.PhysicalPath))
            {
                var files         = Directory.EnumerateFiles(scriptsPath.PhysicalPath, "*.js").Select(it => Path.GetFileName(it));
                var orderFilePath = Path.Combine(scriptsPath.PhysicalPath, FileOrderHelper.OrderFileName);
                if (File.Exists(orderFilePath))
                {
                    files = FileOrderHelper.OrderFiles(orderFilePath, files);
                }
                foreach (var file in files)
                {
                    yield return(new ModuleItemPath(scriptsPath, file));
                }
            }
        }
Exemple #4
0
        public virtual IEnumerable <FileEntry> GetFiles(Site site, string dirRelativePath)
        {
            var dir = GetDirectory(site, dirRelativePath);

            if (dir.Exists())
            {
                var files = EnumerateFiles(dir.PhysicalPath);
                files = FileOrderHelper.OrderFiles(FileOrderHelper.GetOrderFile(dir.PhysicalPath), files);
                return(files.Select(it => new FileInfo(Path.Combine(dir.PhysicalPath, it)))
                       .Select(it => new FileEntry(GetRootDir(site), GetRelativePath(dirRelativePath, it.Name))
                {
                    FileSize = it.Length,
                    Name = it.Name,
                    FileExtension = it.Extension,
                    FileName = it.FullName,
                    CreateDate = it.LastWriteTimeUtc
                }));
            }
            return(new FileEntry[0]);
        }