List <ThemeItem> GetThemes() { var themes = new List <ThemeItem>(); var themeList = _store.GetThemes(); if (themeList != null && themeList.Count > 0) { var current = new ThemeItem(); foreach (var themeTitle in themeList) { var theme = themeTitle.ToLower(); var file = Path.Join(AppSettings.WebRootPath, "themes", theme, Constants.ThemeScreenshot); var data = Path.Join(AppSettings.WebRootPath, "themes", theme, "assets", Constants.ThemeDataFile); var item = new ThemeItem { Title = themeTitle, Cover = System.IO.File.Exists(file) ? $"themes/{theme}/{Constants.ThemeScreenshot}" : Constants.ImagePlaceholder, IsCurrent = theme == _blog.Theme.ToLower(), HasSettings = System.IO.File.Exists(data) }; if (theme == _blog.Theme.ToLower()) { current = item; } else { themes.Add(item); } } themes.Insert(0, current); } return(themes); }
List <ThemeItem> GetThemes() { var themes = new List <ThemeItem>(); var combined = new List <string>(); var storageThemes = _store.GetThemes(); if (storageThemes != null) { combined.AddRange(storageThemes); } if (AppConfig.EmbeddedThemes != null) { combined.AddRange(AppConfig.EmbeddedThemes); } combined = combined.Distinct().ToList(); combined.Sort(); if (combined != null && combined.Count > 0) { var current = new ThemeItem(); foreach (var themeTitle in combined) { var theme = themeTitle.ToLower(); var slash = Path.DirectorySeparatorChar.ToString(); var file = $"{AppSettings.WebRootPath}{slash}themes{slash}{theme}{slash}{Constants.ThemeScreenshot}"; var data = $"{AppSettings.WebRootPath}{slash}themes{slash}{theme}{slash}assets{slash}{Constants.ThemeDataFile}"; var item = new ThemeItem { Title = themeTitle, Cover = System.IO.File.Exists(file) ? $"themes/{theme}/{Constants.ThemeScreenshot}" : Constants.ImagePlaceholder, IsCurrent = theme == _blog.Theme.ToLower(), HasSettings = System.IO.File.Exists(data) }; if (theme == _blog.Theme.ToLower()) { current = item; } else { themes.Add(item); } } themes.Insert(0, current); } return(themes); }
List <ThemeItem> GetThemes() { var themes = new List <ThemeItem>(); var combined = new List <string>(); var storageThemes = _store.GetThemes(); if (storageThemes != null) { combined.AddRange(storageThemes); } if (AppConfig.EmbeddedThemes != null) { combined.AddRange(AppConfig.EmbeddedThemes); } combined = combined.Distinct().ToList(); combined.Sort(); if (combined != null && combined.Count > 0) { var current = new ThemeItem(); foreach (var theme in combined) { var slash = Path.DirectorySeparatorChar.ToString(); var file = $"{AppSettings.WebRootPath}{slash}themes{slash}{theme}{slash}{theme}.png"; var item = new ThemeItem { Title = theme, Cover = System.IO.File.Exists(file) ? $"themes/{theme}/{theme}.png" : "lib/img/img-placeholder.png", IsCurrent = theme == _blog.Theme }; if (theme == _blog.Theme) { current = item; } else { themes.Add(item); } } themes.Insert(0, current); } return(themes); }
List <ThemeItem> GetThemes() { var themes = new List <ThemeItem>(); var themeList = _store.GetThemes(); if (themeList != null && themeList.Count > 0) { var current = new ThemeItem(); foreach (var themeTitle in themeList) { var theme = themeTitle.ToLower(); var slash = Path.DirectorySeparatorChar.ToString(); var file = $"{AppSettings.WebRootPath}{slash}themes{slash}{theme}{slash}{Constants.ThemeScreenshot}"; var data = $"{AppSettings.WebRootPath}{slash}themes{slash}{theme}{slash}assets{slash}{Constants.ThemeDataFile}"; var item = new ThemeItem { Title = themeTitle, Cover = System.IO.File.Exists(file) ? $"themes/{theme}/{Constants.ThemeScreenshot}" : Constants.ImagePlaceholder, IsCurrent = theme == _blog.Theme.ToLower(), HasSettings = System.IO.File.Exists(data) }; if (theme == _blog.Theme.ToLower()) { current = item; } else { themes.Add(item); } } themes.Insert(0, current); } return(themes); }