< Back

Document Subject: Create RSS feed for your Lotus Notes web site or database
Hint Short Cut: Add this to your code & documentation to help you find this page.
http://#RSS or http://A555F9/nn.nsf/ByAlias/RSS

RSS is seems to be becoming more and more popular, I thought I would find out about it and add a feed from my Lotus Notes website. Here is the simple code and some hints and tips.




RSS stands for Really Simple Syndication

Example RSS feed: http://www.notesninjas.com/A555F9/nn.nsf/rss091!openagent&.xml

For an explanation of RSS check out this great page: http://webservices.xml.com/pub/a/ws/2002/11/19/rssfeedquality.html

The agent should be a of type "Run Once..." and to make the borwsers etc think it is xml, call it ny using:

   -> http://dbpath/RSS!openagent&.xml

My agent code:

 On Error Goto ErrHdlr
Print "Content-type: application/rss+xml\n\n"
Print "<?xml version=""1.0"" encoding=""ISO-8859-1"" ?>"
Print "<rss version=""0.91"">"
Print "<channel>"
Print "<title>Lotus Notes Ninjas</title>"
Print "<link>http://www.NotesNinjas.com</link>";
Print"<description>Lotus Notes tips hints and news Updated every few days - FOR PERSONAL USE ONLY</description>"
Print"<category>Lotus Notes</category>"
Print "<language>en-gb</language>"
Print "<ttl>720</ttl>" ' mins to wait until reloading
Print "<generator>http://www.NotesNinjas.com/#RSS</generator>"; ' what generated this

Dim dow(7) As String
dow(1)="Sun"
dow(2)="Mon"
dow(3)="Tue"
dow(4)="Wed"
dow(5)="Thu"
dow(6)="Fri"
dow(7)="Sat"

Dim mon(12)
mon(1)="Jan"
mon(2)="Feb"
mon(3)="Mar"
mon(4)="Apr"
mon(5)="May"
mon(6)="Jun"
mon(7)="Jul"
mon(8)="Aug"
mon(9)="Sep"
mon(10)="Oct"
mon(11)="Nov"
mon(12)="Dec"

Dim s As New notessession
Dim db As notesdatabase
Set db = s.currentdatabase
Dim v As notesview
Set v = db.getview("Hints_By_Title")

count=1
Dim doc As notesdocument
Set doc = v.getfirstdocument()

Dim niPubDate As notesitem

'pub date
Set niPubDate = doc.getfirstitem("DocCreated")
If Not(niPubDate Is Nothing) Then
 Set ndt = niPubDate.datetimevalue
 
 If ndt Is Nothing Then
   'use default doc.created or doc.lastmodified
  lslocaltime = doc.lastmodified
 Else
  lsLocalTime =ndt.lslocaltime
 End If
Else
              'use default doc.created or doc.lastmodified
 lslocaltime = doc.lastmodified
End If

Print "<pubDate>" &   dow(Weekday(Today)) & ", " &  Day(Today) & " " & _
mon(Month(Today)) & " " & Year(Today) & _
" " & Right("0" & Hour(Now),2) & ":" & Right("0" & Minute(Now),2) & ":" & _
Right("0" & Second(Now),2) & " GMT" & _
"</pubDate>"

Print "<lastBuildDate>" &   dow(Weekday(lsLocalTime)) & ", " & Day(lsLocalTime) & " " & _
mon(Month(lsLocalTime)) & " " & Year(lsLocalTime) & _
" 00:00:01 GMT" & _
"</lastBuildDate>"

Print "<copyright>Copyright: (C) Adam Foster, http://www.AdFos.com</copyright>";
Print "<docs>http://www.AdFos.com</docs>";

Print "<image>"
Print"<title>Lotus Notes Ninjas</title>"
Print "<url>http://www.notesninjas.com/A555F9/nn.nsf/32e1ea7a6b090c16802569e200807da8/$Body/0.43C!OpenElement</url>";
Print "<link>http://www.NotesNinjas.com</link>";
Print "</image>"


Dim ab As notesrichtextitem

'RSS spec 0.91 says that 15 is the maximum number of items
Do Until count>14 Or doc Is Nothing
 Print "<item>"
 Print "<title>" & doc.subject(0) & "</title>"
 ' In this code Abstract is a rich text item
 Set ab = doc.getfirstitem("Abstract")
 
 Print "<description>" & Left(ab.text,150) & "</description>"
 
 'pub date
 Set niPubDate = doc.getfirstitem("DocCreated")
 If Not(niPubDate Is Nothing) Then
  Set ndt = niPubDate.datetimevalue
 
If ndt Is Nothing Then
   'use default doc.created or doc.lastmodified
   lslocaltime = doc.lastmodified
  Else
   lsLocalTime =ndt.lslocaltime
  End If
 Else
              'use default doc.created or doc.lastmodified
  lslocaltime = doc.lastmodified
 End If
 
 Print "<pubDate>" &   dow(Weekday(lsLocalTime)) & ", " & Day(lsLocalTime) & " " & _
 mon(Month(lsLocalTime)) & " " & Year(lsLocalTime) & _
 " " & Right("0" & Hour(lsLocalTime),2) & ":" & Right("0" & Minute(lsLocalTime),2)  & _
 ":" & Right("0" & Second(lsLocalTime),2) & " GMT" & _
"</pubDate>"
 'category
 Print "<category>Lotus Notes</category>"
 Print "<link>http://www.notesninjas.com/A555F9/nn.nsf/ByAlias/"; & doc.alias(0) & "</link>"
Print "</item>"
 Set doc =v.getnextdocument(doc)
 count=count+1

Loop

Print "</channel>"
Print "</rss>"
Print "<!-- Code: http://www.NotesNinjas.com/#RSS   (c) Adam Foster -->"
End
ErrHdlr:
Print "</channel>"
Print "</rss>"
Print "<!-- Error:" & Err & "  " & Error$ & "  Line: " & Erl & " -->"
Print "<!-- Code: http://www.NotesNinjas.com/#RSS   (c) Adam Foster -->"
End


 

RSS Specification

Here is a good description of the 2.0 Spec: http://blogs.law.harvard.edu/tech/rss

Checking your RSS Feed is well formed

A free online RSS feed checker: http://www.xml.com/pub/a/tools/ruwf/check.html

Using this I worked out that you cannot put & in your feed anywhere, which can be a problem with Lotus Notes URLs.

NB: Dates are supposed to be RFC 822 or RFC822 or RFC-822 however you denote it. I find this means that years need to be 4 digits.

I have written a function to code this date format: http://www.notesninjas.com/A555F9/nn.nsf/ByAlias/RFC882dates

Also: URLs cannot have spaces in.

It also allowed me to check syntaxes etc.

 

Try it in a free RSS Reader

I used the free reader at: http://reader.rocketinfo.com/desktop  or at http://my.yahoo.com .

How to add your RSS feed into your main website as an alternative URL

Stick this in the head part of the webpage:

<link href="http://www.notesninjas.com/A555F9/nn.nsf/rss091!openagent&.xml"; rel="alternate" type="application/rss+xml" title="rss" />

This is how the bbc does it anyway:  

From: http://news.bbc.co.uk/  

See: <link href="http://news.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss091.xml"; rel="alternate" type="application/rss+xml" title="rss" />

 You can test this by entering http://www.NotesNinjas.com into: http://www.skyzyx.com/rss/?feed

 

A Java RSS solution for Lotus Notes

There is a Java solution in the sandbox on http://www.Notes.net

An OPML for Notes blogs

See http://news4notes.com   Linkk here: http://news4notes.com/lotus-links/domino.opml

A Lotus Notes Client RSS reader: http://falsepositives.blogspot.com/2003/07/lotus-notes-news-reader-v03.html

One good RSS readers is: Wizz RSS 2.0.6 available from: http://www.wizzcomputers.com

One usful feature is being able to save your feeds to their server, and retrieve, so you can keep it for use on different machines.

Ampersands (and other special characters) really mess up a feed. XML errors will occur, so add code to remove ampersands from item vvalues or replace them with their entity reference equivalents. See: http://www.w3.org/TR/html401/sgml/entities.html

I have written a subroutine to covert these strings: http://www.notesninjas.com/A555F9/nn.nsf/ByAlias/XMLTextEncode

Complete Link A complete link is required in RSS standards. A relative link works in atom only. Lotusphere 2006 forum now use a complete link :)