protected void SubmitStory_Click(object sender, EventArgs e) { if (Page.IsValid) { if (!KickPage.KickUserProfile.IsVetted) { throw new SecurityException("This user can't submit stories"); } short categoryID = short.Parse(Category.SelectedValue); string storyIdentifier = StoryBR.AddStory(KickPage.HostProfile.HostID, Title.Text, Description.Text, Url.Text, categoryID, KickPage.KickUserProfile, KickPage.IPAddress); NewStoryPanel.Visible = false; SuccessPanel.Visible = true; string categoryName = CategoryCache.GetCategory(categoryID, KickPage.HostProfile.HostID).CategoryIdentifier; UpcomingStoryQueue.NavigateUrl = UrlFactory.CreateUrl(UrlFactory.PageName.NewStories); UpcomingStoryQueue.Text = "upcoming queue"; StoryLink.NavigateUrl = UrlFactory.CreateUrl(UrlFactory.PageName.ViewStory, storyIdentifier, categoryName); // Bind the story original url to the image customization user control KickItImagePersonalization.StoryUrl = Url.Text; } }
protected override void Render(HtmlTextWriter writer) { if (relatedStory == null) { return; } if (!String.IsNullOrEmpty(this.Title)) { writer.WriteLine(@"<div class=""PageSmallCaption"">{0}</div>", this.Title); } writer.WriteLine("<ul id=\"relatedStoriesList\">"); foreach (Story s in relatedStory) { Category category = CategoryCache.GetCategory(s.CategoryID, KickPage.HostProfile.HostID); string kickStoryUrl = UrlFactory.CreateUrl(UrlFactory.PageName.ViewStory, s.StoryIdentifier, category.CategoryIdentifier); writer.WriteLine("<li><a href=\"{0}\">{1}</a></li>", kickStoryUrl, s.Title); } writer.WriteLine("</ul>"); }
//NOTE: GJ: this page will be depreciated in favour of tagging protected void Page_Init(object sender, EventArgs e) { this.Caption = "Latest " + CategoryCache.GetCategory(this.UrlParameters.CategoryID, this.HostProfile.HostID).Name + " stories"; this.Title = this.HostProfile.SiteTitle + " - " + this.Caption; this.PageName = UrlFactory.PageName.ViewCategory; this.RssFeedUrl = UrlFactory.CreateUrl(UrlFactory.PageName.ViewCategoryRss, this.UrlParameters.CategoryIdentifier); }
public void GetCategoryReturnsNullWhenCachedCategoryNotFoundTest() { var expected = Model.Create <Category>(); var cacheKey = "Category|" + expected.Group + "|" + expected.Name; var cache = Substitute.For <IMemoryCache>(); var config = Substitute.For <ICacheConfig>(); object value; cache.TryGetValue(cacheKey, out value).Returns(x => false); var sut = new CategoryCache(cache, config); var actual = sut.GetCategory(expected.Group, expected.Name); actual.Should().BeNull(); }
//NOTE: GJ: this page will be depreciated in favour of tagging protected void Page_Init(object sender, EventArgs e) { if (!this.UrlParameters.CategoryIdentifierSpecified) { this.Caption = "Upcoming stories"; this.Title = this.HostProfile.SiteTitle + " - " + this.Caption; } else { this.Caption = "Upcoming " + CategoryCache.GetCategory(this.UrlParameters.CategoryID, this.HostProfile.HostID).Name + " stories"; this.Title = this.HostProfile.SiteTitle + " - " + this.Caption; } this.PageName = UrlFactory.PageName.ViewCategoryNewStories; this.RssFeedUrl = UrlFactory.CreateUrl(UrlFactory.PageName.ViewCategoryNewStoriesRss, this.UrlParameters.CategoryIdentifier); this.DisplayAds = false; }
protected override void Render(HtmlTextWriter writer) { if (_comment.IsSpam) { _comment.CommentX = "<em>[comment removed]</em>"; } string alternativeCssClass = ""; if (_useAlternativeStyle) { alternativeCssClass = "CommentAlt"; } writer.WriteLine(@"<a name=""Comment_{0}""></a><div class=""Comment {0}"">", _comment.CommentID, alternativeCssClass); //when displaying user comments //need to show which story they commented on if (_displayStoryTitle) { //build local URL to story Category category = CategoryCache.GetCategory(_comment.Story.CategoryID, KickPage.HostProfile.HostID); string categoryIdentifier = category.CategoryIdentifier; string kickStoryUrl = UrlFactory.CreateUrl(UrlFactory.PageName.ViewStory, _comment.Story.StoryIdentifier, categoryIdentifier); //story title writer.Write(@"<div class=""storyTitle""><a href=""{0}#Comment_{1}"">{2}</a></div><br />", kickStoryUrl, _comment.CommentID, _comment.Story.Title); } writer.WriteLine(@"<div class=""CommentText"">{0}</div> <div class=""CommentAuthor"">posted by ", KickPage.KickUserProfile.ShowEmoticons ? TextHelper.ReplaceEmoticons(_comment.CommentX, KickPage.StaticEmoticonsRootUrl) : _comment.CommentX); UserLink userLink = new UserLink(); userLink.DataBind(UserCache.GetUser(_comment.UserID)); userLink.RenderControl(writer); writer.WriteLine(@" {0}</div></div>", Dates.ReadableDiff(_comment.CreatedOn, DateTime.Now)); }
public void GetCategoryReturnsCachedCategoryTest() { var expected = Model.Create <Category>(); var cacheKey = "Category|" + expected.Group + "|" + expected.Name; var cache = Substitute.For <IMemoryCache>(); var config = Substitute.For <ICacheConfig>(); object value; cache.TryGetValue(cacheKey, out value).Returns( x => { x[1] = expected; return(true); }); var sut = new CategoryCache(cache, config); var actual = sut.GetCategory(expected.Group, expected.Name); actual.Should().BeEquivalentTo(expected); }
/// <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>"); }
protected void Page_Load(object sender, EventArgs e) { //TODO: GJ: decode url string url = Request["url"].Trim(); string title = Request["title"]; if (String.IsNullOrEmpty(title)) { title = ""; } title = title.Trim(); //TODO: GJ: we could improve performance here (better story cache) Incremental.Kick.Dal.Story story = Incremental.Kick.Dal.Story.FetchStoryByUrl(url); if (story == null) { this.Response.Redirect("~/submit/?url=" + HttpUtility.UrlEncode(url) + "&title=" + HttpUtility.UrlEncode(title)); } else { //TODO: GJ: should we auto kick??? this.Response.Redirect(UrlFactory.CreateUrl(UrlFactory.PageName.ViewStory, story.StoryIdentifier, CategoryCache.GetCategory(story.CategoryID, this.HostProfile.HostID).CategoryIdentifier)); } }
/// <summary> /// Writes content to render on a client to the specified <see cref="T:System.Web.UI.HtmlTextWriter"></see> object. /// </summary> /// <param name="writer">A <see cref="T:System.Web.UI.HtmlTextWriter"></see> that contains the output stream to render on the client.</param> protected override void Render(HtmlTextWriter writer) { // <!-- Breadcrumbs --> //<div id="BreadcrumbNavigation"> // <ul> // <li class="first">Home</li> // <li>Test</li> // </ul> //</div> writer.WriteBeginTag("div"); writer.WriteAttribute("id", "BreadcrumbNavigation"); writer.Write(HtmlTextWriter.TagRightChar); writer.RenderBeginTag(HtmlTextWriterTag.Ul); RenderBreadcrumbItem("home", UrlFactory.CreateUrl(UrlFactory.PageName.Home), writer); string categoryName = CategoryCache.GetCategory(KickPage.UrlParameters.CategoryID, KickPage.HostProfile.HostID).Name.ToLower(); switch (KickPage.PageName) { //---------------- category trail case UrlFactory.PageName.ViewCategory: RenderBreadcrumbItem("category", "#", writer); RenderBreadcrumbItem(categoryName, writer); break; //view popular (main) trail case UrlFactory.PageName.PopularToday: RenderBreadcrumbItem("popular stories", UrlFactory.CreateUrl(UrlFactory.PageName.Home), writer); RenderBreadcrumbItem("today", writer); break; case UrlFactory.PageName.PopularWeek: RenderBreadcrumbItem("popular stories", UrlFactory.CreateUrl(UrlFactory.PageName.Home), writer); RenderBreadcrumbItem("this week", writer); break; case UrlFactory.PageName.PopularTenDays: RenderBreadcrumbItem("popular stories", UrlFactory.CreateUrl(UrlFactory.PageName.Home), writer); RenderBreadcrumbItem("past ten days", writer); break; case UrlFactory.PageName.PopularMonth: RenderBreadcrumbItem("popular stories", UrlFactory.CreateUrl(UrlFactory.PageName.Home), writer); RenderBreadcrumbItem("this month", writer); break; case UrlFactory.PageName.PopularYear: RenderBreadcrumbItem("popular stories", UrlFactory.CreateUrl(UrlFactory.PageName.Home), writer); RenderBreadcrumbItem("this year", writer); break; //-------------- view upcoming trail case UrlFactory.PageName.ViewCategoryNewStories: if (KickPage.UrlParameters.CategoryIdentifierSpecified) { RenderBreadcrumbItem(categoryName, UrlFactory.CreateUrl(UrlFactory.PageName.ViewCategory, KickPage.UrlParameters.CategoryIdentifier), writer); } RenderBreadcrumbItem("upcoming stories", writer); break; case UrlFactory.PageName.UpcomingWeek: RenderBreadcrumbItem("upcoming stories", UrlFactory.CreateUrl(UrlFactory.PageName.NewStories), writer); RenderBreadcrumbItem("this week", writer); break; case UrlFactory.PageName.UpcomingToday: RenderBreadcrumbItem("upcoming stories", UrlFactory.CreateUrl(UrlFactory.PageName.NewStories), writer); RenderBreadcrumbItem("top today", writer); break; //----------------- view story trail case UrlFactory.PageName.ViewStory: RenderBreadcrumbItem(categoryName, UrlFactory.CreateUrl(UrlFactory.PageName.ViewCategory, KickPage.UrlParameters.CategoryIdentifier), writer); RenderBreadcrumbItem("view story", writer); break; //--------------- tag trail case UrlFactory.PageName.ViewTag: RenderBreadcrumbItem("tags", UrlFactory.CreateUrl(UrlFactory.PageName.ViewTags), writer); RenderBreadcrumbItem(KickPage.UrlParameters.TagIdentifier, writer); break; //--------------- zeitgeist trail case UrlFactory.PageName.Zeitgeist: if (KickPage.UrlParameters.Year == null) { RenderBreadcrumbItem("zeitgeist", writer); } else if (KickPage.UrlParameters.Month == null) { RenderBreadcrumbItem("zeitgeist", UrlFactory.CreateUrl(UrlFactory.PageName.Zeitgeist), writer); RenderBreadcrumbItem(KickPage.UrlParameters.Year.ToString(), writer); } else if (KickPage.UrlParameters.Day == null) { RenderBreadcrumbItem("zeitgeist", UrlFactory.CreateUrl(UrlFactory.PageName.Zeitgeist), writer); RenderBreadcrumbItem(KickPage.UrlParameters.Year.ToString(), UrlFactory.CreateUrl(UrlFactory.PageName.Zeitgeist, KickPage.UrlParameters.Year.ToString()), writer); RenderBreadcrumbItem(new DateTime(KickPage.UrlParameters.Year.Value, KickPage.UrlParameters.Month.Value, 1).ToString("MMMM"), writer); } else { RenderBreadcrumbItem("zeitgeist", UrlFactory.CreateUrl(UrlFactory.PageName.Zeitgeist), writer); RenderBreadcrumbItem(KickPage.UrlParameters.Year.ToString(), UrlFactory.CreateUrl(UrlFactory.PageName.Zeitgeist, KickPage.UrlParameters.Year.ToString()), writer); RenderBreadcrumbItem(new DateTime(KickPage.UrlParameters.Year.Value, KickPage.UrlParameters.Month.Value, 1).ToString("MMMM"), UrlFactory.CreateUrl(UrlFactory.PageName.Zeitgeist, KickPage.UrlParameters.Year.ToString(), KickPage.UrlParameters.Month.ToString()), writer); RenderBreadcrumbItem(KickPage.UrlParameters.Day.ToString(), writer); } break; //---------------- top level trail case UrlFactory.PageName.Login: RenderBreadcrumbItem("login", writer); break; case UrlFactory.PageName.Register: RenderBreadcrumbItem("create an account", writer); break; case UrlFactory.PageName.ForgotPassword: RenderBreadcrumbItem("forgot password", writer); break; case UrlFactory.PageName.About: RenderBreadcrumbItem("about us", writer); break; case UrlFactory.PageName.SubmitStory: RenderBreadcrumbItem("submit story", writer); break; //-------------- community pages case UrlFactory.PageName.WhoIsOnline: case UrlFactory.PageName.KickSpy: RenderBreadcrumbItem("community", "#", writer); RenderBreadcrumbItem("online users", writer); break; //----------------- user profile trail case UrlFactory.PageName.UserProfile: RenderBreadcrumbItem("users", "#", writer); RenderBreadcrumbItem(KickPage.UrlParameters.UserIdentifier, writer); break; case UrlFactory.PageName.UserComments: RenderBreadcrumbItem("users", "#", writer); RenderBreadcrumbItem(KickPage.UrlParameters.UserIdentifier, UrlFactory.CreateUrl(UrlFactory.PageName.UserHome, KickPage.UrlParameters.UserIdentifier), writer); RenderBreadcrumbItem("comments", writer); break; case UrlFactory.PageName.UserSubmittedStories: RenderBreadcrumbItem("users", "#", writer); RenderBreadcrumbItem(KickPage.UrlParameters.UserIdentifier, UrlFactory.CreateUrl(UrlFactory.PageName.UserHome, KickPage.UrlParameters.UserIdentifier), writer); RenderBreadcrumbItem("submitted stories", writer); break; case UrlFactory.PageName.UserKickedStories: RenderBreadcrumbItem("users", "#", writer); RenderBreadcrumbItem(KickPage.UrlParameters.UserIdentifier, UrlFactory.CreateUrl(UrlFactory.PageName.UserHome, KickPage.UrlParameters.UserIdentifier), writer); RenderBreadcrumbItem("kicked stories", writer); break; case UrlFactory.PageName.UserFriends: RenderBreadcrumbItem("users", "#", writer); RenderBreadcrumbItem(KickPage.UrlParameters.UserIdentifier, UrlFactory.CreateUrl(UrlFactory.PageName.UserHome, KickPage.UrlParameters.UserIdentifier), writer); RenderBreadcrumbItem("friends", writer); break; case UrlFactory.PageName.FriendsKickedStories: RenderBreadcrumbItem("users", "#", writer); RenderBreadcrumbItem(KickPage.UrlParameters.UserIdentifier, UrlFactory.CreateUrl(UrlFactory.PageName.UserHome, KickPage.UrlParameters.UserIdentifier), writer); RenderBreadcrumbItem("friends", UrlFactory.CreateUrl(UrlFactory.PageName.UserFriends, KickPage.UrlParameters.UserIdentifier), writer); RenderBreadcrumbItem("kicked by friends", writer); break; case UrlFactory.PageName.FriendsSubmittedStories: RenderBreadcrumbItem("users", "#", writer); RenderBreadcrumbItem(KickPage.UrlParameters.UserIdentifier, UrlFactory.CreateUrl(UrlFactory.PageName.UserHome, KickPage.UrlParameters.UserIdentifier), writer); RenderBreadcrumbItem("friends", UrlFactory.CreateUrl(UrlFactory.PageName.UserFriends, KickPage.UrlParameters.UserIdentifier), writer); RenderBreadcrumbItem("submitted by friends", writer); break; case UrlFactory.PageName.UserTags: RenderBreadcrumbItem("users", "#", writer); RenderBreadcrumbItem(KickPage.UrlParameters.UserIdentifier, UrlFactory.CreateUrl(UrlFactory.PageName.UserHome, KickPage.UrlParameters.UserIdentifier), writer); RenderBreadcrumbItem("tags", writer); break; //api case UrlFactory.PageName.ApiOverview: RenderBreadcrumbItem("API", "#", writer); break; case UrlFactory.PageName.ApiGenerateKey: RenderBreadcrumbItem("API", UrlFactory.CreateUrl(UrlFactory.PageName.ApiOverview), writer); RenderBreadcrumbItem("generate key", "#", writer); break; } writer.RenderEndTag(); //ul writer.WriteEndTag("div"); //navigationbreadcrumbs }
public static string AddStory(int hostID, string title, string description, string url, short categoryID, User user, string ipAddress) { if (user.IsBanned) { return(GetStoryIdentifier(title)); //to stop the spammers } //TODO: improve the validation string storyIdentifier = GetStoryIdentifier(title); if (description.Length > 2500) { description = description.Substring(0, 2500); } url = url.Trim(); if (url.Length > 980) { throw new Exception("The url is too long"); } title = HttpUtility.HtmlEncode(title); description = HttpUtility.HtmlEncode(description); Story story = new Story(); story.HostID = hostID; story.StoryIdentifier = storyIdentifier; story.Title = title; story.Description = description; story.Url = url; story.CategoryID = categoryID; story.UserID = user.UserID; story.KickCount = 0; story.SpamCount = 0; story.ViewCount = 0; story.CommentCount = 0; story.IsPublishedToHomepage = false; story.IsSpam = false; story.AdsenseID = user.AdsenseID; story.IPAddress = ipAddress; story.PublishedOn = DateTime.Now; story.UpdatedOn = DateTime.Now; story.Save(); UserAction.RecordStorySubmission(hostID, user, story); UserCache.KickStory(story.StoryID, user.UserID, hostID, ipAddress); TagBR.AddUserStoryTags(CategoryCache.GetCategory(categoryID, hostID).TagIdentifier, user, story.StoryID, hostID); System.Diagnostics.Trace.WriteLine("AddStory: " + title); //now send a trackback ping Host host = HostCache.GetHost(hostID); string storyUrl = host.RootUrl + "/" + CategoryCache.GetCategory(categoryID, hostID).CategoryIdentifier + "/" + story.StoryIdentifier; TrackbackHelper.SendTrackbackPing_Begin(url, title, storyUrl, "You've been kicked (a good thing) - Trackback from " + host.SiteTitle, host.SiteTitle); return(story.StoryIdentifier); }
public virtual void ProcessRequest(HttpContext context) { this._hostProfile = HostCache.GetHost(HostHelper.GetHostAndPort(context.Request.Url)); this.GetStoryData(context); int storyCount = Math.Min( !string.IsNullOrEmpty(context.Request["count"]) ? Convert.ToUInt16(context.Request["count"]) : _stories.Count, _stories.Count); context.Response.ContentType = "text/javascript"; this.WriteJavaScriptLine(@"<div class=""KickStoryList"">", context); foreach (Story story in this._stories.GetRange(0, storyCount)) { this.WriteJavaScriptLine(@"<div class=""KickStory"">", context); this.WriteJavaScriptLine(String.Format(@"<a href=""{0}"">{1}</a>", UrlFactory.CreateUrl(UrlFactory.PageName.ViewStory, story.StoryIdentifier, CategoryCache.GetCategory(story.CategoryID, this._hostProfile.HostID).CategoryIdentifier, this._hostProfile), story.Title), context); this.WriteJavaScriptLine(@"</div>", context); } this.WriteJavaScriptLine(@"</div>", context); }
public static RssChannel ConvertToRssChannel(StoryCollection stories, string title, string description, string link, Host host) { RssChannel channel = new RssChannel(); channel.Title = title; channel.Description = description; channel.Link = new System.Uri(link); channel.Language = "en-us"; channel.Generator = host.SiteTitle + " - " + host.TagLine; channel.Docs = ""; channel.TimeToLive = 30; channel.Copyright = "Atweb Publishing Ltd."; if (stories.Count == 0) { RssItem item = new RssItem(); item.Title = " "; item.Description = " "; item.PubDate = DateTime.Now.ToUniversalTime(); channel.Items.Add(item); } else { foreach (Story story in stories) { string storyUrl = host.RootUrl + UrlFactory.CreateUrl(UrlFactory.PageName.ViewStory, story.StoryIdentifier, CategoryCache.GetCategory(story.CategoryID, host.HostID).CategoryIdentifier); //TODO: GJ: add category info RssItem item = new RssItem(); item.Title = story.Title; item.Description = story.Description + " <br /><br /><br />" + Incremental.Common.Web.Helpers.ControlHelper.RenderControl(new Incremental.Kick.Web.Controls.StoryDynamicImage(story.Url, host)); item.PubDate = story.PublishedOn.ToUniversalTime(); RssGuid guid = new RssGuid(); guid.Name = storyUrl; guid.PermaLink = true; item.Guid = guid; item.Link = new Uri(storyUrl); channel.Items.Add(item); } } return(channel); }
public ApiStory ToApi() { Host host = HostCache.GetHost(this.HostID); return(new ApiStory( this.Title, host.RootUrl + UrlFactory.CreateUrl(UrlFactory.PageName.ViewStory, this.StoryIdentifier, CategoryCache.GetCategory(this.CategoryID, this.HostID).CategoryIdentifier), this.Description, this.CreatedOn, this.PublishedOn, this.IsPublishedToHomepage, this.KickCount, this.CommentCount, UserCache.GetUser(this.UserID).ToApi(host))); }