Changeset 187


Ignore:
Timestamp:
Jun 2, 2004, 8:08:54 PM (17 years ago)
Author:
kake
Message:

Er,this is the up to date version (0.03)

Location:
cgi-wiki-plugin-rss-modwiki/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cgi-wiki-plugin-rss-modwiki/trunk/MANIFEST

    r183 r187  
     1Changes
    12MANIFEST
    23Makefile.PL
    34README
    4 TODO
    55lib/CGI/Wiki/Plugin/RSS/ModWiki.pm
    66t/00_setup.t
  • cgi-wiki-plugin-rss-modwiki/trunk/lib/CGI/Wiki/Plugin/RSS/ModWiki.pm

    r183 r187  
    44
    55use vars qw( $VERSION );
    6 $VERSION = '0.01';
     6$VERSION = '0.03';
    77
    88use XML::RSS;
     
    139139  print $rss->recent_changes;
    140140
     141  # Or get something other than the default of the latest 15 changes.
     142  print $rss->recent_changes( items => 50 );
     143  print $rss->recent_changes( days => 7 );
     144
    141145B<Note:> Many of the fields emitted by the RSS generator are taken
    142146from the node metadata. The form of this metadata is I<not> mandated
     
    146150=over 4
    147151
    148 =item B<comment> - a brief comment summarising the edit that has just been made; will be used as the RDF description for this item.  Defaults to the empty string.
    149 
    150 =item B<username> - an identifier for the person who made the edit; will be used as the RDF author for this item.  Defaults to the empty string.
    151 
    152 =item B<host> - the hostname or IP address of the computer used to make the edit; if no username is supplied then this will be used as the RDF author for this item.  Defaults to the empty string.
     152=item B<comment> - a brief comment summarising the edit that has just been made; will be used in the RDF description for this item.  Defaults to the empty string.
     153
     154=item B<username> - an identifier for the person who made the edit; will be used as the Dublin Core contributor for this item, and also in the RDF description.  Defaults to the empty string.
     155
     156=item B<host> - the hostname or IP address of the computer used to make the edit; if no username is supplied then this will be used as the Dublin Core contributor for this item.  Defaults to the empty string.
    153157
    154158=item B<major_change> - true if the edit was a major edit and false if it was a minor edit; used for the importance of the item.  Defaults to true (ie if C<major_change> was not defined or was explicitly stored as C<undef>).
     
    156160=back
    157161
    158 Currently this is very simple and only emits the last 15 changes,
    159 major or minor. There are interesting parameters at
    160 L<http://www.usemod.com/cgi-bin/wiki.pl?WikiPatches/XmlRss> that I will
    161 get around to implementing at some point.
    162 
    163162=cut
    164163
    165164sub recent_changes {
    166     my $self = shift;
     165    my ($self, %args) = @_;
    167166
    168167    my $rss = new XML::RSS (version => '1.0');
     
    188187    );
    189188
    190     # Get the latest 15 changes.
     189    # If we're not passed any parameters to limit the items returned,
     190    # default to 15, which is apparently the modwiki standard.
    191191    my $wiki = $self->{wiki};
    192     my @changes = $wiki->list_recent_changes( last_n_changes => 15 );
     192    my @changes;
     193    if ( $args{days} ) {
     194        @changes = $wiki->list_recent_changes( days => $args{days} );
     195    } else {
     196        my $items = $args{items} || 15;
     197        @changes = $wiki->list_recent_changes( last_n_changes => $items );
     198    }
    193199    foreach my $change (@changes) {
    194200        my $node_name   = $change->{name};
     
    201207        $timestamp = $time->strftime( "%Y-%m-%dT%H:%M:%S" );
    202208
    203         my $description = $change->{metadata}{comment}[0] || "";
    204209        my $author      = $change->{metadata}{username}[0]
    205210                            || $change->{metadata}{host}[0] || "";
     211
     212        my $description = $change->{metadata}{comment}[0] || "";
     213        $description .= " [$author]" if $author;
    206214
    207215        my $version = $change->{version};
  • cgi-wiki-plugin-rss-modwiki/trunk/t/01_add_test_data.t

    r183 r187  
    1919      my $wiki = CGI::Wiki->new( store => $store );
    2020
     21      $wiki->write_node( "Old Node",
     22                         "We will write at least 15 nodes after this one" );
     23
     24      my $slept = sleep(2);
     25      warn "Slept for less than a second, 'days=n' test may pass even if buggy"
     26        unless $slept >= 1;
     27
     28      for my $i ( 1 .. 15 ) {
     29          $wiki->write_node( "Temp Node $i", "foo" );
     30      }
     31
     32      $slept = sleep(2);
     33      warn "Slept for less than a second, test results may not be trustworthy"
     34        unless $slept >= 1;
     35
    2136      $wiki->write_node( "Test Node 1",
    2237                         "Just a plain test",
     
    2641                         }
    2742                       );
     43
     44      $slept = sleep(2);
     45      warn "Slept for less than a second, 'items=n' test may fail"
     46        unless $slept >= 1;
    2847
    2948      $wiki->write_node( "Calthorpe Arms",
     
    3756      );
    3857
     58      $wiki->write_node( "Test Node 2",
     59                         "Gosh, another test!",
     60                         undef,
     61                         { username => "nou",
     62                           comment  => "testy testy",
     63                         }
     64                       );
     65
    3966      pass "$store_name test backend primed with test data";
    4067    }
  • cgi-wiki-plugin-rss-modwiki/trunk/t/recentchanges.t

    r183 r187  
     1use strict;
    12use CGI::Wiki::TestConfig::Utilities;
    23use CGI::Wiki;
     
    45
    56use Test::More tests =>
    6   (3 + 11 * $CGI::Wiki::TestConfig::Utilities::num_stores);
     7  (3 + 14 * $CGI::Wiki::TestConfig::Utilities::num_stores);
    78
    89use_ok( "CGI::Wiki::Plugin::RSS::ModWiki" );
     
    2122while ( ($store_name, $store) = each %stores ) {
    2223  SKIP: {
    23       skip "$store_name storage backend not configured for testing", 11
     24      skip "$store_name storage backend not configured for testing", 14
    2425          unless $store;
    2526
     
    6364            "username picked up as contributor" );
    6465
     66      like( $feed, qr|<description>testy testy \[nou]</description>|,
     67            "username included in description" );
     68
    6569      # Check that interwiki things are passed through right.
    6670      $rss = CGI::Wiki::Plugin::RSS::ModWiki->new(
     
    98102            "make_history_url used" );
    99103
     104      # Test the 'items' parameter.
     105      $feed = $rss->recent_changes( items => 2 );
     106      unlike( $feed, qr|<title>Test Node 1</title>|, "items param works" );
     107
     108      # Test the 'days' parameter.
     109      $feed = $rss->recent_changes( days => 2 );
     110      like( $feed, qr|<title>Old Node</title>|, "days param works" );
    100111  }
    101112}
Note: See TracChangeset for help on using the changeset viewer.