示例#1
0
        private string ThemeRuleBody(string moduleName, string themeName)
        {
            ModuleEntryPath themePath     = GetThemePath(moduleName, themeName);
            ModuleEntryPath themeRuleFile = new ModuleEntryPath(themePath, "Theme.rule");

            if (File.Exists(themeRuleFile.PhysicalPath))
            {
                return(File.ReadAllText(themeRuleFile.PhysicalPath));
            }
            return(string.Empty);
        }
示例#2
0
        public virtual IEnumerable <ModuleEntryPath> AllScripts(string moduleName)
        {
            ModuleEntryPath scriptsPath = new ModuleEntryPath(moduleName, "Scripts");

            if (Directory.Exists(scriptsPath.PhysicalPath))
            {
                foreach (var file in Directory.EnumerateFiles(scriptsPath.PhysicalPath, "*.js"))
                {
                    yield return(new ModuleEntryPath(scriptsPath, Path.GetFileName(file)));
                }
            }
        }
示例#3
0
        //public bool Verify(string moduleName)
        //{
        //    if (!File.Exists(RouteTables.GetRoutesFilePath(moduleName).PhysicalPath))
        //    {
        //        return false;
        //    }
        //    if (!File.Exists(ModuleInfo.GetModuleInfoPath(moduleName).PhysicalPath))
        //    {
        //        return false;
        //    }
        //    return true;
        //}
        //public bool Verify(ZipFile zipFile)
        //{
        //    var moduleConfigEntry = zipFile[RouteTables.RouteFile];
        //    var routesConfigEntry = zipFile[ModuleInfo.ModuleInfoFileName];
        //    if (moduleConfigEntry == null || routesConfigEntry == null)
        //    {
        //        return false;
        //    }
        //    return true;
        //}
        //public void Upload(string moduleName, Stream zipStream, bool @override)
        //{
        //    if (!@override && All().Any(it => it.EqualsOrNullEmpty(moduleName, StringComparison.CurrentCultureIgnoreCase)))
        //    {
        //        throw new KoobooException(string.Format("The module '{0}' already exists.", moduleName));
        //    }

        //    ModulePath modulePath = new ModulePath(moduleName);
        //    using (ZipFile zipFile = ZipFile.Read(zipStream))
        //    {
        //        if (!Verify(zipFile))
        //        {
        //            throw new KoobooException("The module is invalid.");
        //        }
        //        var webconfigEntry = zipFile["web.config"];
        //        if (webconfigEntry != null)
        //        {
        //            zipFile.RemoveEntry(webconfigEntry);
        //        }

        //        zipFile.ExtractAll(modulePath.PhysicalPath, ExtractExistingFileAction.OverwriteSilently);
        //    }
        //}

        public virtual IEnumerable <string> All()
        {
            var baseDirectory = ModulePath.BaseDirectory;

            if (Directory.Exists(baseDirectory))
            {
                foreach (var dir in IO.IOUtility.EnumerateDirectoriesExludeHidden(baseDirectory))
                {
                    var moduleName = dir.Name;

                    var moduleConfigFile = new ModuleEntryPath(moduleName, ModuleInfo.ModuleInfoFileName);

                    if (File.Exists(moduleConfigFile.PhysicalPath))
                    {
                        yield return(moduleName);
                    }
                }
            }
        }
示例#4
0
        public virtual IEnumerable <ModuleEntryPath> AllThemeFiles(string moduleName, string themeName, out string themeRuleBody)
        {
            ModuleEntryPath        themePath  = GetThemePath(moduleName, themeName);
            List <ModuleEntryPath> themeFiles = new List <ModuleEntryPath>();

            themeRuleBody = "";
            if (Directory.Exists(themePath.PhysicalPath))
            {
                foreach (var file in Directory.EnumerateFiles(themePath.PhysicalPath, "*.css"))
                {
                    themeFiles.Add(new ModuleEntryPath(themePath, Path.GetFileName(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 ModuleEntryPath[0]);
        }
示例#5
0
            private static string GetSitesModuleRelationDataFile(string moduleName)
            {
                ModuleEntryPath entryPath = new ModuleEntryPath(moduleName, "Sites.config");

                return(entryPath.PhysicalPath);
            }