public virtual ActionResult ChangeHeaderBackground(string themeName) { var theme = new Theme(Site, themeName); ViewBag.VirtualPath = ServiceFactory.HeaderBackgroundManager.GetVirutalPath(theme); ViewBag.ContainerSize = ServiceFactory.HeaderBackgroundManager.GetContainerSize(Site); return View(); }
/// <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 void TestPhysicalPath() { string themeName = "theme1"; var site = new Site("Site1"); var theme = new Theme(site, themeName); string expected1 = Path.Combine(site.PhysicalPath, "themes", themeName); Assert.AreEqual(expected1, theme.PhysicalPath, true); }
public 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 void TestVirtualPath() { string themeName = "theme1"; var site = new Site("Site1"); var theme = new Theme(site, themeName); string expected1 = Kooboo.Web.Url.UrlUtility.Combine(site.VirtualPath, "themes", themeName); Assert.AreEqual(expected1, theme.VirtualPath, true); }
public void TestParseFromPhysicalPath() { string siteName = "site1"; string themeName = "theme1"; string physicalPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "sites", siteName, "themes", themeName); var theme = new Theme(physicalPath); Assert.AreEqual(themeName, theme.Name); Assert.IsTrue(theme.Site.IsDummy); Assert.AreEqual(siteName, theme.Site.Name); }
public override ActionResult Index(string directoryPath) { ViewData["Title"] = "Themes".Localize(); var themeName = ControllerContext.RequestContext.GetRequestValue("ThemeName"); if (!string.IsNullOrEmpty(themeName)) { var theme = new Theme(Site, themeName); ViewBag.Theme = theme; } return base.Index(directoryPath); }
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 IEnumerable<ThemeImageFile> AllImagesEnumerable(Theme theme) { List<ThemeImageFile> list = new List<ThemeImageFile>(); theme = theme.LastVersion(); if (theme.Exists()) { ThemeImageFile dummy = new ThemeImageFile(theme, "dummy"); var baseDir = dummy.BasePhysicalPath; if (Directory.Exists(baseDir)) { foreach (var file in Directory.EnumerateFiles(baseDir)) { list.Add(new ThemeImageFile(theme, Path.GetFileName(file))); } } } return list; }
public virtual bool IsEanbled(Theme theme) { return false; }
public virtual string GetVirutalPath(Theme theme) { return ""; }
public virtual void Change(Theme theme, string originalFile, int x, int y) { }
public StyleFile(Theme theme, string fileName) : base(theme, fileName) { }
public void Add(Theme item) { IOUtility.EnsureDirectoryExists(item.PhysicalPath); }
/// <summary> /// The appointed theme file url of site /// </summary> /// <param name="frontUrlHelper">The front url helper</param> /// <param name="themeName">the theme</param> /// <param name="relativeUrl">The relative theme file path of site</param> /// <returns></returns> public static IHtmlString ThemeFileUrl(this FrontUrlHelper frontUrlHelper, string baseUri, string themeName, string relativeUrl) { var site = Site.Current; string resourceDomain = site.ResourceDomain; IHtmlString url = new HtmlString(""); if (!string.IsNullOrEmpty(themeName)) { var fileExists = false; var themeFileUrl = ""; do { site = site.AsActual(); Theme theme = new Theme(site, themeName).LastVersion(); themeFileUrl = Kooboo.Web.Url.UrlUtility.Combine(theme.VirtualPath, relativeUrl); var physicalPath = HttpContext.Current.Server.MapPath(themeFileUrl); fileExists = File.Exists(physicalPath); site = theme.Site.Parent; } while (site != null && !fileExists); if (!string.IsNullOrEmpty(resourceDomain)) { baseUri = resourceDomain; } return new HtmlString(UrlUtility.ToHttpAbsolute(baseUri, themeFileUrl)); } return frontUrlHelper.ThemeFileUrl(baseUri, relativeUrl); }
/// <summary> /// The theme file url of site /// </summary> /// <param name="frontUrlHelper">The front url helper</param> /// <param name="site">The site</param> /// <param name="baseUri">Base uri</param> /// <param name="relativeThemeFilePath">The relative theme file path of site</param> /// <returns></returns> public static IHtmlString ThemeFileUrl(this FrontUrlHelper frontUrlHelper, Site site, string baseUri, string relativeThemeFilePath) { string resourceDomain = site.ResourceDomain; bool themeFileExists = false; string themeFileUrl = String.Empty; string themeFilePhysicalPath = String.Empty; do { site = site.AsActual(); Theme theme = new Theme(site, site.Theme).LastVersion(); themeFileUrl = UrlUtility.Combine(theme.VirtualPath, relativeThemeFilePath); themeFilePhysicalPath = HttpContext.Current.Server.MapPath(themeFileUrl); themeFileExists = File.Exists(themeFilePhysicalPath); site = theme.Site.Parent; } while (site != null && !themeFileExists); if (!String.IsNullOrEmpty(resourceDomain)) { baseUri = resourceDomain; // CDN have high priority } return new HtmlString(UrlUtility.ToHttpAbsolute(baseUri, themeFileUrl)); }
public void Update(Theme @new, Theme old) { }
public ThemeImageFile(Theme theme, string fileName) : base(theme, fileName) { }
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; }
public virtual ThemeRuleFile GetCssHack(Theme theme) { return GetCssHack(theme.Site, theme.Name); }
public IQueryable<ThemeImageFile> AllImages(Theme theme) { return AllImagesEnumerable(theme).AsQueryable(); }
public void Remove(Theme item) { System.IO.DirectoryInfo di = new DirectoryInfo(item.PhysicalPath); di.Delete(true); }
public Theme Get(Theme dummy) { throw new NotImplementedException(); }
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; }
public ThemeFile(Theme theme, string fileName) : base(theme.Site, fileName) { this.Theme = theme; }
public virtual IEnumerable<StyleFile> AllStyles(Theme theme) { return AllStylesEnumerable(theme.Site, theme.Name).AsQueryable(); }
public ThemeRuleFile(Theme theme) : base(theme, "Theme.rule") { }
/// <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 = Kooboo.Web.Url.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 virtual ActionResult SaveBackground(string themeName, string Url, int Width, int Height, int x, int y) { var theme = new Theme(Site, themeName); ServiceFactory.HeaderBackgroundManager.Change(theme, Url, x, y); var filePath = Server.MapPath(Url); if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } return Json(true); }