Author: ivorw Date: 2006-03-05 11:53:09 +0000 (Sun, 05 Mar 2006) New Revision: 739
Modified: trunk/Changes trunk/lib/OpenGuides/Template.pm trunk/t/51_display_node.t trunk/templates/map_index.tt trunk/templates/navbar.tt Log: Closes #87 Editing a mirrored page now edits on source site
Modified: trunk/Changes =================================================================== --- trunk/Changes 2006-03-05 10:50:23 UTC (rev 738) +++ trunk/Changes 2006-03-05 11:53:09 UTC (rev 739) @@ -14,6 +14,7 @@ #67 Default website for a page is now http:// Fix mod_perl redirect bug. Fix test failure with CGI.pm 3.16. + #87 Edit on mirrored pages now goes to source site
0.51 15 November 2005 Important changes:
Modified: trunk/lib/OpenGuides/Template.pm =================================================================== --- trunk/lib/OpenGuides/Template.pm 2006-03-05 10:50:23 UTC (rev 738) +++ trunk/lib/OpenGuides/Template.pm 2006-03-05 11:53:09 UTC (rev 739) @@ -304,6 +304,10 @@ summary => $summary, );
+ if (exists $metadata{source}) { + ($vars{source_site}) = $metadata{source}[0] =~ /^(.*?)(?:?|$)/; + } + if ( $args{metadata} ) { foreach my $var ( qw( phone fax address postcode os_x os_y osie_x osie_y latitude longitude map_link website
Modified: trunk/t/51_display_node.t =================================================================== --- trunk/t/51_display_node.t 2006-03-05 10:50:23 UTC (rev 738) +++ trunk/t/51_display_node.t 2006-03-05 11:53:09 UTC (rev 739) @@ -2,7 +2,7 @@ use CGI::Wiki::Setup::SQLite; use OpenGuides::Config; use OpenGuides; -use Test::More tests => 5; +use Test::More tests => 7;
eval { require DBD::SQLite; }; my $have_sqlite = $@ ? 0 : 1; @@ -31,15 +31,17 @@ isa_ok( $guide, "OpenGuides" ); my $wiki = $guide->wiki; isa_ok( $wiki, "CGI::Wiki" ); - $wiki->write_node( "Test Page", "foo" ); + $wiki->write_node( "Test Page", "foo", undef, { source => "alternate.cgi?Test_Page" } ); my $output = eval { $guide->display_node( id => "Test Page", return_output => 1 ); }; is( $@, "", "->display_node doesn't die" );
+ like( $output, qr{<a.*?\Qhref="alternate.cgi?id=Test_Page;action=edit">Edit this page</a>\E}, "...and edit link is redirected to source URL" ); $config->home_name( "My Home Page" ); $output = $guide->display_node( return_output => 1 ); like( $output, qr/My Home Page/, "...and defaults to the home node, and takes notice of what we want to call it" ); + like( $output, qr{\Q<a href="wiki.cgi?action=edit;id=My_Home_Page">Edit this page</a>\E}, "...and home page has an edit link" ); my %tt_vars = $guide->display_node( return_tt_vars => 1 ); ok( defined $tt_vars{recent_changes}, "...and recent_changes is set for the home node even if we have changed its name" ); }
Modified: trunk/templates/map_index.tt =================================================================== --- trunk/templates/map_index.tt 2006-03-05 10:50:23 UTC (rev 738) +++ trunk/templates/map_index.tt 2006-03-05 11:53:09 UTC (rev 739) @@ -35,7 +35,10 @@ [% IF metadata.latitude.list.first AND metadata.longitude.list.first %] var point[% i %] = new GPoint([% metadata.longitude.list.first %], [% metadata.latitude.list.first %]); var marker[% i %] = new GMarker(point[% i %],baseIcon); - var htmlString[% i %] = "<a href="?[% node.param %]">[% node.name %]</a> <a style='text-decoration:none;' href="?id=[% node.param %];action=edit">(edit)</a><br />[% metadata.address.list.first %]<br />[% metadata.city.list.first %]"; + [% IF metadata.source %] + [% source_url = metadata.source.list.first.match('^(.*?)?(?:?|$)').first %] + [% END %] + var htmlString[% i %] = "<a href="?[% node.param %]">[% node.name %]</a> <a style='text-decoration:none;' href="%[ source_url %]?id=[% node.param %];action=edit">(edit)</a><br />[% metadata.address.list.first %]<br />[% metadata.city.list.first %]"; GEvent.addListener(marker[% i %], "click", function() { marker[% i %].openInfoWindowHtml(htmlString[% i %]); });
Modified: trunk/templates/navbar.tt =================================================================== --- trunk/templates/navbar.tt 2006-03-05 10:50:23 UTC (rev 738) +++ trunk/templates/navbar.tt 2006-03-05 11:53:09 UTC (rev 739) @@ -54,7 +54,7 @@ <div class="navbar_group_title">This page:</div>
<ul> - <li><a class="edit_page_link" href="[% full_cgi_url %]?id=[% node_param %];action=edit">Edit this page</a></li> + <li><a class="edit_page_link" href="[% source_site or full_cgi_url %]?id=[% node_param %];action=edit">Edit this page</a></li> <li><a href="[% cgi_url %]?action=show_backlinks;id=[% node_param %]">Show pages linking here</a></li> [% IF version AND version > 1 %] <li><a href="[% cgi_url %]?action=list_all_versions;id=[% node_param %]">List all revisions</a></li>