Пример #1
0
        /// <summary>
        /// Renders the full story summary.
        /// </summary>
        /// <param name="writer">The writer.</param>
        protected void RenderFullSummary(HtmlTextWriter writer)
        {
            Category category     = CategoryCache.GetCategory(_story.CategoryID, KickPage.HostProfile.HostID);
            string   kickStoryUrl =
                UrlFactory.CreateUrl(UrlFactory.PageName.ViewStory, _story.StoryIdentifier, category.CategoryIdentifier);

            string categoryUrl    = UrlFactory.CreateUrl(UrlFactory.PageName.ViewCategory, category.CategoryIdentifier);
            string kickCountClass = GetKickCountClass();

            bool isKicked = UserCache.HasUserKickedStory(_story.StoryID, KickPage.KickUserProfile.UserID);

            string kickItCssClass = "visible";
            string kickedCssClass = "hidden";

            if (isKicked)
            {
                kickItCssClass = "hidden";
                kickedCssClass = "visible";
            }

            string adminHtml = "";

            string tableClass = "storySummaryTable storySummaryTable";

            if (_isOddRow)
            {
                tableClass += "Odd";
            }
            else
            {
                tableClass += "Even";
            }

            //TODO: remove inline style from table
            // Render kick it side image
            writer.WriteLine(
                @"<div id =""m_{3}"" class=""u_{9}"">
                <table class=""" + tableClass +
                @"""><tr>
                    <td class=""storySummaryKickTD"">
                        <div class=""storyKickCount {2}""><a href=""{0}""><span id=""{3}_KickCount"">{1}</span></a><br /><span class=""smallText"">kicks</span></div>
                        <div class=""storyKickIt {4}"" id=""{3}_KickIt""><a href=""javascript:KickIt({3}, {6});"">
                            kick it</a></div>
                        <div class=""storyKicked {5}"" id=""{3}_UnKickIt""><a href=""javascript:UnKickIt({3});"">kicked</a></div>
                    {8}</td>
            ",
                kickStoryUrl, _story.KickCount, kickCountClass, _story.StoryID, kickItCssClass, kickedCssClass,
                KickPage.User.Identity.IsAuthenticated.ToString().ToLower(), KickPage.StaticIconRootUrl, adminHtml, _story.UserID);

            string publishedHtml  = "";
            string linkAttributes = "";

            // Create published date string
            if (_story.IsPublishedToHomepage)
            {
                publishedHtml = "published " + Dates.ReadableDiff(_story.PublishedOn, DateTime.Now) + ", ";
            }
            else
            {
                linkAttributes = "rel=\"nofollow\"";
            }

            //TODO: remove inline style from table
            // Render submitted by link
            writer.WriteLine(
                @"
                    <td class=""storySummaryMainTD xfolkentry""><table width=""100%"" class=""WideTable"" cellpadding=""0"" cellspacing=""0""><tr><td valign=""top"">
                        <div class=""storyTitle""><a class=""taggedlink"" onclick=""plusViewCount({5});"" href=""{0}"" {4}>{1}</a> <a href=""{0}""><img onclick=""plusViewCount({5});"" src=""{3}/external.png"" width=""10"" height=""10"" border=""0""/></a></div>
                        <div class=""storySubmitted"">{2} submitted by ",
                _story.Url, _story.Title, publishedHtml, KickPage.StaticIconRootUrl, linkAttributes, _story.StoryID);

            // Render user link
            UserLink userLink = new UserLink();

            userLink.DataBind(UserCache.GetUser(_story.UserID));
            userLink.RenderControl(writer);
            string hostname = GetHostName(_story.Url);
            // Render read more link
            string moreLink = "";

            if (ShowMoreLink)
            {
                moreLink = String.Format(@" <a href=""{0}"" onclick=""javascript:plusViewCount({1});"">read more...</a>", kickStoryUrl, _story.StoryID);
            }
            // Rended add comment/number of comments link
            writer.WriteLine(
                @"
                {0}</div>
        
                        <p class=""description"">{1}</p>

                        <div class=""storyActions"">
                            <a href=""{2}"" class=""commentsLink"">
            ",
                Dates.ReadableDiff(_story.CreatedOn, DateTime.Now), hostname + _story.Description + moreLink, kickStoryUrl);

            writer.WriteLine(@"<img src=""{0}/comment.png"" alt=""Add a comment"" width=""16"" height=""16"" border=""0"" /> ",
                             KickPage.StaticIconRootUrl);

            if (_story.CommentCount == 0)
            {
                writer.WriteLine(@"<a href=""{0}#comments"">add a comment</a>", kickStoryUrl);
            }
            else if (_story.CommentCount == 1)
            {
                writer.WriteLine(@"<a href=""{0}#comments"">1 comment</a>", kickStoryUrl);
            }
            else
            {
                writer.WriteLine(@"<a href=""{0}#comments"">{1} comments</a>", kickStoryUrl, _story.CommentCount);
            }

            // Render category html
            string categoryIcon = "";

            if (category.IconNameSpecified)
            {
                categoryIcon =
                    String.Format(@"<a href=""{0}""><img src=""{1}/{2}"" width=""16"" height=""16"" border=""0"" /></a>",
                                  categoryUrl, KickPage.StaticIconRootUrl, category.IconName);
            }
            writer.WriteLine(@" | 
                category: {0} <a href=""{1}"" rel=""tag"">{2}</a> | Views: {3}", categoryIcon, categoryUrl,
                             category.Name, _story.ViewCount);

            // Render Get Kick Image html
            if (_showGetKickImageCodeLink)
            {
                writer.WriteLine(@" | <a href=""javascript:;"" onclick=""$('#kickImagePersonalization').toggle();"">Get KickIt image code</a>");
            }

            // Render report as spam link
            if (KickPage.IsAuthenticated)
            {
                writer.WriteLine(
                    @" | <span class=""ReportAsSpamLink""><a href=""javascript:ReportAsSpam({0});"">report as spam</a></span>",
                    _story.StoryID);
            }


            // Render delete story link
            if (KickPage.IsHostModerator)
            {
                string deleteText = "delete";
                string banText    = "ban";
                if (_story.SpamCount > 0)
                {
                    deleteText += " (spam count is " + _story.SpamCount + ")";
                }
                if (_story.IsSpam)
                {
                    writer.WriteLine(
                        @" |
                    <span class=""ModeratorLink""><a href=""javascript:UnDelete({0});"">{1}</a></span>
                    ",
                        _story.StoryID, "un" + deleteText);
                }
                else
                {
                    writer.WriteLine(
                        @" |
                    <span class=""ModeratorLink""><a href=""javascript:Delete({0});"">{1}</a></span>
                     |
                    <span class=""BanLink""><a href=""javascript:Ban({2});"">{3}</a></span>
                    ",
                        _story.StoryID, deleteText, _story.UserID, banText);
                }
            }


            // Render story thumbnail
            //writer.WriteLine(@"</td><td width=""94""><a href=""http://{0}""><img src=""http://thumboo.com/?size=t&url={0}"" width=""92"" height=""70"" class=""Thumbnail"" /></a></td></tr></table>", this._storyRow.Url.Replace("http://", ""));
            // writer.WriteLine(@"</td><td width=""94""><a href=""{0}""><img src=""http://images.websnapr.com/?size=t&url={0}"" width=""92"" height=""70"" class=""Thumbnail"" /></a></td></tr></table>", this._story.Url);
            if (!KickPage.IsAuthenticated || KickPage.KickUserProfile.ShowStoryThumbnail)
            {
                writer.WriteLine(
                    @"</td><td width=""94""><a onclick=""javascript:plusViewCount({2});"" href=""{0}""><img src=""http://dotnetkicks.kwiboo.com/getimage.aspx?size=thumb&url={1}"" width=""92"" height=""70"" class=""Thumbnail"" /></a>",
                    _story.Url, HttpUtility.UrlEncode(_story.Url), _story.StoryID);
            }

            writer.WriteLine(@"</td></tr></table>", _story.Url);

            // Render tag list html
            writer.WriteLine(@"<span class=""TagListSummary"">");
            WeightedTagList tags = TagCache.GetStoryTags(_story.StoryID);

            tags.Sort(new WeightedTagList.UsageCountComparer());
            TagCommaList tagCommaList = new TagCommaList();

            Controls.Add(tagCommaList);
            tagCommaList.DataBind(tags.GetTopTags(5), _story.StoryID);
            tagCommaList.RenderControl(writer);
            writer.WriteLine(@"</span>");

            writer.WriteLine("</div><br /><br />");

            tags.Sort(new WeightedTagList.AlphabeticalComparer());
            StoryTagList storyTagList = new StoryTagList();

            Controls.Add(storyTagList);
            storyTagList.DataBind(tags, _story.StoryID);
            storyTagList.RenderControl(writer);

            writer.WriteLine("</td></tr></table></div>");
        }
Пример #2
0
        /// <summary>
        /// Renders the full story summary.
        /// </summary>
        /// <param name="writer">The writer.</param>
        protected void RenderFullSummary(HtmlTextWriter writer)
        {
            Category category = CategoryCache.GetCategory(_story.CategoryID, KickPage.HostProfile.HostID);
            string kickStoryUrl =
                UrlFactory.CreateUrl(UrlFactory.PageName.ViewStory, _story.StoryIdentifier, category.CategoryIdentifier);

            string categoryUrl = UrlFactory.CreateUrl(UrlFactory.PageName.ViewCategory, category.CategoryIdentifier);
            string kickCountClass = GetKickCountClass();

            bool isKicked = UserCache.HasUserKickedStory(_story.StoryID, KickPage.KickUserProfile.UserID);

            string kickItCssClass = "visible";
            string kickedCssClass = "hidden";
            if(isKicked)
            {
                kickItCssClass = "hidden";
                kickedCssClass = "visible";
            }

            string adminHtml = "";

            string tableClass = "storySummaryTable storySummaryTable";
            if(_isOddRow)
                tableClass += "Odd";
            else
                tableClass += "Even";

            //TODO: remove inline style from table
            // Render kick it side image
            writer.WriteLine(
                @"<div id =""m_{3}"" class=""u_{9}"">
                <table class=""" + tableClass +
                @"""><tr>
                    <td class=""storySummaryKickTD"">
                        <div class=""storyKickCount {2}""><a href=""{0}""><span id=""{3}_KickCount"">{1}</span></a><br /><span class=""smallText"">kicks</span></div>
                        <div class=""storyKickIt {4}"" id=""{3}_KickIt""><a href=""javascript:KickIt({3}, {6});"">
                            kick it</a></div>
                        <div class=""storyKicked {5}"" id=""{3}_UnKickIt""><a href=""javascript:UnKickIt({3});"">kicked</a></div>
                    {8}</td>
            ",
                kickStoryUrl, _story.KickCount, kickCountClass, _story.StoryID, kickItCssClass, kickedCssClass,
                KickPage.User.Identity.IsAuthenticated.ToString().ToLower(), KickPage.StaticIconRootUrl, adminHtml, _story.UserID);

            string publishedHtml = "";
            string linkAttributes = "";

            // Create published date string
            if(_story.IsPublishedToHomepage)
                publishedHtml = "published " + Dates.ReadableDiff(_story.PublishedOn, DateTime.Now) + ", ";
            else
                linkAttributes = "rel=\"nofollow\"";

            //TODO: remove inline style from table
            // Render submitted by link
            writer.WriteLine(
                @"
                    <td class=""storySummaryMainTD xfolkentry""><table width=""100%"" class=""WideTable"" cellpadding=""0"" cellspacing=""0""><tr><td valign=""top"">
                        <div class=""storyTitle""><a class=""taggedlink"" onclick=""plusViewCount({5});"" href=""{0}"" {4}>{1}</a> <a href=""{0}""><img onclick=""plusViewCount({5});"" src=""{3}/external.png"" width=""10"" height=""10"" border=""0""/></a></div>
                        <div class=""storySubmitted"">{2} submitted by ",
                _story.Url, _story.Title, publishedHtml, KickPage.StaticIconRootUrl, linkAttributes, _story.StoryID);

            // Render user link
            UserLink userLink = new UserLink();
            userLink.DataBind(UserCache.GetUser(_story.UserID));
            userLink.RenderControl(writer);
            string hostname = GetHostName(_story.Url);
            // Render read more link
            string moreLink = "";
            if (ShowMoreLink)
                moreLink = String.Format(@" <a href=""{0}"" onclick=""javascript:plusViewCount({1});"">read more...</a>", kickStoryUrl, _story.StoryID);
            // Rended add comment/number of comments link
            writer.WriteLine(
                @"
                {0}</div>

                        <p class=""description"">{1}</p>

                        <div class=""storyActions"">
                            <a href=""{2}"" class=""commentsLink"">
            ",
                Dates.ReadableDiff(_story.CreatedOn, DateTime.Now), hostname + _story.Description + moreLink, kickStoryUrl);

            writer.WriteLine(@"<img src=""{0}/comment.png"" alt=""Add a comment"" width=""16"" height=""16"" border=""0"" /> ",
                             KickPage.StaticIconRootUrl);

            if(_story.CommentCount == 0)
                writer.WriteLine(@"<a href=""{0}#comments"">add a comment</a>", kickStoryUrl);
            else if(_story.CommentCount == 1)
                writer.WriteLine(@"<a href=""{0}#comments"">1 comment</a>", kickStoryUrl);
            else
                writer.WriteLine(@"<a href=""{0}#comments"">{1} comments</a>", kickStoryUrl, _story.CommentCount);

            // Render category html
            string categoryIcon = "";
            if(category.IconNameSpecified)
                categoryIcon =
                    String.Format(@"<a href=""{0}""><img src=""{1}/{2}"" width=""16"" height=""16"" border=""0"" /></a>",
                                  categoryUrl, KickPage.StaticIconRootUrl, category.IconName);
            writer.WriteLine(@" |
                category: {0} <a href=""{1}"" rel=""tag"">{2}</a> | Views: {3}", categoryIcon, categoryUrl,
                             category.Name, _story.ViewCount);

            // Render Get Kick Image html
            if(_showGetKickImageCodeLink)
                writer.WriteLine(@" | <a href=""javascript:;"" onclick=""$('#kickImagePersonalization').toggle();"">Get KickIt image code</a>");

            // Render report as spam link
            if(KickPage.IsAuthenticated)
                writer.WriteLine(
                    @" | <span class=""ReportAsSpamLink""><a href=""javascript:ReportAsSpam({0});"">report as spam</a></span>",
                    _story.StoryID);

            // Render delete story link
            if (KickPage.IsHostModerator)
            {
                string deleteText = "delete";
                string banText = "ban";
                if (_story.SpamCount > 0)
                    deleteText += " (spam count is " + _story.SpamCount + ")";
                if (_story.IsSpam)
                {
                    writer.WriteLine(
                        @" |
                    <span class=""ModeratorLink""><a href=""javascript:UnDelete({0});"">{1}</a></span>
                    ",
                        _story.StoryID, "un" + deleteText);
                }
                else
                {
                    writer.WriteLine(
                     @" |
                    <span class=""ModeratorLink""><a href=""javascript:Delete({0});"">{1}</a></span>
                     |
                    <span class=""BanLink""><a href=""javascript:Ban({2});"">{3}</a></span>
                    ",
                     _story.StoryID, deleteText, _story.UserID, banText);
                }
            }

            // Render story thumbnail
            //writer.WriteLine(@"</td><td width=""94""><a href=""http://{0}""><img src=""http://thumboo.com/?size=t&url={0}"" width=""92"" height=""70"" class=""Thumbnail"" /></a></td></tr></table>", this._storyRow.Url.Replace("http://", ""));
            // writer.WriteLine(@"</td><td width=""94""><a href=""{0}""><img src=""http://images.websnapr.com/?size=t&url={0}"" width=""92"" height=""70"" class=""Thumbnail"" /></a></td></tr></table>", this._story.Url);
            if(!KickPage.IsAuthenticated || KickPage.KickUserProfile.ShowStoryThumbnail)
            writer.WriteLine(
                @"</td><td width=""94""><a onclick=""javascript:plusViewCount({2});"" href=""{0}""><img src=""http://dotnetkicks.kwiboo.com/getimage.aspx?size=thumb&url={1}"" width=""92"" height=""70"" class=""Thumbnail"" /></a>",
                _story.Url, HttpUtility.UrlEncode(_story.Url), _story.StoryID);

            writer.WriteLine(@"</td></tr></table>", _story.Url);

            // Render tag list html
            writer.WriteLine(@"<span class=""TagListSummary"">");
            WeightedTagList tags = TagCache.GetStoryTags(_story.StoryID);

            tags.Sort(new WeightedTagList.UsageCountComparer());
            TagCommaList tagCommaList = new TagCommaList();
            Controls.Add(tagCommaList);
            tagCommaList.DataBind(tags.GetTopTags(5), _story.StoryID);
            tagCommaList.RenderControl(writer);
            writer.WriteLine(@"</span>");

            writer.WriteLine("</div><br /><br />");

            tags.Sort(new WeightedTagList.AlphabeticalComparer());
            StoryTagList storyTagList = new StoryTagList();
            Controls.Add(storyTagList);
            storyTagList.DataBind(tags, _story.StoryID);
            storyTagList.RenderControl(writer);

            writer.WriteLine("</td></tr></table></div>");
        }
Пример #3
0
        public static UserAction RecordTag(int hostID, User user, Story story, WeightedTagList tags)
        {
            UserAction userAction = Create(hostID, user.UserID, story.StoryID, ActionType.Tag);

            if (tags.Count > 0) {
                TagCommaList tagList = new TagCommaList();
                tagList.DataBind(tags, story.StoryID, false);

                userAction.Message = String.Format("tagged {0} with {1}", GetStoryLink(story), ControlHelper.RenderControl(tagList));
                userAction.Save();
            }
            return userAction;
        }