예제 #1
0
파일: ThemeFile.cs 프로젝트: eyouyou/Bsc
        /// <summary>
        /// Parses the object.
        /// </summary>
        /// <param name="relativePaths">The relative paths. <example>{"site1","themes","default","style1.css"}</example></param>
        /// <returns>
        /// the remaining paths.<example>{"site1"}</example>
        /// </returns>
        public override IEnumerable<string> ParseObject(IEnumerable<string> relativePaths)
        {
            //call base return {"site1","themes","default"}
            relativePaths = base.ParseObject(relativePaths);

            this.Theme = new Theme();

            // return {"site1"}
            return this.Theme.ParseObject(relativePaths);
        }
예제 #2
0
파일: ThemeManager.cs 프로젝트: eyouyou/Bsc
        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());
        }
예제 #3
0
        public static IEnumerable<ThemeFile> Parse(Theme theme, out string themeRuleBody, string baseUri = null)
        {
            theme = theme.LastVersion();
            IEnumerable<ThemeFile> themeFiles = ServiceFactory.ThemeManager.AllStyles(theme);
            ThemeRuleFile cssHackFile = ServiceFactory.ThemeManager.GetCssHack(theme);
            if (cssHackFile == null || !cssHackFile.Exists())
            {
                themeRuleBody = "";
                return themeFiles;
            }

            var themeRuleFiles = Parser.Parse(cssHackFile.Read(), (fileVirtualPath) => UrlUtility.ToHttpAbsolute(baseUri, new ThemeFile(theme, fileVirtualPath).LastVersion().VirtualPath), out themeRuleBody);

            return themeFiles.Where(it => !themeRuleFiles.Any(cf => cf.EqualsOrNullEmpty(it.FileName, StringComparison.CurrentCultureIgnoreCase)));
        } 
예제 #4
0
 public virtual string GetVirutalPath(Theme theme)
 {
     return "";
 }
예제 #5
0
        public virtual void Change(Theme theme, string originalFile, int x, int y)
        {

        }
예제 #6
0
 public virtual bool IsEanbled(Theme theme)
 {
     return false;
 }
예제 #7
0
        /// <summary>
        /// the file URL under the theme of current site.
        /// </summary>
        /// <param name="relativeUrl">The relative URL.<example>images/logo.png</example></param>
        /// <returns></returns>
        public virtual IHtmlString ThemeFileUrl(string relativeUrl)
        {
            var site = this.Site;
            IHtmlString url = new HtmlString("");
            if (!string.IsNullOrEmpty(site.Name))
            {
                var fileExists = false;
                var themeFileUrl = "";
                do
                {
                    site = site.AsActual();

                    Theme theme = new Theme(site, site.Theme).LastVersion();
                    themeFileUrl = UrlUtility.Combine(theme.VirtualPath, relativeUrl);
                    var physicalPath = UrlUtility.MapPath(themeFileUrl);
                    fileExists = File.Exists(physicalPath);

                    site = theme.Site.Parent;
                } while (site != null && !fileExists);

                url = ResourceCDNUrl(themeFileUrl);
            }

            return url;
        }
예제 #8
0
파일: ThemeFile.cs 프로젝트: eyouyou/Bsc
 public ThemeFile(Theme theme, string fileName)
     : base(theme.Site, fileName)
 {
     this.Theme = theme;
 }
예제 #9
0
파일: ThemeManager.cs 프로젝트: eyouyou/Bsc
 public virtual ThemeRuleFile GetCssHack(Theme theme)
 {
     return GetCssHack(theme.Site, theme.Name);
 }
예제 #10
0
파일: ThemeManager.cs 프로젝트: eyouyou/Bsc
 public virtual IEnumerable<StyleFile> AllStyles(Theme theme)
 {
     return AllStylesEnumerable(theme.Site, theme.Name).AsQueryable();
 }
예제 #11
0
파일: ThemeManager.cs 프로젝트: eyouyou/Bsc
 private ThemeRuleFile GetCssHack(Site site, string themeName)
 {
     while (site != null)
     {
         var theme = new Theme(site, themeName);
         var themeRuleFile = new ThemeRuleFile(theme);
         if (themeRuleFile.Exists())
         {
             return themeRuleFile;
         }
         site = site.Parent;
     }
     return null;
 }
예제 #12
0
파일: ThemeManager.cs 프로젝트: eyouyou/Bsc
        private IEnumerable<string> EnumerateCssFilesWithPath(Site site, string themeName)
        {
            List<string> results = new List<string>();

            while (site != null)
            {
                Theme theme = new Theme(site, themeName);
                var baseDir = theme.PhysicalPath;
                if (Directory.Exists(baseDir))
                {
                    var tempResults = EnumerateCssFiles(baseDir);
                    if (results.Count == 0)
                    {
                        results.AddRange(tempResults);
                    }
                    else
                    {
                        foreach (var item in tempResults)
                        {
                            if (!results.Any(it => Path.GetFileName(it).Equals(Path.GetFileName(item), StringComparison.InvariantCultureIgnoreCase)))
                            {
                                results.Add(item);
                            }
                        }
                    }
                }
                site = site.Parent;
            }
            return results;
        }