Inheritance: BlogMLNode
Exemplo n.º 1
0
        public void Process(BlogMLBlog blogml)
        {
            Log.Info("Fetching Tags.");

            using (var query = new OxiteReader("SELECT * FROM oxite_Tag"))
            {
                var tags = query.Execute();

                foreach (var tag in tags)
                {
                    var category = new BlogMLCategory
                    {
                        Approved = true,
                        DateCreated = tag.CreatedDate,
                        DateModified = tag.CreatedDate,
                        Description = tag.TagName,
                        ID = tag.TagID.ToString(),
                        ParentRef = tag.TagID.ToString() == tag.ParentTagID.ToString() ? "0" : tag.ParentTagID.ToString(),
                        Title = tag.TagName
                    };

                    blogml.Categories.Add(category);
                }
            }

            Log.InfoFormat("Finished adding {0} tags.", blogml.Categories.Count);
        }
Exemplo n.º 2
0
 public LinkCategory ConvertCategory(BlogMLCategory category)
 {
     return new LinkCategory
     {
         Title = category.Title.Left(MaxCategoryTitleLength),
         Description = category.Description,
         IsActive = category.Approved,
         CategoryType = CategoryType.PostCollection
     };
 }
Exemplo n.º 3
0
 public static BlogMLCategory CreateCategoryInstance(string id, string title, string description, bool approved, string parentId, DateTime dateCreated, DateTime dateModified)
 {
     BlogMLCategory category = new BlogMLCategory();
     category.ID = id;
     category.Title = title;
     category.Description = description;
     category.Approved = approved;
     category.ParentRef = parentId;
     category.DateCreated = dateCreated;
     category.DateModified = dateModified;
     return category;
 }
Exemplo n.º 4
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;
        }
        public void ConvertCategory_WithTitleTooLong_TruncatesTitleToMaxLength()
        {
            // arrange
            var title = new string('a', 151);
            var category = new BlogMLCategory { Title = title };
            var mapper = new BlogMLImportMapper();

            // act
            LinkCategory linkCategory = mapper.ConvertCategory(category);

            // assert
            Assert.AreEqual(150, linkCategory.Title.Length);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Returns every blog category in the blog.
        /// </summary>
        /// <param name="blogId"></param>
        /// <returns></returns>
        public override IList<BlogMLCategory> GetAllCategories(string blogId)
        {
            IList<LinkCategory> categories = Links.GetCategories(CategoryType.PostCollection, ActiveFilter.None);
            IList<BlogMLCategory> bmlCategories = new Collection<BlogMLCategory>();

            foreach(LinkCategory category in categories)
            {
                BlogMLCategory bmlCategory = new BlogMLCategory();
                bmlCategory.ID = category.Id.ToString();
                bmlCategory.Title = category.Title;
                bmlCategory.Approved = category.IsActive;
                bmlCategory.DateCreated = DateTime.Now;
                bmlCategory.DateModified = DateTime.Now;
                if (category.HasDescription)
                    bmlCategory.Description = category.Description;

                bmlCategories.Add(bmlCategory);
            }
            return bmlCategories;
        }
    private void AddEntry(AtomEntry entry, BlogMLBlog blog)
    {
      BlogMLPost post = new BlogMLPost()
      {
        Approved = entry.Visible,
        Content = new BlogMLContent() { Text = entry.Content.ToString() },
        DateCreated = entry.Published.HasValue ? entry.Published.Value.DateTime : entry.Updated.DateTime,
        DateModified = entry.Updated.DateTime,
        HasExcerpt = entry.Summary != null,
        Excerpt = entry.Summary != null ? new BlogMLContent() { Text = entry.Summary.Text } : null,
        ID = entry.Id.ToString(),
        PostName = entry.Id.EntryPath,
        PostType = BlogML.BlogPostTypes.Normal,
        PostUrl = entry.LocationWeb.ToString(),
        Title = entry.Title.ToString()
      };

      foreach (AtomPerson author in entry.Authors)
      {
        BlogMLAuthor a = new BlogMLAuthor()
        {
          Approved = true,
          DateCreated = DateTime.UtcNow,
          DateModified = DateTime.UtcNow,
          Email = author.Email,
          ID = author.Id,
          Title = author.Name
        };

        if (blog.Authors.Where(x => x.ID == a.ID).Count() == 0) blog.Authors.Add(a);
        post.Authors.Add(new BlogMLAuthorReference() { Ref = a.ID });
      }

      foreach (AtomCategory cat in entry.Categories)
      {
        BlogMLCategory c = new BlogMLCategory()
        {
          ID = cat.Term,
          Approved = false,
          DateCreated = DateTime.UtcNow,
          DateModified = DateTime.UtcNow,
          Title = cat.ToString()
        };
        if (blog.Categories.Where(x => x.ID == c.ID).Count() == 0) blog.Categories.Add(c);
        post.Categories.Add(new BlogMLCategoryReference() { Ref = c.ID });
      }


      IPagedList<AtomEntry> anns = null;
      int page = 0;
      do
      {
        anns = AtomPubService.GetEntries(new EntryCriteria() { EntryId = entry.Id, Annotations = true, Authorized = true, Deep = true },
        page, 100); page++;
        foreach (AtomEntry ann in anns)
        {
          try
          {
            LogService.Info("Processing annotation with ID='{0}'", ann.Id);
            AddAnnotation(ann, post, blog);
          }
          catch (Exception ex)
          {
            LogService.Error(ex);
          }
        }
      } while (anns.PageIndex < anns.PageCount);

      //TODO: attachments
      //post.Attachments.Add(new BlogMLAttachment()
      //{

      //});

      blog.Posts.Add(post);
    }