Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] REBOL Script to convert REBOL format to RSS XML

From: premshree:pillai:gmai:l at: 31-Dec-2004 2:46

Hello, So I wrote a small script that generates valid RSS 2.0 feeds from the REBOL data for Carl's blog. I don't know where else to post the code (because it won't be of use generally), so I'm posting it here: === BEGIN REBOL CODE === REBOL [ Title: "RSS Generator for Carl's Blog" Date: 31-Dec-2004 Version: 0.0.1 File: %carl-rss.r Home: http://www.livejournal.com/~premshree Author: "Premshree Pillai" Version: 0.0.1 Purpose: { Generates valid RSS 2.0 feeds for Carl's blogs } ] ;; channel data channel: [ title "Carl's REBOL Blog - Vive la REBOLution" link http://www.rebol.net/ description "describes this blog channel" language "English" copyright "2005 Carl Sassenrath" generator "REBOL Messaging Language" ] ;; blog items go here items: [ [ title "Blog item title...." link http://www.rebol.net/cgi-bin/blog.r?view=0080 author "Carl Sassenrath" pubdate 30-Dec-2004 content {the blog goes here} ] [ title "Blog item title 2...." link http://www.rebol.net/cgi-bin/blog.r?view=0081 author "Carl Sassenrath" pubdate 31-Dec-2004 content {the blog 2 goes here} ] ] ;; no edits required below this point channel-title: select channel 'title channel-link: select channel 'link channel-description: select channel 'description channel-language: "en" channel-copyright: select channel 'copyright channel-generator: select channel 'generator output: rejoin ["<?xml version='1.0' encoding='utf-8' ?><rss version='2.0'><channel><title>" channel-title "</title>"] output: rejoin [output "<link>" channel-link "</link>" "<description>" channel-description "</description>"] output: rejoin [output "<language>" channel-language "</language>" <copyright> channel-copyright "</copyright>"] output: rejoin [output "<generator>" channel-generator "</generator>"] for count 1 length? items 1 [ title: select items/:count 'title link: select items/:count 'link author: select items/:count 'author pubdate: parse to-string select items/:count 'pubdate "-" pubdate: rejoin ["Mon, " pubdate/1 " " pubdate/2 " " pubdate/3 " 00:00:00 GMT"] content: select items/:count 'content output: rejoin [output "<item><guid isPermaLink='true'>" link </guid><pubDate> pubdate "</pubDate>"] output: rejoin [output "<title>" title "</title><link>" link "</link>"] output: rejoin [output "<description>" content "</description></item>"] ] output: rejoin[output "</channel></rss>"] write %carl-rss2.xml output === END REBOL CODE === The REBOL data in Carl's blog (see http://www.rebol.net/cgi-bin/blog.r?view=0080) doesn't provide the time of posting, so it just takes it as 00:00:00 GMT, but that's okay, I guess. If there are improvements possible, please point so/do so. :) Thanks. -- Premshree Pillai http://www.livejournal.com/~premshree