Posts tagged RSS (Really Simple Syndication)
Rendering an RSS feed as HTML
0So… the RSS embed plugin for our school wiki server has been broken since before school started, with no sign of a fix in sight (other things are taking higher priority). Of course, since I have zero desire to post each new training video to our school video as I make them, this is a bit of a stumbling block. But…
I slapped together a script that makes use of the Magpie RSS framework to render some (most?) RSS feeds as a simple HTML page, which I can then embed as an IFRAME in our school wiki. Et voilá, no more having to paste in individual links! You can give it a whirl yourself: paste an RSS feed into this form:
Obviously, if you have need of this on a regular basis, I would be happy to share the code — don’t just run it off my poor little web server!
Creating RSS Feeds in FirstClass
0Since this is available nowhere else on the internet, I’m posting it here for safekeeping. I believe that this applies to at least FirstClass 10, perhaps also FirstClass 9 (but that’s just a W.A.G.). This is from FirstClass tech support:
An RSS feed can be generated for any FirstClass container object (folder, conference, etc.) which is visible to the Web by adding a template override parameter to the URL. In other words, if the URL to the news conference on your Web site was http://www.mysite.com/News , then the URL to the RSS feed for that conference would be http://www.mysite.com/News?Templates=RSS&items . If you have an RSS feed reader you can simply enter that URL, give it a name, and you’ll have a feed. Usually, sites that offer an RSS feed will put a little icon on their main Web page to show that they have one. If your main page is a FirstClass document all you need to do is:
- Paste in your preferred RSS image
- Highlight the image in the editor and right-click your mouse, choose “Make Link”
- Enter the RSS feed URL, in our example http://www.mysite.com/News?Templates=RSS&items or ?plugin=RSS&Items
Buyer beware: I have not seen this work yet in my own tinkering. But I am hopeful that somehow I’m doing something wrong.
The Internet Tubes (and Yahoo Pipes)
1So, a couple days ago, Nate posted about my Yahoo Pipes solution for a blog comment aggregating conundrum he was running into in his history class. My solution ended up being a little technical, but I think it’s an interesting enough example of the power of Yahoo Pipes that it’s worth talking through what’s going on. (I love Yahoo Pipes — although one of my colleagues is a major fan of WebRSS, which meets similar needs.)
A mildly cleaned-up version of the solution is below, in the Pipes’ visual programming diagram:
- The pipe itself starts on the left, with Fetch Feed module, in which Nate had helpfully plugged in the comments feeds for all of his students. This takes all of the comment feeds from their blogs and aggregates them into one, enormous comment feed.
- Following the blue “pipe” from the Fetch Feed module, we reach the Rename module, which is actually be used to rename a copy of the “link” field of each item to “orig_author”. Clearly, this sentence needs some explanation. In an RSS feed, each item represents a single entry (in this case, a single comment on a particular blog). The RSS feed is made up of a bunch of items (usually the ten or so most recent items in the feed, so the ten most recent comments on each blog). We have aggregated these ten most recent comments from each blog into a feed that includes the hundred or so most recent comments from all the blogs (ten blogs x ten comments each = one hundred comments). Each item is made up of a series of fields that describe the item (title, description, link, etc.). Normally, in a feed reader, we only see the title and description, although we may also “see” the link field when the title is turned into a link back to the original comment on the originating blog. In this case, I have made a copy of the link field, for future reference, so that every item now has a second copy of the link field, named “orig_author” (short for original author, because programmers are lazy). It turns out that, in the WordPress.com comment feeds, the link is the only part of the item that refers to the name of the blog on which the comment was made, and that cryptically (e.g. “http://nkogan.wordpress.com/2009/08/…” — i.e., as the first word in the address of the blog itself). More on this in a second.
- Again, following the blue pipe from the Rename module to the Regex module, we see two lines, which read, more or less:
- In item.orig_author replace
http://(.*)\.wordpress.*
with
$1
- In item.title replace
(Comment on )(.*)( by .*)
with
$1${orig_author}’s post “$2”$3
What this means, in layman’s terms, is basically that I want to take whatever text appears in the orig_author field (which is a copy of the link field, which was a link to the original comment on the originating blog), and extract only the name of the blog from the URL. I won’t dive into the details of regular expressions right now, but what the first one above essentially says is “look for a pattern that starts with ‘http://’ followed by any number of characters — (.*) — followed by ‘.wordpress’ followed by any number of characters — .* — and replace the text that matches that pattern with whatever was in the first set of parentheses — $1.” In other words, replace the entire link with just the name of the blog that’s between ‘http://’ and ‘.wordpress’.
The second regular expression is a bit more involved. At this point, it helps to realize that each set of parentheses is referred to by its order in the sequence of the original pattern, prefaced by a dollar sign — $1, $2, $3, etc. In this case, we’re looking at the original title of the comment item, which started off something like “Comment on My First Blog Post by Seth B.” I want to take my newly discovered blog name (from the first regular expression) and insert it into this in a meaningful way. To do that, I create a pattern that breaks the original title into its component phrases “Comment on “, “My First Blog Post” and “by Seth B.” With this in hand, I just plug in the current value of the orig_author field — which I just clipped in the previous regular expression, add some nice curly quotes, and put it all back together again to read something like “Comment on nkogan’s post “My First Blog Post” by Seth B.” - In item.orig_author replace
- Again, following the pipe down to the Sort module, I’ve added the handy little fillip of sorting all of the comments in our aggregated feed by the time at which they were posted (rather than grouping them by the blog on which they were posted, as they would be coming out of the original Fetch Feeds module — the first blog linked to, followed by the second blog linked to, etc.
I hope this is useful, or at least intriguing, in thinking about using the both Yahoo Pipes and regular expressions. A really wonderful reference on regular expressions can be found at Regular-Expressions.info, and I really like JRX as a tool for fine-tuning my regular expressions as I write them.
