예제 #1
0
 public TagListModel(
     IMasterModel masterModel,
     string name,
     int pageSize,
     PostTagCollection tags)
     : base(masterModel.RootBlogNode)
 {
     _name = name;
     Theme = masterModel.Theme;
     RootBlogNode = masterModel.RootBlogNode;
     BlogArchiveNode = masterModel.BlogArchiveNode;
     PageSize = pageSize;
     BlogTitle = masterModel.BlogTitle;
     BlogDescription = masterModel.BlogDescription;
     Tags = tags;
     BlogBanner = masterModel.BlogBanner;
     BlogLogo = masterModel.BlogLogo;
     DisqusShortName = masterModel.DisqusShortName;
     CustomRssFeed = masterModel.CustomRssFeed;
 }
예제 #2
0
        public static IHtmlString TagCloud(this HtmlHelper html, PostTagCollection model, decimal maxWeight, int maxResults)
        {
            var tagsAndWeight = model.Select(x => new { tag = x, weight = model.GetTagWeight(x, maxWeight) })
                                .OrderByDescending(x => x.weight)
                                .Take(maxResults)
                                .RandomOrder();

            var ul = new TagBuilder("ul");

            ul.AddCssClass("tag-cloud");
            foreach (var tag in tagsAndWeight)
            {
                var li = new TagBuilder("li");
                li.AddCssClass("tag-cloud-" + tag.weight);
                var a = new TagBuilder("a");
                a.MergeAttribute("href", tag.tag.TagUrl);
                a.MergeAttribute("title", tag.tag.TagName);
                a.SetInnerText(tag.tag.TagName);
                li.InnerHtml  = a.ToString();
                ul.InnerHtml += li.ToString();
            }
            return(MvcHtmlString.Create(ul.ToString()));
        }
예제 #3
0
        public static HelperResult TagCloud(this HtmlHelper html, PostTagCollection model, Func <PostsByTagModel, HelperResult> tagLink, decimal maxWeight, int maxResults)
        {
            return(new HelperResult(writer =>
            {
                var tagsAndWeight = model.Select(x => new { tag = x, weight = model.GetTagWeight(x, maxWeight) })
                                    .OrderByDescending(x => x.weight)
                                    .Take(maxResults)
                                    .RandomOrder();

                var ul = new TagBuilder("ul");
                ul.AddCssClass("tag-cloud");
                foreach (var tag in tagsAndWeight)
                {
                    var li = new TagBuilder("li");
                    li.AddCssClass("tag-cloud-" + tag.weight);

                    li.InnerHtml = tagLink(tag.tag).ToString();
                    ul.InnerHtml += li.ToString();
                }

                writer.Write(ul.ToString());
            }));
        }