private void WriteEntries()
        {
            BlogConfigurationSettings settings = Config.Settings;

            ClientHasAllFeedItems = true;
            LatestPublishDate     = DateLastViewedFeedItemPublished;

            foreach (T entry in Items)
            {
                if (UseDeltaEncoding && GetSyndicationDate(entry) <= DateLastViewedFeedItemPublished)
                {
                    // Since Entries are ordered by DatePublished descending, as soon
                    // as we encounter one that is smaller than or equal to
                    // one the client has already seen, we're done as we
                    // know the client already has the rest of the items in
                    // the collection.
                    return;
                }

                // If we're here, we know that entry.EntryId is larger than
                // the LastViewedFeedItemId.  Thus we can send it.
                WriteStartElement("item");
                EntryXml(entry, settings);
                WriteEndElement();
                if (GetSyndicationDate(entry) > LatestPublishDate)
                {
                    LatestPublishDate = GetSyndicationDate(entry);
                }

                ClientHasAllFeedItems = false;
            }
        }
Exemple #2
0
        private void WriteEntries()
        {
            BlogConfigurationSettings settings = Config.Settings;

            ClientHasAllFeedItems = true;
            LatestPublishDateUtc  = DateLastViewedFeedItemPublishedUtc;

            foreach (Entry entry in Items)
            {
                // We'll show every entry if RFC3229 is not enabled.
                //TODO: This is wrong.  What if a post is not published and then gets published later. It will not be displayed.
                if (!UseDeltaEncoding || entry.DatePublishedUtc > DateLastViewedFeedItemPublishedUtc)
                {
                    WriteStartElement("entry");
                    EntryXml(entry, settings, Blog.TimeZone);
                    WriteEndElement();
                    ClientHasAllFeedItems = false;

                    //Update the latest publish date.
                    if (entry.DateSyndicated > LatestPublishDateUtc)
                    {
                        LatestPublishDateUtc = entry.DateSyndicated;
                    }
                }
            }
        }
        /// <summary>
        /// Writes the XML for a single entry.
        /// </summary>
        protected virtual void EntryXml(T item, BlogConfigurationSettings settings)
        {
            //core
            WriteElementString("title", GetTitleFromItem(item));

            ICollection <string> categories = GetCategoriesFromItem(item);

            if (categories != null)
            {
                foreach (string category in categories)
                {
                    WriteElementString("category", category);
                }
            }

            string fullUrl = GetLinkFromItem(item);

            WriteElementString("link", fullUrl);
            WriteElementString
            (
                "description", //Tag
                string.Format
                (
                    CultureInfo.InvariantCulture,
                    "{0}{1}", //tag def
                    GetBodyFromItem(item),
                    (UseAggBugs && settings.Tracking.EnableAggBugs)
                        ? TrackingUrls.AggBugImage(GetAggBugUrl(item))
                        : null //use aggbugs
                )
            );

            string author = GetAuthorFromItem(item);

            if (!String.IsNullOrEmpty(author))
            {
                WriteElementString("dc:creator", author);
            }

            WriteElementString("guid", GetGuid(item));
            WriteElementString("pubDate", GetPublishedDateUtc(item).ToString("r", CultureInfo.InvariantCulture));

            if (ItemCouldContainComments(item))
            {
                if (AllowComments && Blog.CommentsEnabled && ItemAllowsComments(item) && !CommentsClosedOnItem(item))
                {
                    // Comment API (http://wellformedweb.org/story/9)
                    WriteElementString("wfw:comment", GetCommentApiUrl(item));
                }

                WriteElementString("comments", fullUrl + "#feedback");

                if (GetFeedbackCount(item) > 0)
                {
                    WriteElementString("slash:comments", GetFeedbackCount(item).ToString(CultureInfo.InvariantCulture));
                }

                WriteElementString("wfw:commentRss", GetCommentRssUrl(item));

                if (Blog.TrackbacksEnabled)
                {
                    WriteElementString("trackback:ping", GetTrackBackUrl(item));
                }
            }

            EnclosureItem encItem = GetEnclosureFromItem(item);

            if (encItem != null)
            {
                WriteStartElement("enclosure");
                WriteAttributeString("url", encItem.Url);
                WriteAttributeString("length", encItem.Size.ToString(CultureInfo.InvariantCulture));
                WriteAttributeString("type", encItem.MimeType);
                WriteEndElement();
            }
        }
Exemple #4
0
        protected virtual void EntryXml(Entry entry, BlogConfigurationSettings settings, ITimeZone timezone)
        {
            WriteElementString("title", entry.Title);

            WriteStartElement("link");
            //(Duncanma 11/13/2005, changing alternate to self for 1.0 feed)
            WriteAttributeString("rel", "alternate");
            WriteAttributeString("type", "text/html");
            WriteAttributeString("href", UrlHelper.EntryUrl(entry).ToFullyQualifiedUrl(Blog).ToString());
            WriteEndElement();

            WriteElementString("id", UrlHelper.EntryUrl(entry).ToFullyQualifiedUrl(Blog).ToString());

            //(Duncanma 11/13/2005, hiding created, change issued to
            //published and modified to updated for 1.0 feed)
            //this.WriteElementString("created",W3Utcz(entry.DateCreated));
            WriteElementString("published", W3Utcz(entry.DateCreatedUtc));
            WriteElementString("updated", W3Utcz(entry.DateModifiedUtc));

            if (entry.HasDescription)
            {
                WriteStartElement("summary");
                //(Duncanma 11/13/2005, changing text/html to html for 1.0 feed)
                WriteAttributeString("type", "html");
                WriteString(entry.Description);
                WriteEndElement();
            }

            WriteStartElement("content");
            //(Duncanma 11/13/2005, changing text/html to html for 1.0 feed)
            WriteAttributeString("type", "html");
            //(Duncanma 11/13/2005, hiding mode for 1.0 feed)
            //this.WriteAttributeString("mode","escaped");

            WriteString
            (
                string.Format
                    (CultureInfo.InvariantCulture, "{0}{1}",                         //tag def
                    entry.SyndicateDescriptionOnly ? entry.Description : entry.Body, //use desc or full post
                    (UseAggBugs && settings.Tracking.EnableAggBugs)
                         ? TrackingUrls.AggBugImage(UrlHelper.AggBugUrl(entry.Id))
                         : null //use aggbugs
                    )
            );
            WriteEndElement();

            if (AllowComments && Blog.CommentsEnabled && entry.AllowComments && !entry.CommentingClosed)
            {
                //optional for CommentApi Post location
                WriteElementString("wfw:comment", UrlHelper.CommentApiUrl(entry.Id));
                //optional url for comments
                //this.WriteElementString("comments",entry.Link + "#feedback");
                //optional comment count
                WriteElementString("slash:comments", entry.FeedBackCount.ToString(CultureInfo.InvariantCulture));
                //optional commentRss feed location
                WriteElementString("wfw:commentRss", UrlHelper.CommentRssUrl(entry.Id));
                //optional trackback location
                WriteElementString("trackback:ping", UrlHelper.TrackbacksUrl(entry.Id));
                //core
            }
        }