Changeset 730
- Timestamp:
- 12/21/05 18:16:36 (3 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 11 modified
-
Build.PL (modified) (1 diff)
-
Changes (modified) (1 diff)
-
lib/OpenGuides.pm (modified) (4 diffs)
-
lib/OpenGuides/CGI.pm (modified) (6 diffs)
-
lib/OpenGuides/Config.pm (modified) (4 diffs)
-
lib/OpenGuides/Template.pm (modified) (2 diffs)
-
lib/OpenGuides/Utils.pm (modified) (3 diffs)
-
preferences.cgi (modified) (3 diffs)
-
t/28_wgs84_coords.t (added)
-
templates/header.tt (modified) (1 diff)
-
templates/node.tt (modified) (1 diff)
-
templates/preferences.tt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Build.PL
r718 r730 77 77 admin_pass stylesheet_url site_name navbar_on_home_page home_name 78 78 site_desc default_city default_country contact_email default_language 79 formatting_rules_node backlinks_in_title 79 formatting_rules_node backlinks_in_title gmaps_api_key centre_long 80 centre_lat default_gmaps_zoom default_gmaps_search_zoom force_wgs84 80 81 ) ) { 81 82 my $q_method = $var . "__qu"; -
trunk/Changes
r729 r730 8 8 Fix missing bracket in node.tt. 9 9 Add custom_node template just below main content in node.tt. 10 Google Maps support! There is a new index type, 11 wiki.cgi?action=index;format=map, and maps appear in the node listings 12 (the latter feature is user-configurable). 10 13 Fix <link> in RSS to point to RecentChanges page, not the feed itself. 11 14 #67 Default website for a page is now http:// -
trunk/lib/OpenGuides.pm
r728 r730 172 172 my %metadata = %{$node_data{metadata}}; 173 173 174 my ($wgs84_long, $wgs84_lat) = OpenGuides::Utils->get_wgs84_coords( 175 longitude => $metadata{longitude}[0], 176 latitude => $metadata{latitude}[0], 177 config => $config); 174 178 if ($args{format} && $args{format} eq 'raw') { 175 179 print "Content-Type: text/plain\n\n"; … … 193 197 language => $config->default_language, 194 198 oldid => $oldid, 199 enable_gmaps => 1, 200 display_google_maps => $self->get_cookie("display_google_maps"), 201 wgs84_long => $wgs84_long, 202 wgs84_lat => $wgs84_lat 195 203 ); 196 204 … … 543 551 $template = "plain_index.tt"; 544 552 $conf{content_type} = "text/plain"; 553 } elsif ( $args{format} eq "map" ) { 554 my $q = CGI->new; 555 $tt_vars{zoom} = $q->param('zoom') || ''; 556 $tt_vars{lat} = $q->param('lat') || ''; 557 $tt_vars{long} = $q->param('long') || ''; 558 $tt_vars{centre_long} = $self->config->centre_long; 559 $tt_vars{centre_lat} = $self->config->centre_lat; 560 $tt_vars{default_gmaps_zoom} = $self->config->default_gmaps_zoom; 561 $tt_vars{enable_gmaps} = 1; 562 $tt_vars{display_google_maps} = 1; # override for this page 563 $template = "map_index.tt"; 564 545 565 } 546 566 } else { … … 929 949 } 930 950 931 932 951 =back 933 952 -
trunk/lib/OpenGuides/CGI.pm
r587 r730 2 2 use strict; 3 3 use vars qw( $VERSION ); 4 $VERSION = '0.0 6';4 $VERSION = '0.07'; 5 5 6 6 use Carp qw( croak ); … … 39 39 cookie_expires => "never", 40 40 track_recent_changes_views => 1, 41 display_google_maps => 1 41 42 ); 42 43 … … 83 84 cookie_expires => "never", 84 85 track_recent_changes_views => 1, 86 display_google_maps => 1 85 87 ); 86 88 … … 125 127 exp => $args{cookie_expires}, 126 128 trackrc => $args{track_recent_changes_views} || 0, 129 gmaps => $args{display_google_maps} || 0 127 130 }, 128 131 -expires => $expires, … … 162 165 cookie_expires => $data{exp} || "month", 163 166 track_recent_changes_views => $data{trackrc} || 0, 167 display_google_maps => $data{gmaps} || 0 164 168 ); 165 169 } … … 256 260 =head1 COPYRIGHT 257 261 258 Copyright (C) 2003-200 4The OpenGuides Project. All Rights Reserved.262 Copyright (C) 2003-2005 The OpenGuides Project. All Rights Reserved. 259 263 260 264 This module is free software; you can redistribute it and/or modify it -
trunk/lib/OpenGuides/Config.pm
r662 r730 10 10 admin_pass stylesheet_url site_name navbar_on_home_page home_name 11 11 site_desc default_city default_country contact_email default_language 12 formatting_rules_node formatting_rules_link backlinks_in_title template_path custom_template_path 13 geo_handler ellipsoid 12 formatting_rules_node formatting_rules_link backlinks_in_title template_path 13 custom_template_path geo_handler ellipsoid gmaps_api_key centre_long 14 centre_lat default_gmaps_zoom default_gmaps_search_zoom force_wgs84 14 15 ); 15 16 my @questions = map { $_ . "__qu" } @variables; … … 77 78 backlinks_in_title => 0, 78 79 geo_handler => 1, 79 ellipsoid => "International" 80 ellipsoid => "International", 81 centre_long => 0, 82 centre_lat => 0, 83 default_gmaps_zoom => 5, 84 default_gmaps_search_zoom => 3, 85 force_wgs84 => 0 80 86 ); 81 87 … … 135 141 backlinks_in_title => "Make node titles link to node backlinks (C2 style)?", 136 142 ellipsoid => "Which ellipsoid do you want to use? (eg 'Airy', 'WGS-84')", 143 gmaps_api_key => "Do you have a Google Maps API key to use with this guide? If you enter it here the Google Maps functionality will be automatically enabled.", 144 centre_long => "What is the longitude of the centre point of a map to draw for your guide? (This question can be ignored if you aren't using Google Maps)", 145 centre_lat => "What is the latitude of the centre point of a map to draw for your guide? (This question can be ignored if you aren't using Google Maps)", 146 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)", 147 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)", 148 force_wgs84 => "Forcibly treat stored lat/long data as if they used the WGS84 ellipsoid?" 137 149 ); 138 150 … … 223 235 =item * ellipsoid (default: C<International>) 224 236 237 =item * gmaps_api_key 238 239 =item * centre_long 240 241 =item * centre_lat 242 243 =item * default_gmaps_zoom 244 245 =item * default_gmaps_search_zoom 246 247 =item * force_wgs84 248 225 249 =back 226 250 -
trunk/lib/OpenGuides/Template.pm
r718 r730 86 86 87 87 =item * C<home_name> 88 89 =item * C<gmaps_api_key> 88 90 89 91 =back … … 154 156 language => $config->default_language, 155 157 default_city => $default_city, 158 gmaps_api_key => $config->gmaps_api_key 156 159 }; 157 160 -
trunk/lib/OpenGuides/Utils.pm
r717 r730 3 3 use strict; 4 4 use vars qw( $VERSION ); 5 $VERSION = '0.0 8';5 $VERSION = '0.09'; 6 6 7 7 use Carp qw( croak ); … … 217 217 } 218 218 219 =item B<get_wgs84_coords> 220 221 Returns coordinate data suitable for use with Google Maps (and other GIS 222 systems that assume WGS-84 data). 223 224 my ($wgs84_long, $wgs84_lat) = OpenGuides::Utils->get_wgs84_coords( 225 longitude => $longitude, 226 latitude => $latitude, 227 config => $config 228 ); 229 230 =cut 231 232 sub get_wgs84_coords { 233 my ($self, %args) = @_; 234 my ($longitude, $latitude, $config) = ($args{longitude}, $args{latitude}, 235 $args{config}) 236 or croak "No longitude supplied to get_wgs84_coords"; 237 croak "geo_handler not defined!" unless $config->geo_handler; 238 if ($config->force_wgs84) { 239 # Only as a rough approximation, good enough for large scale guides 240 return ($longitude, $latitude); 241 } elsif ($config->geo_handler == 1) { 242 # Do conversion here 243 return undef; 244 } elsif ($config->geo_handler == 2) { 245 # Do conversion here 246 return undef; 247 } elsif ($config->geo_handler == 3) { 248 if ($config->ellipsoid eq "WGS-84") { 249 return ($longitude, $latitude); 250 } else { 251 # Do conversion here 252 return undef; 253 } 254 } else { 255 croak "Invalid geo_handler config option $config->geo_handler"; 256 } 257 } 219 258 220 259 =back … … 226 265 =head1 COPYRIGHT 227 266 228 Copyright (C) 2003-200 4The OpenGuides Project. All Rights Reserved.267 Copyright (C) 2003-2005 The OpenGuides Project. All Rights Reserved. 229 268 230 269 This module is free software; you can redistribute it and/or modify it -
trunk/preferences.cgi
r621 r730 34 34 my $expires = $cgi->param("cookie_expires") || "month"; 35 35 my $track_rc = $cgi->param("track_recent_changes_views") || 0; 36 my $gmaps = $cgi->param("display_google_maps") || 0; 36 37 my $prefs_cookie = OpenGuides::CGI->make_prefs_cookie( 37 38 config => $config, … … 45 46 cookie_expires => $expires, 46 47 track_recent_changes_views => $track_rc, 48 display_google_maps => $gmaps 47 49 ); 48 50 my @cookies = ( $prefs_cookie ); … … 72 74 cookie_expires => $expires, 73 75 track_recent_changes_views => $track_rc, 76 display_google_maps => $gmaps 74 77 } 75 78 ); -
trunk/templates/header.tt
r701 r730 29 29 <meta name="robots" content="noindex,nofollow" /> 30 30 [% END %] 31 [% IF enable_gmaps AND display_google_maps AND gmaps_api_key %] 32 <script src="http://maps.google.com/maps?file=api&v=1&key=[% gmaps_api_key %]" type="text/javascript"></script> 33 [% END %] 31 34 </head> 32 35 <body> 36 [% IF enable_gmaps AND display_google_maps AND gmaps_api_key %] 37 <script defer="defer" type="text/javascript"> 38 //<![CDATA[ 39 var baseIcon = new GIcon(); 40 baseIcon.image = "http://www.google.com/mapfiles/marker.png"; 41 baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png"; 42 baseIcon.iconSize = new GSize(10, 17); 43 baseIcon.shadowSize = new GSize(20, 17); 44 baseIcon.iconAnchor = new GPoint(5, 17); 45 baseIcon.infoWindowAnchor = new GPoint(9, 2); 46 baseIcon.infoShadowAnchor = new GPoint(9, 12); 47 //]]> 48 </script> 49 [% END %] -
trunk/templates/node.tt
r716 r730 7 7 [% IF oldid %] 8 8 <div id="redirect_message">(redirected from <a href="[% full_cgi_url %]?id=[% oldid %];redirect=0">[% oldid.replace('_', ' ') %]</a>)</div> 9 [% END %] 10 11 [% IF wgs84_lat AND wgs84_long AND display_google_maps and gmaps_api_key %] 12 <div id="map" style="float:right; width: 300px; height: 200px"></div> 13 <script defer="defer" type="text/javascript"> 14 //<![CDATA[ 15 var map = new GMap(document.getElementById("map")); 16 map.addControl(new GSmallMapControl()); 17 map.centerAndZoom(new GPoint([% longitude %], [% latitude %]), 3); 18 var point0 = new GPoint([% wgs84_long %], [% wgs84_lat %]); 19 var marker0 = new GMarker(point0,baseIcon); 20 GEvent.addListener(marker0, "click", function() { 21 marker0.openInfoWindowHtml("[% node_name %]"); 22 }); 23 map.addOverlay(marker0); 24 //]]> 25 </script> 9 26 [% END %] 10 27 -
trunk/templates/preferences.tt
r617 r730 76 76 </p> 77 77 78 [% IF gmaps_api_key %] 79 <p> 80 [% IF display_google_maps %] 81 <input type="checkbox" id="display_google_maps" name="display_google_maps" value="1" checked="1" /> 82 [% ELSE %] 83 <input type="checkbox" id="display_google_maps" name="display_google_maps" value="1" /> 84 [% END %] 85 <label for="display_google_maps">Display Google Maps.</label> 86 </p> 87 [% END %] 88 78 89 <p> 79 90 <label for="default_edit_type">Default edit type:</label> … … 151 162 be tracked.</p> 152 163 164 [% IF gmaps_api_key %] 165 <p>Google Maps will 166 [% UNLESS display_google_maps %] not [% END %] 167 be displayed.</p> 168 [% END %] 169 153 170 <p>Default edit type set to 154 171 [% IF default_edit_type == 'normal' %]
