[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#697447: marked as done (unblock: openguides/0.65-3)



Your message dated Sun, 06 Jan 2013 22:52:22 +0000
with message-id <1357512742.6386.61.camel@jacala.jungle.funky-badger.org>
and subject line Re: Bug#697447: unblock: openguides/0.65-3
has caused the Debian Bug report #697447,
regarding unblock: openguides/0.65-3
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
697447: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=697447
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: release.debian.org
Severity: normal
User: release.debian.org@packages.debian.org
Usertags: unblock

Please unblock package openguides

This update addresses a latent bug which will appear when the GMaps2
API stops working (announced as being May 2013), by backporting changes
to use the Leaflet mapping library from current upstream releases.

Debdiff attached.

unblock openguides/0.65-3
diff -Nru openguides-0.65/debian/changelog openguides-0.65/debian/changelog
--- openguides-0.65/debian/changelog	2011-05-17 22:17:07.000000000 +0100
+++ openguides-0.65/debian/changelog	2013-01-02 17:38:39.000000000 +0000
@@ -1,3 +1,10 @@
+openguides (0.65-3) unstable; urgency=low
+
+  * Backport Leaflet mapping support from 0.70 to allow an alternative
+    to the deprecated GMaps2 API (closes: #697184)
+
+ -- Dominic Hargreaves <dom@earth.li>  Wed, 02 Jan 2013 17:38:31 +0000
+
 openguides (0.65-2) unstable; urgency=low
 
   * Add Danish debconf translation (closes: #626639)
diff -Nru openguides-0.65/debian/control openguides-0.65/debian/control
--- openguides-0.65/debian/control	2011-05-17 21:56:21.000000000 +0100
+++ openguides-0.65/debian/control	2013-01-02 16:54:39.000000000 +0000
@@ -2,7 +2,7 @@
 Section: perl
 Priority: optional
 Build-Depends: debhelper (>= 5), po-debconf
-Build-Depends-Indep: perl (>= 5.8.0-7), perl-modules (>= 5.10.0) | libmodule-build-perl (>= 0.26), libconfig-tiny-perl, libclass-accessor-perl, libdbd-sqlite3-perl, libwiki-toolkit-perl (>= 0.77), libwiki-toolkit-formatter-usemod-perl, libwiki-toolkit-plugin-locator-grid-perl, libgeography-nationalgrid-perl, libwiki-toolkit-plugin-rss-reader-perl, libxml-rss-perl, libwiki-toolkit-plugin-categoriser-perl, libwiki-toolkit-plugin-diff-perl, libtemplate-perl (>= 2.15), libplucene-perl, libgeo-coordinates-utm-perl, libtest-html-content-perl, libwiki-toolkit-plugin-ping-perl, libgeo-helmerttransform-perl, libhtml-parser-perl, libmime-lite-perl, libdata-validate-uri-perl, libnet-netmask-perl, libwiki-toolkit-plugin-json-perl
+Build-Depends-Indep: perl (>= 5.8.0-7), perl-modules (>= 5.10.0) | libmodule-build-perl (>= 0.26), libconfig-tiny-perl, libclass-accessor-perl, libdbd-sqlite3-perl, libwiki-toolkit-perl (>= 0.77), libwiki-toolkit-formatter-usemod-perl, libwiki-toolkit-plugin-locator-grid-perl, libgeography-nationalgrid-perl, libwiki-toolkit-plugin-rss-reader-perl, libxml-rss-perl, libwiki-toolkit-plugin-categoriser-perl, libwiki-toolkit-plugin-diff-perl, libtemplate-perl (>= 2.15), libplucene-perl, libgeo-coordinates-utm-perl, libtest-html-content-perl, libwiki-toolkit-plugin-ping-perl, libgeo-helmerttransform-perl, libhtml-parser-perl, libmime-lite-perl, libdata-validate-uri-perl, libnet-netmask-perl, libwiki-toolkit-plugin-json-perl, libtemplate-plugin-json-escape-perl
 Maintainer: Dominic Hargreaves <dom@earth.li>
 Standards-Version: 3.9.2
 
@@ -23,7 +23,8 @@
      libdbd-sqlite3-perl | libdbd-pg-perl | libdbd-mysql-perl,
      libwiki-toolkit-plugin-ping-perl, libgeo-helmerttransform-perl,
      libhtml-parser-perl, libmime-lite-perl, libdata-validate-uri-perl,
-     libnet-netmask-perl, libwiki-toolkit-plugin-json-perl
+     libnet-netmask-perl, libwiki-toolkit-plugin-json-perl,
+     libtemplate-plugin-json-escape-perl
 Pre-Depends: debconf
 Description:  web application for managing a collaboratively-written city guide
  The OpenGuides software provides the framework for a collaboratively-written
diff -Nru openguides-0.65/debian/NEWS openguides-0.65/debian/NEWS
--- openguides-0.65/debian/NEWS	2007-10-23 22:54:14.000000000 +0100
+++ openguides-0.65/debian/NEWS	2013-01-02 17:38:26.000000000 +0000
@@ -1,3 +1,21 @@
+openguides (0.65-3) unstable; urgency=low
+
+  The static_url configuration option is now used by OpenGuides;
+  to ensure continued operation, you will need to ensure that it is set
+  to a URL which maps to /usr/share/openguides/static; see
+  /usr/share/doc/openguides/examples/apache.openguides.conf for an
+  example.
+
+  OpenGuides now supports mapping via the Leaflet library. The old
+  Google Maps API is expected to be discontinued in May 2013, so you are
+  advised to update your configuration to use it by setting use_leaflet = 1
+  and removing the gmaps_api_key configuration option. You will also need
+  to ensure that div#map_index_canvas is given a non-zero height in your
+  stylesheet (you may also want to style div#map_index_node_list and
+  div#node_map_canvas).
+
+ -- Dominic Hargreaves <dom@earth.li>  Tue, 01 Jan 2013 23:40:08 +0000
+
 openguides (0.61-1) unstable; urgency=low
 
   * In general, information requiring admin action is from upstream
diff -Nru openguides-0.65/debian/patches/leaflet-mapping openguides-0.65/debian/patches/leaflet-mapping
--- openguides-0.65/debian/patches/leaflet-mapping	1970-01-01 01:00:00.000000000 +0100
+++ openguides-0.65/debian/patches/leaflet-mapping	2013-01-02 16:54:39.000000000 +0000
@@ -0,0 +1,734 @@
+diff --git a/Build.PL b/Build.PL
+index 35c0ec3..f8ab434 100644
+--- a/Build.PL
++++ b/Build.PL
+@@ -46,12 +46,12 @@ EOF
+ my %yn_vars = map { $_ => 1 }
+    qw(use_plucene enable_page_deletion navbar_on_home_page backlinks_in_title
+       moderation_requires_password enable_node_image enable_common_categories
+-      enable_common_locales recent_changes_on_home_page
++      enable_common_locales recent_changes_on_home_page use_leaflet
+       random_page_omits_locales random_page_omits_categories
+       content_above_navbar_in_html show_gmap_in_node_display force_wgs84
+       send_moderation_notifications read_only);
+ 
+-my $skip_config = $force ? 'y' : Module::Build->y_n("Skip OpenGuides configuration?", "n");
++my $skip_config = $force || $ENV{AUTOMATED_TESTING} ? 'y' : Module::Build->y_n("Skip OpenGuides configuration?", "n");
+ if ( $skip_config ) {
+     print <<EOF;
+ ===========================================================================
+@@ -97,6 +97,9 @@ push @answers, { question => $dbtype_qu,
+ 
+ my $install_directory; # used to suggest template paths
+ my $use_plucene = 1; # keep track of this so we know what to put in prereqs
++my $use_leaflet; # if true, we skip the GMaps questions
++my %gmaps_vars = map { $_ => 1 } qw( gmaps_api_key centre_long centre_lat
++                                default_gmaps_zoom default_gmaps_search_zoom );
+ my $centre_lat = ''; # contains centre lat derived from Google Maps URL
+ foreach my $var ( qw(
+    dbname dbuser dbpass dbhost dbport script_name
+@@ -106,8 +109,8 @@ foreach my $var ( qw(
+    recent_changes_on_home_page random_page_omits_locales
+    random_page_omits_categories content_above_navbar_in_html home_name
+    site_desc default_city default_country contact_email default_language
+-   formatting_rules_node backlinks_in_title gmaps_api_key centre_long
+-   centre_lat show_gmap_in_node_display default_gmaps_zoom
++   formatting_rules_node backlinks_in_title use_leaflet gmaps_api_key
++   centre_long centre_lat show_gmap_in_node_display default_gmaps_zoom
+    default_gmaps_search_zoom force_wgs84 google_analytics_key
+    licence_name licence_url licence_info_url moderation_requires_password
+    enable_node_image enable_common_categories enable_common_locales
+@@ -148,6 +151,15 @@ foreach my $var ( qw(
+         next;
+     }
+ 
++    # If we're using Leaflet, we can skip the GMaps stuff.  Don't erase any
++    # previous answers from their config file though.
++    if ( $use_leaflet && $gmaps_vars{$var} ) {
++        push @answers, { question => $qu,
++                         variable => $var,
++                         value => $val };
++        next;
++    }
++
+     # Make sensible suggestions for template paths if we don't already
+     # have them stored.  Not really a default, but a useful hint/shortcut.
+     if ( $var eq "template_path" && !defined $existing_config->$var ) {
+@@ -197,6 +209,10 @@ foreach my $var ( qw(
+     # From Module::Build docs: ->y_n returns a Perl boolean true or false.
+     $use_plucene = 1 if $var eq "use_plucene" and $val;
+ 
++    # If they've just chosen to use Leaflet, we won't need to ask any of the
++    # GMaps questions.
++    $use_leaflet = 1 if $var eq "use_leaflet" and $val;
++
+     # Make sure that script_url ends in a /
+     if ( $var eq "script_url" and $val !~ /\/$/ ) {
+         $val .= "/";
+@@ -308,6 +324,7 @@ my $build = OpenGuides::Build->new(
+         $search_module                        => 0,
+         'POSIX'                               => 0,
+         'Template'                            => '2.15', # for hash.delete and string.remove vmethods
++        'Template::Plugin::JSON::Escape'      => 0,
+         'Time::Piece'                         => 0,
+         'URI::Escape'                         => 0,
+         'XML::RSS'                            => 0,
+@@ -365,6 +382,7 @@ $build->config_data( __templates     => [
+                       "header.tt",
+                       "home_node.tt",
+                       "map_index.tt",
++                      "map_index_leaflet.tt",
+                       "missing_metadata.tt",
+                       "moderate_confirm.tt",
+                       "moderate_password_wrong.tt",
+@@ -393,6 +411,7 @@ $build->config_data( __templates     => [
+                       "read_only.tt",
+                       "recent_changes.tt",
+                       "search_results.tt",
++                      "search_results_leaflet.tt",
+                       "site_index.tt",
+                       "search.tt",
+                       "spam_detected.tt",
+@@ -401,7 +420,7 @@ $build->config_data( __templates     => [
+     ] );
+ 
+ $build->config_data( __static_files => [
+-    # XXX to be supplied when we have some
++        "map-leaflet.js",
+     ] );
+ 
+ # Finally write the build script.
+diff --git a/INSTALL b/INSTALL
+index 96b479c..f863c85 100644
+--- a/INSTALL
++++ b/INSTALL
+@@ -223,17 +223,37 @@ This refers to turning titles into links which bring up a list of referring
+ pages. This was the convention with older wikis ("C2" refers to the original
+ wiki at http://c2.com/cgi/wiki), but is not intuitive.
+ 
++  "Do you want to use the Leaflet mapping library?"
++
++Answer "y" or "n", but "y" is recommended.  In version 0.67 of OpenGuides,
++we switched from using the Google Maps API to the open source Leaflet mapping
++library.  For now, Google Maps support is retained for legacy reasons, but is
++deprecated and will be removed in the future.  We therefore recommend that
++you answer "y" to this question.
++
++  "Would you like to display a map on every node that has geodata?"
++
++Answer "y" or "n".  Note that an answer of "y" will only take effect if you've
++either chosen to use the Leaflet mapping library, or you've supplied a Google
++Maps API key.  Note further that users can choose to turn this off in their
++preferences.
++ 
+   "Do you have a Google Maps API key to use with this guide?"
+ 
+-If you want Google Maps integration, you need to register with Google to get
+-an API key. Visit http://www.google.com/apis/maps/signup.html and follow the
++As of version 0.67 of OpenGuides, we recommend using the Leaflet mapping
++library instead of Google Maps - our Google Maps support is out of date and
++no longer maintained.  However, if you do want to use Google Maps, you need
++to register with Google to get an API key. Visit
++http://www.google.com/apis/maps/signup.html and follow the
+ instructions. Paste the great long string into the console window where you
+ are installing. See README.GMAPS for more information.
+ 
+   "What is the longitude of the centre point of a map to draw for your guide?"
+   "What is the latitude of the centre point of a map to draw for your guide?"
+ 
+-It's probably a good idea to pick some notionally central point for your
++This is only necessary if you're using Google Maps - our Leaflet code will
++figure this out for you.  If you do choose to use Google Maps, it's probably
++a good idea to pick some notionally central point for your
+ guide. For example, Carfax for Oxford, Charing Cross for London. As a
+ convenience, you may paste in a Google Maps URL for the centre longitude
+ question and the (long,lat) will be parsed out from the URL.
+@@ -243,12 +263,6 @@ question and the (long,lat) will be parsed out from the URL.
+ 
+ The defaults are probably appropriate in most cases.
+ 
+-  "Would you like to display a Google Map on every node that has geodata?"
+-
+-Answer "y" or "n".  Note that an answer of "y" will only take effect if you've
+-supplied a Google Maps API key above.  Note further that users can choose to
+-turn this off in their preferences.
+- 
+   "Forcibly treat stored lat/long data as if they used the WGS84 ellipsoid?"
+ 
+ Default this answer if you don't know what it means.
+diff --git a/README.GMAPS b/README.GMAPS
+index b8094b3..54a8dd9 100644
+--- a/README.GMAPS
++++ b/README.GMAPS
+@@ -1,3 +1,16 @@
++NOTE: as of version 0.67, OpenGuides has switched from the Google Maps API
++to the open source Leaflet mapping library.  Our Google Maps support is
++out of date and no longer maintained.  To ensure you're using the latest
++mapping code, set
++
++  use_leaflet = 1
++
++in your wiki.conf.
++
++The instructions below are retained for the benefit of legacy users.
++
++----------------------------------------------------------------------
++
+ As of 0.52, OpenGuides supports Google Maps using the API. The support has a
+ few rough edges that still need ironing out, mostly relating to ellipsoids,
+ and for that reason they aren't exposed by default.
+diff --git a/lib/OpenGuides.pm b/lib/OpenGuides.pm
+index eeb43e3..047d049 100644
+--- a/lib/OpenGuides.pm
++++ b/lib/OpenGuides.pm
+@@ -881,6 +881,7 @@ sub show_index {
+     my ($self, %args) = @_;
+     my $wiki = $self->wiki;
+     my $formatter = $wiki->formatter;
++    my $use_leaflet = $self->config->use_leaflet;
+     my %tt_vars;
+     my @selnodes;
+ 
+@@ -927,7 +928,9 @@ sub show_index {
+                             param     => $formatter->node_name_to_node_param($_) }
+                         } sort @selnodes;
+ 
+-    # Convert the lat+long to WGS84 as required
++    # Convert the lat+long to WGS84 as required, and count how many nodes
++    # we have for the map (if using Leaflet).
++    my $nodes_on_map;
+     for(my $i=0; $i<scalar @nodes;$i++) {
+         my $node = $nodes[$i];
+         if($node) {
+@@ -943,6 +946,15 @@ sub show_index {
+ 
+             push @{$nodes[$i]->{node_data}->{metadata}->{wgs84_long}}, $wgs84_long;
+             push @{$nodes[$i]->{node_data}->{metadata}->{wgs84_lat}},  $wgs84_lat;
++            if ( $use_leaflet ) {
++                if ( defined $wgs84_lat && $wgs84_lat =~ /^[-.\d]+$/
++                     && defined $wgs84_long && $wgs84_long =~ /^[-.\d]+$/ ) {
++                    $node->{has_geodata} = 1;
++                    $node->{wgs84_lat} = $wgs84_lat;
++                    $node->{wgs84_long} = $wgs84_long;
++                    $nodes_on_map++;
++                }
++            }
+         }
+     }
+ 
+@@ -961,18 +973,36 @@ sub show_index {
+             $template = "plain_index.tt";
+             $conf{content_type} = "text/plain";
+         } elsif ( $args{format} eq "map" ) {
+-            my $q = CGI->new;
+-            $tt_vars{zoom} = $q->param('zoom') || '';
+-            $tt_vars{lat} = $q->param('lat') || '';
+-            $tt_vars{long} = $q->param('long') || '';
+-            $tt_vars{map_type} = $q->param('map_type') || '';
+-            $tt_vars{centre_long} = $self->config->centre_long;
+-            $tt_vars{centre_lat} = $self->config->centre_lat;
+-            $tt_vars{default_gmaps_zoom} = $self->config->default_gmaps_zoom;
+-            $tt_vars{enable_gmaps} = 1;
+             $tt_vars{display_google_maps} = 1; # override for this page
+-            $template = "map_index.tt";
+-            
++            if ( $use_leaflet ) {
++                if ( $nodes_on_map ) {
++                    my @points = map {
++                    {  wgs84_lat =>
++                           $_->{node_data}->{metadata}->{wgs84_lat}[0],
++                      wgs84_long =>
++                           $_->{node_data}->{metadata}->{wgs84_long}[0]
++                    }
++                                     } @nodes;
++                    my %minmaxdata = OpenGuides::Utils->get_wgs84_min_max(
++                        nodes => \@points );
++                    %tt_vars = ( %tt_vars, %minmaxdata );
++                } else {
++                    $tt_vars{no_nodes_on_map} = 1;
++                }
++                $template = "map_index_leaflet.tt";
++            } else {
++                my $q = CGI->new;
++                $tt_vars{zoom} = $q->param('zoom') || '';
++                $tt_vars{lat} = $q->param('lat') || '';
++                $tt_vars{long} = $q->param('long') || '';
++                $tt_vars{map_type} = $q->param('map_type') || '';
++                $tt_vars{centre_long} = $self->config->centre_long;
++                $tt_vars{centre_lat} = $self->config->centre_lat;
++                $tt_vars{default_gmaps_zoom}
++                                      = $self->config->default_gmaps_zoom;
++                $tt_vars{enable_gmaps} = 1;
++                $template = "map_index.tt";
++            }
+         } elsif( $args{format} eq "rss" || $args{format} eq "atom") {
+             # They really wanted a recent changes style rss/atom feed
+             my $feed_type = $args{format};
+diff --git a/lib/OpenGuides/Config.pm b/lib/OpenGuides/Config.pm
+index a366fe1..a8ca3c9 100644
+--- a/lib/OpenGuides/Config.pm
++++ b/lib/OpenGuides/Config.pm
+@@ -20,7 +20,7 @@ my @variables = qw(
+    default_language http_charset ping_services
+    formatting_rules_node formatting_rules_link backlinks_in_title template_path
+    custom_template_path geo_handler ellipsoid gmaps_api_key centre_long
+-   show_gmap_in_node_display google_analytics_key
++   show_gmap_in_node_display google_analytics_key use_leaflet
+    centre_lat default_gmaps_zoom default_gmaps_search_zoom force_wgs84
+    licence_name licence_url licence_info_url
+    moderation_requires_password moderate_whitelist
+@@ -104,6 +104,7 @@ sub _init {
+                      backlinks_in_title => 0,
+                      geo_handler => 1,
+                      ellipsoid => "WGS-84",
++                     use_leaflet => 0,
+                      show_gmap_in_node_display => 1,
+                      centre_long => 0,
+                      centre_lat => 0,
+@@ -188,12 +189,13 @@ sub _init {
+         formatting_rules_link => "What URL do you want to use for the text formatting rules (leave blank to use a wiki node instead)?",
+         backlinks_in_title => "Make node titles link to node backlinks (C2 style)?",
+         ellipsoid => "Which ellipsoid do you want to use? (eg 'Airy', 'WGS-84')",
+-        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.",
+-        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). You may paste in a Google Maps URL here (hint: copy URL from 'Link to this page')",
+-        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)",
++        use_leaflet => "Do you want to use the Leaflet mapping library? (this is recommended)",
++        gmaps_api_key => "Do you have a Google Maps API key to use with this guide? If so, enter it here. (Note: our Google Maps support is deprecated, and we recommend you choose to use Leaflet instead.)",
++        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 - we recommend you use Leaflet instead, as our Leaflet code will figure this out for you.) You may paste in a Google Maps URL here (hint: copy URL from 'Link to this page')",
++        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 - we recommend you use Leaflet instead, as our Leaflet code will figure this out for you.)",
+         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)",
+         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)",
+-        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)",
++        show_gmap_in_node_display => "Would you like to display a map on every node that has geodata?",
+         force_wgs84 => "Forcibly treat stored lat/long data as if they used the WGS84 ellipsoid?",
+         google_analytics_key => "Do you have a Google Analytics key to use with this guide? If you enter it here, then Google Analytics functionality will be automatically enabled.",
+         licence_name => "What licence will you use for the guide?",
+@@ -309,6 +311,8 @@ sub script_url {
+ 
+ =item * ellipsoid (default: C<WGS-84>)
+ 
++=item * use_leaflet
++
+ =item * gmaps_api_key
+ 
+ =item * centre_long
+diff --git a/lib/OpenGuides/Utils.pm b/lib/OpenGuides/Utils.pm
+index f54a81a..fd2072c 100644
+--- a/lib/OpenGuides/Utils.pm
++++ b/lib/OpenGuides/Utils.pm
+@@ -338,6 +338,51 @@ sub get_wgs84_coords {
+     }
+ }
+ 
++=item B<get_wgs84_min_max>
++
++Given a set of WGS84 coordinate data, returns the minimum, maximum,
++and centre latitude and longitude.
++
++    %data = OpenGuides::Utils->get_wgs84_min_max(
++        nodes => [
++                   { wgs84_lat => 51.1, wgs84_long => 1.1 },
++                   { wgs84_lat => 51.2, wgs84_long => 1.2 },
++                 ]
++    );
++    print "Top right-hand corner is $data{max_lat}, $data{max_long}";
++    print "Centre point is $data{centre_lat}, $data{centre_long}";
++
++The hashes in the C<nodes> argument can include other key/value pairs;
++these will just be ignored.
++
++Returns false if it can't find any valid geodata in the nodes.
++
++=cut
++
++sub get_wgs84_min_max {
++    my ( $self, %args ) = @_;
++    my @nodes = @{$args{nodes}};
++
++    my @lats  = sort
++                grep { defined $_ && /^[-.\d]+$/ }
++                map { $_->{wgs84_lat} }
++                @nodes;
++    my @longs = sort
++                grep { defined $_ && /^[-.\d]+$/ }
++                map { $_->{wgs84_long} }
++                @nodes;
++
++    if ( !scalar @lats || !scalar @longs ) {
++        return;
++    }
++
++    my %data = ( min_lat  => $lats[0],  max_lat  => $lats[$#lats],
++                 min_long => $longs[0], max_long => $longs[$#longs] );
++    $data{centre_lat} = ( $data{min_lat} + $data{max_lat} ) / 2;
++    $data{centre_long} = ( $data{min_long} + $data{max_long} ) / 2;
++    return %data;
++}
++
+ =item B<detect_redirect>
+ 
+     $redir = OpenGuides::Utils->detect_redirect( content => "foo" );
+diff --git a/static/map-leaflet.js b/static/map-leaflet.js
+new file mode 100644
+index 0000000..ed91acd
+--- /dev/null
++++ b/static/map-leaflet.js
+@@ -0,0 +1,80 @@
++var centre_lat, centre_long, min_lat, min_long, max_lat, max_long, map, map_div_id;
++var positions = [], markers = [];
++
++var gicon = L.Icon.extend( {
++    options: {
++      iconUrl: 'http://maps.google.com/mapfiles/ms/micons/red-dot.png',
++      shadowUrl: null,
++      iconSize: new L.Point( 32, 32 ),
++      iconAnchor: new L.Point( 15, 32 ),
++      popupAnchor: new L.Point( 0, -30 )
++    }
++} );
++
++$(
++  function() {
++    if ( map_div_id && centre_lat && centre_long ) {
++      var map_centre = new L.LatLng( centre_lat, centre_long );
++
++      var mq_url = 'http://{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png';
++      var subdomains = [ 'otile1', 'otile2', 'otile3', 'otile4' ];
++      var attrib = 'Data, imagery and map information provided by <a href="http://open.mapquest.co.uk"; target="_blank">MapQuest</a>, <a href="http://www.openstreetmap.org/"; target="_blank">OpenStreetMap</a> and contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/"; target="_blank">CC-BY-SA</a>';
++      var mapquest_layer = new L.TileLayer( mq_url, { maxZoom: 18, attribution: attrib, subdomains: subdomains } );
++
++      var osm_layer = new L.TileLayer(
++          'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' );
++
++      map = new L.Map( map_div_id, {
++        center: map_centre,
++        layers: [ osm_layer ],
++      } );
++
++      if ( !min_lat ) {
++        map.setView( map_centre, 13 );
++      } else if ( min_lat == max_lat && min_long == max_long) {
++        map.setView( new L.LatLng( min_lat, min_long ), 18 );
++      } else {
++        var bounds = new L.LatLngBounds( new L.LatLng( min_lat, min_long ),
++                                         new L.LatLng( max_lat, max_long ) );
++        map.fitBounds( bounds );
++      }
++
++      var layersControl = new L.Control.Layers( {
++        "MapQuest": mapquest_layer,
++        "OpenStreetMap": osm_layer,
++      } );
++      map.addControl( layersControl );
++
++      add_markers();
++    }
++  }
++);
++
++function add_marker( i, node ) {
++  var content, marker, position;
++
++  // This should have already been checked, but no harm in checking again.
++  if ( !node.lat || !node.long ) {
++    return;
++  }
++
++  position = new L.LatLng( node.lat, node.long );
++
++  marker = new L.Marker( position, { icon: new gicon() } );
++  map.addLayer( marker );
++
++  content = '<a href="?' + node.param + '">' + node.name + '</a>';
++  if ( node.address ) {
++    content += '<br />' + node.address;
++  }
++  marker.bindPopup( content );
++
++  markers[ i ] = marker;
++  positions[ i ] = position;
++}
++
++function show_marker( i ) {
++  markers[ i ].openPopup();
++  map.panTo( positions[ i ] );
++  return false;
++}
+diff --git a/templates/header.tt b/templates/header.tt
+index 7d0ad0a..656b66d 100644
+--- a/templates/header.tt
++++ b/templates/header.tt
+@@ -26,9 +26,19 @@ category.name %][%- ", " %][% END %][% END %][% IF locales.size AND
+ locales.size > 0 %][% FOREACH locale = locales %][% locale.name %][%-
+ ", " UNLESS loop.last %][% END %][% END %]" />
+   [% END %]
++
+   [% IF stylesheet %]
+     <link rel="stylesheet" href="[% stylesheet %]" type="text/css" title="Stylesheet for [% site_name %]" />
++  [% ELSE %]
++    <link rel="stylesheet" href="[% config.static_url %]openguides-base.css" type="text/css" title="Basic OpenGuides stylesheet" />
++  [% END %]
++  [% IF config.use_leaflet %]
++    <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.4/leaflet.css"; />
++    <!--[if lte IE 8]>
++      <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.4/leaflet.ie.css"; />
++    <![endif]-->
+   [% END %]
++
+   [% IF feed_base %]
+     <link rel="alternate" type="application/rss+xml" title="Page as RSS" href="[% feed_base %];format=rss" />
+     <link rel="alternate" type="application/atom+xml" title="Page as Atom" href="[% feed_base %];format=atom" />
+@@ -59,8 +69,19 @@ locales.size > 0 %][% FOREACH locale = locales %][% locale.name %][%-
+     <link rel="alternate" type="application/wiki" title="Edit this page!"
+      href="[% source_site or full_cgi_url %]?id=[% node_param %];action=edit">
+   [% END %]
+-  [% IF enable_gmaps AND display_google_maps AND gmaps_api_key %]
+-    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=[% gmaps_api_key %]" type="text/javascript"></script>
++
++  [% IF display_google_maps %]
++    [% IF config.use_leaflet %]
++      <script
++         src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js";
++         type="text/javascript"></script>
++      <script src="http://cdn.leafletjs.com/leaflet-0.4/leaflet.js";
++              type="text/javascript"></script>
++      <script src="[% config.static_url %]map-leaflet.js"
++              type="text/javascript"></script>
++    [% ELSIF enable_gmaps AND gmaps_api_key %]
++      <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=[% gmaps_api_key %]" type="text/javascript"></script>
++    [% END %]
+   [% END %]
+ 
+   [% TRY %]
+@@ -71,7 +92,8 @@ locales.size > 0 %][% FOREACH locale = locales %][% locale.name %][%-
+ </head>
+ <body>
+   <div id="body_wrapper">
+-  [% IF enable_gmaps AND display_google_maps AND gmaps_api_key %]
++  [% IF !config.use_leaflet AND enable_gmaps AND display_google_maps
++     AND gmaps_api_key %]
+     <script defer="defer" type="text/javascript">
+       //<![CDATA[
+         var baseIcon = new GIcon();
+diff --git a/templates/map_index_leaflet.tt b/templates/map_index_leaflet.tt
+new file mode 100644
+index 0000000..3808c4d
+--- /dev/null
++++ b/templates/map_index_leaflet.tt
+@@ -0,0 +1,31 @@
++[% IF criteria %]
++  [% page_title = "Map of $criteria_title - $site_name" %]
++[% ELSE %]
++  [% page_title = "Map of all nodes - $site_name" %]
++[% END %]
++[% INCLUDE header.tt %]
++[% INCLUDE banner.tt %]
++
++[%# NOTE: the "content" div is closed off in footer.tt %]
++<div id="content">
++
++  <div id="maincontent_no_navbar">
++
++    <h2>Map of
++      [% IF criteria %]
++        [% links = [] %]
++        [% FOREACH criterion = criteria %]
++          [% links.push( '<a href="' _ cgi_url _ '?' _ criterion.param _ '">' _ criterion.name _ '</a>' ) %]
++        [% END %]
++        [% links.join( ' and ' ) %]
++      [% ELSE %]
++        all nodes
++      [% END %]
++      (<a href="[% feed_base %]">view as a list</a>)
++    </h2>
++
++    [% INCLUDE search_results_leaflet.tt %]
++
++  </div>
++
++[% INCLUDE footer.tt %]
+diff --git a/templates/node.tt b/templates/node.tt
+index a2b26b9..f2bfed5 100644
+--- a/templates/node.tt
++++ b/templates/node.tt
+@@ -1,4 +1,5 @@
+ [% USE CGI %]
++[% USE JSON.Escape %]
+ [% INCLUDE header.tt %]
+ [% INCLUDE banner.tt %]
+ <div id="content">
+@@ -10,21 +11,36 @@
+ <div id="redirect_message">(redirected from <a href="[% full_cgi_url %]?id=[% oldid %];redirect=0">[% oldid.replace('_', ' ') %]</a>)</div>
+ [% END %]
+ 
+-[% IF wgs84_lat AND wgs84_long AND display_google_maps and gmaps_api_key %]
+-  <div id="map" style="float:right; width: 300px; height: 200px"></div>
+-  <script defer="defer" type="text/javascript">
+-  //<![CDATA[
+-    var map = new GMap(document.getElementById("map"));
+-    map.addControl(new GSmallMapControl());
+-    map.centerAndZoom(new GPoint([% wgs84_long %], [% wgs84_lat %]), 3);
+-    var point0 = new GPoint([% wgs84_long %], [% wgs84_lat %]);
+-    var marker0 = new GMarker(point0,baseIcon);
+-    GEvent.addListener(marker0, "click", function() {
+-      marker0.openInfoWindowHtml("[% node_name %]");
+-      });
+-    map.addOverlay(marker0);
+-  //]]>
+-  </script>
++[% IF wgs84_lat AND wgs84_long AND display_google_maps %]
++  [% IF config.use_leaflet %]
++    <div id="node_map_canvas"></div>
++    <script type="text/javascript">
++      map_div_id = 'node_map_canvas';
++      centre_lat = [% wgs84_lat %];
++      centre_long = [% wgs84_long %];
++      function add_markers() {
++        var position = new L.LatLng( [% wgs84_lat %], [% wgs84_long %] );
++        marker = new L.Marker( position, { icon: new gicon() } );
++        map.addLayer( marker );
++        marker.bindPopup( [% node_name.json %] );
++      }
++    </script>
++  [% ELSIF gmaps_api_key %]
++    <div id="map" style="float:right; width: 300px; height: 200px"></div>
++    <script defer="defer" type="text/javascript">
++    //<![CDATA[
++      var map = new GMap(document.getElementById("map"));
++      map.addControl(new GSmallMapControl());
++      map.centerAndZoom(new GPoint([% wgs84_long %], [% wgs84_lat %]), 3);
++      var point0 = new GPoint([% wgs84_long %], [% wgs84_lat %]);
++      var marker0 = new GMarker(point0,baseIcon);
++      GEvent.addListener(marker0, "click", function() {
++        marker0.openInfoWindowHtml("[% node_name %]");
++        });
++      map.addOverlay(marker0);
++    //]]>
++    </script>
++  [% END %]
+ [% END %]
+ 
+ [% IF node_image %]
+@@ -53,8 +69,6 @@
+   [% IF backlinks_in_title AND is_indexable_node %]
+     <h2 class="node_name"><a href="[% cgi_url %]?action=index;index_type=[% CGI.escape(index_type) %];index_value=[% CGI.escape(index_value) %]">[% node_name %]</a></h2>
+   [% ELSIF backlinks_in_title %]
+-    <h2 class="node_name"><a href="[% cgi_url %]?action=show_backlinks;id=[% CGI.escape(node_name) %]">[% node_name %]</a></h2>
+-  [% ELSE %]
+     <h2 class="node_name">[% node_name %]</h2>
+   [% END %]
+ [% ELSE %]
+diff --git a/templates/preferences.tt b/templates/preferences.tt
+index 996ebfd..da62445 100644
+--- a/templates/preferences.tt
++++ b/templates/preferences.tt
+@@ -75,14 +75,15 @@
+       <label for="track_recent_changes_views">Track my visits to Recent Changes and offer me a link for &#8220;changes since I last viewed Recent Changes&#8221;.</label>
+     </p>
+ 
+-    [% IF gmaps_api_key AND config.show_gmap_in_node_display %]
++    [% IF ( config.use_leaflet OR gmaps_api_key )
++       AND config.show_gmap_in_node_display %]
+       <p>
+         [% IF prefs.display_google_maps %]
+           <input type="checkbox" id="display_google_maps" name="display_google_maps" value="1" checked="1" />
+         [% ELSE %]
+           <input type="checkbox" id="display_google_maps" name="display_google_maps" value="1" />
+         [% END %]
+-        <label for="display_google_maps">Display Google Maps.</label>
++        <label for="display_google_maps">Display a map on every page with geodata.</label>
+       </p>
+     [% END %]
+ 
+@@ -165,10 +166,11 @@
+     [% UNLESS prefs.track_recent_changes_views %] not [% END %]
+   be tracked.</p>
+ 
+-  [% IF prefs.gmaps_api_key AND config.show_gmap_in_node_display %]
+-    <p>Google Maps will
+-      [% UNLESS display_google_maps %] not [% END %]
+-    be displayed.</p>
++  [% IF ( config.use_leaflet OR gmaps_api_key )
++     AND config.show_gmap_in_node_display %]
++    <p>Maps will
++      [% UNLESS prefs.display_google_maps %] not [% END %]
++    be displayed on pages with geodata.</p>
+   [% END %]
+ 
+   <p>Default edit type set to
+diff --git a/templates/search_results_leaflet.tt b/templates/search_results_leaflet.tt
+new file mode 100644
+index 0000000..3098f39
+--- /dev/null
++++ b/templates/search_results_leaflet.tt
+@@ -0,0 +1,70 @@
++[% USE JSON.Escape %]
++
++<div id="map_index_node_list">
++  <ul>
++    [% IF no_nodes_on_map %]
++      [% FOREACH node = nodes %]
++        <li><a href="?[% node.param %]">[% node.name %]</a></li>
++      [% END %]
++    [% ELSE %]
++      [% i = 0 %]
++      [% FOREACH node = nodes %]
++        [% i = i + 1 %]
++        <li>
++          [% IF node.has_geodata %]
++            <a href="#" onclick="return show_marker( [% i %] )">[% node.name | html %]</a>
++          [% ELSE %]
++            [% node.name | html %] (not on map &#8212;
++              <a href="?[% node.param %]">view info</a>)
++          [% END %]
++        </li>
++      [% END %]
++    [% END %]
++  </ul>
++</div>
++
++<div id="map_index_canvas">
++  [% IF no_nodes_on_map %]
++    <p class="no_nodes_on_map">No pages with geodata - nothing to display
++    on map!</p>
++  [% ELSE %]
++    <span id="map_index_no_js">
++      <p>Sorry! JavaScript is required to view the map - you may prefer to
++      <a href="[% feed_base %]">view the results as a list</a> instead.</p>
++    </span>
++
++    <script type="text/javascript">
++
++      $('#map_index_no_js').hide();
++
++      map_div_id = 'map_index_canvas';
++      centre_lat = [% centre_lat %];
++      centre_long = [% centre_long %];
++      min_lat = [% min_lat %];
++      max_lat = [% max_lat %];
++      min_long = [% min_long %];
++      max_long = [% max_long %];
++
++      function add_markers() {
++        var node;
++        [% i = 0 %]
++        [% FOREACH node = nodes %]
++          [% i = i + 1 %]
++          [% IF node.has_geodata %]
++            node = {
++              name: [% node.name.json %],
++              param: [% node.param.json %],
++              [% address = node.node_data.metadata.address.list.first %]
++              [% IF address %]
++                address: [% address.json %],
++              [% END %]
++              lat: [% node.wgs84_lat.json %],
++              long: [% node.wgs84_long.json %],
++            };
++            add_marker( [% i %], node );
++          [% END %]
++        [% END %]
++      }
++    </script>
++  [% END %]
++</div>
diff -Nru openguides-0.65/debian/patches/series openguides-0.65/debian/patches/series
--- openguides-0.65/debian/patches/series	2011-05-17 22:01:52.000000000 +0100
+++ openguides-0.65/debian/patches/series	2013-01-02 16:54:39.000000000 +0000
@@ -1,2 +1,3 @@
 usr-bin-perl
 build-tweaks
+leaflet-mapping
diff -Nru openguides-0.65/debian/rules openguides-0.65/debian/rules
--- openguides-0.65/debian/rules	2011-05-17 22:02:58.000000000 +0100
+++ openguides-0.65/debian/rules	2013-01-02 16:54:39.000000000 +0000
@@ -61,6 +61,7 @@
 	mkdir -p $(TMP)/etc/openguides/default/templates
 	mkdir -p $(TMP)/usr/lib/cgi-bin/openguides
 	cp -pr templates $(TMP)/usr/share/openguides
+	cp -pr static $(TMP)/usr/share/openguides
 	cp -p debian/wiki.conf $(TMP)/etc/openguides/default/
 	chgrp www-data $(TMP)/etc/openguides/default/wiki.conf
 	chmod 640 $(TMP)/etc/openguides/default/wiki.conf
diff -Nru openguides-0.65/debian/wiki.conf openguides-0.65/debian/wiki.conf
--- openguides-0.65/debian/wiki.conf	2011-05-17 22:02:37.000000000 +0100
+++ openguides-0.65/debian/wiki.conf	2013-01-02 16:54:39.000000000 +0000
@@ -93,16 +93,19 @@
 # This is only used if you select geo_handler = 3 above
 ellipsoid = WGS-84
 
-# 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.
+# Do you want to use the Leaflet mapping library? (this is recommended)
+use_leaflet = 1
+
+# Do you have a Google Maps API key to use with this guide? If so, enter it here. (Note: our Google Maps support is deprecated, and we recommend you choose to use Leaflet instead.)
 gmaps_api_key = 
 
-# 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)
+# 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 - we recommend you use Leaflet instead, as our Leaflet code will figure this out for you.) You may paste in a Google Maps URL here (hint: copy URL from 'Link to this page')
 centre_long = 0
 
-# 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)
+# 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 - we recommend you use Leaflet instead, as our Leaflet code will figure this out for you.)
 centre_lat = 0
 
-# 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)
+# Would you like to display a map on every node that has geodata?
 show_gmap_in_node_display = 1
 
 # What default zoom level shall we use for Google Maps? (This question can be ignored if you aren't using Google Maps)

--- End Message ---
--- Begin Message ---
On Sat, 2013-01-05 at 13:32 +0000, Dominic Hargreaves wrote:
> Please unblock package openguides
> 
> This update addresses a latent bug which will appear when the GMaps2
> API stops working (announced as being May 2013), by backporting changes
> to use the Leaflet mapping library from current upstream releases.

Whilst not being hugely keen on the diff, I'd also rather get this out
of the way now rather than as a stable update.

Unblocked.

Regards,

Adam

--- End Message ---

Reply to: