Changeset 1271 for trunk

Show
Ignore:
Timestamp:
06/20/09 00:12:21 (15 months ago)
Author:
dom
Message:

Return HTTP 404 status when displaying a node that doens't exist (fixes #102)

Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/Changes

    r1269 r1271  
    77        Fix some more broken POD and add POD unit test (#268) 
    88        Don't display revision info for nodes that don't exist (#193) 
     9        Return HTTP 404 status when displaying a node that doens't exist (#102) 
    910 
    10110.64    23 February 2009 
  • trunk/lib/OpenGuides.pm

    r1270 r1271  
    274274                        ); 
    275275 
     276    my $node_exists = $wiki->node_exists($id); 
     277    my $http_status = $node_exists ? undef : '404 Not Found'; 
    276278    %tt_vars = ( 
    277279                   %tt_vars, 
     
    287289                   wgs84_long    => $wgs84_long, 
    288290                   wgs84_lat     => $wgs84_lat, 
    289                    empty_node    => !$wiki->node_exists($id) 
     291                   empty_node    => !$node_exists 
    290292               ); 
    291293 
     
    309311                                                  template      => "node.tt", 
    310312                                                  tt_vars       => \%tt_vars, 
     313                                                  http_status   => $http_status 
    311314                                                ); 
    312315            return $output if $return_output; 
     
    364367                                                template      => "home_node.tt", 
    365368                                                tt_vars       => \%tt_vars, 
     369                                                http_status   => $http_status 
    366370                                            ); 
    367371        return $output if $return_output; 
     
    373377                                                template      => "node.tt", 
    374378                                                tt_vars       => \%tt_vars, 
     379                                                http_status   => $http_status 
    375380                                            ); 
    376381        return $output if $return_output; 
     
    22522257    my ($self, %args) = @_; 
    22532258    my %output_conf = ( 
    2254                           wiki     => $self->wiki, 
    2255                           config   => $self->config, 
    2256                           node     => $args{id}, 
    2257                           template => $args{template}, 
    2258                           vars     => $args{tt_vars}, 
    2259                           cookies  => $args{cookies}, 
     2259                          wiki        => $self->wiki, 
     2260                          config      => $self->config, 
     2261                          node        => $args{id}, 
     2262                          template    => $args{template}, 
     2263                          vars        => $args{tt_vars}, 
     2264                          cookies     => $args{cookies}, 
     2265                          http_status => $args{http_status} 
    22602266                      ); 
    22612267    if ( $args{content_type} ) { 
  • trunk/t/51_display_node.t

    r1269 r1271  
    1414} 
    1515 
    16 plan tests => 18; 
     16plan tests => 19; 
    1717 
    1818Wiki::Toolkit::Setup::SQLite::cleardb( { dbname => "t/node.db" } ); 
     
    121121unlike( $output, qr{\QLast edited}, 
    122122    "bogus last edited doesn't show up" ); 
     123like ( $output, qr{404 Not Found}, "404 status for empty node" );