[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

commit2html.rb or rss2html.rb

Bil Kleb

12/16/2004 6:04:00 PM

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,
--
Bil Kleb, Hampton, Virginia
http://fun3d.lar...
2 Answers

Dave Thomas

12/16/2004 9:28:00 PM

0


On Dec 16, 2004, at 12:07, Bil Kleb wrote:

> 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/syn...
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




Dave Thomas

12/17/2004 1:26:00 AM

0

On Dec 16, 2004, at 12:07, Bil Kleb wrote:

> 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/syn...
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