protected override void Render(HtmlTextWriter writer)
        {
            IPagedCollection <MetaTag> blogMetaTags = MetaTags.GetMetaTagsForBlog(Blog, 0, int.MaxValue);

            foreach (MetaTag tag in blogMetaTags)
            {
                var htmlMetaTag = new HtmlMeta {
                    Content = tag.Content
                };

                if (!string.IsNullOrEmpty(tag.Name))
                {
                    htmlMetaTag.Name = tag.Name;
                }
                else
                {
                    htmlMetaTag.HttpEquiv = tag.HttpEquiv;
                }

                var newLineLiteral = new Literal {
                    Text = Environment.NewLine
                };
                newLineLiteral.RenderControl(writer);
                htmlMetaTag.RenderControl(writer);
            }
        }
        public void CanDeleteEntryMetaTag()
        {
            var   blog  = UnitTestHelper.CreateBlogAndSetupContext();
            Entry entry =
                UnitTestHelper.CreateEntryInstanceForSyndication("Steven Harman", "Sweet arse entry!",
                                                                 "Giddy, giddy, goo!");

            UnitTestHelper.Create(entry);

            MetaTag tag = UnitTestHelper.BuildMetaTag("Foo, bar, zaa?", "author", null, blog.Id, entry.Id, DateTime.Now);

            MetaTags.Create(tag);

            Assert.AreEqual(1, MetaTags.GetMetaTagsForBlog(blog, 0, 100).Count,
                            "Should be one (1) MetaTag for this blog.");
            Assert.AreEqual(1, MetaTags.GetMetaTagsForEntry(entry, 0, 100).Count,
                            "Should be one (1) MetaTag for this entry.");

            // Now let's remove it from the data store
            Assert.IsTrue(MetaTags.Delete(tag.Id), "Deleting the MetaTag failed.");

            Assert.AreEqual(0, MetaTags.GetMetaTagsForBlog(blog, 0, 100).Count,
                            "Should be zero (0) MetaTags for this blog.");
            Assert.AreEqual(0, MetaTags.GetMetaTagsForEntry(entry, 0, 100).Count,
                            "Should be zero (0) MetaTag for this entry.");
        }
Beispiel #3
0
        public void CanUpdateMetaTag(string content, string name, string httpequiv)
        {
            var blog = UnitTestHelper.CreateBlogAndSetupContext();

            MetaTag tag = UnitTestHelper.BuildMetaTag(content, name, httpequiv, blog.Id, null, DateTime.Now);

            MetaTags.Create(tag);

            string randomStr = UnitTestHelper.GenerateUniqueString().Left(20);

            tag.Content = content + randomStr;

            if (!string.IsNullOrEmpty(name))
            {
                tag.Name = name + randomStr;
            }

            if (!string.IsNullOrEmpty(httpequiv))
            {
                tag.HttpEquiv = httpequiv + randomStr;
            }

            Assert.IsTrue(MetaTags.Update(tag));

            MetaTag updTag = MetaTags.GetMetaTagsForBlog(blog, 0, 100)[0];

            ValidateMetaTags(tag, updTag);
        }
        public void CanGetMetaTagsForBlog()
        {
            blog = UnitTestHelper.CreateBlogAndSetupContext();

            InsertNewMetaTag("Adding description meta tag", "description", null, DateTime.Now, blog.Id, null);
            InsertNewMetaTag("no-cache", null, "cache-control", DateTime.Now, blog.Id, null);

            ICollection <MetaTag> tags = MetaTags.GetMetaTagsForBlog(blog, 0, 100);

            Assert.AreEqual(2, tags.Count, "Should be two tags for this blog.");
        }
Beispiel #5
0
        protected override void BindLocalUI()
        {
            Blog blog = Config.CurrentBlog;
            IPagedCollection <MetaTag> tags = MetaTags.GetMetaTagsForBlog(blog, _pageIndex, resultsPager.PageSize);

            ContainsTags = tags.Count > 0;

            // we want to databind either way so we can alter the DOM via JavaScript and AJAX requests.
            MetatagRepeater.DataSource = tags;
            MetatagRepeater.DataBind();

            resultsPager.ItemCount = tags.MaxItems;
            resultsPager.PageSize  = Preferences.ListingItemCount;
            resultsPager.PageIndex = _pageIndex;

            base.BindLocalUI();
        }
Beispiel #6
0
        public void CanRemoveHttpEquivAndAddName()
        {
            var blog = UnitTestHelper.CreateBlogAndSetupContext();

            MetaTag tag = UnitTestHelper.BuildMetaTag("Still nothing to see here.", null, "expires", blog.Id, null,
                                                      DateTime.Now);

            MetaTags.Create(tag);

            tag.HttpEquiv = null;
            tag.Name      = "author";
            tag.Content   = "Steve-o-rino!";

            MetaTags.Update(tag);

            ValidateMetaTags(tag, MetaTags.GetMetaTagsForBlog(blog, 0, 100)[0]);
        }
Beispiel #7
0
        public void CanRemoveNameAndAddHttpEquiv()
        {
            var blog = UnitTestHelper.CreateBlogAndSetupContext();

            MetaTag tag = UnitTestHelper.BuildMetaTag("Nothing to see here.", "description", null, blog.Id, null,
                                                      DateTime.Now);

            MetaTags.Create(tag);

            tag.HttpEquiv = "cache-control";
            tag.Name      = null;
            tag.Content   = "no-cache";

            MetaTags.Update(tag);

            ValidateMetaTags(tag, MetaTags.GetMetaTagsForBlog(blog, 0, 100)[0]);
        }
        public void CanDeleteBlogMetaTag()
        {
            var blog = UnitTestHelper.CreateBlogAndSetupContext();

            MetaTag tag =
                UnitTestHelper.BuildMetaTag("Steve Harman likes to delete stuff!", "description", null, blog.Id, null,
                                            DateTime.Now);

            MetaTags.Create(tag);
            Assert.AreEqual(1, MetaTags.GetMetaTagsForBlog(blog, 0, 100).Count,
                            "Should be one (1) MetaTag for this blog.");

            // Now let's remove it from the data store
            Assert.IsTrue(MetaTags.Delete(tag.Id), "Deleting the MetaTag failed.");

            Assert.AreEqual(0, MetaTags.GetMetaTagsForBlog(blog, 0, 100).Count,
                            "Should be zero (0) MetaTags for this blog.");
        }
        public void CanInsertNewMetaTag(string content, string name, string httpEquiv, bool withEntry, string errMsg)
        {
            blog = UnitTestHelper.CreateBlogAndSetupContext();

            int?entryId = null;

            if (withEntry)
            {
                Entry e = UnitTestHelper.CreateEntryInstanceForSyndication("Steven Harman", "My Post", "Foo Bar Zaa!");
                entryId = UnitTestHelper.Create(e);
            }

            MetaTag mt = UnitTestHelper.BuildMetaTag(content, name, httpEquiv, blog.Id, entryId, DateTime.Now);

            // make sure there are no meta-tags for this blog in the data store
            ICollection <MetaTag> tags = MetaTags.GetMetaTagsForBlog(blog, 0, 100);

            Assert.AreEqual(0, tags.Count, "Should be zero MetaTags.");

            // add the meta-tag to the data store
            int tagId = MetaTags.Create(mt);

            tags = MetaTags.GetMetaTagsForBlog(blog, 0, 100);

            Assert.AreEqual(1, tags.Count, errMsg);

            MetaTag newTag = tags.First();

            // make sure all attributes of the meta-tag were written to the data store correctly.
            Assert.AreEqual(tagId, newTag.Id, "Wrong Id");
            Assert.AreEqual(mt.Content, newTag.Content, "Wrong content");
            Assert.AreEqual(mt.Name, newTag.Name, "wrong name attribute");
            Assert.AreEqual(mt.HttpEquiv, newTag.HttpEquiv, "Wrong http-equiv attriubte");
            Assert.AreEqual(mt.BlogId, newTag.BlogId, "Wrong blogId");
            Assert.AreEqual(mt.EntryId, newTag.EntryId, "Wrong entryId");
            Assert.AreEqual(mt.DateCreated.Date, newTag.DateCreated.Date, "Wrong created date");
        }
 public void GetReturnsZeroWhenNoMetaTagsExistForBlog()
 {
     blog = UnitTestHelper.CreateBlogAndSetupContext();
     Assert.AreEqual(0, MetaTags.GetMetaTagsForBlog(blog, 0, 100).Count,
                     "Shouldn't have found any MetaTags for this blog.");
 }
Beispiel #11
0
 public IPagedCollection <MetaTag> GetPagedItems(int pageIndex, int pageSize)
 {
     return(MetaTags.GetMetaTagsForBlog(Config.CurrentBlog, pageIndex, pageSize));
 }