comment(#!/usr/bin/env ruby)
comment(# Sidebarize is a quite simple converter, like a lot others.)
comment(# But in one way Sidebarize is special: it converts)
comment(# feeds into HTML-pages suitable for sidebars in Gecko-browsers.)
comment(# import support for all kinds of feeds)
ident(require) string
ident(require) string
ident(require) string
comment(# import support for encodings)
ident(require) string
comment(# import support for CGI)
ident(require) string
comment(# import support for getting files from URLs)
ident(require) string
ident(require) string
constant(Version) operator(=) string
constant(Header) operator(=) string
%s Sidebar
%s
)delimiter(\))>
constant(Footer) operator(=) string
generated by Sidebarize %s
)delimiter(\))>
constant(Entry) operator(=) string
%s
)delimiter(\))>
reserved(class) class(FeedConverter)
reserved(def) method(initialize)
instance_variable(@xml_source) operator(=) string
instance_variable(@feed_data) operator(=) operator([)operator(])
instance_variable(@feed_version) operator(=) string
instance_variable(@feed_description) operator(=) string
reserved(end)
reserved(def) method(from_file)operator(()ident(filename)operator(\))
ident(f) operator(=) constant(File)operator(::)ident(open)operator(()ident(filename)operator(\))
instance_variable(@xml_source) operator(=) ident(f)operator(.)ident(read)
ident(f)operator(.)ident(close)
reserved(end)
reserved(def) method(from_url)operator(()ident(url)operator(\))
instance_variable(@xml_source) operator(=) constant(Net)operator(::)constant(HTTP)operator(.)ident(get)operator(()constant(URI)operator(.)ident(parse)operator(()ident(url)operator(\))operator(\))
reserved(end)
reserved(def) method(parse)
ident(feed) operator(=) constant(RSS)operator(::)constant(Parser)operator(.)ident(parse)operator(()instance_variable(@xml_source)operator(\))
instance_variable(@feed_description) operator(=) ident(feed)operator(.)ident(channel)operator(.)ident(description)
instance_variable(@feed_name) operator(=) ident(feed)operator(.)ident(channel)operator(.)ident(title)
ident(feed)operator(.)ident(items)operator(.)ident(each) reserved(do) operator(|)ident(item)operator(|)
ident(item_data) operator(=) operator({)operator(})
ident(item_data)operator([)stringoperator(]) operator(=) ident(item)operator(.)ident(title)
ident(item_data)operator([)stringoperator(]) operator(=) ident(item)operator(.)ident(link)
instance_variable(@feed_data) operator(<<) ident(item_data)
reserved(end)
reserved(end)
comment(# Output HTML from the internal data structure)
reserved(def) method(to_html)
comment(# header)
ident(puts) constant(Header) operator(%) operator([)ident(convert_entity)operator(()instance_variable(@feed_name)operator(\))operator(,) ident(convert_entity)operator(()instance_variable(@feed_description)operator(\))operator(])
comment(# the entries)
instance_variable(@feed_data)operator(.)ident(each) reserved(do) operator(|)ident(item)operator(|)
ident(puts) constant(Entry) operator(%) operator([)ident(item)operator([)stringoperator(])operator(,) ident(convert_entity)operator(()ident(item)operator([)stringoperator(])operator(\))operator(])
reserved(end)
comment(# footer)
ident(print) constant(Footer) operator(%) constant(Version)
reserved(end)
reserved(end)
comment(# Converts entities)
comment(# uses code by murphy extended with iconv conversion)
reserved(def) method(convert_entity)operator(()ident(text)operator(\))
ident(text) operator(=) constant(Iconv)operator(.)ident(new)operator(()stringoperator(,) stringoperator(\))operator(.)ident(iconv)operator(()ident(text)operator(\))
ident(feed) operator(=) ident(text)operator(.)ident(inspect)operator([)integer(1)operator(...)integer(-1)operator(])
ident(feed)operator(.)ident(gsub!)operator(()regexpoperator(\)) reserved(do)
reserved(if) global_variable($2)
global_variable($&)
reserved(else)
string operator(%) global_variable($1)operator(.)ident(to_i)operator(()integer(8)operator(\))operator(.)ident(to_s)operator(()integer(10)operator(\))
reserved(end)
reserved(end)
ident(feed)operator(.)ident(gsub!)operator(()stringoperator(,) stringoperator(\))
reserved(return) ident(feed)
reserved(end)
comment(# Starter)
reserved(def) method(main)
ident(fc) operator(=) constant(FeedConverter)operator(.)ident(new)
ident(cgi) operator(=) constant(CGI)operator(.)ident(new)
reserved(if) ident(cgi)operator(.)ident(has_key?) string
comment(# yeah, the user pointed us to an URL)
ident(fc)operator(.)ident(from_url)operator(()ident(cgi)operator([)stringoperator(])operator(\))
comment(#fc.from_file('sd.xml'\))
comment(#fc.from_file('sbarize_design.html'\))
reserved(begin)
comment(# try to parse it and to generate HTML)
ident(fc)operator(.)ident(parse)
ident(puts) string
ident(puts)
ident(fc)operator(.)ident(to_html)
reserved(rescue)
comment(# parsing failed so show an error message)
ident(puts) string
ident(puts)
ident(puts) constant(Header) operator(%) operator([)stringoperator(,) stringoperator(])
ident(puts) constant(Footer) operator(%) constant(Version)
reserved(end)
reserved(else)
comment(# no, we've got no URL, generate error message)
ident(puts) string
ident(puts)
ident(puts) constant(Header) operator(%) operator([)stringoperator(,) stringoperator(])
ident(puts) constant(Footer) operator(%) constant(Version)
reserved(end)
reserved(end)
ident(main) reserved(if) pre_constant(__FILE__) operator(==) global_variable($0)