/// <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); }
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()); }
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))); }
public virtual string GetVirutalPath(Theme theme) { return ""; }
public virtual void Change(Theme theme, string originalFile, int x, int y) { }
public virtual bool IsEanbled(Theme theme) { return false; }
/// <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; }
public ThemeFile(Theme theme, string fileName) : base(theme.Site, fileName) { this.Theme = theme; }
public virtual ThemeRuleFile GetCssHack(Theme theme) { return GetCssHack(theme.Site, theme.Name); }
public virtual IEnumerable<StyleFile> AllStyles(Theme theme) { return AllStylesEnumerable(theme.Site, theme.Name).AsQueryable(); }
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; }
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; }