Editor's note: Meerkat predated the popularity of syndication, feed services, and feed readers. Now that other groups are providing this service, we have removed Meerkat in favor of their better solutions. We maintain these articles for the sense of historical interest.
Meerkat's Open Service API and powerful feed-building tools provide a simple framework for building lightweight portals or bringing fresh syndicated content to your web site.
Some of you may not know this, but quite a bit of what you see on the O'Reilly Network is built out of Meerkat's RSS database. Some, such as our Weblogs and Forums boxes, are automagically generated via a combination of profiles, search patterns, and programmatic wizardry. Others, like our Digests, pull in stories from various channels, some of which are hand-picked for display on our pages.
Meerkat makes building lightweight portals a snap! Whether you want to hand pick stories or set up profiles and filters for automagic feeds, Meerkat will flow fresh content to your pages with little effort. If you can point and click (or the equivalent) and have even minimal experience with HTML, you're on your way. Even programmers should find this pretty
This article takes you step-by-step through the rather simple process of:
Borrowing an existing feed profile
Point-click-and-dragging your own hand-crafted feed
Embedding the feed in your web page(s)
And, for the more adventurous among you,
Adding two or three lines of programming magic for some advanced(ish) fun(ctionality)
To begin, point your web browser at http://meerkat.oreillynet.com/. For access to features we use a little further on in the article, you'll need to be logged in to the O'Reilly Network. To do so, click Login in Meerkat's black toolbar; if you've not already signed up, now would be a good time to do so.
We'll start simply by using a couple of the "global" profiles provided out of the box for your convenience. The "Python" and "Perl" profiles are composed of some rather nice sources and don't need any fine-tuning for our purposes, so we'll borrow them.
Selecting the Python profile in Meerkat.
From Meerkat's Profiles/Mobs popup-menu, select Python. The screen will refresh, pre-setting Meerkat's "Category" to "Lang: Python" and "Show me" widget to "7 DAY".
Now the thing we're most interested in is the URL for the "Python" profile. Copy it from your browser's Address/Location bar and paste it somewhere for safekeeping -- don't forget to note what it
Copy the URL for Meerkat's Python profile.
Repeat steps 1 and 2 for the Perl profile, copying the associated URL.
These URLs will provide us with feeds of the latest stories in the "Lang: Python" and "Lang: Perl" categories' associated channels. This works nicely for solid feeds, but sometimes you'll want to tweak a little here and there, hand-crafting a feed to suit your particular slant.
Feeds come in two flavors:
Profiles are filters based on category, channel, time, and optional search keywords or regular expression; they are constantly self-updating as new items are picked up by Meerkat.
Mobs are groupings of items hand-picked by you -- not unlike a list of favorites/bookmarks. You update mobs manually by adding or removing stories from the list.
Let's build a simple PHP profile, pulling from stories in the "Lang: PHP" category.
Set Meerkat's controls so that "Category" is set to "Lang: PHP," the "Search For" box is empty, and "Show me" is set to "ALL" (PHP items are few and far between).
Select Save Settings to Profile... from the Profiles/Mobs popup-menu.
Saving the new profile.
The screen refreshes and a "Save Settings to" window appears. Type php into the New profile field and click the Save button to save these settings. The "Save Settings to" window closes.
Restoring the custom PHP profile.
Again, we're interested in the URL for our new "PHP" profile. Restore it by selecting PHP from the "My Profiles..." section of the Profiles/Mobs popup-menu.
Copy the URL from your browser's Address/Location bar and paste it somewhere for safekeeping -- again, make note of what it is.
That's all there is to creating a profile. You can always adjust stored settings by restoring the profile, making desired changes, selecting "Save Settings to Profile...," and selecting an "Existing profile" to save to.
Next we'll try our hand at building a mob, a hand-picked list of items for inclusion in a feed. By the way, in case you were wondering, a "mob" is the collective term for more than one Meerkat: "a mob of meerkats."
If you've never created a mob before, you'll need to do so now. Select Manage my Mobs... from the Profiles/Mobs popup menu. The "Mob Manager" window appears.
Click the New button to create your first mob. Name it top_news and click the OK dialog box button.
Creating the top_news Meerkat mob.
Your empty "top_news" mob is created and displayed. Now we'll need that URL again, so copy it and paste it along with the others.
Getting the URL of the mob.
I'd suggest supplying a description and category for reference. Click the Save button and close the "Mob Manager" window when finished. You can always make changes to your mob information by selecting it from the "Mob Manager," making changes, and saving them.
Saving changes to a mob.
Adding an item to a mob.
Let's get on to adding items to our new mob. You'll notice in Meerkat's "Action" column a set of icons alongside each item; the dotted-circular one is used to add the associated item to a mob. Clicking the icon summons the "Meerkat Mobs" window.
Select the appropriate mob from the "Meerkat Mobs" window; the window will disappear automatically. Add items to any of your mobs at any time this way.
Adding and removing items from a mob.
Remove items from a mob by un-checking their associated checkbox(s) and clicking Save.
That's all there is to creating feeds. You can also whip up feeds on-the-fly using Meerkat's URL-line API, documented in Meerkat: An Open Service API.
flavor produces a .js file containing a snippet of code for inclusion into our Web page. This code is nothing more than a few
document.writeln() calls to write the Meerkat items into the document on-the-fly. And the magical line is:
Notice the URL in there? We'll be replacing part of it with those URLs we've been faithfully copying as we went along.
Let's start with the "PHPerlthon" home page and our "top_news" mob. ...
In your favorite text editor (vi, Notepad, SimpleText), create a new HTML page like so:
You'll notice that we altered the URL slightly, adding
Rinse, lather, repeat ... for each of the three profiles (Globals "Python" and "Perl" and our own "PHP"). Simply replace
That's all there is to embedding Meerkat feeds in your web pages. Take a gander at our four feeds in action...
Source flavor includes CSS stylesheet support. We'll whip up a quick CSS stylesheet,
phperlthon.css, like so:
To link it into our "PHPerlthon" home page, we just add
<link rel="stylesheet" type="text/css" href="./phperlthon.css" /> to
<head> element and we've got style!
Those of you with a modicum of programming know-how can easily build more advanced functionality. We'll use a little PHP to pull all of our site into only one page with links between our Home, Python, Perl, and PHP views. And we'll add bit of HTML to spice things up.
(Note: The long URL line was broken up for presentation purposes.)
phperlthon.php a whirl. The links pass appropriate arguments back to the PHP page itself, which in turn passes the appropriate switches on to Meerkat on the URL-line. This sort of tomfoolery could just as easily have been accomplished with Server-Side Includes (SSI), CGI scripting, and the like. Hopefully this simple demo provides you with programmatic inspiration on new ways to use Meerkat in your coding.
I hope this article inspires you to use Meerkat in interesting and novel ways. Be sure to drop us a line in the O'Reilly Network RSS Forum and let us know. And, if you're so inclined, spread the Meerkat word with a nifty "Meerkat Powered!" button. To do so, simply copy-and-paste the following HTML into your document:
<a href="http://meerkat.oreillynet.com"> <img src='http://meerkat.oreillynet.com/icons/meerkat-powered.jpg'> </a>
The following is a list of starting points from which to explore further some of the topics covered (or not) in this article.
Rael Dornfest is Founder and CEO of Portland, Oregon-based Values of n. Rael leads the Values of n charge with passion, unearthly creativity, and a repertoire of puns and jokes some of which are actually good. Prior to founding Values of n, he was O'Reilly's Chief Technical Officer, program chair for the O'Reilly Emerging Technology Conference (which he continues to chair), series editor of the bestselling Hacks book series, and instigator of O'Reilly's Rough Cuts early access program. He built Meerkat, the first web-based feed aggregator, was champion and co-author of the RSS 1.0 specification, and has written and contributed to six O'Reilly books. Rael's programmatic pride and joy is the nimble, open source blogging application Blosxom, the principles of which you'll find in the Values of n philosophy and embodied in Stikkit: Little yellow notes that think.
Discuss this article in the O'Reilly Network RSS Forum.
Return to the RSS DevCenter.
Copyright © 2009 O'Reilly Media, Inc.