Author: earle
Date: 2005-10-09 22:26:12 +0100 (Sun, 09 Oct 2005)
New Revision: 682
Modified:
trunk/lib/OpenGuides/Template.pm
Log:
of course I missed some more whitespace needing fixing
Modified: trunk/lib/OpenGuides/Template.pm
===================================================================
--- trunk/lib/OpenGuides/Template.pm 2005-10-09 21:25:24 UTC (rev 681)
+++ trunk/lib/OpenGuides/Template.pm 2005-10-09 21:26:12 UTC (rev 682)
@@ -111,8 +111,8 @@
my $custom_template_path = $config->custom_template_path || "";
my $tt = Template->new( { INCLUDE_PATH => "$custom_template_path:$template_path" } );
- my $script_name = $config->script_name;
- my $script_url = $config->script_url;
+ my $script_name = $config->script_name;
+ my $script_url = $config->script_url;
my $default_city = $config->default_city;
# Check cookie to see if we need to set the formatting_rules_link.
@@ -126,8 +126,8 @@
if (( $formatting_rules_node ) and !( $formatting_rules_link )){
$formatting_rules_link = $script_url . $script_name . "?"
. uri_escape($args{wiki}->formatter->node_name_to_node_param($formatting_rules_node));
+ }
}
- }
my $enable_page_deletion = 0;
if ( $config->enable_page_deletion
Author: earle
Date: 2005-10-05 05:05:16 +0100 (Wed, 05 Oct 2005)
New Revision: 678
Modified:
trunk/Changes
trunk/lib/OpenGuides.pm
trunk/templates/node.tt
trunk/wiki.cgi
Log:
Change the behaviour of the "redirected" message to link to a rendered version of the old page, not the editing view.
Modified: trunk/Changes
===================================================================
--- trunk/Changes 2005-10-05 03:10:22 UTC (rev 677)
+++ trunk/Changes 2005-10-05 04:05:16 UTC (rev 678)
@@ -1,6 +1,8 @@
0.51
Replace underscores in node names in redirection message with spaces.
-
+ Redirection message now links to a rendered version of the old page
+ rather than the editing view.
+
0.50 2 October 2005
Remove rogue ampersand that had crept into the RSS feed.
Modified: trunk/lib/OpenGuides.pm
===================================================================
--- trunk/lib/OpenGuides.pm 2005-10-05 03:10:22 UTC (rev 677)
+++ trunk/lib/OpenGuides.pm 2005-10-05 04:05:16 UTC (rev 678)
@@ -143,6 +143,7 @@
my $wiki = $self->wiki;
my $config = $self->config;
my $oldid = $args{oldid} || '';
+ my $do_redirect = $args{redirect} || 1;
my %tt_vars;
@@ -160,46 +161,57 @@
my $current_version = $current_data{version};
undef $version if ($version && $version == $current_version);
my %criteria = ( name => $id );
- $criteria{version} = $version if $version;#retrieve_node default is current
+ $criteria{version} = $version if $version; # retrieve_node default is current
my %node_data = $wiki->retrieve_node( %criteria );
- my $raw = $node_data{content};
- if ( $raw =~ /^#REDIRECT\s+(.+?)\s*$/ ) {
- my $redirect = $1;
- # Strip off enclosing [[ ]] in case this is an extended link.
- $redirect =~ s/^\[\[//;
- $redirect =~ s/\]\]\s*$//;
- # See if this is a valid node, if not then just show the page as-is.
- # Avoid loops by not generating redirects to the same node or the
- # previous node.
- if ( $wiki->node_exists($redirect) && $redirect ne $id && $redirect ne $oldid ) {
- my $output = $self->redirect_to_node($redirect, $id);
- return $output if $return_output;
- print $output;
- exit 0;
- }
- }
+ my $raw = $node_data{content};
my $content = $wiki->format($raw);
my $modified = $node_data{last_modified};
my %metadata = %{$node_data{metadata}};
my %metadata_vars = OpenGuides::Template->extract_metadata_vars(
wiki => $wiki,
- config => $config,
+ config => $config,
metadata => $node_data{metadata} );
%tt_vars = (
%tt_vars,
- %metadata_vars,
- content => $content,
- last_modified => $modified,
- version => $node_data{version},
+ %metadata_vars,
+ content => $content,
+ last_modified => $modified,
+ version => $node_data{version},
node => $id,
language => $config->default_language,
oldid => $oldid,
);
+ if ( $raw =~ /^#REDIRECT\s+(.+?)\s*$/ ) {
+ my $redirect = $1;
+ # Strip off enclosing [[ ]] in case this is an extended link.
+ $redirect =~ s/^\[\[//;
+ $redirect =~ s/\]\]\s*$//;
+
+ # Don't redirect if the parameter "redirect" is given as 0.
+ if ($do_redirect == 0) {
+ return %tt_vars if $args{return_tt_vars};
+ $tt_vars{current} = 1;
+ my $output = $self->process_template(
+ id => $id,
+ template => "node.tt",
+ tt_vars => \%tt_vars,
+ );
+ return $output if $return_output;
+ 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;
+ exit 0;
+ }
+ }
+
# We've undef'ed $version above if this is the current version.
$tt_vars{current} = 1 unless $version;
@@ -838,12 +850,13 @@
sub process_template {
my ($self, %args) = @_;
- my %output_conf = ( wiki => $self->wiki,
+ my %output_conf = (
+ wiki => $self->wiki,
config => $self->config,
node => $args{id},
template => $args{template},
vars => $args{tt_vars},
- cookies => $args{cookies},
+ cookies => $args{cookies},
);
if ( $args{content_type} ) {
$output_conf{content_type} = "";
@@ -869,7 +882,7 @@
$redir_param .= 'id=' if $oldid;
$redir_param .= $id;
$redir_param .= ";oldid=$oldid" if $oldid;
-
+
return CGI->redirect( $redir_param );
}
Modified: trunk/templates/node.tt
===================================================================
--- trunk/templates/node.tt 2005-10-05 03:10:22 UTC (rev 677)
+++ trunk/templates/node.tt 2005-10-05 04:05:16 UTC (rev 678)
@@ -5,7 +5,7 @@
[% INCLUDE navbar.tt %]
<div id="maincontent">
[% IF oldid %]
-<div id="redirect_message">(redirected from <a href="[% full_cgi_url %]?action=edit&id=[% oldid %]">[% oldid.replace('_', ' ') %]</a></div>
+<div id="redirect_message">(redirected from <a href="[% full_cgi_url %]?id=[% oldid %];redirect=0">[% oldid.replace('_', ' ') %]</a></div>
[% END %]
[% IF current %]
Modified: trunk/wiki.cgi
===================================================================
--- trunk/wiki.cgi 2005-10-05 03:10:22 UTC (rev 677)
+++ trunk/wiki.cgi 2005-10-05 04:05:16 UTC (rev 678)
@@ -124,7 +124,7 @@
} else {
my $redirect;
- if ($q->param("redirect") && ($q->param("redirect") == 0)) {
+ if ((defined $q->param("redirect")) && ($q->param("redirect") == 0)) {
$redirect = 0;
} else {
$redirect = 1;
@@ -134,11 +134,10 @@
id => $node,
version => $version,
oldid => $oldid,
- redirect => $redirect;
- );
-
+ redirect => $redirect,
+ );
+ }
}
- }
}
};