Ticket #192: openguides-fix-gmaps-pref.patch
| File openguides-fix-gmaps-pref.patch, 7.5 kB (added by ilmari, 19 months ago) |
|---|
-
templates/preferences.tt
==== Patch <openguides-fix-gmaps-pref> level 1 Source: 46bc3436-8211-0410-8564-d96f7a728040:/local/openguides/hackfestsummer2007:22761 Target: a7917b76-13f7-0310-8727-ec6248764fd6:/trunk:1045 (https://urchin.earth.li/svn/openguides) Log: r22760@vesla: ilmari | 2007-06-09 19:08:52 +0100 Local branch for the hackfest r22761@vesla: ilmari | 2007-06-09 19:15:22 +0100 Only display the google maps preference if node maps are enabled (fixes #192) === templates/preferences.tt ==================================================================66 66 <label for="track_recent_changes_views">Track my visits to Recent Changes and offer me a link for “changes since I last viewed Recent Changes”.</label> 67 67 </p> 68 68 69 [% IF gmaps_api_key %]69 [% IF gmaps_api_key AND config.show_gmap_in_node_display %] 70 70 <p> 71 71 [% IF display_google_maps %] 72 72 <input type="checkbox" id="display_google_maps" name="display_google_maps" value="1" checked="1" /> … … 152 152 [% UNLESS track_recent_changes_views %] not [% END %] 153 153 be tracked.</p> 154 154 155 [% IF gmaps_api_key %]155 [% IF gmaps_api_key AND config.show_gmap_in_node_display %] 156 156 <p>Google Maps will 157 157 [% UNLESS display_google_maps %] not [% END %] 158 158 be displayed.</p> -
t/59_preferences.t
=== t/59_preferences.t ==================================================================
1 use Wiki::Toolkit::Setup::SQLite; 2 use OpenGuides; 3 use OpenGuides::Test; 4 use Test::More; 5 6 eval { require DBD::SQLite; }; 7 8 if ( $@ ) { 9 my ($error) = $@ =~ /^(.*?)\n/; 10 plan skip_all => "DBD::SQLite could not be used - no database to test with ($error)"; 11 } 12 13 eval { require DBD::SQLite; }; 14 if ( $@ ) { 15 plan skip_all => "DBD::SQLite not installed - no database to test with"; 16 exit 0; 17 } 18 19 eval { require Test::HTML::Content; }; 20 if ( $@ ) { 21 plan skip_all => "Test::HTML::Content not installed"; 22 exit 0; 23 } 24 25 plan tests => 2; 26 27 Wiki::Toolkit::Setup::SQLite::cleardb( { dbname => "t/prefs.db" } ); 28 Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/prefs.db" } ); 29 my $config = OpenGuides::Test->make_basic_config; 30 my $guide = OpenGuides->new( config => $config ); 31 my $wiki = $guide->wiki; 32 33 $config->gmaps_api_key( "This is not a real API key." ); 34 $config->show_gmap_in_node_display( 1 ); 35 36 my $cookie = OpenGuides::CGI->make_prefs_cookie( 37 config => $config, 38 display_google_maps => 1, 39 ); 40 # If the google API is present and node maps are enabled, we should have the pref 41 Test::HTML::Content::tag_ok( get_output($wiki, $config, $cookie), 'input', 42 { type => 'checkbox', name => 'display_google_maps' }, 43 'Google maps pref shown' 44 ); 45 46 # But not if the node map is globally disabled 47 $config->show_gmap_in_node_display( 0 ); 48 Test::HTML::Content::no_tag( get_output($wiki, $config, $cookie), 'input', 49 { type => 'checkbox', name => 'display_google_maps' }, 50 'No google maps prefs if node maps disabled' 51 ); 52 53 sub get_output { 54 my ($wiki, $config) = @_; 55 56 return OpenGuides::Template->output( 57 wiki => $wiki, 58 config => $config, 59 template => "preferences.tt", 60 content_type => '', 61 vars => { OpenGuides::CGI->get_prefs_from_cookie( config => $config ), 62 not_editable => 1, 63 show_form => 1 64 }, 65 ); 66 } 67 -
lib/OpenGuides/Template.pm
=== lib/OpenGuides/Template.pm ==================================================================
56 56 Returns everything you need to send to STDOUT, including the 57 57 Content-Type: header. Croaks unless C<template> is supplied. 58 58 59 The variables supplied in C<vars> are passed through to the template60 specified. Additional Template Toolkit variables are automatically 61 set and passed through as well, as described below. B<Note:> 62 variables set in C<vars> will over-ride any variables of the same name63 in the config object or the user cookies.59 The config object and variables supplied in C<vars> are passed through 60 to the template specified. Additional Template Toolkit variables are 61 automatically set and passed through as well, as described below. 62 B<Note:> variables set in C<vars> will over-ride any variables of the 63 same name in the config object or the user cookies. 64 64 65 65 =over 66 66
