Changeset 347

Show
Ignore:
Timestamp:
05/06/04 18:15:35 (5 years ago)
Author:
earle
Message:

New RSS feed-embedding macro.

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/Build.PL

    r336 r347  
    215215    license => "perl", 
    216216    requires => { 
    217         'Algorithm::Diff' => '0.13', # for sdiff  
    218         'CGI' => '2.42', # unescape not in early versions, Dom says use this 
    219         'CGI::Carp' => 0, 
    220         'CGI::Cookie' => 0, 
    221         'CGI::Wiki' => '0.49', 
    222         'CGI::Wiki::Formatter::UseMod' => '0.09', 
    223         'CGI::Wiki::Plugin::Categoriser' => 0, 
    224         'CGI::Wiki::Plugin::Diff' => 0, 
    225         'CGI::Wiki::Plugin::GeoCache' => 0, 
    226         'CGI::Wiki::Plugin::Locator::UK' => '0.06', 
     217        'Algorithm::Diff'                 => '0.13', # for sdiff  
     218        'CGI'                             => '2.42', # unescape not in early versions, Dom says use this 
     219        'CGI::Carp'                       => 0, 
     220        'CGI::Cookie'                     => 0, 
     221        'CGI::Wiki'                       => '0.49', 
     222        'CGI::Wiki::Formatter::UseMod'    => '0.09', 
     223        'CGI::Wiki::Plugin::Categoriser'  => 0, 
     224        'CGI::Wiki::Plugin::Diff'         => 0, 
     225        'CGI::Wiki::Plugin::GeoCache'     => 0, 
     226        'CGI::Wiki::Plugin::Locator::UK'  => '0.06', 
    227227        'CGI::Wiki::Plugin::RSS::ModWiki' => '0.02', 
    228         'Config::Tiny' => 0, 
    229         'Data::Dumper' => 0, 
    230         $drivers{$dbtype} => 0, 
    231         'File::Spec::Functions' => 0, 
    232         'Geography::NationalGrid' => 0, 
    233         'Parse::RecDescent' => 0, 
    234         'Search::InvertedIndex' => 0, 
    235         'Template' => 0, 
    236         'Test::MockObject' => '0.07', # earlier doesn't use 'mock' 
    237         'Time::Piece' => 0, 
    238         'URI::Escape' => 0, 
     228        'CGI::Wiki::Plugin::RSS::Reader'  => 0, 
     229        'Config::Tiny'                    => 0, 
     230        'Data::Dumper'                    => 0, 
     231        $drivers{$dbtype}                 => 0, 
     232        'File::Spec::Functions'           => 0, 
     233        'Geography::NationalGrid'         => 0, 
     234        'LWP::Simple'                     => 0, 
     235        'Parse::RecDescent'               => 0, 
     236        'Search::InvertedIndex'           => 0, 
     237        'Template'                        => 0, 
     238        'Test::MockObject'                => '0.07', # earlier doesn't use 'mock' 
     239        'Time::Piece'                     => 0, 
     240        'URI::Escape'                     => 0, 
     241        'XML::RSS'                        => 0, 
    239242        }, 
    240243    build_requires => { 
  • trunk/Changes

    r345 r347  
    110.31     
     2        Created a new macro to allow the embedding of RSS feeds into 
     3          pages, using CGI::Wiki::Plugin::RSS::Reader. This allows you 
     4          to do this to produce a list of up to ten hyperlinks: 
     5            @RSS_FEED [http://example.com/example.rss] 
    26        
    37        Numerous template tweaks to comply with the W3C's Web Content  
  • trunk/PREREQUISITES

    r317 r347  
    1313CGI::Wiki::Plugin::Locator::UK (version 0.06 or later) 
    1414CGI::Wiki::Plugin::RSS::ModWiki (version 0.02 or later) 
     15CGI::Wiki::Plugin::RSS::Reader 
    1516Config::Tiny 
    1617Data::Dumper 
     
    2425File::Spec::Functions 
    2526Geography::NationalGrid 
     27LWP::Simple 
    2628Module::Build (version 0.18 or later) 
    2729Parse::RecDescent 
     
    3133Time::Piece 
    3234URI::Escape 
     35XML::RSS 
  • trunk/lib/OpenGuides/Utils.pm

    r344 r347  
    55$VERSION = '0.06'; 
    66 
     7use lib '/home/earle/lib'; 
    78use Carp qw( croak ); 
    89use CGI::Wiki; 
    910use CGI::Wiki::Formatter::UseMod; 
     11use CGI::Wiki::Plugin::RSS::Reader; 
    1012use CGI::Wiki::Search::SII; 
    1113use Search::InvertedIndex::DB::DB_File_SplitHash; 
     
    107109            qq(<form action="$search_url" method="get"><input type="text" size="20" name="search"><input type="submit" name="Go" value="Search"></form>), 
    108110        qr/\@INDEX_LINK\s+\[\[(Category|Locale)\s+([^\]|]+)\|?([^\]]+)?\]\]/ => 
    109             sub { my $link_title = $_[2] || "View all pages in $_[0] $_[1]"; return qq(<a href="$script_name?action=index;index_type=) . uri_escape(lc($_[0])) . qq(;index_value=) . uri_escape($_[1]) . qq(">$link_title</a>) 
    110                 } 
     111            sub { 
     112                  my $link_title = $_[2] || "View all pages in $_[0] $_[1]"; 
     113                  return qq(<a href="$script_name?action=index;index_type=) . uri_escape(lc($_[0])) . qq(;index_value=) . uri_escape($_[1]) . qq(">$link_title</a>); 
     114                }, 
     115        qr/\@RSS_FEED\s+\[(.*?)\]/ => sub {  
     116                                            # Get the URL. It's already been formatted into a  
     117                                            # hyperlink so we need to reverse that. 
     118                                            my $url_raw = $_[0]; 
     119                                            $url_raw =~ />(.*?)</; 
     120                                            my $url = $1; 
     121 
     122                                            # Retrieve the RSS from the given URL. 
     123                                            my $rss = CGI::Wiki::Plugin::RSS::Reader->new(url => $url); 
     124                                            my @items = $rss->retrieve; 
     125 
     126                                            # Ten items only at this till. 
     127                                            $#items = 10 if $#items > 10; 
     128 
     129                                            # Make an HTML list with them. 
     130                                            my $list = "<ul>\n"; 
     131                                            foreach (@items) 
     132                                            { 
     133                                              $list .= qq{\t<li><a href="} . $_->{link} . qq{">} . $_->{title} . "</a></li>\n"; 
     134                                            } 
     135                                            $list .= "</ul>\n"; 
     136 
     137                                            return $list; 
     138                                          } 
    111139    ); 
    112140