Last active
March 17, 2020 02:15
-
-
Save chrisdpeters/1848689 to your computer and use it in GitHub Desktop.
Aggregating RSS Feeds with Delicious, Yahoo! Pipes, FeedBurner, and CFML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- URL to RSS feed ---> | |
<cfparam name="arguments.articlesRss" type="url"> | |
<!--- URL to Delicious page ---> | |
<cfparam name="arguments.articlesUrl" type="url"> | |
<!--- Number of items to display from feed ---> | |
<cfparam name="arguments.numToDisplay" type="numeric" default="10"> | |
<!--- Note: we are breaking the convention of data access in the view here so that we can cache this partial ---> | |
<cfset articles = articles(arguments.articlesRss)> | |
<cfoutput> | |
<div id="community-articles"> | |
<h3> | |
#Replace(articles.title, "ColdFusion on Wheels ", "")# | |
<a href="#arguments.articlesRss#" class="image">#imageTag(source="feed-icon-14x14.png", alt="Articles Feed")#</a> | |
</h3> | |
<p>#HtmlEditFormat(articles.description)#</p> | |
<dl> | |
<cfloop from="1" to="#arguments.numToDisplay#" index="i"> | |
<dt> | |
<a href="#articles.item[i].link#">#articles.item[i].title#</a> | |
<span class="date">(discovered #Replace(timeAgoInWords(articles.item[i].pubDate), " ", " ", "all")# ago)</span> | |
</a> | |
</dt> | |
<dd>#articles.item[i].description.value#</dd> | |
</cfloop> | |
</dl> | |
<h4>Read More Articles</h4> | |
<ul class="calls-to-action"> | |
<li class="delicious"><a href="#arguments.articlesUrl#">All Articles on Delicious</a></li> | |
<li class="feed"><a href="#arguments.articlesRss#" title="Articles Feed"><abbr title="Really Simple Syndication">RSS</abbr> Feed</a></li> | |
</ul> | |
</div> | |
</cfoutput> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cffeed name="articles" source="#arguments.rssUrl#"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cffunction name="articles" hint="Fetches latest article data from specified RSS feed."> | |
<cfargument name="rssUrl" type="string" hint="URL of RSS feed to check."> | |
<cfset var loc = {}> | |
<!--- Design mode will not cache, so let's store data in session to keep FeedBurner happy ---> | |
<cfif get("environment") is "design"> | |
<cfif not StructKeyExists(session, "articles")> | |
<cffeed name="session.articles" source="#arguments.rssUrl#"> | |
</cfif> | |
<cfset loc.articles = session.articles> | |
<!--- This is cached in production mode ---> | |
<cfelse> | |
<cffeed name="loc.articles" source="#arguments.rssUrl#"> | |
</cfif> | |
<cfreturn loc.articles> | |
</cffunction> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#includePartial( | |
partial="articles", | |
articlesRss=articlesRss, | |
articlesUrl=articlesUrl, | |
numToDisplay=5, | |
cache=5 | |
)# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment