Author: ilmari Date: 2007-06-17 03:15:31 +0100 (Sun, 17 Jun 2007) New Revision: 1086
Added: trunk/t/58_navbar_common_locales_categories.t Removed: trunk/t/58_recent_changes_navbar.t Modified: trunk/ trunk/Changes trunk/lib/OpenGuides.pm trunk/newpage.cgi trunk/templates/navbar_categories.tt trunk/templates/navbar_locales.tt Log: r22807@vesla: ilmari | 2007-06-17 02:04:48 +0100 Move the common categories/locales navbar display decision into the templates (fixes #214)
Property changes on: trunk ___________________________________________________________________ Name: svk:merge + 46bc3436-8211-0410-8564-d96f7a728040:/local/openguides/trunk:22807
Modified: trunk/Changes =================================================================== --- trunk/Changes 2007-06-16 23:57:32 UTC (rev 1085) +++ trunk/Changes 2007-06-17 02:15:31 UTC (rev 1086) @@ -22,6 +22,8 @@ List all contributors in RDF version of nodes (#106). The "Look for nearby geocaches" preference and link now actually work (#216). + Move the common categories/locales navbar display decision into the + templates (#214).
0.60 13 May 2007 Removed footer search from edit page (shouldn't have been there).
Modified: trunk/lib/OpenGuides.pm =================================================================== --- trunk/lib/OpenGuides.pm 2007-06-16 23:57:32 UTC (rev 1085) +++ trunk/lib/OpenGuides.pm 2007-06-17 02:15:31 UTC (rev 1086) @@ -260,15 +260,6 @@ $tt_vars{display_google_maps} = 1; }
- # Should we include a standard list of categories or locales? - 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="; - } - my $redirect = OpenGuides::Utils->detect_redirect( content => $node_data{content} ); if ( $redirect ) { @@ -670,13 +661,6 @@ } } $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-16 23:57:32 UTC (rev 1085) +++ trunk/newpage.cgi 2007-06-17 02:15:31 UTC (rev 1086) @@ -30,24 +30,15 @@ }
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 => %tt_vars, + vars => { + not_editable => 1, + not_deletable => 1, + deter_robots => 1, + disallowed_chars => @badchars, + pagename => $pagename } ); }
Added: trunk/t/58_navbar_common_locales_categories.t =================================================================== --- trunk/t/58_navbar_common_locales_categories.t (rev 0) +++ trunk/t/58_navbar_common_locales_categories.t 2007-06-17 02:15:31 UTC (rev 1086) @@ -0,0 +1,84 @@ +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; +} + +sub get_recent_changes { + my ($guide) = @_; + + my $output = $guide->display_recent_changes( return_output => 1 ); + $output =~ s/^Content-Type.*[\r\n]+//m; + + return $output; +} + +sub get_preferences { + my ($guide) = @_; + + return OpenGuides::Template->output( + wiki => $guide->wiki, + config => $guide->config, + template => "preferences.tt", + content_type => '', + vars => { + not_editable => 1, + show_form => 1 + }, + ); +} + +my %pages = ( + recent_changes => &get_recent_changes, + preferences => &get_preferences, +); + +plan tests => 4 * keys %pages; + +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" } ); + +while (my ($page, $get_content) = each %pages) { + + # 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. + $output = $get_content->($guide); + + Test::HTML::Content::tag_ok( $output, "div", { id => "navbar_categories" }, + "common categories in $page 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. + $output = $get_content->($guide); + + Test::HTML::Content::no_tag( $output, "div", { id => "navbar_categories" }, + "common categories in $page navbar" ); + Test::HTML::Content::no_tag( $output, "div", { id => "navbar_locales" }, + "...common locales too" ); +}
Deleted: trunk/t/58_recent_changes_navbar.t =================================================================== --- trunk/t/58_recent_changes_navbar.t 2007-06-16 23:57:32 UTC (rev 1085) +++ trunk/t/58_recent_changes_navbar.t 2007-06-17 02:15:31 UTC (rev 1086) @@ -1,56 +0,0 @@ -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" );
Modified: trunk/templates/navbar_categories.tt =================================================================== --- trunk/templates/navbar_categories.tt 2007-06-16 23:57:32 UTC (rev 1085) +++ trunk/templates/navbar_categories.tt 2007-06-17 02:15:31 UTC (rev 1086) @@ -1,10 +1,10 @@ -[% IF common_categories %] +[% IF config.enable_common_categories %] <div id="navbar_categories"> <div class="navbar_group_title">Categories:</div> <ul class="navbar_group"> [% FOREACH cat = [ 'Cafes', 'Coffee Shops', 'Pubs', 'Restaurants', 'Supermarkets', 'Cinemas', 'Theatres' ] %] - <li><a href="[% catloc_link %]Category_[% cat %]">[% cat %]</a></li> + <li><a href="[% config.script_url _ config.script_name %]?id=Category_[% cat %]">[% cat %]</a></li> [% END %] </ul> </div>
Modified: trunk/templates/navbar_locales.tt =================================================================== --- trunk/templates/navbar_locales.tt 2007-06-16 23:57:32 UTC (rev 1085) +++ trunk/templates/navbar_locales.tt 2007-06-17 02:15:31 UTC (rev 1086) @@ -1,9 +1,9 @@ -[% IF common_locales %] +[% IF config.enable_common_locales %] <div id="navbar_locales"> <div class="navbar_group_title">Locales:</div> <ul class="navbar_group"> [% FOREACH loc = [ 'North', 'South', 'East', 'West', 'Central' ] %] - <li><a href="[% catloc_link %]Locale_[% loc %]">[% loc %]</a></li> + <li><a href="[% config.script_url _ config.script_name %]?id=Locale_[% loc %]">[% loc %]</a></li> [% END %] </ul> </div>