private MetaWeblog.Post Create(Entry entry) { if (entry == null) { throw new ArgumentNullException("entry"); } var post = new MetaWeblog.Post(); post.description = entry.Content ?? ""; post.mt_excerpt = entry.Description ?? ""; post.dateCreated = entry.CreatedUtc; post.title = entry.Title ?? ""; post.link = post.permalink = dasBlogSettings.GetPermaLinkUrl(entry.EntryId); post.postid = entry.EntryId ?? ""; post.categories = entry.GetSplitCategories(); post.mt_text_more = "true"; return(post); }
/// <summary>Fills a DasBlog entry from a MetaWeblog Post structure.</summary> /// <param name="entry">DasBlog entry to fill.</param> /// <param name="post">MetaWeblog post structure to fill from.</param> /// <returns>TrackbackInfoCollection of posts to send trackback pings.</returns> private TrackbackInfoCollection FillEntryFromMetaWeblogPost(Entry entry, MetaWeblog.Post post) { // W.Bloggar doesn't pass in the DataCreated, // so we have to check for that if (post.dateCreated != DateTime.MinValue) { entry.CreatedUtc = post.dateCreated.ToUniversalTime(); } //Patched to avoid html entities in title entry.Title = WebUtility.HtmlDecode(post.title); entry.Content = post.description; entry.Description = NoNull(post.mt_excerpt); // If mt_allow_comments is null, then the sender did not specify. Use default dasBlog behavior in that case if (post.mt_allow_comments != null) { int nAllowComments = Convert.ToInt32(post.mt_allow_comments); if (nAllowComments == 0 || nAllowComments == 2) { entry.AllowComments = false; } else { entry.AllowComments = true; } } if (post.categories != null && post.categories.Length > 0) { // handle categories var categories = ""; var sb = new StringBuilder(); var needSemi = false; post.categories = RemoveDups(post.categories, true); foreach (string category in post.categories) { //watch for "" as a category if (category.Length > 0) { if (needSemi) { sb.Append(";"); } sb.Append(category); needSemi = true; } } categories = sb.ToString(); if (categories.Length > 0) { entry.Categories = categories; } } // We'll always return at least an empty collection var trackbackList = new TrackbackInfoCollection(); // Only MT supports trackbacks in the post if (post.mt_tb_ping_urls != null) { foreach (var trackbackUrl in post.mt_tb_ping_urls) { trackbackList.Add(new TrackbackInfo( trackbackUrl, dasBlogSettings.GetPermaLinkUrl(entry.EntryId), entry.Title, entry.Description, dasBlogSettings.SiteConfiguration.Title)); } } return(trackbackList); }
public string metaweblog_newPost(string blogid, string username, string password, MetaWeblog.Post post, bool publish) { VerifyAccess(username, password); var newPost = new Entry(); newPost.Initialize(); newPost.Author = username; var trackbackList = FillEntryFromMetaWeblogPost(newPost, post); newPost.IsPublic = publish; newPost.Syndicated = publish; dataService.SaveEntry(newPost); return(newPost.EntryId); }
public bool metaweblog_editPost(string postid, string username, string password, MetaWeblog.Post post, bool publish) { VerifyAccess(username, password); Entry entry = dataService.GetEntryForEdit(postid); if (entry != null) { entry.Author = username; TrackbackInfoCollection trackbackList = FillEntryFromMetaWeblogPost(entry, post); entry.IsPublic = publish; entry.Syndicated = publish; dataService.SaveEntry(entry); } return(true); }
public string metaweblog_newPost(string blogid, string username, string password, MetaWeblog.Post post, bool publish) { if (!dasBlogSettings.SiteConfiguration.EnableBloggerApi) { throw new ServiceDisabledException(); } if (!VerifyLogin(username, password)) { throw new SecurityException(); } var newPost = new Entry(); newPost.Initialize(); newPost.Author = username; var trackbackList = FillEntryFromMetaWeblogPost(newPost, post); newPost.IsPublic = publish; newPost.Syndicated = publish; dataService.SaveEntry(newPost); return(newPost.EntryId); }
public bool metaweblog_editPost(string postid, string username, string password, MetaWeblog.Post post, bool publish) { if (!dasBlogSettings.SiteConfiguration.EnableBloggerApi) { throw new ServiceDisabledException(); } if (!VerifyLogin(username, password)) { throw new SecurityException(); } Entry entry = dataService.GetEntryForEdit(postid); if (entry != null) { entry.Author = username; TrackbackInfoCollection trackbackList = FillEntryFromMetaWeblogPost(entry, post); entry.IsPublic = publish; entry.Syndicated = publish; dataService.SaveEntry(entry); } return(true); }