2 # Copyright (C) 2003 Alex Schroeder <alex@emacswiki.org>
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the
16 # Free Software Foundation, Inc.
17 # 59 Temple Place, Suite 330
18 # Boston, MA 02111-1307 USA
20 use CGI qw
/:standard/;
21 use CGI
::Carp
qw(fatalsToBrowser);
24 if (not param
('url')) {
26 start_html
('MoinMoin Search RSS 3.0'),
27 h1
('MoinMoin Search RSS 3.0'),
28 p
('Translates a MoinMoin Search result into RSS 3.0 usable by Oddmuse.'),
29 start_form
(-method
=>'GET'),
30 p
('Search URL: ', textfield
('url'), submit
()),
36 print header
(-type
=>'text/plain; charset=UTF-8');
38 my $ua = new LWP
::UserAgent
;
39 my $request = HTTP
::Request
->new('GET', param
('url'));
40 my $response = $ua->request($request);
41 my $data = $response->content;
43 $data =~ /\<title\>([^<]*)/i;
44 print "title: $1\n" if $1;
45 print "link: " . param
('url') . "\n\n";
47 $data =~ /\<ul\>((.*\n)*.*)\<\/ul\
>/i
;
49 foreach $item (split(/\<li\>/i, $1)) {
50 next unless $item =~ /\<a[^>]*\>([^<]+)/i;
53 while ($item =~ m/\<font[^>]*\>((.*?\n)*?.*?)\<\/font\
>/gi
) {
55 $word =~ s/^\.\.\.\S+/\.\.\./;
56 $word =~ s/\S+\.\.\.$/\.\.\./;
60 $desc =~ s/\<\/?b\>//gi
;
61 $desc =~ s/[\r\n\t]+/ /g;
62 $desc =~ s/\.\.\. \.\.\./\.\.\./g;
63 print "description: $desc\n";