Author: kake Date: 2007-06-09 17:49:43 +0100 (Sat, 09 Jun 2007) New Revision: 1045
Added: trunk/t/58_recent_changes_navbar.t Modified: trunk/lib/OpenGuides.pm trunk/newpage.cgi Log: Make sure that common categories and locales (if configured) show up on recent changes and create new page form (fixes #199).
Modified: trunk/lib/OpenGuides.pm =================================================================== --- trunk/lib/OpenGuides.pm 2007-06-09 14:38:14 UTC (rev 1044) +++ trunk/lib/OpenGuides.pm 2007-06-09 16:49:43 UTC (rev 1045) @@ -628,6 +628,13 @@ } } $tt_vars{not_editable} = 1; + if ($config->enable_common_categories || $config->enable_common_locales) { + $tt_vars{common_catloc} = 1; + $tt_vars{common_categories} = $config->enable_common_categories; + $tt_vars{common_locales} = $config->enable_common_locales; + $tt_vars{catloc_link} = $config->script_url . $config->script_name + . "?id="; + } $tt_vars{recent_changes} = %recent_changes; my %processing_args = ( id => $id,
Modified: trunk/newpage.cgi =================================================================== --- trunk/newpage.cgi 2007-06-09 14:38:14 UTC (rev 1044) +++ trunk/newpage.cgi 2007-06-09 16:49:43 UTC (rev 1045) @@ -30,15 +30,24 @@ }
sub show_form { + my %tt_vars = ( + not_editable => 1, + not_deletable => 1, + deter_robots => 1, + disallowed_chars => @badchars, + pagename => $pagename, + ); + if ($config->enable_common_categories || $config->enable_common_locales) { + $tt_vars{common_catloc} = 1; + $tt_vars{common_categories} = $config->enable_common_categories; + $tt_vars{common_locales} = $config->enable_common_locales; + $tt_vars{catloc_link} = $config->script_url . $config->script_name + . "?id="; + } print OpenGuides::Template->output( wiki => $wiki, config => $config, template => "newpage.tt", - vars => { - not_editable => 1, - not_deletable => 1, - deter_robots => 1, - disallowed_chars => @badchars, - pagename => $pagename } + vars => %tt_vars, ); }
Added: trunk/t/58_recent_changes_navbar.t =================================================================== --- trunk/t/58_recent_changes_navbar.t (rev 0) +++ trunk/t/58_recent_changes_navbar.t 2007-06-09 16:49:43 UTC (rev 1045) @@ -0,0 +1,56 @@ +use strict; +use OpenGuides; +use OpenGuides::Test; +use Test::More; +use Wiki::Toolkit::Setup::SQLite; + +eval { require DBD::SQLite; }; +if ( $@ ) { + plan skip_all => "DBD::SQLite not installed - no database to test with"; + exit 0; +} + +eval { require Test::HTML::Content; }; +if ( $@ ) { + plan skip_all => "Test::HTML::Content not installed"; + exit 0; +} + +plan tests => 4; + +my ( $config, $guide, $wiki, $output ); + +# Clear out the database from any previous runs. +unlink "t/node.db"; +unlink <t/indexes/*>; +Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } ); + +# Make a guide with common categories and locales enabled. +$config = OpenGuides::Test->make_basic_config; +$config->enable_common_categories( 1 ); +$config->enable_common_locales( 1 ); +$guide = OpenGuides->new( config => $config ); + +# Make sure common categories and locales show up on recent changes display. +$output = $guide->display_recent_changes( + return_output => 1, + ); +$output =~ s/^Content-Type.*[\r\n]+//m; +Test::HTML::Content::tag_ok( $output, "div", { id => "navbar_categories" }, + "common categories in recent changes navbar" ); +Test::HTML::Content::tag_ok( $output, "div", { id => "navbar_locales" }, + "...common locales too" ); + +# Now make a guide with common categories and locales disabled. +$config = OpenGuides::Test->make_basic_config; +$guide = OpenGuides->new( config => $config ); + +# Make sure common categories/locales are omitted from recent changes display. +$output = $guide->display_recent_changes( + return_output => 1, + ); +$output =~ s/^Content-Type.*[\r\n]+//m; +Test::HTML::Content::no_tag( $output, "div", { id => "navbar_categories" }, + "common categories in recent changes navbar" ); +Test::HTML::Content::no_tag( $output, "div", { id => "navbar_locales" }, + "...common locales too" );
openguides-commits@lists.openguides.org