Esempio n. 1
0
        public async void ActivatePluginAsync_on_plugin_that_is_not_active()
        {
            // Arrange a plugin meta
            var key      = "myplugin";
            var myPlugin = new MyPlugin();
            var meta     = new Meta {
                Id = 1, Key = key, Value = JsonConvert.SerializeObject(myPlugin), Type = EMetaType.Plugin
            };

            metaRepoMock.Setup(repo => repo.GetAsync(key, EMetaType.Plugin)).Returns(Task.FromResult(meta));
            metaRepoMock.Setup(repo => repo.GetAsync(1)).Returns(Task.FromResult(meta));

            // Act when user activates it
            var plugin = await pluginService.ActivatePluginAsync(myPlugin.Folder);

            // Assert the plugin is updated at datasource
            metaRepoMock.Verify(repo => repo.UpdateAsync(It.IsAny <Meta>()), Times.Once);
        }
Esempio n. 2
0
        /// <summary>
        /// Activates plugins.
        /// </summary>
        /// <remarks>
        /// Currently since I don't have the installation step for plugins yet, unactivated plugins
        /// that have a settings page when you activate it for the first time, the settings icon is
        /// not shown immediately.
        /// </remarks>
        private async Task SetupPluginsAsync()
        {
            await pluginService.ActivatePluginAsync("ForkMeRibbon");

            await pluginService.ActivatePluginAsync("Shortcodes");
        }
Esempio n. 3
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");
        }
Esempio n. 4
0
        public async Task <IActionResult> OnPostActivateAsync([FromBody] PluginDto dto)
        {
            var id = await pluginService.ActivatePluginAsync(dto.Folder);

            return(new JsonResult(id));
        }