#!/usr/bin/perl # Copyright (C) 2000-2003 William R Thomas # Last Changed by: $Author: corvar $ # on: $Date: 2003/04/11 09:42:00 $ # Version: $Revision: 1.1 $ # Maintainer: William R Thomas # Keywords: convenience # This file is free software; you can redistribute it and/or modify # it under the terms of version 2 of the GNU General Public License # as published by the Free Software Foundation. # This file is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # Revision History: # 1.0 Initial version; Allow for simple installation of RSS data sources # into Mozilla browser sidebar. # 1.1 3 years worth of misc bug fixes. Dealing with a more expansive set # of domain names than the original version is the major improvement. # Requirements: # LWP::Simple # CGI # URI::Escape # XML::Parser use LWP::Simple; use XML::RSS; use URI::Escape; use CGI; $page = new CGI; $DISPLAY = "http://www.theonering.net/staff/corvar/cgi-bin/sidebar.pl"; $SELF = "http://www.theonering.net/staff/corvar/cgi-bin/sidebar-inst.pl"; $tmppath = "/tmp"; # some XUL, if we've generated it if($page->param('url')) { print $page->header(); print $page->start_html(-title=>'Mozilla RSS Sidebar Installer', -author=>'Corvar@theonering.net', 'bgcolor'=>'#FFFFFF'); $url = uri_escape($page->param('url')); $url =~ s/&/%26/g; if( $url =~ /http%3A%2F%2F([A-Za-z0-9\-.]*)%2F(.*)/){ $site = $1; $path = $2; $file = uri_unescape("http://".$site.$path); $file =~ s/[^a-zA-Z0-9]//g; print qq(\n); print qq(\n); print qq(
\n); print qq(\n); print qq(\n); $p1 = new XML::RSS; print STDERR "$file\n"; eval { $p1->parsefile($tmppath."/".$file) }; $title = uri_unescape($p1->channel('title')); print "Title: $title
\n"; print qq(\(Note if Title is empty, but the preview displays correctly please hit reload before installing. This is a small bug in the script which I am too lazy to fix.\)\n); print "

To the left is an example of what the sidebar will look similar to. If you wish to install this source into your sidebar, you can click the button below.

"; my $javascript_title = $title; $javascript_title =~ s|'|\\'|g; print qq(\n); print qq(

Back to Sidebar Installer Start); print qq(
\n); print $page->end_html; exit; } else { print "A valid url is of the form http://hostname/path/to/file, not $url

\n"; } } if(! $page->param('url') ) { print $page->header(); print $page->start_html(-title=>'Mozilla RSS Sidebar Installer', -author=>'Corvar@theonering.net', 'bgcolor'=>'#FFFFFF'); } print <Install a Mozilla Sidebar

This installer will evaluate a RSS data source, and if it is valid give you a preview and allow you to install that source as a Mozilla Sidebar.

$msg

RSS Data Source

Or, rather than type a URL in above, you can choose from a number of my favorite RSS sources.

Tips on finding RSS Sources: There are a number of resources to find the URL of the RSS sources you are looking for. The above list is short and highly subjective (i.e. what I am interested in). If you are looking for a RSS feed of a different nature, try XMLTree and my.userland.com (Userland requires you to register). The more people who add a particular feed, the more likely I will add a direct link to the feed.

The author, Corvar, welcomes comments.

This script owes quite a bit to the work of DJ Adams on his mysidebar.pl script. EO_FORM exit;