コード例 #1
0
        public void Process(BlogMLPost postml)
        {
            Log.Debug("Fetching trackbacks.");

            using (var query = new OxiteReader("SELECT * FROM oxite_Trackback WHERE PostID='" + postml.ID + "'"))
            {
                var trackbacks = query.Execute();

                foreach (var track in trackbacks)
                {
                    var trackbackml = new BlogMLTrackback
                    {
                        Approved = false, /* Oxite has no trackback approving */
                        DateCreated = track.CreatedDate,
                        DateModified = track.ModifiedDate,
                        ID = track.TrackbackID.ToString(),
                        Title = track.Title,
                        Url = track.Url
                    };

                    postml.Trackbacks.Add(trackbackml);
                }
            }

            Log.DebugFormat("Finished adding {0} trackbacks.", postml.Trackbacks.Count);
        }
コード例 #2
0
ファイル: BlogMLPost.cs プロジェクト: Gutek/MovingScrewdriver
 public void Add(BlogMLTrackback value)
 {
     base.Add(value);
 }
コード例 #3
0
        public void Import_WithBlogPostHavingTrackback_CreatesTrackbackUsingPostId()
        {
            // arrange
            var blog = new BlogMLBlog();
            var post = new BlogMLPost();
            var trackback = new BlogMLTrackback();
            post.Trackbacks.Add(trackback);
            blog.Posts.Add(post);
            var repository = new Mock<IBlogImportRepository>();
            repository.Setup(r => r.CreateBlogPost(blog, post)).Returns("98053");
            bool trackbackCreated = false;
            repository.Setup(r => r.CreateTrackback(trackback, "98053")).Callback(() => trackbackCreated = true);
            var service = new BlogImportService(repository.Object);

            // act
            service.Import(blog);

            // assert
            Assert.IsTrue(trackbackCreated);
        }
コード例 #4
0
 public void Add(BlogMLTrackback value)
 {
     base.Add(value);
 }
コード例 #5
0
ファイル: ObjectHydrator.cs プロジェクト: ayende/Subtext
 public static BlogMLTrackback CreateTrackBackInstance(string id, string title, string url, bool approved, DateTime dateCreated, DateTime dateModified)
 {
     BlogMLTrackback trackback = new BlogMLTrackback();
     trackback.ID = id;
     trackback.Url = url;
     trackback.Title = title;
     trackback.Approved = approved;
     trackback.DateCreated = dateCreated;
     trackback.DateModified = dateModified;
     return trackback;
 }
コード例 #6
0
ファイル: ObjectHydrator.cs プロジェクト: ayende/Subtext
 /// <summary>
 /// Loads the trackback from data reader.
 /// </summary>
 /// <param name="reader">The reader.</param>
 /// <returns></returns>
 public static BlogMLTrackback LoadTrackbackFromDataReader(IDataReader reader)
 {
     FeedbackItem trackback = DataHelper.LoadFeedbackItem(reader);
     BlogMLTrackback blogMLTrackback = new BlogMLTrackback();
     blogMLTrackback.ID = trackback.Id.ToString(CultureInfo.InvariantCulture);
     blogMLTrackback.Title = trackback.Title;
     blogMLTrackback.Approved = trackback.Approved;
     blogMLTrackback.DateCreated = trackback.DateCreated;
     blogMLTrackback.DateModified = trackback.DateModified;
     if (trackback.SourceUrl != null)
         blogMLTrackback.Url = trackback.SourceUrl.ToString();
     return blogMLTrackback;
 }
コード例 #7
0
        private BlogMLBlog BuildBlogML()
        {
            var mlBlog = new BlogMLBlog();
            var author = new BlogMLAuthor {Title = "admin"};
            mlBlog.Authors.Add(author);
            var cat = new BlogMLCategory {Title = "Title 1", ID = "1"};
            mlBlog.Categories.Add(cat);
            cat = new BlogMLCategory { Title = "Title 2", ID = "2" };
            mlBlog.Categories.Add(cat);
            cat = new BlogMLCategory { Title = "Title 3", ID = "3" };
            mlBlog.Categories.Add(cat);
            cat = new BlogMLCategory { Title = "Title 4", ID = "4" };
            mlBlog.Categories.Add(cat);
            cat = new BlogMLCategory { Title = "Title 5", ID = "5" };
            mlBlog.Categories.Add(cat);
            cat = new BlogMLCategory { Title = "Title 6", ID = "6" };
            mlBlog.Categories.Add(cat);
            cat = new BlogMLCategory { Title = "Title 7", ID = "7" };
            mlBlog.Categories.Add(cat);
            cat = new BlogMLCategory { Title = "Title 8", ID = "8" };
            mlBlog.Categories.Add(cat);

            var mlPost = new BlogMLPost();
            mlPost.Categories.Add("1");
            mlPost.Approved = true;
            mlPost.Content = new BlogMLContent {ContentType = ContentTypes.Text, Text = "post 1"};
            mlPost.DateCreated = new DateTime(2012, 2, 2);
            mlPost.DateModified = new DateTime(2012, 2, 2);
            mlPost.Excerpt = new BlogMLContent { ContentType = ContentTypes.Text, Text = "post 1" };
            mlPost.HasExcerpt = true;
            mlPost.ID = "1";
            mlPost.PostName = "name 1";
            mlPost.PostType = BlogPostTypes.Normal;
            var trackback = new BlogMLTrackback
                                            {
                                                Approved = true,
                                                DateCreated = new DateTime(2012, 2, 2),
                                                DateModified = new DateTime(2012, 2, 2),
                                                ID = "2",
                                                Title = "trackback title 2",
                                                Url = "url2"
                                            };
            mlPost.Trackbacks.Add(trackback);
            mlPost.Title = "Title 1";
            mlPost.Views = 0;
            mlBlog.Posts.Add(mlPost);

            mlPost = new BlogMLPost();
            mlPost.Categories.Add("1");
            mlPost.Approved = true;
            mlPost.Content = new BlogMLContent { ContentType = ContentTypes.Text, Text = "post 3" };
            mlPost.DateCreated = new DateTime(2032, 3, 3);
            mlPost.DateModified = new DateTime(2032, 3, 3);
            mlPost.Excerpt = new BlogMLContent { ContentType = ContentTypes.Text, Text = "post 3" };
            mlPost.HasExcerpt = true;
            mlPost.ID = "3";
            mlPost.PostName = "name 3";
            mlPost.PostType = BlogPostTypes.Normal;
            trackback = new BlogMLTrackback
            {
                Approved = true,
                DateCreated = new DateTime(2032, 3, 3),
                DateModified = new DateTime(2032, 3, 3),
                ID = "3",
                Title = "trackback title 3",
                Url = "url1"
            };
            mlPost.Trackbacks.Add(trackback);
            mlPost.Title = "Title 2";
            mlPost.Views = 0;
            mlBlog.Posts.Add(mlPost);

            return mlBlog;
        }
コード例 #8
0
 public void CreateTrackback(BlogMLTrackback trackback, string newPostId)
 {
     var pingTrack = Mapper.ConvertTrackback(trackback, newPostId);
     CommentService.Create(pingTrack, false /*runfilters*/);
 }
コード例 #9
0
        public void ConvertTrackback_WithValidSourceUrl_SetsUrlAndAuthorUsingHostname()
        {
            // arrange
            var trackback = new BlogMLTrackback { Url = "http://example.com/valid-url" };
            var mapper = new BlogMLImportMapper();

            // act
            var convertedTrackback = mapper.ConvertTrackback(trackback, "123");

            // assert
            Assert.AreEqual(new Uri("http://example.com/valid-url"), convertedTrackback.SourceUrl);
            Assert.AreEqual("example.com", convertedTrackback.Author);
        }
コード例 #10
0
        public void ConvertTrackback_WithInvalidSourceUrl_IgnoresUrl()
        {
            // arrange
            var trackback = new BlogMLTrackback {Url = "not-valid-url"};
            var mapper = new BlogMLImportMapper();

            // act
            var convertedTrackback = mapper.ConvertTrackback(trackback, "123");

            // assert
            Assert.AreEqual(null, convertedTrackback.SourceUrl);
        }
コード例 #11
0
        public void ConvertTrackback_ReturnsFeedbackItemAsPingTrack()
        {
            // arrange
            var trackback = new BlogMLTrackback();
            var mapper = new BlogMLImportMapper();

            // act
            var convertedTrackback = mapper.ConvertTrackback(trackback, "123");

            // assert
            Assert.AreEqual(FeedbackType.PingTrack, convertedTrackback.FeedbackType);
        }
コード例 #12
0
 public FeedbackItem ConvertTrackback(BlogMLTrackback trackback, string parentPostId)
 {
     string author = null;
     Uri sourceUri = ConvertUri(trackback.Url);
     if(sourceUri != null)
     {
         author = sourceUri.Host;
     }
     return new FeedbackItem(FeedbackType.PingTrack)
     {
         EntryId = int.Parse(parentPostId, CultureInfo.InvariantCulture),
         Title = trackback.Title,
         SourceUrl = sourceUri,
         Approved = trackback.Approved,
         DateCreated = trackback.DateCreated,
         DateModified = trackback.DateModified,
         Author = author ?? string.Empty,
         Body = string.Empty
     };
 }
コード例 #13
0
        /// <summary>
        /// Creates a trackback for the post.
        /// </summary>
        /// <param name="trackback"></param>
        /// <param name="newPostId"></param>
        public override void CreatePostTrackback(BlogMLTrackback trackback, string newPostId)
        {
            FeedbackItem newPingTrack = new FeedbackItem(FeedbackType.PingTrack);
            newPingTrack.BlogId = Config.CurrentBlog.Id;
            newPingTrack.EntryId = int.Parse(newPostId);
            newPingTrack.Title = trackback.Title;
            newPingTrack.SourceUrl = new Uri(trackback.Url);
            newPingTrack.Approved = trackback.Approved;
            newPingTrack.DateCreated = trackback.DateCreated;
            newPingTrack.DateModified = trackback.DateModified;
            // we use an actual name here, but BlogML doesn't support this, so let's try
            // to parse the url's host out of the url.
            newPingTrack.Author = UrlFormats.GetHostFromExternalUrl(trackback.Url);
            // so the duplicate Comment Filter doesn't break when computing the checksum
            newPingTrack.Body = string.Empty;

            FeedbackItem.Create(newPingTrack, null);
        }
コード例 #14
0
ファイル: BlogMlProvider.cs プロジェクト: ayende/Subtext
 /// <summary>
 /// Creates a trackback for the post.
 /// </summary>
 /// <param name="trackback"></param>
 public abstract void CreatePostTrackback(BlogMLTrackback trackback, string newPostId);