commit2html.rb or rss2html.rb

B

Bil Kleb

The other month we hooked Dave's commit2rss.rb script up
to our CVS repository to gain an RSS feed. (Thanks Dave!)

Now we'd like to display the RSS feed in a sidebar. What's
the best method to do this? Currently our web person is
using some third-party converter that produces some rather
ugly HTML.

rss2html clueless,
 
D

Dave Thomas

The other month we hooked Dave's commit2rss.rb script up
to our CVS repository to gain an RSS feed. (Thanks Dave!)

Now we'd like to display the RSS feed in a sidebar. What's
the best method to do this? Currently our web person is
using some third-party converter that produces some rather
ugly HTML.

My Dr Dobbs article has a trivial program to do exactly that.

Here's a variant of it that we use on the PragProg site to create some
HTML which is injected into Mike Clark's automation page. It reads his
blog's RSS, then uploads a converted file to our website.

Cheers

Dave


# Such down the top 'n' articles from an RSS feed
# and summarize for a web site

require 'rss/0.9'
require 'open-uri'
require 'rdoc/template'
require 'net/ftp'

TEMPLATE = %{
<div class="blogentries">
START:entries
<div class="blogentry">
<a href="%link%"><span class="blogentrytitle">%title%</span></a>
<div class="blogentrydescription">
%description%
</div>
</div>
END:entries
</div>
}

TMP_FILE = "/tmp/topfive"
BLOG_URL =
'http://www.pragmaticautomation.com/cgi-bin/pragauto.cgi/synopsis.rss?
count=5'

open(BLOG_URL) do |http|
result = RSS::parser.parse(http.read, false)
entries = result.items.map do |item|
{
'title' => item.title,
'link' => item.link,
'description' => item.description
}
end

File.open(TMP_FILE, "w") do |f|
t = TemplatePage.new(TEMPLATE)
t.write_html_on(f, 'entries' => entries)
end
end

Net::FTP.open('www.yoursite.com') do |ftp|
ftp.login('user', 'passwd')
ftp.chdir('somedir')
ftp.put(TMP_FILE, 'topfive', 1024)
end
 
D

Dave Thomas

The other month we hooked Dave's commit2rss.rb script up
to our CVS repository to gain an RSS feed. (Thanks Dave!)

Now we'd like to display the RSS feed in a sidebar. What's
the best method to do this? Currently our web person is
using some third-party converter that produces some rather
ugly HTML.

My Dr Dobbs article has a trivial program to do exactly that.

Here's a variant of it that we use on the PragProg site to create some
HTML which is injected into Mike Clark's automation page. It reads his
blog's RSS, then uploads a converted file to our website.

Cheers

Dave


# Such down the top 'n' articles from an RSS feed
# and summarize for a web site

require 'rss/0.9'
require 'open-uri'
require 'rdoc/template'
require 'net/ftp'

TEMPLATE = %{
<div class="blogentries">
START:entries
<div class="blogentry">
<a href="%link%"><span class="blogentrytitle">%title%</span></a>
<div class="blogentrydescription">
%description%
</div>
</div>
END:entries
</div>
}

TMP_FILE = "/tmp/topfive"
BLOG_URL =
'http://www.pragmaticautomation.com/cgi-bin/pragauto.cgi/synopsis.rss?
count=5'

open(BLOG_URL) do |http|
result = RSS::parser.parse(http.read, false)
entries = result.items.map do |item|
{
'title' => item.title,
'link' => item.link,
'description' => item.description
}
end

File.open(TMP_FILE, "w") do |f|
t = TemplatePage.new(TEMPLATE)
t.write_html_on(f, 'entries' => entries)
end
end

Net::FTP.open('www.yoursite.com') do |ftp|
ftp.login('user', 'passwd')
ftp.chdir('somedir')
ftp.put(TMP_FILE, 'topfive', 1024)
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,164
Messages
2,570,897
Members
47,439
Latest member
shasuze

Latest Threads

Top