Changeset 1064
- Timestamp:
- 06/11/07 03:23:11 (16 months ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
lib/OpenGuides.pm (modified) (3 diffs)
-
t/51_display_node.t (modified) (1 diff)
-
t/54_redirect.t (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/OpenGuides.pm
r1056 r1064 164 164 ); 165 165 166 If C<version> is omitted then the latest version will be displayed. 166 If C<version> is omitted then it will assume you want the latest version. 167 168 Note that if you pass the C<return_output> parameter, and your node is a 169 redirecting node, this method will fake the redirect and return the output 170 that will actually end up in the user's browser. If instead you want to see 171 the HTTP headers that will be printed in order to perform the redirect, pass 172 the C<intercept_redirect> parameter as well. The C<intercept_redirect> 173 parameter has no effect if the node isn't a redirect, or if the 174 C<return_output> parameter is omitted. 175 176 (At the moment, C<return_tt_vars> acts as if the C<intercept_redirect> 177 parameter was passed.) 167 178 168 179 =cut … … 171 182 my ($self, %args) = @_; 172 183 my $return_output = $args{return_output} || 0; 184 my $intercept_redirect = $args{intercept_redirect}; 173 185 my $version = $args{version}; 174 186 my $id = $args{id} || $self->config->home_name; … … 277 289 } elsif ( $wiki->node_exists($redirect) && $redirect ne $id && $redirect ne $oldid ) { 278 290 # Avoid loops by not generating redirects to the same node or the previous node. 279 my $output = $self->redirect_to_node($redirect, $id); 280 return $output if $return_output; 281 print $output; 291 if ( $return_output ) { 292 if ( $intercept_redirect ) { 293 return $self->redirect_to_node( $redirect, $id ); 294 } else { 295 return $self->display_node( id => $redirect, 296 oldid => $id, 297 return_output => 1, 298 ); 299 } 300 } 301 print $self->redirect_to_node( $redirect, $id ); 282 302 return 0; 283 303 } -
trunk/t/51_display_node.t
r1056 r1064 51 51 $wiki->write_node( 'Redirect Test', '#REDIRECT Test Page', undef ); 52 52 53 $output = $guide->display_node( id => 'Redirect Test', return_output => 1 ); 53 $output = $guide->display_node( id => 'Redirect Test', 54 return_output => 1, 55 intercept_redirect => 1 ); 54 56 55 57 like( $output, qr{^\QLocation: http://example.com/wiki.cgi?id=Test_Page;oldid=Redirect_Test}ms, -
trunk/t/54_redirect.t
r956 r1064 42 42 or die "Can't write node"; 43 43 my $output = eval { 44 $guide->display_node( id => "Test Page", return_output => 1 ); 44 $guide->display_node( id => "Test Page", 45 return_output => 1, 46 intercept_redirect => 1 ); 45 47 }; 46 48 is( $@, "", "->display_node doesn't die when page is a redirect" );
