public ActionResult Index() { PostDto item = new PostDto(); item.Title = "Post Title"; item.Excerpt = "Post abstract"; item.Content = "This is the body of a fake post"; item.PublishAt = DateTime.Today; item.Slug = "PostSlug"; item.Status = ItemStatus.Published; item.Tags = new [] { "tag1", "tag2" }; this.postService.SaveOrUpdate(item); return this.Content("Fake data added"); }
public static MvcHtmlString TrackBackRdf(this HtmlHelper helper, PostDto item) { IUrlBuilder u = DexterContainer.Resolve<IUrlBuilder>(); BlogConfigurationDto c = DexterContainer.Resolve<IConfigurationService>().GetConfiguration(); if (!c.Tracking.EnableTrackBackReceive) { return MvcHtmlString.Empty; } StringBuilder sb = new StringBuilder(); sb.Append("<!--"); sb.Append("<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:trackback=\"http://madskills.com/public/xml/rss/module/trackback/\">"); sb.AppendLine(); sb.AppendFormat("<rdf:Description rdf:about=\"{0}\" dc:identifier=\"{0}\" dc:title=\"{1}\" trackback:ping=\"{2}\" />", u.Post.Permalink(item), item.Title, u.Post.TrackBack(item)); sb.AppendLine("</rdf:RDF>"); sb.AppendLine("-->"); return MvcHtmlString.Create(sb.ToString()); }
public async Task InitializeAsync(Setup item) { string defaultPostPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Setup/defaultPost.dxt"); var defaultPostTask = this.GetDefaultPostContent(defaultPostPath, item.SiteDomain.Host); var membershipTask = this.CreateMembershipAndRole(item); BlogConfigurationDto configuration = new BlogConfigurationDto(item.BlogName, item.SiteDomain); configuration.TimeZone = TimeZoneInfo.FindSystemTimeZoneById("UTC"); this.configurationDataService.CreateSetupConfiguration(configuration); this.logger.Debug("Created blog configuration."); //Creating default category this.categoryService.SaveOrUpdate(new CategoryDto { Name = "Various", IsDefault = true }); this.logger.Debug("Created default category."); PostDto defaultPost = new PostDto(); defaultPost.Title = "Welcome to Dexter!"; defaultPost.Tags = new[] { "Dexter" }; defaultPost.Categories = new[] { "Various" }; defaultPost.Status = ItemStatus.Published; defaultPost.PublishAt = DateTimeOffset.Now.AsMinutes(); defaultPost.Author = item.AdminUsername; defaultPost.AllowComments = true; await Task.WhenAll(defaultPostTask, membershipTask); defaultPost.Content = defaultPostTask.Result; this.postDataService.SaveOrUpdate(defaultPost); this.logger.Debug("Created default post."); }
private Post GetMetaweblogPost(PostDto item, IEnumerable<WpAuthor> authors) { string authorId = this.GetAuthorId(item, authors); // the fields reported here are all the ones you should use Post p = new Post { dateCreated = item.CreatedAt.DateTime.ToUniversalTime(), userid = authorId, postid = item.Id.ToString(), description = item.Content, title = item.Title, link = this.urlBuilder.Post.Permalink(item), permalink = this.urlBuilder.Post.Permalink(item), categories = item.Categories.ToArray(), mt_excerpt = item.Excerpt, mt_text_more = string.Empty, mt_allow_comments = item.AllowComments ? 1 : 2, // open or close mt_allow_pings = 1, mt_keywords = string.Join(",", item.Tags), wp_slug = item.Slug, wp_password = string.Empty, wp_author_id = authorId, wp_author_display_name = item.Author, date_created_gmt = item.CreatedAt.DateTime.ToUniversalTime(), post_status = item.Status.ToString(), custom_fields = null, sticky = false }; return p; }
private SyndicationItem BuildSyndicationItem(PostDto item) { SyndicationItem feedItem = new SyndicationItem { Title = new TextSyndicationContent(item.Title), BaseUri = this.UrlBuilder.Post.Permalink(item), LastUpdatedTime = item.PublishAt, Content = new TextSyndicationContent(item.Content), PublishDate = item.PublishAt }; feedItem.Authors.Add(new SyndicationPerson { Name = item.Author }); return feedItem; }
public void SaveOrUpdate(PostDto item) { if (item == null) { throw new ArgumentNullException("item", "The post must be contains a valid instance"); } Post post = this.Session.Load<Post>(item.Id) ?? new Post { CreatedAt = DateTimeOffset.Now }; if (string.IsNullOrEmpty(item.Author)) { item.Author = Thread.CurrentPrincipal.Identity.Name; } item.MapPropertiesToInstance(post); if (string.IsNullOrEmpty(post.Excerpt)) { string generateAbstract = AbstractHelper.GenerateAbstract(post.Content); post.Excerpt = generateAbstract; } if (string.IsNullOrEmpty(post.Slug)) { post.Slug = SlugHelper.GenerateSlug(post.Title, post.Id, this.GetPostBySlugInternal); } if (post.IsTransient) { ItemComments comments = new ItemComments { Item = new ItemReference { Id = post.Id, Status = post.Status, ItemPublishedAt = post.PublishAt } }; this.Session.Store(comments); post.CommentsId = comments.Id; ItemTrackbacks trackbacks = new ItemTrackbacks { Item = new ItemReference { Id = post.Id, Status = post.Status, ItemPublishedAt = post.PublishAt } }; this.Session.Store(trackbacks); post.TrackbacksId = trackbacks.Id; } this.Session.Store(post); UpdateDenormalizedItemIndex.UpdateIndexes(this.store, this.Session, post); item.Id = RavenIdHelper.Resolve(post.Id); }