#!/usr/bin/perl # # Name: News Publisher to RSS # Description: Converts news from Grant Williams News Publisher into a # RSS file. # Copyright (C) 2000 William R Thomas # Author: William R Thomas (aka Corvar) # Distribution site: http://www.theonering.net/staff/corvar/software/ # # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program 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. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # GPL Reference: http://www.gnu.org/copyleft/gpl.html # use strict; #use LWP::Simple; use XML::RSS; use CGI; my $rss = new XML::RSS; my $cgi = new CGI; my $path = "/www01/customers/lotr-news"; my $type = $cgi->param('type') || "1"; my $limit = $cgi->param('limit') || "15"; my @cells; $rss->channel('title' => 'TheOneRing.Net', 'link' => 'http://www.theonering.net', 'description' => 'Forged by and for the fans of J.R.R. Tokien', 'language' => 'en'); $rss->image(title => 'TheOneRing.net', url => 'http://www.theonering.net/images/logo_88X37.jpg', link => 'http://www.theonering.net', width => 88, height => 37, description => 'TheOneRing.net' ); $rss->textinput('title' => 'Search TheOneRing.Net', 'description' => 'Search the TheOneRing.Net Site', 'name' => 'words', 'link' => 'http://www.theonering.net/cgi-bin/htsearch'); #if((time() - (stat("$path/$type.news"))[10]) > (60 * 60)) #{ # getstore("http://theonering.net/news-data/$type.news", # "$path/$type.news"); #} open(FH,"$path/$type.news"); { while() { if($limit > 0) { (@cells)=split(/\|/,$_); $cells[4] =~ s/&/&/g; $cells[4] =~ s/\'/'/g; if(length($cells[4]) > 99 ) { $cells[4] = substr($cells[4],0,90)." ... "; } $rss->add_item('title' => $cells[4], 'link' => "http://www.theonering.net/perl/newsview/$type/$cells[5]"); $limit--; } } } close(FH); print $cgi->header(-type=>'text/plain'), $rss->as_string;