public override async Task InitializeAsync() { using (var api = CreateApi()) { // Import content types new PageTypeBuilder(api) .AddType(typeof(BlogArchive)) .Build(); new PostTypeBuilder(api) .AddType(typeof(BlogPost)) .Build(); // Add site var site = new Site { Id = SITE_ID, Title = "Comment Site", InternalId = "CommentSite", IsDefault = true }; await api.Sites.SaveAsync(site); // Add archive var blog = await BlogArchive.CreateAsync(api); blog.Id = BLOG_ID; blog.SiteId = SITE_ID; blog.Title = "Blog"; blog.EnableComments = true; blog.Published = DateTime.Now; await api.Pages.SaveAsync(blog); var news = await BlogArchive.CreateAsync(api); news.Id = NEWS_ID; news.SiteId = SITE_ID; news.Title = "News"; blog.EnableComments = true; news.Published = DateTime.Now; await api.Pages.SaveAsync(news); // Add posts var blogPost = await BlogPost.CreateAsync(api); blogPost.Id = BLOGPOST_ID; blogPost.BlogId = BLOG_ID; blogPost.Category = "The Category"; blogPost.Title = "Welcome To The Blog"; blogPost.Published = DateTime.Now; await api.Posts.SaveAsync(blogPost); var newsPost = await BlogPost.CreateAsync(api); newsPost.Id = NEWSPOST_ID; newsPost.BlogId = NEWS_ID; newsPost.Category = "The Category"; newsPost.Title = "Welcome To The News"; newsPost.Published = DateTime.Now; await api.Posts.SaveAsync(newsPost); } }
public async Task <IActionResult> Seed() { // Get the default site var site = await _api.Sites.GetDefaultAsync(); site.SiteTypeId = nameof(BlogSite); await _api.Sites.SaveAsync(site); // Add media assets var bannerId = Guid.NewGuid(); using (var stream = System.IO.File.OpenRead("seed/pexels-photo-355423.jpeg")) { await _api.Media.SaveAsync(new Piranha.Models.StreamMediaContent() { Id = bannerId, Filename = "pexels-photo-355423.jpeg", Data = stream }); } var banner = await _api.Media.GetByIdAsync(bannerId); var logoId = Guid.NewGuid(); using (var stream = System.IO.File.OpenRead("seed/logo.png")) { await _api.Media.SaveAsync(new Piranha.Models.StreamMediaContent() { Id = logoId, Filename = "logo.png", Data = stream }); } // Add the site info var blogSite = await BlogSite.CreateAsync(_api); blogSite.Information.SiteLogo = logoId; blogSite.Information.SiteTitle = "Piranha CMS"; blogSite.Information.Tagline = "A lightweight & unobtrusive CMS for Asp.NET Core."; await _api.Sites.SaveContentAsync(site.Id, blogSite); // Add the blog archive var blogId = Guid.NewGuid(); var blogPage = await BlogArchive.CreateAsync(_api); blogPage.Id = blogId; blogPage.SiteId = site.Id; blogPage.Title = "Blog Archive"; blogPage.MetaKeywords = "Inceptos, Tristique, Pellentesque, Lorem, Vestibulum"; blogPage.MetaDescription = "Morbi leo risus, porta ac consectetur ac, vestibulum at eros."; blogPage.NavigationTitle = "Blog"; blogPage.Published = DateTime.Now; await _api.Pages.SaveAsync(blogPage); // Add a blog post var post = await BlogPost.CreateAsync(_api); post.BlogId = blogPage.Id; post.Category = "Piranha CMS"; post.Tags.Add("Welcome", "Fresh Start", "Information"); post.Title = "Welcome to Piranha CMS!"; post.MetaKeywords = "Welcome, Piranha CMS, AspNetCore, MVC, .NET Core"; post.MetaDescription = "Piranha is the fun, fast and lightweight framework for developing cms-based web applications with ASP.Net Core."; post.Hero.PrimaryImage = bannerId; post.Hero.Ingress = "<p>Piranha CMS is a <strong>lightweight</strong>, <strong>cross-platform</strong> CMS <string>library</string> for <code>NetStandard 2.0</code>, <code>.NET Core</code> & <code>Entity Framework Core</code>. It can be used to add CMS functionality to your existing application or to build a new website from scratch. It has an extensible & pluggable architecture that can support a wide variety of runtime scenarios.</p>"; post.Blocks.Add(new HtmlBlock { Body = "<p>Piranha CMS is a <strong>lightweight</strong>, <strong>cross-platform</strong> CMS <string>library</string> for <code>NetStandard 2.0</code>, <code>.NET Core</code> & <code>Entity Framework Core</code>. It can be used to add CMS functionality to your existing application or to build a new website from scratch. It has an extensible & pluggable architecture that can support a wide variety of runtime scenarios.</p><p>Piranha CMS is totally <strong>package based</strong> and available on <code>NuGet</code>. You can read more about the different packages available in the documentation.</p>" }); post.Blocks.Add(new HtmlBlock { Body = "<h2>Getting Started</h2><p>To log into the manager interface and start writing content simply go the URL <code>/manager</code> and login with <code>admin</code> / <code>password</code> as your username and password.</p>" }); post.Blocks.Add(new HtmlBlock { Body = "<h2>Licensing</h2><p>Piranha CMS is released under the <strong>MIT</strong> license. It is a permissive free software license, meaning that it permits reuse within proprietary software provided all copies of the licensed software include a copy of the MIT License terms and the copyright notice.</p>" }); post.Published = DateTime.Now; await _api.Posts.SaveAsync(post); // Add about page var page = await StandardPage.CreateAsync(_api); page.SiteId = site.Id; page.SortOrder = 1; page.Title = "About Me"; page.MetaKeywords = "Inceptos, Tristique, Pellentesque, Lorem, Vestibulum"; page.MetaDescription = "Morbi leo risus, porta ac consectetur ac, vestibulum at eros."; page.Blocks.Add(new HtmlBlock { Body = "<p>Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Vestibulum id ligula porta felis euismod semper. Nulla vitae elit libero, a pharetra augue. Donec id elit non mi porta gravida at eget metus. Donec ullamcorper nulla non metus auctor fringilla.</p>" }); page.Blocks.Add(new QuoteBlock { Body = "Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod." }); page.Blocks.Add(new ColumnBlock { Items = new List <Block> { new HtmlBlock { Body = $"<p><img src=\"{banner.PublicUrl.Replace("~", "")}\"></p>" }, new HtmlBlock { Body = "<p>Maecenas faucibus mollis interdum. Aenean lacinia bibendum nulla sed consectetur. Integer posuere erat a ante venenatis dapibus posuere velit aliquet.</p>" } } }); page.Published = DateTime.Now; await _api.Pages.SaveAsync(page); return(Redirect("~/")); }
public async Task <IActionResult> Seed() { // Get the default site var site = await _api.Sites.GetDefaultAsync(); // Add media assets var bannerId = Guid.NewGuid(); using (var stream = System.IO.File.OpenRead("seed/pexels-photo-355423.jpeg")) { await _api.Media.SaveAsync(new Piranha.Models.StreamMediaContent() { Id = bannerId, Filename = "pexels-photo-355423.jpeg", Data = stream }); } // Add the blog archived var blogId = Guid.NewGuid(); var blogPage = await BlogArchive.CreateAsync(_api); blogPage.Id = blogId; blogPage.SiteId = site.Id; blogPage.Title = "Blog Archive"; blogPage.MetaKeywords = "Inceptos, Tristique, Pellentesque, Lorem, Vestibulum"; blogPage.MetaDescription = "Morbi leo risus, porta ac consectetur ac, vestibulum at eros."; blogPage.NavigationTitle = "Blog"; blogPage.Hero.PrimaryImage = bannerId; blogPage.Hero.Ingress = "Curabitur blandit tempus porttitor. Maecenas sed diam eget risus varius blandit sit amet non magna."; blogPage.Published = DateTime.Now; await _api.Pages.SaveAsync(blogPage); // Add a blog post var postId = Guid.NewGuid(); var post = await BlogPost.CreateAsync(_api); post.Id = postId; post.BlogId = blogPage.Id; post.Category = "Uncategorized"; post.Tags.Add("Ornare", "Pellentesque", "Fringilla Ridiculus"); post.Title = "Dapibus Cursus Justo"; post.MetaKeywords = "Nullam, Mollis, Cras, Sem, Ipsum"; post.MetaDescription = "Aenean lacinia bibendum nulla sed consectetur."; post.Hero.PrimaryImage = bannerId; post.Hero.Ingress = "Sed posuere consectetur est at lobortis. Praesent commodo cursus magna, vel scelerisque nisl consectetur et."; post.Blocks.Add(new HtmlBlock { Body = "<p>Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas sed diam eget risus varius blandit sit amet non magna. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Curabitur blandit tempus porttitor. Maecenas faucibus mollis interdum.</p>" }); post.Published = DateTime.Now; await _api.Posts.SaveAsync(post); // Add the startpage var startPage = await StartPage.CreateAsync(_api); startPage.SiteId = site.Id; startPage.Title = "Porta Tortor Euismod"; startPage.MetaKeywords = "Fusce, Tristique, Nullam, Parturient, Pellentesque"; startPage.MetaDescription = "Vestibulum id ligula porta felis euismod semper."; startPage.NavigationTitle = "Home"; startPage.Hero.PrimaryImage = bannerId; startPage.Hero.Ingress = "Aenean lacinia bibendum nulla sed consectetur."; startPage.Blocks.Add(new HtmlBlock { Body = "<p>Nulla vitae elit libero, a pharetra augue. Curabitur blandit tempus porttitor. Nulla vitae elit libero, a pharetra augue. Donec id elit non mi porta gravida at eget metus. Curabitur blandit tempus porttitor.</p><p>Etiam porta sem malesuada magna mollis euismod. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Curabitur blandit tempus porttitor. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>" }); startPage.Published = DateTime.Now; // Add teasers startPage.Teasers.Add(new Teaser() { Title = "Lorem Consectetur", SubTitle = "Ultricies Nullam Cras", Body = "Aenean lacinia bibendum nulla sed consectetur. Donec id elit non mi porta gravida at eget metus.", PageLink = blogPage }); startPage.Teasers.Add(new Teaser() { Title = "Vestibulum Bibendum", SubTitle = "Tortor Cras Tristique", Body = "Nullam id dolor id nibh ultricies vehicula ut id elit. Cras justo odio, dapibus ac facilisis in, egestas eget quam.", PostLink = post }); await _api.Pages.SaveAsync(startPage); return(Redirect("~/")); }