/// <summary> /// Inserts an element into the AtomContentCollection at the specified index /// </summary> /// <param name="index"> /// The index at which the AtomContent is to be inserted. /// </param> /// <param name="value"> /// The AtomContent to insert. /// </param> public virtual void Insert(int index, AtomContent value) { this.List.Insert(index, value); }
/// <summary> /// Removes the first occurrence of a specific AtomContent from this AtomContentCollection. /// </summary> /// <param name="value"> /// The AtomContent value to remove from this AtomContentCollection. /// </param> public virtual void Remove(AtomContent value) { this.List.Remove(value); }
/// <summary> /// Determines whether a specfic AtomContent value is in this AtomContentCollection. /// </summary> /// <param name="value"> /// The AtomContent value to locate in this AtomContentCollection. /// </param> /// <returns> /// true if value is found in this AtomContentCollection; /// false otherwise. /// </returns> public virtual bool Contains(AtomContent value) { return(this.List.Contains(value)); }
/// <summary> /// Return the zero-based index of the first occurrence of a specific value /// in this AtomContentCollection /// </summary> /// <param name="value"> /// The AtomContent value to locate in the AtomContentCollection. /// </param> /// <returns> /// The zero-based index of the first occurrence of the _ELEMENT value if found; /// -1 otherwise. /// </returns> public virtual int IndexOf(AtomContent value) { return(this.List.IndexOf(value)); }
private AtomRoot GetAtomCore(string category, int maxDayCount, int maxEntryCount) { if (RedirectToFeedBurnerIfNeeded(category) == true) { return null; } EntryCollection entries = null; //We only build the entries if blogcore doesn't exist and we'll need them later... if (dataService.GetLastEntryUpdate() == DateTime.MinValue) { entries = BuildEntries(category, maxDayCount, maxEntryCount); } //Try to get out as soon as possible with as little CPU as possible if ( inASMX ) { if (SiteUtilities.GetStatusNotModified(SiteUtilities.GetLatestModifedEntryDateTime(dataService, entries))) return null; } if ( inASMX ) { string referrer = Context.Request.UrlReferrer!=null?Context.Request.UrlReferrer.AbsoluteUri:""; if (ReferralBlackList.IsBlockedReferrer(referrer)) { if (siteConfig.EnableReferralUrlBlackList404s) { return null; } } else { loggingService.AddReferral( new LogDataItem( Context.Request.RawUrl, referrer, Context.Request.UserAgent, Context.Request.UserHostName)); } } //not-modified didn't work, do we have this in cache? string CacheKey = "Atom:" + category + ":" + maxDayCount.ToString() + ":" + maxEntryCount.ToString(); AtomRoot atomFeed = cache[CacheKey] as AtomRoot; if (atomFeed == null) //we'll have to build it... { atomFeed = new AtomRoot(); //However, if we made it this far, the not-modified check didn't work, and we may not have entries... if(entries == null) { entries = BuildEntries(category, maxDayCount, maxEntryCount); } if (siteConfig.RssLanguage != null && siteConfig.RssLanguage.Length >0) { atomFeed.Lang = siteConfig.RssLanguage; } else //original default behavior of dasBlog { atomFeed.Lang = "en-us"; } if(category == null) { atomFeed.Title = siteConfig.Title; } else { atomFeed.Title = siteConfig.Title + " - " + category; } atomFeed.Tagline = siteConfig.Subtitle; atomFeed.Links.Add(new AtomLink(SiteUtilities.GetBaseUrl(siteConfig))); atomFeed.Links.Add(new AtomLink(SiteUtilities.GetAtomUrl(siteConfig),"self",null)); atomFeed.Author = new AtomParticipant(); atomFeed.Author.Name = siteConfig.Copyright; atomFeed.Generator = new AtomGenerator(); atomFeed.Generator.Version = GetType().Assembly.GetName().Version.ToString(); atomFeed.Icon = "favicon.ico"; atomFeed.Id = SiteUtilities.GetBaseUrl(siteConfig); atomFeed.Logo = null; if (siteConfig.ChannelImageUrl != null && siteConfig.ChannelImageUrl.Trim().Length > 0) { if (siteConfig.ChannelImageUrl.StartsWith("http")) { atomFeed.Logo = siteConfig.ChannelImageUrl; } else { atomFeed.Logo= SiteUtilities.RelativeToRoot(siteConfig,siteConfig.ChannelImageUrl); } } DateTime feedModified = DateTime.MinValue; foreach (Entry entry in entries) { if (entry.IsPublic == false || entry.Syndicated == false) { continue; } string entryLink = SiteUtilities.GetPermaLinkUrl(siteConfig, entry); string entryGuid = SiteUtilities.GetPermaLinkUrl(siteConfig, entry.EntryId); AtomEntry atomEntry = new AtomEntry(entry.Title, new AtomLink(entryLink), entryGuid, entry.CreatedUtc, entry.ModifiedUtc); //atomEntry.Created = entry.CreatedUtc; //not needed in 1.0 atomEntry.Summary = PreprocessItemContent(entry.EntryId, entry.Description); if (entry.Categories != null && entry.Categories.Length > 0) { if(atomEntry.Categories == null) atomEntry.Categories = new AtomCategoryCollection(); string[] cats = entry.Categories.Split(';'); foreach(string c in cats) { AtomCategory cat = new AtomCategory(); //paulb: scheme should be a valid IRI, acsording to the spec // (http://www.atomenabled.org/developers/syndication/atom-format-spec.php#element.category) // so I changed this to the Category view for specified category. Now the feed validator likes us again ;-) cat.Scheme = SiteUtilities.GetCategoryViewUrl( siteConfig, c ); // "hierarchical"; // sub categories should be delimited using the path delimiter string cleanCat = c.Replace('|', '/'); //Grab the first category, atom doesn't let us do otherwise! cat.Term = HttpUtility.HtmlEncode(cleanCat); cat.Label = HttpUtility.HtmlEncode(cleanCat); atomEntry.Categories.Add(cat); } } // only if we don't have a summary we emit the content if ( siteConfig.AlwaysIncludeContentInRSS || entry.Description == null || entry.Description.Length == 0 ) { atomEntry.Summary = null; // remove empty summary tag try { AtomContent atomContent = new AtomContent(); atomContent.Type = "xhtml"; XmlDocument xmlDoc2 = new XmlDocument(); xmlDoc2.LoadXml(ContentFormatter.FormatContentAsXHTML(PreprocessItemContent(entry.EntryId, entry.Content),"div")); atomContent.anyElements = new XmlElement[]{xmlDoc2.DocumentElement}; // set the langauge for the content item atomContent.Lang = entry.Language; atomEntry.Content = atomContent; } catch(Exception) //XHTML isn't happening today { //Try again as HTML AtomContent atomContent = new AtomContent(); atomContent.Type = "html"; atomContent.TextContent = ContentFormatter.FormatContentAsHTML(PreprocessItemContent(entry.EntryId, entry.Content)); // set the langauge for the content item atomContent.Lang = entry.Language; atomEntry.Content = atomContent; } } if (atomEntry.ModifiedUtc > feedModified) feedModified = atomEntry.ModifiedUtc; atomFeed.Entries.Add(atomEntry); } // set feed modified date to the most recent entry date atomFeed.ModifiedUtc = feedModified; cache.Insert(CacheKey,atomFeed,DateTime.Now.AddMinutes(5)); } return atomFeed; }
/// <summary> /// Adds an instance of type AtomContent to the end of this AtomContentCollection. /// </summary> /// <param name="value"> /// The AtomContent to be added to the end of this AtomContentCollection. /// </param> public virtual void Add(AtomContent value) { this.List.Add(value); }
/// <summary> /// Return the zero-based index of the first occurrence of a specific value /// in this AtomContentCollection /// </summary> /// <param name="value"> /// The AtomContent value to locate in the AtomContentCollection. /// </param> /// <returns> /// The zero-based index of the first occurrence of the _ELEMENT value if found; /// -1 otherwise. /// </returns> public virtual int IndexOf(AtomContent value) { return this.List.IndexOf(value); }
/// <summary> /// Determines whether a specfic AtomContent value is in this AtomContentCollection. /// </summary> /// <param name="value"> /// The AtomContent value to locate in this AtomContentCollection. /// </param> /// <returns> /// true if value is found in this AtomContentCollection; /// false otherwise. /// </returns> public virtual bool Contains(AtomContent value) { return this.List.Contains(value); }
/// <summary> /// Adds the elements of an array to the end of this AtomContentCollection. /// </summary> /// <param name="content"> /// The array whose elements are to be added to the end of this AtomContentCollection. /// </param> public virtual void AddRange(AtomContent[] content) { foreach (AtomContent contentEntry in content) { this.List.Add(contentEntry); } }
/// <summary> /// Initializes a new instance of the AtomContentCollection class, containing elements /// copied from an array. /// </summary> /// <param name="content"> /// The array whose elements are to be added to the new AtomContentCollection. /// </param> public AtomContentCollection(AtomContent[] content) { this.AddRange(content); }