Author: dom Date: 2009-06-19 23:41:38 +0100 (Fri, 19 Jun 2009) New Revision: 1269
Modified: trunk/Changes trunk/lib/OpenGuides.pm trunk/t/51_display_node.t trunk/templates/navbar.tt trunk/templates/node.tt Log: Don't display revision info for nodes that don't exist (fixes #193)
Modified: trunk/Changes =================================================================== --- trunk/Changes 2009-04-12 07:34:29 UTC (rev 1268) +++ trunk/Changes 2009-06-19 22:41:38 UTC (rev 1269) @@ -5,6 +5,7 @@
0.65 Fix some more broken POD and add POD unit test (#268) + Don't display revision info for nodes that don't exist (#193)
0.64 23 February 2009 Correctly specify all build_requires (#245)
Modified: trunk/lib/OpenGuides.pm =================================================================== --- trunk/lib/OpenGuides.pm 2009-04-12 07:34:29 UTC (rev 1268) +++ trunk/lib/OpenGuides.pm 2009-06-19 22:41:38 UTC (rev 1269) @@ -288,6 +288,12 @@ wgs84_lat => $wgs84_lat );
+ $tt_vars{empty_node} = !($tt_vars{content} || + $tt_vars{coord_field_1_value} || + $tt_vars{coord_field_2_value} || + $tt_vars{latitude} || + $tt_vars{longitude}); + # Hide from search engines if showing a specific version. $tt_vars{'deter_robots'} = 1 if $args{version};
Modified: trunk/t/51_display_node.t =================================================================== --- trunk/t/51_display_node.t 2009-04-12 07:34:29 UTC (rev 1268) +++ trunk/t/51_display_node.t 2009-06-19 22:41:38 UTC (rev 1269) @@ -13,7 +13,7 @@ plan skip_all => "DBD::SQLite could not be used - no database to test with ($error)"; }
-plan tests => 15; +plan tests => 18;
Wiki::Toolkit::Setup::SQLite::cleardb( { dbname => "t/node.db" } ); Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } ); @@ -110,3 +110,13 @@ "wrongly-cased categories are linked as they should be" ); like( $output, qr{\Q<a href="wiki.cgi?Locale_Does_Exist"}, "wrongly-cased locales are linked as they should be" ); + +$output = $guide->display_node( id => "Does not exist", + return_output => 1 + ); +like( $output, qr{\QWe don't have a node called "Does not exist".}, + "not found message shows up" ); +unlike( $output, qr{\QRevision 0}, + "bogus revision number doesn't show up" ); +unlike( $output, qr{\QLast edited}, + "bogus last edited doesn't show up" );
Modified: trunk/templates/navbar.tt =================================================================== --- trunk/templates/navbar.tt 2009-04-12 07:34:29 UTC (rev 1268) +++ trunk/templates/navbar.tt 2009-06-19 22:41:38 UTC (rev 1269) @@ -12,7 +12,9 @@ [% INCLUDE navbar_categories.tt %] [% INCLUDE navbar_locales.tt %] </div> +[% UNLESS empty_node %] [% INCLUDE navbar_revision_info.tt %] +[% END %]
</div> </div>
Modified: trunk/templates/node.tt =================================================================== --- trunk/templates/node.tt 2009-04-12 07:34:29 UTC (rev 1268) +++ trunk/templates/node.tt 2009-06-19 22:41:38 UTC (rev 1269) @@ -68,7 +68,7 @@ <span class="node_name">[% node_name %]</span></em> </h2> [% END %] -[% IF not (content || coord_field_1_value || coord_field_2_value || latitude || longitude) %] +[% IF empty_node %] </div> <div id="nonexistent_node_message">We don't have a node called "[% node_name %]". Would you like to <a href="[% full_cgi_url %]?action=edit;id=[% node_param %]">create it</a>?</div> [% ELSE %]
openguides-commits@lists.openguides.org