Default style (Cherry Eve). Switch styles (Capricorn). XML Feed Calendar
All | General
20040908 Wednesday September 08, 2004

RSS On BBS

Yesterday, I created a RSS feed in our BBS. The template was got form nytimes. It is pretty simple and straight forward (compare to the others using rdf).

Below is the file structure:

<?xml version="1.0" encoding="iso-8859-1" ?>
 <rss version="2.0">
 <channel>
     <title>...</title>
      <link>...</link>
      <description>...</description>
      <copyright>...</copyright>
      <language>...</language>
      <lastBuildDate>...</lastBuildDate>
      <item>
          <title>...</title>
          <link>...</link>
          <description>...</description>
          <author>...</author>
          <pubDate>...</pubDate>
          <guid isPermaLink="false">...</guid>
      </item>
      <item>
          ...
      </item>
  </channel>
</rss>

I hacked into the post.cgi, updated the rss file when a new post coming by

  1. copy the header,
  2. fill in the new item,
  3. remove the oldest item if the total items exceeded 10.

Both lastBuildDate and pubDate need to be a RFC 822 compliant date format, like Tue, 07 Sep 2004 00:00:00 EDT. I spended some time to study how to do it in Perl, and came up with the following code:

use Time::gmtime;

$gm = gmtime(time);
$weekday = (qw(Sun Mon Tue Wed Thu Fri Sat Sun))[$gm->wday()];
$month = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[$gm->mon()];
$date = sprintf("%s, %02d %s %d %02d:%02d:%02d GMT", $weekday, $gm->mday(),
                $month, $gm->year() + 1900,
                $gm->hour(), $gm->min(), $gm->sec());

The guid field value need to be globally unique. So I combine the site URL and the current time together to make it a really GUID.

I downloaded a RssReader to verify my work. It works very well. I also found a useful site that can verify whether your feed is valid.


RSS 2.0 spec

September 08, 2004 09:29 AM PDT Permalink

Comments:

Post a Comment:

Comments are closed for this entry.

Calendar

« November 2009
SunMonTueWedThuFriSat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
     
       
Today

Links


Navigation


Referers

Today's Page Hits: 1