Author: kake
Date: 2007-06-11 04:24:22 +0100 (Mon, 11 Jun 2007)
New Revision: 1067
Modified:
trunk/lib/OpenGuides.pm
Log:
Make sure all TT vars are returned if return_tt_vars is passed to OpenGuides->display_node
Modified: trunk/lib/OpenGuides.pm
===================================================================
--- trunk/lib/OpenGuides.pm 2007-06-11 03:06:21 UTC (rev 1066)
+++ trunk/lib/OpenGuides.pm 2007-06-11 03:24:22 UTC (rev 1067)
@@ -274,8 +274,8 @@
if ( $redirect ) {
# Don't redirect if the parameter "redirect" is given as 0.
if ($do_redirect == 0) {
+ $tt_vars{current} = 1;
return %tt_vars if $args{return_tt_vars};
- $tt_vars{current} = 1;
my $output = $self->process_template(
id => $id,
template => "node.tt",
Author: kake
Date: 2007-06-11 03:26:08 +0100 (Mon, 11 Jun 2007)
New Revision: 1065
Modified:
trunk/Changes
trunk/README.CSS
trunk/templates/node.tt
Log:
Added new div#nonexistent_node_message for displaying message when someone tries to view a nonexistent node.
Modified: trunk/Changes
===================================================================
--- trunk/Changes 2007-06-11 02:23:11 UTC (rev 1064)
+++ trunk/Changes 2007-06-11 02:26:08 UTC (rev 1065)
@@ -16,6 +16,8 @@
Respect redirect=0 (#104).
If an unknown action is supplied to wiki.cgi, redirect to
action=display (partial fix for #102)
+ Added new div#nonexistent_node_message for displaying message when
+ someone tries to view a nonexistent node.
0.60 13 May 2007
Removed footer search from edit page (shouldn't have been there).
Modified: trunk/README.CSS
===================================================================
--- trunk/README.CSS 2007-06-11 02:23:11 UTC (rev 1064)
+++ trunk/README.CSS 2007-06-11 02:26:08 UTC (rev 1065)
@@ -284,6 +284,10 @@
Used in: node.tt
Purpose: Display the node name and an "edit this page" link.
+div#nonexistent_node_message
+ Used in: node.tt
+ Purpose: Display message when someone tries to view a nonexistent node.
+
div#rdf_link
Used in: node.tt
Purpose: Link to an RDF version of the node
Modified: trunk/templates/node.tt
===================================================================
--- trunk/templates/node.tt 2007-06-11 02:23:11 UTC (rev 1064)
+++ trunk/templates/node.tt 2007-06-11 02:26:08 UTC (rev 1065)
@@ -49,7 +49,7 @@
[% END %]
[% IF not (content || coord_field_1_value || coord_field_2_value || wgs84_lat || wgs84_long) %]
</div>
-We don't have a node called "[% node_param %]". Would you like to <a href="[% full_cgi_url %]?action=edit;id=[% node_param %]">create it</a>?
+<div id="nonexistent_node_message">We don't have a node called "[% node_param %]". Would you like to <a href="[% full_cgi_url %]?action=edit;id=[% node_param %]">create it</a>?</div>
[% ELSE %]
<div id="title_edit_link">
<a href="[% full_cgi_url %]?action=edit;id=[% node_param %]">Edit this page</a>
Author: kake
Date: 2007-06-11 03:23:11 +0100 (Mon, 11 Jun 2007)
New Revision: 1064
Modified:
trunk/lib/OpenGuides.pm
trunk/t/51_display_node.t
trunk/t/54_redirect.t
Log:
Add intercept_redirect parameter to Openguides->display_node - used with the return_output parameter for testing.
Modified: trunk/lib/OpenGuides.pm
===================================================================
--- trunk/lib/OpenGuides.pm 2007-06-10 17:31:17 UTC (rev 1063)
+++ trunk/lib/OpenGuides.pm 2007-06-11 02:23:11 UTC (rev 1064)
@@ -163,13 +163,25 @@
return_tt_vars => 1,
);
-If C<version> is omitted then the latest version will be displayed.
+If C<version> is omitted then it will assume you want the latest version.
+Note that if you pass the C<return_output> parameter, and your node is a
+redirecting node, this method will fake the redirect and return the output
+that will actually end up in the user's browser. If instead you want to see
+the HTTP headers that will be printed in order to perform the redirect, pass
+the C<intercept_redirect> parameter as well. The C<intercept_redirect>
+parameter has no effect if the node isn't a redirect, or if the
+C<return_output> parameter is omitted.
+
+(At the moment, C<return_tt_vars> acts as if the C<intercept_redirect>
+parameter was passed.)
+
=cut
sub display_node {
my ($self, %args) = @_;
my $return_output = $args{return_output} || 0;
+ my $intercept_redirect = $args{intercept_redirect};
my $version = $args{version};
my $id = $args{id} || $self->config->home_name;
my $wiki = $self->wiki;
@@ -276,9 +288,17 @@
print $output;
} elsif ( $wiki->node_exists($redirect) && $redirect ne $id && $redirect ne $oldid ) {
# Avoid loops by not generating redirects to the same node or the previous node.
- my $output = $self->redirect_to_node($redirect, $id);
- return $output if $return_output;
- print $output;
+ if ( $return_output ) {
+ if ( $intercept_redirect ) {
+ return $self->redirect_to_node( $redirect, $id );
+ } else {
+ return $self->display_node( id => $redirect,
+ oldid => $id,
+ return_output => 1,
+ );
+ }
+ }
+ print $self->redirect_to_node( $redirect, $id );
return 0;
}
}
Modified: trunk/t/51_display_node.t
===================================================================
--- trunk/t/51_display_node.t 2007-06-10 17:31:17 UTC (rev 1063)
+++ trunk/t/51_display_node.t 2007-06-11 02:23:11 UTC (rev 1064)
@@ -50,7 +50,9 @@
$wiki->write_node( 'Redirect Test', '#REDIRECT Test Page', undef );
-$output = $guide->display_node( id => 'Redirect Test', return_output => 1 );
+$output = $guide->display_node( id => 'Redirect Test',
+ return_output => 1,
+ intercept_redirect => 1 );
like( $output, qr{^\QLocation: http://example.com/wiki.cgi?id=Test_Page;oldid=Redirect_Test}ms,
'#REDIRECT redirects correctly' );
Modified: trunk/t/54_redirect.t
===================================================================
--- trunk/t/54_redirect.t 2007-06-10 17:31:17 UTC (rev 1063)
+++ trunk/t/54_redirect.t 2007-06-11 02:23:11 UTC (rev 1064)
@@ -41,7 +41,9 @@
$wiki->write_node( "Test Page 2", "foo" )
or die "Can't write node";
my $output = eval {
- $guide->display_node( id => "Test Page", return_output => 1 );
+ $guide->display_node( id => "Test Page",
+ return_output => 1,
+ intercept_redirect => 1 );
};
is( $@, "", "->display_node doesn't die when page is a redirect" );