Changeset 953


Ignore:
Timestamp:
Mar 19, 2007, 11:57:48 PM (15 years ago)
Author:
kake
Message:

Add config option to suppress inline maps on geotagged nodes (#188). Fix preferences to take notice of users turning off inline Google maps (#189).

Location:
trunk
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Build.PL

    r951 r953  
    4141   qw(use_plucene enable_page_deletion navbar_on_home_page backlinks_in_title
    4242      moderation_requires_password enable_node_image enable_common_categories
    43       enable_common_locales recent_changes_on_home_page);
     43      enable_common_locales recent_changes_on_home_page
     44      show_gmap_in_node_display);
    4445
    4546my $skip_config = Module::Build->y_n("Skip OpenGuides configuration?", "n");
     
    9899   site_desc default_city default_country contact_email default_language
    99100   formatting_rules_node backlinks_in_title gmaps_api_key centre_long
    100    centre_lat default_gmaps_zoom default_gmaps_search_zoom force_wgs84
     101   centre_lat show_gmap_in_node_display default_gmaps_zoom
     102   default_gmaps_search_zoom force_wgs84
    101103   licence_name licence_url licence_info_url moderation_requires_password
    102104   enable_node_image enable_common_categories enable_common_locales
  • trunk/Changes

    r951 r953  
    1717          to make it easier for people to change the order in a custom template
    1818        Move common categories/locales into navbar.
     19        Add config option to suppress inline maps on geotagged nodes.
     20        Fix preferences to take notice of users turning off inline Google maps.
    1921        Write tests for and fix:
    2022          #48 (Edit conflict page erroneously converts lat/lon to os_x, os_y).
  • trunk/INSTALL

    r941 r953  
    220220The defaults are probably appropriate in most cases.
    221221
     222  "Would you like to display a Google Map on every node that has geodata?"
     223
     224Answer "y" or "n".  Note that an answer of "y" will only take effect if you've
     225supplied a Google Maps API key above.  Note further that users can choose to
     226turn this off in their preferences.
     227 
    222228  "Forcibly treat stored lat/long data as if they used the WGS84 ellipsoid?"
    223229
  • trunk/MANIFEST

    r951 r953  
    106106t/44_node_image.t
    107107t/45_home_recent_changes.t
     108t/46_map_in_node_display.t
    108109t/51_display_node.t
    109110t/52_display_diffs.t
  • trunk/README.GMAPS

    r736 r953  
    66http://www.google.com/apis/maps/signup.html. When you've put this value into
    77the config file as gmaps_api_key, the maps become available to you in two
    8 places. Firstly, if the user has set the user preference to display Google
    9 Maps, any node which has location information will get an inset map
    10 pinpointing the location. Secondly, the URL
     8places. Firstly, if you've set "show_gmap_in_node_display", and if the user
     9has set their preferences to display Google Maps, any node which has
     10location information will get an inset map pinpointing the location.
     11Secondly, the URL
    1112http://.../wiki.cgi?action=index;format=map becomes a large map with a list
    1213of all nodes (regardless of the user settings). The latter will become very
  • trunk/lib/OpenGuides.pm

    r941 r953  
    240240                   oldid         => $oldid,
    241241                   enable_gmaps  => 1,
    242                    display_google_maps => $self->get_cookie("display_google_maps"),
    243242                   wgs84_long    => $wgs84_long,
    244243                   wgs84_lat     => $wgs84_lat
    245244               );
     245
     246    if ( $config->show_gmap_in_node_display
     247           && $self->get_cookie( "display_google_maps" ) ) {
     248        $tt_vars{display_google_maps} = 1;
     249    }
    246250
    247251    # Should we include a standard list of categories or locales?
  • trunk/lib/OpenGuides/CGI.pm

    r888 r953  
    156156        %data = $cookies{$cookie_name}->value; # call ->value in list context
    157157    }
    158     return ( username                   => $data{user}       || "Anonymous",
    159              include_geocache_link      => $data{gclink}     || 0,
    160              preview_above_edit_box     => $data{prevab}     || 0,
    161              latlong_traditional        => $data{lltrad}     || 0,
    162              omit_help_links            => $data{omithlplks} || 0,
    163              show_minor_edits_in_rc     => $data{rcmined}    || 0,
    164              default_edit_type          => $data{defedit}    || "normal",
    165              cookie_expires             => $data{exp}        || "month",
    166              track_recent_changes_views => $data{trackrc}    || 0,
    167              display_google_maps        => $data{gmaps}      || 1
    168            );
     158    my %defaults = (
     159                     username                   => "Anonymous",
     160                     include_geocache_link      => 0,
     161                     preview_above_edit_box     => 0,
     162                     latlong_traditional        => 0,
     163                     omit_help_links            => 0,
     164                     show_minor_edits_in_rc     => 0,
     165                     default_edit_type          => "normal",
     166                     cookie_expires             => "month",
     167                     track_recent_changes_views => 0,
     168                     display_google_maps        => 1,
     169                   );
     170    my %long_forms = (
     171                       user       => "username",
     172                       gclink     => "include_geocache_link",
     173                       prevab     => "preview_above_edit_box",
     174                       lltrad     => "latlong_traditional",
     175                       omithlplks => "omit_help_links",
     176                       rcmined    => "show_minor_edits_in_rc",
     177                       defedit    => "default_edit_type",
     178                       exp        => "cookie_expires",
     179                       trackrc    => "track_recent_changes_views",
     180                       gmaps      => "display_google_maps",
     181                     );
     182    my %return;
     183    foreach my $key ( keys %long_forms ) {
     184        my $long_key = $long_forms{$key};
     185        if ( defined $data{$key} ) {
     186            $return{$long_key} = $data{$key};
     187        } else {
     188            $return{$long_key} = $defaults{$long_key};
     189        }
     190    }
     191    return %return;
    169192}
    170193
  • trunk/lib/OpenGuides/Config.pm

    r948 r953  
    1717   formatting_rules_node formatting_rules_link backlinks_in_title template_path
    1818   custom_template_path geo_handler ellipsoid gmaps_api_key centre_long
     19   show_gmap_in_node_display
    1920   centre_lat default_gmaps_zoom default_gmaps_search_zoom force_wgs84
    2021   licence_name licence_url licence_info_url moderation_requires_password
     
    9394                     geo_handler => 1,
    9495                     ellipsoid => "WGS-84",
     96                     show_gmap_in_node_display => 1,
    9597                     centre_long => 0,
    9698                     centre_lat => 0,
     
    172174        default_gmaps_zoom => "What default zoom level shall we use for Google Maps? (This question can be ignored if you aren't using Google Maps)",
    173175        default_gmaps_search_zoom => "What default zoom level shall we use for Google Maps in the search results? (This question can be ignored if you aren't using Google Maps)",
     176        show_gmap_in_node_display => "Would you like to display a Google Map on every node that has geodata? (This question can be ignored if you aren't using Google Maps)",
    174177        force_wgs84 => "Forcibly treat stored lat/long data as if they used the WGS84 ellipsoid?",
    175178        licence_name => "What licence will you use for the guide?",
     
    282285=item * default_gmaps_search_zoom
    283286
     287=item * show_gmap_in_node_display
     288
    284289=item * force_wgs84
    285290
  • trunk/t/13_cookies.t

    r731 r953  
    44use Time::Piece;
    55use Time::Seconds;
    6 use Test::More tests => 20;
     6use Test::More tests => 27;
    77
    88eval { OpenGuides::CGI->make_prefs_cookie; };
     
    1717is( $@, "", "...but not if it is" );
    1818
     19# Use nonsense values here to make sure the test is a good one regardless
     20# of defaults - can't do this for cookie_expires, unfortunately.
    1921my $cookie = OpenGuides::CGI->make_prefs_cookie(
    2022    config                     => $config,
    21     username                   => "Kake",
    22     include_geocache_link      => 1,
    23     preview_above_edit_box     => 1,
    24     latlong_traditional        => 1,
    25     omit_help_links            => 1,
    26     show_minor_edits_in_rc     => 1,
    27     default_edit_type          => "tidying",
     23    username                   => "un_pref",
     24    include_geocache_link      => "gc_pref",
     25    preview_above_edit_box     => "pv_pref",
     26    latlong_traditional        => "ll_pref",
     27    omit_help_links            => "hl_pref",
     28    show_minor_edits_in_rc     => "me_pref",
     29    default_edit_type          => "et_pref",
    2830    cookie_expires             => "never",
    29     track_recent_changes_views => 1,
    30     display_google_maps => 1
     31    track_recent_changes_views => "rc_pref",
     32    display_google_maps        => "gm_pref",
    3133);
    3234isa_ok( $cookie, "CGI::Cookie", "->make_prefs_cookie returns a cookie" );
     
    5557
    5658my %prefs = OpenGuides::CGI->get_prefs_from_cookie( config => $config );
    57 is( $prefs{username}, "Kake",
    58     "get_prefs_from_cookie can find username" );
    59 is( $prefs{include_geocache_link}, 1, "...and geocache prefs" );
    60 is( $prefs{preview_above_edit_box}, 1, "...and preview prefs" );
    61 is( $prefs{latlong_traditional}, 1, "...and latlong prefs" );
    62 is( $prefs{omit_help_links}, 1, "...and help link prefs" );
    63 is( $prefs{show_minor_edits_in_rc}, 1, "...and minor edits prefs" );
    64 is( $prefs{default_edit_type}, "tidying", "...and default edit prefs" );
     59is( $prefs{username}, "un_pref", "get_prefs_from_cookie can find username" );
     60is( $prefs{include_geocache_link}, "gc_pref", "...and geocache prefs" );
     61is( $prefs{preview_above_edit_box}, "pv_pref", "...and preview prefs" );
     62is( $prefs{latlong_traditional}, "ll_pref", "...and latlong prefs" );
     63is( $prefs{omit_help_links}, "hl_pref", "...and help link prefs" );
     64is( $prefs{show_minor_edits_in_rc}, "me_pref", "...and minor edits prefs" );
     65is( $prefs{default_edit_type}, "et_pref", "...and default edit prefs" );
    6566is( $prefs{cookie_expires}, "never", "...and requested cookie expiry" );
    66 ok( $prefs{track_recent_changes_views}, "...and recent changes tracking" );
    67 is( $prefs{display_google_maps}, 1, "...and Google Maps display preference" );
     67is( $prefs{track_recent_changes_views}, "rc_pref",
     68                                     "...and recent changes tracking" );
     69is( $prefs{display_google_maps}, "gm_pref",
     70                                     "...and Google Maps display preference" );
     71
     72# Now make sure that true/false preferences are taken account of when
     73# they're false.
     74$cookie = OpenGuides::CGI->make_prefs_cookie(
     75    config                     => $config,
     76    include_geocache_link      => 0,
     77    preview_above_edit_box     => 0,
     78    latlong_traditional        => 0,
     79    omit_help_links            => 0,
     80    show_minor_edits_in_rc     => 0,
     81    track_recent_changes_views => 0,
     82    display_google_maps        => 0,
     83);
     84
     85$ENV{HTTP_COOKIE} = $cookie;
     86
     87%prefs = OpenGuides::CGI->get_prefs_from_cookie( config => $config );
     88ok( !$prefs{include_geocache_link}, "geocache prefs taken note of when false");
     89ok( !$prefs{preview_above_edit_box}, "...and preview prefs" );
     90ok( !$prefs{latlong_traditional}, "...and latlong prefs" );
     91ok( !$prefs{omit_help_links}, "...and help link prefs" );
     92ok( !$prefs{show_minor_edits_in_rc}, "...and minor edits prefs" );
     93ok( !$prefs{track_recent_changes_views}, "...and recent changes prefs" );
     94ok( !$prefs{display_google_maps}, "...and Google Maps prefs" );
    6895
    6996# Check that cookie parsing fails nicely if no cookie set.
Note: See TracChangeset for help on using the changeset viewer.