private void AddStoryInNewsSiteMap(HttpContextBase context, XContainer target, IStory story, SiteMapUpdatePriority priority, string dateFormat) { XElement url = CreateEntry(context, Settings.RootUrl, "Detail", new { name = story.UniqueName }, story.LastActivityAt, SiteMapChangeFrequency.Daily, priority, false); string keyWords = story.BelongsTo.Name; if (story.HasTags()) { keyWords += ", " + string.Join(", ", story.Tags.Select(t => t.Name).ToArray()); } url.Add(new XElement(_googleNews + "news", new XElement(_googleNews + "publication_date", story.PublishedAt.Value.ToString(dateFormat, Constants.CurrentCulture)), new XElement(_googleNews + "keywords", keyWords))); target.Add(url); }
private void AppendStoryInAtom(XContainer feed, IStory story, UrlHelper urlHelper, string dateFormat) { string detailUrl = string.Concat(_model.RootUrl, urlHelper.RouteUrl("Detail", new { name = story.UniqueName })); string storyDescription = PrepareDescription(story, detailUrl); string userUrl = string.Concat(_model.RootUrl, urlHelper.RouteUrl("User", new { name = story.PostedBy.Id.Shrink(), tab = UserDetailTab.Promoted, page = 1 })); XElement entry = new XElement( atom + "entry", new XElement(atom + "id", detailUrl), new XElement(atom + "title", story.Title), new XElement(atom + "updated", story.CreatedAt.ToString(dateFormat, Constants.CurrentCulture)), new XElement(atom + "content", new XAttribute("type", "html"), storyDescription), new XElement(atom + "link", new XAttribute("rel", "alternate"), new XAttribute("href", detailUrl)), new XElement(atom + "contributor", new XElement(atom + "name", story.PostedBy.UserName), new XElement(atom + "uri", userUrl)) ); if (story.IsPublished()) { entry.Add(new XElement(atom + "published", story.PublishedAt.Value.ToString(dateFormat, Constants.CurrentCulture))); } if (story.HasTags()) { AppendTagsInAtom(entry, story.Tags, urlHelper); } entry.Add(new XElement(_ns + "link", detailUrl)); entry.Add(new XElement(_ns + "voteCount", story.VoteCount)); entry.Add(new XElement(_ns + "viewCount", story.ViewCount)); entry.Add(new XElement(_ns + "commentCount", 0)); //GH:71 begin entry.Add(new XElement(_ns + "textContent", story.TextDescription)); entry.Add(new XElement(_ns + "articleLink", story.Url)); entry.Add(new XElement(_ns + "imageLink", ThumbnailHelper.GetThumbnailVirtualPathForStory(story.Id.Shrink(), ThumbnailSize.Small, true).AttributeEncode())); //GH:71 end ICategory category = story.BelongsTo; string categoryUrl = string.Concat(_model.RootUrl, urlHelper.Action("Category", "Story", new { name = category.UniqueName })); entry.Add(new XElement(_ns + "category", new XAttribute("term", category.Name), new XAttribute("scheme", categoryUrl))); feed.Add(entry); }
private void AppendStoryInRss(XContainer channel, IStory story, UrlHelper urlHelper, string dateFormat) { string detailUrl = string.Concat(_model.RootUrl, urlHelper.RouteUrl("Detail", new { name = story.UniqueName })); string storyDescription = PrepareDescription(story, detailUrl); XElement item = new XElement( "item", new XElement("guid", new XAttribute("isPermaLink", "true"), detailUrl), new XElement("link", detailUrl), new XElement("title", story.Title), new XElement("description", new XCData(storyDescription)), new XElement("comments", "{0}#comments".FormatWith(detailUrl)) ); if (story.IsPublished()) { item.Add(new XElement("pubDate", story.PublishedAt.Value.ToString(dateFormat, Constants.CurrentCulture))); } if (story.HasTags()) { AppendTagsInRss(item, story.Tags, urlHelper); } item.Add(new XElement(_ns + "link", detailUrl)); item.Add(new XElement(_ns + "voteCount", story.VoteCount)); item.Add(new XElement(_ns + "viewCount", story.ViewCount)); item.Add(new XElement(_ns + "commentCount", 0)); item.Add(new XElement(_ns + "id", story.Id.Shrink())); ICategory category = story.BelongsTo; string categoryUrl = string.Concat(_model.RootUrl, urlHelper.Action("Category", "Story", new { name = category.UniqueName })); item.Add(new XElement(_ns + "category", new XAttribute("domain", categoryUrl), category.Name)); string userUrl = string.Concat(_model.RootUrl, urlHelper.RouteUrl("User", new { name = story.PostedBy.Id.Shrink(), tab = UserDetailTab.Promoted, page = 1 })); item.Add(new XElement(_ns + "contributer", new XAttribute("domain", userUrl), story.PostedBy.UserName)); channel.Add(item); }