Revision as of 19:44, 22 November 2006

Contents

Author

Tobbe

How to setup a RSS feed with Yaws

Introduction

You probably already know how useful RSS is to aggregate information feeds. If you don't, then simply use your Mozilla Firebird browser and go to an RSS-enabled site, e.g http://slashdot.org. Note the little orange icon down in the right corner of the browser window. Click on the icon and add the RSS-feed to you personal toolbar. Then click on your toolbar, on the RSS-bookmark and watch the nice menu of slashdot article-summarys popping up.

The module yaws_rss.erl provides an RSS store/interface so that you can RSS enable your application. It is dead simple to get your RSS feed going, and we will show here how you can do it.

To create a RSS feed.

Make sure your top page has the corresponding link information in the 'head' part as shown in the example below. Don't forget to change the URL (www.blaha.org) to point to your own server.

To insert RSS items into the feed from your application, you can write code like:

Code listing 1.3: Adding RSS info from your Erlang code.

....
yaws_rss:insert(test, xml, "Yaws now support RSS feeds.",
"http://www.blaha.org/latest_news.html",
"Yaws has now been extended to support....",
"Bill Smith").
....

First comes the application (RSSid), followed by a tag (these were used in rss.yaws when we retrieved the RSS content). Then follows the Title, Link, Description and Creator.

The idea is that several independent application should be able to use the yaws_rss.erl API without affecting each other. Also, one application may have several RSS feeds (hence the Tag). So in your case you could change the RSSid and Tag to something more suitable.

How to configure Yaws

Inside a <server> block you specify the application you want to produce RSS content. In our example, our application was named: test.

So for example, by setting the rss_expire to days you can set the number of days items will show up with rss_days. You can also have expired items removed and/or limit the maximum number of items you want to store.

This is it! Your RSS feed is now ready to go. Was this dead simple or not... ;-)