public void AddComplex() { using (var api = new Api(GetDb(), null)) { var builder = new PageTypeBuilder(api) .AddType(typeof(ComplexPageType)); builder.Build(); var type = api.PageTypes.GetById("Complex"); Assert.NotNull(type); Assert.Equal(2, type.Regions.Count); Assert.Equal("Slider", type.Regions[0].Id); Assert.Equal("Intro", type.Regions[0].Title); Assert.True(type.Regions[0].Collection); Assert.Equal(1, type.Regions[0].Fields.Count); Assert.Equal("Content", type.Regions[1].Id); Assert.Equal("Main content", type.Regions[1].Title); Assert.False(type.Regions[1].Collection); Assert.Equal(2, type.Regions[1].Fields.Count); Assert.Equal(1, type.Routes.Count); Assert.Equal("/complex", type.Routes[0]); } }
protected override void Init() { using (var api = new Api(GetDb(), new ContentServiceFactory(services), storage)) { // Initialize Piranha.App.Init(); var pageTypeBuilder = new PageTypeBuilder(api) .AddType(typeof(BlogPage)); pageTypeBuilder.Build(); // Add site var site = new Data.Site() { Id = SITE_ID, Title = "Hook Site", IsDefault = true }; api.Sites.Save(site); // Add blog page var page = BlogPage.Create(api); page.Id = BLOG_ID; page.SiteId = SITE_ID; page.Title = "Hook Blog"; api.Pages.Save(page); // Add category api.Categories.Save(new Data.Category() { Id = ID, BlogId = BLOG_ID, Title = "Hook Category" }); } }
public async Task AddComplexPageType() { using (var api = CreateApi()) { var builder = new PageTypeBuilder(api) .AddType(typeof(ComplexPageType)); builder.Build(); var type = await api.PageTypes.GetByIdAsync("Complex"); Assert.NotNull(type); Assert.Equal(2, type.Regions.Count); Assert.Equal("Slider", type.Regions[0].Id); Assert.Equal("Intro", type.Regions[0].Title); Assert.True(type.Regions[0].Collection); Assert.Equal(1, type.Regions[0].Fields.Count); Assert.Equal("Content", type.Regions[1].Id); Assert.Equal("Main content", type.Regions[1].Title); Assert.False(type.Regions[1].Collection); Assert.Equal(2, type.Regions[1].Fields.Count); Assert.Equal(1, type.Routes.Count); Assert.Equal("/complex", type.Routes[0]); Assert.Equal(1, type.CustomEditors.Count); Assert.Equal("Custom Editor", type.CustomEditors[0].Title); Assert.Equal("custom-editor", type.CustomEditors[0].Component); Assert.Equal("fas fa-fish", type.CustomEditors[0].Icon); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApi api) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } // Initialize Piranha App.Init(api); // Configure cache level App.CacheLevel = Piranha.Cache.CacheLevel.Basic; var builder = new PageTypeBuilder(api) .AddType(typeof(Models.CustomPage)); builder.Build(); // Build content types new ContentTypeBuilder(api) .AddAssembly(typeof(Startup).Assembly) .Build() .DeleteOrphans(); // Configure Tiny MCE EditorConfig.FromFile("editorconfig.json"); // Middleware setup app.UsePiranha(options => { options.UseManager(); options.UseTinyMCE(); options.UseIdentity(); }); }
protected override void Init() { using (var api = new Api(services, GetDb(), storage, cache)) { Piranha.App.Init(api); var builder = new PageTypeBuilder(api) .AddType(typeof(MyPage)); builder.Build(); api.Sites.Save(new Data.Site() { Id = SITE_1_ID, InternalId = SITE_1, Title = SITE_1, Hostnames = SITE_1_HOSTS, IsDefault = true }); api.Sites.Save(new Data.Site() { InternalId = SITE_4, Title = SITE_4 }); api.Sites.Save(new Data.Site() { InternalId = SITE_5, Title = SITE_5 }); api.Sites.Save(new Data.Site() { InternalId = SITE_6, Title = SITE_6 }); var page1 = MyPage.Create(api); page1.SiteId = SITE_1_ID; page1.Title = "Startpage"; page1.Text = "Welcome"; page1.IsHidden = true; page1.Published = DateTime.Now; api.Pages.Save(page1); var page2 = MyPage.Create(api); page2.SiteId = SITE_1_ID; page2.SortOrder = 1; page2.Title = "Second page"; page2.Text = "The second page"; api.Pages.Save(page2); var page3 = MyPage.Create(api); page3.SiteId = SITE_1_ID; page3.ParentId = page2.Id; page3.Title = "Subpage"; page3.Text = "The subpage"; page3.Published = DateTime.Now; api.Pages.Save(page3); } }
protected override void Init() { using (var api = CreateApi()) { Piranha.App.Init(api); var builder = new PageTypeBuilder(api) .AddType(typeof(MyPage)); builder.Build(); // Add site var site1 = new Site { Id = SITE1_ID, Title = "Page Site", InternalId = "PageSite", IsDefault = true }; api.Sites.Save(site1); var site2 = new Site { Id = SITE2_ID, Title = "Page Site 2", InternalId = "PageSite2", Hostnames = "www.myothersite.com", IsDefault = false }; api.Sites.Save(site2); // Add pages var page1 = MyPage.Create(api); page1.Id = PAGE1_ID; page1.SiteId = SITE1_ID; page1.Title = "My first page"; page1.Body = "My first body"; page1.Published = DateTime.Now; api.Pages.Save(page1); var page2 = MyPage.Create(api); page2.Id = PAGE2_ID; page2.SiteId = SITE2_ID; page2.Title = "My second page"; page2.Body = "My second body"; page2.Published = DateTime.Now; api.Pages.Save(page2); var page3 = MyPage.Create(api); page3.Id = PAGE3_ID; page3.SiteId = SITE1_ID; page3.SortOrder = 1; page3.Title = "My third page"; page3.Published = DateTime.Now; page3.RedirectUrl = "http://www.redirect.com"; page3.RedirectType = Models.RedirectType.Temporary; api.Pages.Save(page3); } }
public static void BuildPageTypes(IApi api) { var pageTypeBuilder = new PageTypeBuilder(api) .AddType(typeof(StandardPage)) .AddType(typeof(StartPage)); pageTypeBuilder.Build() .DeleteOrphans(); }
private void Initialize() { using var api = CreateApi(); Piranha.App.Init(api); var builder = new PageTypeBuilder(api) .AddType(typeof(MyPage)); builder.Build(); var siteBuilder = new SiteTypeBuilder(api) .AddType(typeof(MySiteContent)); siteBuilder.Build(); }
public void AddSimple() { using (var api = new Api(GetDb(), null)) { var builder = new PageTypeBuilder(api) .AddType(typeof(SimplePageType)); builder.Build(); var type = api.PageTypes.GetById("Simple"); Assert.NotNull(type); Assert.Equal(1, type.Regions.Count); Assert.Equal("Body", type.Regions[0].Id); Assert.Equal(1, type.Regions[0].Fields.Count); } }
public async Task AddForwardSlashToPageRoutes() { using (var api = CreateApi()) { var builder = new PageTypeBuilder(api) .AddType(typeof(RoutedPageType)); builder.Build(); var type = await api.PageTypes.GetByIdAsync("Routed"); Assert.NotNull(type); Assert.NotEmpty(type.Routes); Assert.StartsWith("/", type.Routes[0]); } }
public async Task AddArchivePageType() { using (var api = CreateApi()) { var builder = new PageTypeBuilder(api) .AddType(typeof(ArchivePageType)); builder.Build(); var type = await api.PageTypes.GetByIdAsync("Archive"); Assert.NotNull(type); Assert.True(type.IsArchive); Assert.False(type.UseBlocks); Assert.NotEmpty(type.ArchiveItemTypes); } }
public async Task AddSimplePageType() { using (var api = CreateApi()) { var builder = new PageTypeBuilder(api) .AddType(typeof(SimplePageType)); builder.Build(); var type = await api.PageTypes.GetByIdAsync("Simple"); Assert.NotNull(type); Assert.Equal(1, type.Regions.Count); Assert.Equal("Body", type.Regions[0].Id); Assert.Equal(1, type.Regions[0].Fields.Count); } }
protected override void Init() { using (var api = new Api(GetDb(), storage, cache)) { Piranha.App.Init(api); var pageTypeBuilder = new PageTypeBuilder(api) .AddType(typeof(BlogPage)); pageTypeBuilder.Build(); // Add site var site = new Data.Site() { Id = SITE_ID, Title = "Category Site", InternalId = "CategorySite", IsDefault = true }; api.Sites.Save(site); // Add blog page var page = BlogPage.Create(api); page.Id = BLOG_ID; page.SiteId = SITE_ID; page.Title = "Blog"; api.Pages.Save(page); // Add categories api.Categories.Save(new Data.Category() { Id = CAT_1_ID, BlogId = BLOG_ID, Title = CAT_1 }); api.Categories.Save(new Data.Category() { BlogId = BLOG_ID, Title = CAT_4 }); api.Categories.Save(new Data.Category() { Id = CAT_5_ID, BlogId = BLOG_ID, Title = CAT_5 }); } }
public void DeleteOrphans() { using (var api = new Api(GetDb(), null)) { var builder = new PageTypeBuilder(api) .AddType(typeof(SimplePageType)) .AddType(typeof(ComplexPageType)); builder.Build(); Assert.Equal(2, api.PageTypes.GetAll().Count()); builder = new PageTypeBuilder(api) .AddType(typeof(SimplePageType)); builder.DeleteOrphans(); Assert.Single(api.PageTypes.GetAll()); } }
public async Task DeleteOrphans() { using (var api = CreateApi()) { var builder = new PageTypeBuilder(api) .AddType(typeof(SimplePageType)) .AddType(typeof(ComplexPageType)); builder.Build(); Assert.Equal(2, (await api.PageTypes.GetAllAsync()).Count()); builder = new PageTypeBuilder(api) .AddType(typeof(SimplePageType)); builder.DeleteOrphans(); Assert.Single(await api.PageTypes.GetAllAsync()); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApi api) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } App.Init(api); // Configure cache level App.CacheLevel = CacheLevel.Basic; // Custom components App.Blocks.Register <SeparatorBlock>(); // Build content types var pageTypeBuilder = new PageTypeBuilder(api) .AddType(typeof(BlogArchive)) .AddType(typeof(StandardPage)) .AddType(typeof(TeaserPage)); pageTypeBuilder.Build() .DeleteOrphans(); var postTypeBuilder = new PostTypeBuilder(api) .AddType(typeof(BlogPost)); postTypeBuilder.Build() .DeleteOrphans(); // Register middleware app.UseStaticFiles(); app.UseAuthentication(); app.UsePiranha(); app.UsePiranhaManager(); app.UseMvc(routes => { routes.MapRoute("areaRoute", "{area:exists}/{controller}/{action}/{id?}", new { controller = "Home", action = "Index" }); }); Seed.RunAsync(api).GetAwaiter().GetResult(); }
public async Task AddComplexPageType() { using (var api = CreateApi()) { var builder = new PageTypeBuilder(api) .AddType(typeof(ComplexPageType)); builder.Build(); var type = await api.PageTypes.GetByIdAsync("Complex"); Assert.NotNull(type); Assert.Equal(2, type.Regions.Count); Assert.Equal("Slider", type.Regions[0].Id); Assert.Equal("Intro", type.Regions[0].Title); Assert.Equal("Default", type.Regions[0].ListTitleField); Assert.Equal("Add new item", type.Regions[0].ListTitlePlaceholder); Assert.Equal("fa fas-fish", type.Regions[0].Icon); Assert.False(type.Regions[0].ListExpand); Assert.True(type.Regions[0].Collection); Assert.Equal(1, type.Regions[0].Fields.Count); Assert.Equal("Content", type.Regions[1].Id); Assert.Equal("Main content", type.Regions[1].Title); Assert.Equal("This is where you enter the main content", type.Regions[1].Description); Assert.False(type.Regions[1].Collection); Assert.Equal(2, type.Regions[1].Fields.Count); Assert.Equal("Title", type.Regions[1].Fields[0].Id); Assert.Equal("This is the title", type.Regions[1].Fields[0].Description); Assert.Equal("Body", type.Regions[1].Fields[1].Id); Assert.Equal("Main Body", type.Regions[1].Fields[1].Title); Assert.Equal(1, type.Routes.Count); Assert.Equal("/complex", type.Routes[0]); Assert.Equal(2, type.CustomEditors.Count); Assert.Equal("Custom Editor", type.CustomEditors[0].Title); Assert.Equal("custom-editor", type.CustomEditors[0].Component); Assert.Equal("fa fas-fish", type.CustomEditors[0].Icon); } }
protected override void Init() { services = new ServiceCollection() .AddSingleton <IMyService, MyService>() .BuildServiceProvider(); using (var api = new Api(GetDb(), new ContentServiceFactory(services), storage, cache)) { Piranha.App.Init(); Piranha.App.Fields.Register <MyFourthField>(); var builder = new PageTypeBuilder(api) .AddType(typeof(MissingPage)) .AddType(typeof(MyBlogPage)) .AddType(typeof(MyPage)) .AddType(typeof(MyCollectionPage)) .AddType(typeof(MyDIPage)); builder.Build(); var site = new Data.Site { Id = SITE_ID, Title = "Default Site", InternalId = "DefaultSite", IsDefault = true }; var emptysite = new Data.Site { Id = SITE_ID, Title = "Empty Site", InternalId = "EmptySite", IsDefault = false }; api.Sites.Save(site); api.Sites.Save(emptysite); var page1 = MyPage.Create(api); page1.Id = PAGE_1_ID; page1.SiteId = SITE_ID; page1.Title = "My first page"; page1.Ingress = "My first ingress"; page1.Body = "My first body"; page1.Blocks.Add(new Extend.Blocks.TextBlock { Body = "Sollicitudin Aenean" }); page1.Blocks.Add(new Extend.Blocks.TextBlock { Body = "Ipsum Elit" }); api.Pages.Save(page1); var page2 = MyPage.Create(api); page2.Id = PAGE_2_ID; page2.SiteId = SITE_ID; page2.Title = "My second page"; page2.Ingress = "My second ingress"; page2.Body = "My second body"; api.Pages.Save(page2); var page3 = MyPage.Create(api); page3.Id = PAGE_3_ID; page3.SiteId = SITE_ID; page3.Title = "My third page"; page3.Ingress = "My third ingress"; page3.Body = "My third body"; api.Pages.Save(page3); var page4 = MyCollectionPage.Create(api); page4.SiteId = SITE_ID; page4.Title = "My collection page"; page4.SortOrder = 1; page4.Texts.Add(new TextField { Value = "First text" }); page4.Texts.Add(new TextField { Value = "Second text" }); page4.Texts.Add(new TextField { Value = "Third text" }); api.Pages.Save(page4); var page5 = MyBlogPage.Create(api); page5.SiteId = SITE_ID; page5.Title = "Blog Archive"; api.Pages.Save(page5); var page6 = MyDIPage.Create(api); page6.Id = PAGE_DI_ID; page6.SiteId = SITE_ID; page6.Title = "My Injection Page"; api.Pages.Save(page6); var page7 = MyPage.Create(api); page7.Id = PAGE_7_ID; page7.SiteId = SITE_ID; page7.Title = "My base page"; page7.Ingress = "My base ingress"; page7.Body = "My base body"; page7.ParentId = PAGE_1_ID; page7.SortOrder = 1; api.Pages.Save(page7); var page8 = MyPage.Create(api); page8.OriginalPageId = PAGE_7_ID; page8.Id = PAGE_8_ID; page8.SiteId = SITE_ID; page8.Title = "My copied page"; page8.ParentId = PAGE_1_ID; page8.SortOrder = 2; page8.IsHidden = true; page8.Route = "test-route"; api.Pages.Save(page8); } }
protected override void Init() { using (var api = new Api(GetDb(), storage, cache)) { Piranha.App.Init(api); var pageTypeBuilder = new PageTypeBuilder(api) .AddType(typeof(BlogPage)); pageTypeBuilder.Build(); var postTypeBuilder = new PostTypeBuilder(api) .AddType(typeof(MissingPost)) .AddType(typeof(MyPost)) .AddType(typeof(MyCollectionPost)); postTypeBuilder.Build(); // Add site var site = new Data.Site() { Id = SITE_ID, Title = "Post Site", InternalId = "PostSite", IsDefault = true }; api.Sites.Save(site); // Add blog page var page = BlogPage.Create(api); page.Id = BLOG_ID; page.SiteId = SITE_ID; page.Title = "Blog"; api.Pages.Save(page); var category = new Data.Category() { Id = CAT_1_ID, BlogId = BLOG_ID, Title = "My category" }; api.Categories.Save(category); var post1 = MyPost.Create(api); post1.Id = POST_1_ID; post1.BlogId = BLOG_ID; post1.Category = category; post1.Title = "My first post"; post1.Ingress = "My first ingress"; post1.Body = "My first body"; api.Posts.Save(post1); var post2 = MyPost.Create(api); post2.Id = POST_2_ID; post2.BlogId = BLOG_ID; post2.Category = category; post2.Title = "My second post"; post2.Ingress = "My second ingress"; post2.Body = "My second body"; api.Posts.Save(post2); var post3 = MyPost.Create(api); post3.Id = POST_3_ID; post3.BlogId = BLOG_ID; post3.Category = category; post3.Title = "My third post"; post3.Ingress = "My third ingress"; post3.Body = "My third body"; api.Posts.Save(post3); var post4 = MyCollectionPost.Create(api); post4.BlogId = BLOG_ID; post4.Category = category; post4.Title = "My collection post"; post4.Texts.Add(new TextField() { Value = "First text" }); post4.Texts.Add(new TextField() { Value = "Second text" }); post4.Texts.Add(new TextField() { Value = "Third text" }); api.Posts.Save(post4); } }
public override async Task InitializeAsync() { _services = new ServiceCollection() .AddSingleton <IMyService, MyService>() .BuildServiceProvider(); using (var api = CreateApi()) { Piranha.App.Init(api); Piranha.App.Fields.Register <MyFourthField>(); var pageTypeBuilder = new PageTypeBuilder(api) .AddType(typeof(BlogPage)); pageTypeBuilder.Build(); var postTypeBuilder = new PostTypeBuilder(api) .AddType(typeof(MissingPost)) .AddType(typeof(MyPost)) .AddType(typeof(MyCollectionPost)) .AddType(typeof(MyDIPost)); postTypeBuilder.Build(); // Add site var site = new Site { Id = SITE_ID, Title = "Post Site", InternalId = "PostSite", IsDefault = true }; await api.Sites.SaveAsync(site); // Add blog page var page = await BlogPage.CreateAsync(api); page.Id = BLOG_ID; page.SiteId = SITE_ID; page.Title = "Blog"; await api.Pages.SaveAsync(page); var category = new Models.Taxonomy { Id = CAT_1_ID, Title = "My category" }; var post1 = await MyPost.CreateAsync(api); post1.Id = POST_1_ID; post1.BlogId = BLOG_ID; post1.Category = category; post1.Title = "My first post"; post1.Ingress = "My first ingress"; post1.Body = "My first body"; post1.Blocks.Add(new Extend.Blocks.TextBlock { Body = "Sollicitudin Aenean" }); post1.Blocks.Add(new Extend.Blocks.TextBlock { Body = "Ipsum Elit" }); await api.Posts.SaveAsync(post1); var post2 = await MyPost.CreateAsync(api); post2.Id = POST_2_ID; post2.BlogId = BLOG_ID; post2.Category = category; post2.Title = "My second post"; post2.Ingress = "My second ingress"; post2.Body = "My second body"; await api.Posts.SaveAsync(post2); var post3 = await MyPost.CreateAsync(api); post3.Id = POST_3_ID; post3.BlogId = BLOG_ID; post3.Category = category; post3.Title = "My third post"; post3.Ingress = "My third ingress"; post3.Body = "My third body"; await api.Posts.SaveAsync(post3); var post4 = await MyCollectionPost.CreateAsync(api); post4.BlogId = BLOG_ID; post4.Category = category; post4.Title = "My collection post"; post4.Texts.Add(new TextField { Value = "First text" }); post4.Texts.Add(new TextField { Value = "Second text" }); post4.Texts.Add(new TextField { Value = "Third text" }); await api.Posts.SaveAsync(post4); var post6 = await MyDIPost.CreateAsync(api); post6.Id = POST_DI_ID; post6.BlogId = BLOG_ID; post6.Category = category; post6.Title = "My Injection Post"; await api.Posts.SaveAsync(post6); } }
public override async Task InitializeAsync() { using (var api = CreateApi()) { Piranha.App.Init(api); var pageBuilder = new PageTypeBuilder(api) .AddType(typeof(MyPage)); pageBuilder.Build(); var postBuilder = new PostTypeBuilder(api) .AddType(typeof(MyPost)); postBuilder.Build(); // Add site var site1 = new Site { Id = SITE1_ID, Title = "Page Site", InternalId = "PostSite", IsDefault = true }; await api.Sites.SaveAsync(site1); var site2 = new Site { Id = SITE2_ID, Title = "Page Site 2", InternalId = "PostSite2", Hostnames = "www.myothersite.com", IsDefault = false }; await api.Sites.SaveAsync(site2); // Add pages var page1 = await MyPage.CreateAsync(api); page1.Id = PAGE1_ID; page1.SiteId = SITE1_ID; page1.Title = "Blog"; page1.Published = DateTime.Now; await api.Pages.SaveAsync(page1); var page2 = await MyPage.CreateAsync(api); page2.Id = PAGE2_ID; page2.SiteId = SITE2_ID; page2.Title = "News"; page2.Published = DateTime.Now; await api.Pages.SaveAsync(page2); // Add categories var category1 = new Models.Taxonomy { Id = CATEGORY1_ID, Title = "Default category" }; var category2 = new Models.Taxonomy { Id = CATEGORY2_ID, Title = "Default category" }; // Add posts var post1 = await MyPost.CreateAsync(api); post1.Id = POST1_ID; post1.BlogId = page1.Id; post1.Category = category1; post1.Title = "My first post"; post1.Body = "My first body"; post1.Tags.Add(new Models.Taxonomy { Id = TAG1_ID, Title = "My tag" }); post1.Published = DateTime.Now; await api.Posts.SaveAsync(post1); var post2 = await MyPost.CreateAsync(api); post2.Id = POST2_ID; post2.BlogId = page2.Id; post2.Category = category2; post2.Title = "My second post"; post2.Body = "My second body"; post2.Tags.Add(new Models.Taxonomy { Id = TAG2_ID, Title = "My other tag" }); post2.Published = DateTime.Now; await api.Posts.SaveAsync(post2); } }
protected override void Init() { using (var api = new Api(GetDb(), new ContentServiceFactory(services), storage)) { Piranha.App.Init(api); var pageBuilder = new PageTypeBuilder(api) .AddType(typeof(MyPage)); pageBuilder.Build(); var postBuilder = new PostTypeBuilder(api) .AddType(typeof(MyPost)); postBuilder.Build(); // Add site var site1 = new Data.Site() { Id = SITE1_ID, Title = "Page Site", InternalId = "PostSite", IsDefault = true }; api.Sites.Save(site1); var site2 = new Data.Site() { Id = SITE2_ID, Title = "Page Site 2", InternalId = "PostSite2", Hostnames = "www.myothersite.com", IsDefault = false }; api.Sites.Save(site2); // Add pages var page1 = MyPage.Create(api); page1.Id = PAGE1_ID; page1.SiteId = SITE1_ID; page1.Title = "Blog"; page1.Published = DateTime.Now; api.Pages.Save(page1); var page2 = MyPage.Create(api); page2.Id = PAGE2_ID; page2.SiteId = SITE2_ID; page2.Title = "News"; page2.Published = DateTime.Now; api.Pages.Save(page2); // Add categories var category1 = new Data.Category() { Id = CATEGORY1_ID, BlogId = PAGE1_ID, Title = "Default category" }; api.Categories.Save(category1); var category2 = new Data.Category() { Id = CATEGORY2_ID, BlogId = PAGE2_ID, Title = "Default category" }; api.Categories.Save(category2); // Add tags var tag = new Data.Tag() { Id = TAG1_ID, BlogId = PAGE1_ID, Title = "My tag" }; api.Tags.Save(tag); tag = new Data.Tag() { Id = TAG2_ID, BlogId = PAGE2_ID, Title = "My other tag" }; api.Tags.Save(tag); // Add posts var post1 = MyPost.Create(api); post1.Id = POST1_ID; post1.BlogId = page1.Id; post1.Category = category1; post1.Title = "My first post"; post1.Body = "My first body"; post1.Tags.Add("My tag"); post1.Published = DateTime.Now; api.Posts.Save(post1); var post2 = MyPost.Create(api); post2.Id = POST2_ID; post2.BlogId = page2.Id; post2.Category = category2; post2.Title = "My second post"; post2.Body = "My second body"; post2.Tags.Add("My other tag"); post2.Published = DateTime.Now; api.Posts.Save(post2); } }
public override async Task InitializeAsync() { _services = CreateServiceCollection() .AddSingleton <IMyService, MyService>() .BuildServiceProvider(); using (var api = CreateApi()) { Piranha.App.Init(api); Piranha.App.Fields.Register <MyFourthField>(); var builder = new PageTypeBuilder(api) .AddType(typeof(MissingPage)) .AddType(typeof(MyBlogPage)) .AddType(typeof(MyPage)) .AddType(typeof(MyCollectionPage)) .AddType(typeof(MyDIPage)); builder.Build(); var site = new Site { Id = SITE_ID, Title = "My Test Site", InternalId = "MyTestSite", IsDefault = true }; await api.Sites.SaveAsync(site); var page1 = await MyPage.CreateAsync(api); page1.Id = PAGE_1_ID; page1.SiteId = SITE_ID; page1.Title = "My first page"; page1.Ingress = "My first ingress"; page1.Body = "My first body"; page1.Blocks.Add(new Extend.Blocks.TextBlock { Body = "Sollicitudin Aenean" }); page1.Blocks.Add(new Extend.Blocks.TextBlock { Body = "Ipsum Elit" }); page1.Published = DateTime.Now; await api.Pages.SaveAsync(page1); var page2 = await MyPage.CreateAsync(api); page2.Id = PAGE_2_ID; page2.SiteId = SITE_ID; page2.Title = "My second page"; page2.Ingress = "My second ingress"; page2.Body = "My second body"; await api.Pages.SaveAsync(page2); var page3 = await MyPage.CreateAsync(api); page3.Id = PAGE_3_ID; page3.SiteId = SITE_ID; page3.Title = "My third page"; page3.Ingress = "My third ingress"; page3.Body = "My third body"; await api.Pages.SaveAsync(page3); var page4 = await MyCollectionPage.CreateAsync(api); page4.SiteId = SITE_ID; page4.Title = "My collection page"; page4.SortOrder = 1; page4.Texts.Add(new TextField { Value = "First text" }); page4.Texts.Add(new TextField { Value = "Second text" }); page4.Texts.Add(new TextField { Value = "Third text" }); await api.Pages.SaveAsync(page4); var page5 = await MyBlogPage.CreateAsync(api); page5.SiteId = SITE_ID; page5.Title = "Blog Archive"; await api.Pages.SaveAsync(page5); var page6 = await MyDIPage.CreateAsync(api); page6.Id = PAGE_DI_ID; page6.SiteId = SITE_ID; page6.Title = "My Injection Page"; await api.Pages.SaveAsync(page6); var page7 = await MyPage.CreateAsync(api); page7.Id = PAGE_7_ID; page7.SiteId = SITE_ID; page7.Title = "My base page"; page7.Ingress = "My base ingress"; page7.Body = "My base body"; page7.ParentId = PAGE_1_ID; page7.SortOrder = 1; await api.Pages.SaveAsync(page7); var page8 = await MyPage.CreateAsync(api); page8.OriginalPageId = PAGE_7_ID; page8.Id = PAGE_8_ID; page8.SiteId = SITE_ID; page8.Title = "My copied page"; page8.ParentId = PAGE_1_ID; page8.SortOrder = 2; page8.IsHidden = true; page8.Route = "test-route"; await api.Pages.SaveAsync(page8); } }
protected override void Init() { using (var api = new Api(GetDb(), storage, cache)) { Piranha.App.Init(api); var builder = new PageTypeBuilder(api) .AddType(typeof(MissingPage)) .AddType(typeof(MyBlogPage)) .AddType(typeof(MyPage)) .AddType(typeof(MyCollectionPage)); builder.Build(); var site = new Data.Site() { Id = SITE_ID, Title = "Default Site", InternalId = "DefaultSite", IsDefault = true }; var emptysite = new Data.Site() { Id = SITE_ID, Title = "Empty Site", InternalId = "EmptySite", IsDefault = false }; api.Sites.Save(site); api.Sites.Save(emptysite); var page1 = MyPage.Create(api); page1.Id = PAGE_1_ID; page1.SiteId = SITE_ID; page1.Title = "My first page"; page1.Ingress = "My first ingress"; page1.Body = "My first body"; api.Pages.Save(page1); var page2 = MyPage.Create(api); page2.Id = PAGE_2_ID; page2.SiteId = SITE_ID; page2.Title = "My second page"; page2.Ingress = "My second ingress"; page2.Body = "My second body"; api.Pages.Save(page2); var page3 = MyPage.Create(api); page3.Id = PAGE_3_ID; page3.SiteId = SITE_ID; page3.Title = "My third page"; page3.Ingress = "My third ingress"; page3.Body = "My third body"; api.Pages.Save(page3); var page4 = MyCollectionPage.Create(api); page4.SiteId = SITE_ID; page4.Title = "My collection page"; page4.SortOrder = 1; page4.Texts.Add(new TextField() { Value = "First text" }); page4.Texts.Add(new TextField() { Value = "Second text" }); page4.Texts.Add(new TextField() { Value = "Third text" }); api.Pages.Save(page4); var page5 = MyBlogPage.Create(api); page5.SiteId = SITE_ID; page5.Title = "Blog Archive"; api.Pages.Save(page5); } }
public override async Task InitializeAsync() { using (var api = CreateApi()) { Piranha.App.Init(api); var builder = new PageTypeBuilder(api) .AddType(typeof(MyPage)); builder.Build(); var siteBuilder = new SiteTypeBuilder(api) .AddType(typeof(MySiteContent)); siteBuilder.Build(); await api.Sites.SaveAsync(new Site { Id = SITE_1_ID, SiteTypeId = "MySiteContent", InternalId = SITE_1, Title = SITE_1, Hostnames = SITE_1_HOSTS, IsDefault = true }); await api.Sites.SaveAsync(new Site { InternalId = SITE_4, Title = SITE_4 }); await api.Sites.SaveAsync(new Site { InternalId = SITE_5, Title = SITE_5 }); await api.Sites.SaveAsync(new Site { InternalId = SITE_6, Title = SITE_6 }); // Sites for testing hostname routing await api.Sites.SaveAsync(new Site { InternalId = "RoutingTest1", Title = "RoutingTest1", Hostnames = "mydomain.com,localhost" }); await api.Sites.SaveAsync(new Site { InternalId = "RoutingTest2", Title = "RoutingTest2", Hostnames = " mydomain.com/en" }); await api.Sites.SaveAsync(new Site { InternalId = "RoutingTest3", Title = "RoutingTest3", Hostnames = "sub.mydomain.com , sub2.localhost" }); var content = await MySiteContent.CreateAsync(api); content.Header = "<p>Lorem ipsum</p>"; content.Footer = "<p>Tellus Ligula</p>"; await api.Sites.SaveContentAsync(SITE_1_ID, content); var page1 = await MyPage.CreateAsync(api); page1.SiteId = SITE_1_ID; page1.Title = "Startpage"; page1.Text = "Welcome"; page1.IsHidden = true; page1.Published = DateTime.Now; await api.Pages.SaveAsync(page1); var page2 = await MyPage.CreateAsync(api); page2.SiteId = SITE_1_ID; page2.SortOrder = 1; page2.Title = "Second page"; page2.Text = "The second page"; await api.Pages.SaveAsync(page2); var page3 = await MyPage.CreateAsync(api); page3.SiteId = SITE_1_ID; page3.ParentId = page2.Id; page3.Title = "Subpage"; page3.Text = "The subpage"; page3.Published = DateTime.Now; await api.Pages.SaveAsync(page3); } }
protected override void Init() { using (var api = new Api(GetDb(), new ContentServiceFactory(services), storage, cache)) { Piranha.App.Init(); var builder = new PageTypeBuilder(api) .AddType(typeof(MyPage)); builder.Build(); var siteBuilder = new SiteTypeBuilder(api) .AddType(typeof(MySiteContent)); siteBuilder.Build(); api.Sites.Save(new Data.Site() { Id = SITE_1_ID, SiteTypeId = "MySiteContent", InternalId = SITE_1, Title = SITE_1, Hostnames = SITE_1_HOSTS, IsDefault = true }); api.Sites.Save(new Data.Site() { InternalId = SITE_4, Title = SITE_4 }); api.Sites.Save(new Data.Site() { InternalId = SITE_5, Title = SITE_5 }); api.Sites.Save(new Data.Site() { InternalId = SITE_6, Title = SITE_6 }); // Sites for testing hostname routing api.Sites.Save(new Data.Site { InternalId = "RoutingTest1", Title = "RoutingTest1", Hostnames = "mydomain.com,localhost" }); api.Sites.Save(new Data.Site { InternalId = "RoutingTest2", Title = "RoutingTest2", Hostnames = " mydomain.com/en" }); api.Sites.Save(new Data.Site { InternalId = "RoutingTest3", Title = "RoutingTest3", Hostnames = "sub.mydomain.com , sub2.localhost" }); var content = MySiteContent.Create(api); content.Header = "<p>Lorem ipsum</p>"; content.Footer = "<p>Tellus Ligula</p>"; api.Sites.SaveContent(SITE_1_ID, content); var page1 = MyPage.Create(api); page1.SiteId = SITE_1_ID; page1.Title = "Startpage"; page1.Text = "Welcome"; page1.IsHidden = true; page1.Published = DateTime.Now; api.Pages.Save(page1); var page2 = MyPage.Create(api); page2.SiteId = SITE_1_ID; page2.SortOrder = 1; page2.Title = "Second page"; page2.Text = "The second page"; api.Pages.Save(page2); var page3 = MyPage.Create(api); page3.SiteId = SITE_1_ID; page3.ParentId = page2.Id; page3.Title = "Subpage"; page3.Text = "The subpage"; page3.Published = DateTime.Now; api.Pages.Save(page3); } }
protected override void Init() { services = new ServiceCollection() .AddSingleton <IMyService, MyService>() .BuildServiceProvider(); using (var api = new Api(GetDb(), new ContentServiceFactory(services), storage, cache)) { Piranha.App.Init(); Piranha.App.Fields.Register <MyFourthField>(); var pageTypeBuilder = new PageTypeBuilder(api) .AddType(typeof(BlogPage)); pageTypeBuilder.Build(); var postTypeBuilder = new PostTypeBuilder(api) .AddType(typeof(MissingPost)) .AddType(typeof(MyPost)) .AddType(typeof(MyCollectionPost)) .AddType(typeof(MyDIPost)); postTypeBuilder.Build(); // Add site var site = new Data.Site() { Id = SITE_ID, Title = "Post Site", InternalId = "PostSite", IsDefault = true }; api.Sites.Save(site); // Add blog page var page = BlogPage.Create(api); page.Id = BLOG_ID; page.SiteId = SITE_ID; page.Title = "Blog"; api.Pages.Save(page); var category = new Data.Category() { Id = CAT_1_ID, BlogId = BLOG_ID, Title = "My category" }; api.Categories.Save(category); var post1 = MyPost.Create(api); post1.Id = POST_1_ID; post1.BlogId = BLOG_ID; post1.Category = category; post1.Title = "My first post"; post1.Ingress = "My first ingress"; post1.Body = "My first body"; post1.Blocks.Add(new Extend.Blocks.TextBlock { Body = "Sollicitudin Aenean" }); post1.Blocks.Add(new Extend.Blocks.TextBlock { Body = "Ipsum Elit" }); api.Posts.Save(post1); var post2 = MyPost.Create(api); post2.Id = POST_2_ID; post2.BlogId = BLOG_ID; post2.Category = category; post2.Title = "My second post"; post2.Ingress = "My second ingress"; post2.Body = "My second body"; api.Posts.Save(post2); var post3 = MyPost.Create(api); post3.Id = POST_3_ID; post3.BlogId = BLOG_ID; post3.Category = category; post3.Title = "My third post"; post3.Ingress = "My third ingress"; post3.Body = "My third body"; api.Posts.Save(post3); var post4 = MyCollectionPost.Create(api); post4.BlogId = BLOG_ID; post4.Category = category; post4.Title = "My collection post"; post4.Texts.Add(new TextField() { Value = "First text" }); post4.Texts.Add(new TextField() { Value = "Second text" }); post4.Texts.Add(new TextField() { Value = "Third text" }); api.Posts.Save(post4); var post6 = MyDIPost.Create(api); post6.Id = POST_DI_ID; post6.BlogId = BLOG_ID; post6.Category = category; post6.Title = "My Injection Post"; api.Posts.Save(post6); } }