Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        private string PrepareDescription(IStory story, string detailUrl)
        {
            string imageUrl = string.Concat(_model.RootUrl, "/image.axd", "?url=", story.Url.UrlEncode());

            string storyLink = "<a rev=\"vote-for\" href=\"{0}\"><img alt=\"{1}\" src=\"{2}\" style=\"border:0px\"/></a>".FormatWith(detailUrl.AttributeEncode(), Data.PromoteText, imageUrl.AttributeEncode());

            return("<div>" +
                   "<div>" +
                   "<div style=\"float:right\">" +
                   "<img alt =\"\" src=\"{0}\"/>".FormatWith(ThumbnailHelper.GetThumbnailVirtualPathForStory(story.Id.Shrink(), ThumbnailSize.Small, true).AttributeEncode()) +
                   "</div>" +
                   "<div>" +
                   "{0}".FormatWith(story.TextDescription) +
                   "</div>" +
                   "</div>" +
                   "<div style=\"padding-top:4px\">" +
                   "{0}".FormatWith(storyLink) +
                   "</div>" +
                   "</div>");
        }