示例#1
0
        public ActionResult Index()
        {
            string themeDir   = Path.Combine(AppContext.BaseDirectory, "Views", "Themes");
            var    fileThemes = Directory.Exists(themeDir) ? new DirectoryInfo(themeDir).GetDirectories().Select(x => new SelectListItem {
                Text = x.Name
            }) : Enumerable.Empty <SelectListItem>();

            var themePrefix         = "Views_Themes_";
            var themePrefixLength   = themePrefix.Length;
            var compiledViewsThemes = CompiledViewsHelper.GetAllViews()
                                      .Where(x => x.Name.StartsWith(themePrefix))
                                      .Select(x => x.Name.Substring(themePrefixLength))
                                      .Select(x => x.Contains('_') ? x.Substring(0, x.IndexOf("_")) : x)
                                      .Select(x => new SelectListItem {
                Text = x
            }).ToList();

            AdminBasicSettings viewModel = new AdminBasicSettings
            {
                BlogName        = settingRepository.BlogName,
                BlogDescription = settingRepository.BlogDescription,
                Theme           = settingRepository.Theme,
                Themes          = fileThemes.Concat(compiledViewsThemes),
                PostsPerPage    = settingRepository.PostsPerPage,
                TimeZoneId      = settingRepository.TimeZone.Id,
                TimeZones       = TimeZoneInfo.GetSystemTimeZones().Select(x => new SelectListItem {
                    Text = x.DisplayName, Value = x.Id
                }),
                Language = settingRepository.Culture,
                ApplicationInsightsInstrumentationKey = settingRepository.ApplicationInsightsInstrumentationKey,
                CustomCode = settingRepository.CustomCode,
            };

            return(View(viewModel));
        }
示例#2
0
        public WidgetViewComponent(FujiyBlogDatabase db, WidgetSettingRepository widgetSettingRepository)
        {
            this.db = db;
            this.widgetSettingRepository = widgetSettingRepository;

            if (widgets == null || widgets.Length == 0)
            {
                var widgetsViews = CompiledViewsHelper.GetViewsTypes <WidgetSetting>();

                widgets = (from widgetView in widgetsViews
                           let nameWithoutPrefix = widgetView.Name.Substring("Views_Shared_Components_Widget_".Length)
                                                   where nameWithoutPrefix != "Index" && nameWithoutPrefix != "Widget" && !nameWithoutPrefix.EndsWith("Edit")
                                                   select nameWithoutPrefix).ToArray();
            }
        }