Changeset 1026

Show
Ignore:
Timestamp:
04/28/07 09:40:21 (19 months ago)
Author:
kake
Message:

Fixed bug in OpenGuides::Feed - HTML equivalent link now works even if your script_name isn't blank.

Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/Changes

    r1023 r1026  
    55 
    660.60 
     7        Fixed bug in OpenGuides::Feed - HTML equivalent link now works even 
     8          if your script_name isn't blank. 
    79        Rewrote the HTML of the edit page to use <div>s rather than tables. 
    810          Note that you will probably want to provide at least basic styling 
  • trunk/lib/OpenGuides/Feed.pm

    r903 r1026  
    1111use URI::Escape; 
    1212use Carp 'croak'; 
     13 
     14use base qw( Class::Accessor ); 
     15# Add more here if we need them - this one added for testing purposes. 
     16my @variables = qw( html_equiv_link ); 
     17OpenGuides::Feed->mk_accessors( @variables ); 
    1318 
    1419sub new { 
     
    5358    $self->{site_description} = $config->site_desc         || ""; 
    5459    $self->{og_version}       = $args{og_version}; 
    55     $self->{html_equiv_link}  = $self->{config}->script_url . '?action=rc'; 
     60    $self->{html_equiv_link}  = $self->{config}->script_url 
     61                                . $self->{config}->script_name . '?action=rc'; 
    5662 
    5763    $self; 
  • trunk/t/22_feed_recent_changes.t

    r956 r1026  
    44use OpenGuides; 
    55use OpenGuides::Feed; 
     6use OpenGuides::Test; 
    67use OpenGuides::Utils; 
    78use Test::More; 
     
    2122# Which feed types do we test? 
    2223my @feed_types = qw( rss atom ); 
    23 plan tests => 10 * scalar @feed_types; 
     24plan tests => 12 * scalar @feed_types; 
    2425 
    2526my %content_types = (rss=>'application/rdf+xml', atom=>'application/atom+xml'); 
     
    3132 
    3233    Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } ); 
    33     my $config = OpenGuides::Config->new( 
    34            vars => { 
    35                      dbtype             => "sqlite", 
    36                      dbname             => "t/node.db", 
    37                      indexing_directory => "t/indexes", 
    38                      script_name        => "wiki.cgi", 
    39                      script_url         => "http://example.com/", 
    40                      site_name          => "Test Site", 
    41                      template_path      => "./templates", 
    42                      home_name          => "Home", 
    43                      use_plucene        => 1, 
    44                      http_charset       => "UTF-7", 
    45                    } 
    46     ); 
     34    my $config = OpenGuides::Test->make_basic_config; 
     35    $config->script_name( "wiki.cgi" ); 
     36    $config->script_url( "http://example.com/" ); 
     37    $config->http_charset( "UTF-7" ); 
    4738 
    4839    # Basic sanity check first. 
     
    5243                                      config => $config ); 
    5344    is( $feed->default_content_type($feed_type), $content_types{$feed_type}, "Return the right content type" ); 
     45 
     46    like( $feed->html_equiv_link, qr|http://example.com/wiki.cgi\?|, 
     47          "html_equiv_link looks right" ); 
    5448 
    5549    my $feed_output = eval { $feed->make_feed(feed_type => $feed_type, feed_listing => 'recent_changes'); }; 
     
    6559    # Now write some data, first a minor edit then a non-minor one. 
    6660    my $guide = OpenGuides->new( config => $config ); 
    67          
    68     # Set up CGI parameters ready for a node write. 
    69     # Most of these are in here to avoid uninitialised value warnings. 
    70     my $q = CGI->new; 
    71     $q->param( -name => "content", -value => "foo" ); 
    72     $q->param( -name => "categories", -value => "" ); 
    73     $q->param( -name => "locales", -value => "" ); 
    74     $q->param( -name => "phone", -value => "" ); 
    75     $q->param( -name => "fax", -value => "" ); 
    76     $q->param( -name => "website", -value => "" ); 
    77     $q->param( -name => "hours_text", -value => "" ); 
    78     $q->param( -name => "address", -value => "" ); 
    79     $q->param( -name => "postcode", -value => "" ); 
    80     $q->param( -name => "map_link", -value => "" ); 
    81     $q->param( -name => "os_x", -value => "" ); 
    82     $q->param( -name => "os_y", -value => "" ); 
    83     $q->param( -name => "username", -value => "bob" ); 
    84     $q->param( -name => "comment", -value => "foo" ); 
    85     $q->param( -name => "edit_type", -value => "Minor tidying" ); 
    86     $ENV{REMOTE_ADDR} = "127.0.0.1"; 
    8761 
    88     my $output = $guide->commit_node( 
    89                                       return_output => 1, 
    90                                       id => "Wombats", 
    91                                       cgi_obj => $q, 
    92                                     ); 
    93  
    94     $q->param( -name => "edit_type", -value => "Normal edit" ); 
    95     $output = $guide->commit_node( 
    96                                    return_output => 1, 
    97                                    id => "Badgers", 
    98                                    cgi_obj => $q, 
    99                                  ); 
    100  
    101     $q->param( -name => "username", -value => "Kake" ); 
    102     $output = $guide->commit_node( 
    103                                    return_output => 1, 
    104                                    id => "Wombles", 
    105                                    cgi_obj => $q, 
    106                                  ); 
     62    OpenGuides::Test->write_data( 
     63                                  node          => "Wombats", 
     64                                  guide         => $guide, 
     65                                  username      => "bob", 
     66                                  edit_type     => "Minor tidying", 
     67                                  return_output => 1, 
     68                                ); 
     69    OpenGuides::Test->write_data( 
     70                                  node          => "Badgers", 
     71                                  guide         => $guide, 
     72                                  username      => "bob", 
     73                                  edit_type     => "Normal edit", 
     74                                  return_output => 1, 
     75                                ); 
     76    OpenGuides::Test->write_data( 
     77                                  node          => "Wombles", 
     78                                  guide         => $guide, 
     79                                  username      => "Kake", 
     80                                  edit_type     => "Normal edit", 
     81                                  return_output => 1, 
     82                                ); 
    10783 
    10884    # Check that the writes went in. 
     
    11288 
    11389    # Check that the minor edits can be filtered out. 
    114     $output = $guide->display_feed( 
    115                                    feed_type          => $feed_type, 
    116                                    feed_listing       => "recent_changes", 
    117                                    items              => 5, 
    118                                    username           => "bob", 
    119                                    ignore_minor_edits => 1, 
    120                                    return_output      => 1, 
    121                                  ); 
     90    my $output = $guide->display_feed( 
     91                                       feed_type          => $feed_type, 
     92                                       feed_listing       => "recent_changes", 
     93                                       items              => 5, 
     94                                       username           => "bob", 
     95                                       ignore_minor_edits => 1, 
     96                                       return_output      => 1, 
     97                                     ); 
    12298    unlike( $output, qr/Wombats/, "minor edits filtered out when required" ); 
    12399    like( $output, qr/Badgers/, "but normal edits still in" ); 
     
    125101    # Check that the username parameter is taken notice of. 
    126102    unlike( $output, qr/Wombles/, "username parameter taken note of" ); 
     103 
     104    # Now make sure that the HTTP euiv link still works with a blank scriptname 
     105    $config->script_name( "" ); 
     106    $wiki = OpenGuides::Utils->make_wiki_object( config => $config ); 
     107 
     108    $feed = OpenGuides::Feed->new( wiki   => $wiki, 
     109                                   config => $config ); 
     110    like( $feed->html_equiv_link, qr|http://example.com/\?|, 
     111          "html_equiv_link looks right with blank script_name" ); 
    127112}