Ejemplo n.º 1
0
        public async void ActivateThemeAsync_registers_theme_if_not_already_exist()
        {
            // Given
            // "mytheme" meta record not exist
            var myTheme = new MyTheme();

            metaRepoMock.Setup(repo => repo.GetAsync("mytheme", EMetaType.Theme)).Returns(Task.FromResult((Meta)null));

            // When
            await themeService.ActivateThemeAsync(myTheme.Folder);

            // Then
            // mytheme meta record is create
            var metaTheme = new Meta
            {
                Key   = "mytheme",
                Value = "",
                Type  = EMetaType.Theme
            };

            metaRepoMock.Verify(repo =>
                                repo.CreateAsync(It.Is <Meta>(m =>
                                                              m.Key == metaTheme.Key &&
                                                              m.Value == metaTheme.Value &&
                                                              m.Type == metaTheme.Type)),
                                Times.Once);
        }
Ejemplo n.º 2
0
        public async void When_user_activates_a_theme_the_theme_and_its_defined_widget_areas_will_be_registered()
        {
            // When user activates a theme
            await _svc.ActivateThemeAsync("Clarity");

            // Then the theme is registered
            var metaTheme = await _metaRepo.GetAsync("clarity", EMetaType.Theme);

            var metaArea = await _metaRepo.GetAsync("clarity-my-area", EMetaType.WidgetAreaByTheme);

            Assert.Equal("clarity", metaTheme.Key);
            Assert.Equal("clarity-my-area", metaArea.Key);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Activiates the default Clarity theme, registers system-defined widget areas,
        /// then load some widgets.
        /// </summary>
        private async Task SetupThemeAndWidgets()
        {
            // Clarity theme
            await _themeService.ActivateThemeAsync("Clarity");

            // System-defined Areas
            await _widgetSvc.RegisterAreaAsync(WidgetService.BlogSidebar1.Id);

            await _widgetSvc.RegisterAreaAsync(WidgetService.BlogSidebar2.Id);

            await _widgetSvc.RegisterAreaAsync(WidgetService.BlogBeforePost.Id);

            await _widgetSvc.RegisterAreaAsync(WidgetService.BlogAfterPost.Id);

            await _widgetSvc.RegisterAreaAsync(WidgetService.BlogBeforePostList.Id);

            await _widgetSvc.RegisterAreaAsync(WidgetService.BlogAfterPostList.Id);

            await _widgetSvc.RegisterAreaAsync(WidgetService.Footer1.Id);

            await _widgetSvc.RegisterAreaAsync(WidgetService.Footer2.Id);

            await _widgetSvc.RegisterAreaAsync(WidgetService.Footer3.Id);

            // Area: BlogSidebar1

            // Social Icons
            var socialIconsWidget = new SocialIconsWidget {
                Links = SocialIconsWidget.SocialLinkSeeds
            };
            var widgetInstId = await _widgetSvc.CreateWidgetAsync(socialIconsWidget, "SocialIcons");

            await _widgetSvc.AddWidgetToAreaAsync(widgetInstId, WidgetService.BlogSidebar1.Id, 0);

            // Blog Tags
            widgetInstId = await _widgetSvc.CreateWidgetAsync("BlogTags");

            await _widgetSvc.AddWidgetToAreaAsync(widgetInstId, WidgetService.BlogSidebar1.Id, 1);

            // Blog Categories
            widgetInstId = await _widgetSvc.CreateWidgetAsync("BlogCategories");

            await _widgetSvc.AddWidgetToAreaAsync(widgetInstId, WidgetService.BlogSidebar1.Id, 2);

            // Blog Archives
            widgetInstId = await _widgetSvc.CreateWidgetAsync("BlogArchives");

            await _widgetSvc.AddWidgetToAreaAsync(widgetInstId, WidgetService.BlogSidebar1.Id, 3);

            // Area: BlogAfterPost

            // Recent Blog Posts
            var recentBlogPostsWidget = new RecentBlogPostsWidget {
                ShowPostExcerpt = true
            };

            widgetInstId = await _widgetSvc.CreateWidgetAsync(recentBlogPostsWidget, "RecentBlogPosts");

            await _widgetSvc.AddWidgetToAreaAsync(widgetInstId, WidgetService.BlogAfterPost.Id, 0);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Setup theme and 3 areas (1 theme defined, 2 system defined).
        /// </summary>
        /// <returns></returns>
        public async Task InitializeAsync()
        {
            await _svc.RegisterAreaAsync(WidgetService.BlogSidebar1.Id);

            await _svc.RegisterAreaAsync(WidgetService.BlogSidebar2.Id);

            await themeService.ActivateThemeAsync("Clarity");
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Activiates the default Clarity theme and plugins and registers system-defined widget areas,
        /// then load some widgets.
        /// </summary>
        private async Task SetupThemePluginsAndWidgetsAsync()
        {
            // Clarity theme
            await _themeService.ActivateThemeAsync("Clarity");

            // Activate plugins

            await pluginService.ActivatePluginAsync("Editor.md");

            await pluginService.ActivatePluginAsync("ForkMeRibbon");

            await pluginService.ActivatePluginAsync("Shortcodes");

            // System-defined Areas
            await _widgetSvc.RegisterAreaAsync(WidgetService.BlogSidebar1.Id);

            await _widgetSvc.RegisterAreaAsync(WidgetService.BlogSidebar2.Id);

            await _widgetSvc.RegisterAreaAsync(WidgetService.BlogBeforePost.Id);

            await _widgetSvc.RegisterAreaAsync(WidgetService.BlogAfterPost.Id);

            await _widgetSvc.RegisterAreaAsync(WidgetService.BlogBeforePostList.Id);

            await _widgetSvc.RegisterAreaAsync(WidgetService.BlogAfterPostList.Id);

            await _widgetSvc.RegisterAreaAsync(WidgetService.PageSidebar1.Id);

            await _widgetSvc.RegisterAreaAsync(WidgetService.PageSidebar2.Id);

            await _widgetSvc.RegisterAreaAsync(WidgetService.PageBeforeContent.Id);

            await _widgetSvc.RegisterAreaAsync(WidgetService.PageAfterContent.Id);

            await _widgetSvc.RegisterAreaAsync(WidgetService.Footer1.Id);

            await _widgetSvc.RegisterAreaAsync(WidgetService.Footer2.Id);

            await _widgetSvc.RegisterAreaAsync(WidgetService.Footer3.Id);

            // Area: BlogSidebar1

            // Social Icons
            var socialIconsWidget = new SocialIconsWidget {
                Links = SocialIconsWidget.SocialLinkSeeds
            };
            var socialIconsWidgetInstId = await _widgetSvc.CreateWidgetAsync(socialIconsWidget, "SocialIcons");

            await _widgetSvc.AddWidgetToAreaAsync(socialIconsWidgetInstId, WidgetService.BlogSidebar1.Id, 0);

            // Blog Tags
            var blogTagsWidgetInstId = await _widgetSvc.CreateWidgetAsync("BlogTags");

            await _widgetSvc.AddWidgetToAreaAsync(blogTagsWidgetInstId, WidgetService.BlogSidebar1.Id, 1);

            // Blog Categories
            var blogCatsWidgetInstId = await _widgetSvc.CreateWidgetAsync("BlogCategories");

            await _widgetSvc.AddWidgetToAreaAsync(blogCatsWidgetInstId, WidgetService.BlogSidebar1.Id, 2);

            // Blog Archives
            var blogArchivesWidgetInstId = await _widgetSvc.CreateWidgetAsync("BlogArchives");

            await _widgetSvc.AddWidgetToAreaAsync(blogArchivesWidgetInstId, WidgetService.BlogSidebar1.Id, 3);

            // Area: BlogAfterPost

            // Recent Blog Posts
            var recentBlogPostsWidgetInstId = await _widgetSvc.CreateWidgetAsync("RecentBlogPosts");

            await _widgetSvc.AddWidgetToAreaAsync(recentBlogPostsWidgetInstId, WidgetService.BlogAfterPost.Id, 0);

            // Area: PageSidebar1

            // Social Icons
            socialIconsWidgetInstId = await _widgetSvc.CreateWidgetAsync(socialIconsWidget, "SocialIcons");

            await _widgetSvc.AddWidgetToAreaAsync(socialIconsWidgetInstId, WidgetService.PageSidebar1.Id, 0);

            // Recent Blog Posts
            recentBlogPostsWidgetInstId = await _widgetSvc.CreateWidgetAsync("RecentBlogPosts");

            await _widgetSvc.AddWidgetToAreaAsync(recentBlogPostsWidgetInstId, WidgetService.PageSidebar1.Id, 1);

            // Area: PageSidebar2

            // Page Navigation
            var pageNavWidgetInstId = await _widgetSvc.CreateWidgetAsync("PageNavigation");

            await _widgetSvc.AddWidgetToAreaAsync(pageNavWidgetInstId, WidgetService.PageSidebar2.Id, 0);

            _logger.LogInformation("Theme and widgets created");
        }