Documention for: emit-rss.r
Created by: chrisrg
on: 4-Feb-2005
Last updated by: chrisrg on: 11-Sep-2008
Format: html
Downloaded on: 18-Apr-2024

Emit RSS

1. Introduction

A short script that creates RSS Markup from a REBOL Block. The block needs to be specifically constructed to closely match the RSS structure.

2. Usage

The script is designed to be modular. You can load it to your project as follows:

  context load %emit-rss.r

It will add the function 'emit-rss to the global namespace.

3. Example

  context load %emit-rss.r
  write %my-feed.rss emit-rss [
      channel [
          title "Journal Title"
          link http://www.example.com/
          description "Describes this Journal"
          language "en-us"
          generator "REBOL Messaging Language"
      ]

      item [
          title "Journal Entry title...."
          link http://www.example.com/cgi-bin/url.r?....
          author "You"
          pubdate 30-Dec-2004/12:00+9:00
          content {Journal Entry goes here...}
      ]
  ]

4. Methodology

There are two major parts of this script and they both involve 'parse rules. The first escapes non-ascii characters; the second parses the argument block.

Parse

My personal take on 'parse is that you are trying to acurately describe the form of a series! value. On the way, we may manipulate the series! as our needs dictate. This is strongly evident when parsing the argument block as the rule used to interpret it is fairly linear and rigid. You cannot, for example, have channel [link title] -- it must be channel [title link]

4.1 Escape

The escape rule uses charset! values to decide whether to pass through each character in a string!; replace it with a numeric entity or a replace it with a question mark.

4.2 Argument Structure

The rule I've called 'build-rss assumes block parse and signifigantly uses the 'into parse command to probe into the 'channel and 'item sub blocks. As the parse routine passes through the argument block, we accumulate RSS data with the 'emit and 'emit-tags functions.

5. Plans

I have no further plans for this script at this time. Any deficiencies this script has in relation to the RSS 2.0 spec can easily and obviously be remedied upon quick examination of its code.