jenkins-bot has submitted this change and it was merged.

Change subject: Implement ResoureLoader module to get ext map links
......................................................................


Implement ResoureLoader module to get ext map links

For now, something to get us started:
* external links are stored in a file externalLinks.json
* File must have the following structure:

To test:  add "ext.kartographer.extlinks" as a new dependency in 
extension.json's ext.kartographer.box

{
  "services": [
    {
      "name": "openstreetmap", // localization key of the service - as defined 
in i18n, without the 'kartographer-link-' prefix
      "links": [
        {
          "type": "map",        // can also be: satellite, terrain, other, or 
anything else defined in i18n without the 'kartographer-linktype-' prefix
          "url": "http://...";,  // this value may include values like 
{latdegdec}, {londegdec}, etc
        },
...

Bug: T145667
Change-Id: I99e7d67c9296fe2e1a48a644e60de1ae550f3e59
---
M extension.json
A externalLinks.json
M i18n/en.json
M i18n/qqq.json
A includes/DataModuleLinks.php
5 files changed, 436 insertions(+), 0 deletions(-)

Approvals:
  MaxSem: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/extension.json b/extension.json
index a56ab62..969f7ec 100644
--- a/extension.json
+++ b/extension.json
@@ -27,6 +27,7 @@
                "Kartographer\\ApiSanitizeMapData": 
"includes/ApiSanitizeMapData.php",
                "Kartographer\\CoordFormatter": "includes/CoordFormatter.php",
                "Kartographer\\DataModule": "includes/DataModule.php",
+               "Kartographer\\DataModuleLinks": "includes/DataModuleLinks.php",
                "Kartographer\\Hooks": "includes/Hooks.php",
                "Kartographer\\SimpleStyleParser": 
"includes/SimpleStyleParser.php",
                "Kartographer\\SpecialMap": "includes/SpecialMap.php",
@@ -48,6 +49,9 @@
                "ext.kartographer": {
                        "class": "Kartographer\\DataModule"
                },
+               "ext.kartographer.extlinks": {
+                       "class": "Kartographer\\DataModuleLinks"
+               },
                "ext.kartographer.style": {
                        "styles": [
                                "styles/kartographer.less",
diff --git a/externalLinks.json b/externalLinks.json
new file mode 100644
index 0000000..e49cc09
--- /dev/null
+++ b/externalLinks.json
@@ -0,0 +1,294 @@
+{
+       "services": [
+               {
+                       "name": "acme-mapper",
+                       "links": [
+                               {
+                                       "type": "map",
+                                       "url": 
"http://mapper.acme.com/?ll={latdegdec},{londegdec}&z={osmzoom}&t=M&marker0={latdegdec},{londegdec},{titlee}";
+                               },
+                               {
+                                       "type": "satellite",
+                                       "url": 
"http://mapper.acme.com/?ll={latdegdec},{londegdec}&z={osmzoom}&t=H&marker0={latdegdec},{londegdec},{titlee}";
+                               },
+                               {
+                                       "type": "terrain",
+                                       "url": 
"http://mapper.acme.com/?ll={latdegdec},{londegdec}&z={osmzoom}&t=R&marker0={latdegdec},{londegdec},{titlee}";
+                               },
+                               {
+                                       "type": "topo",
+                                       "url": 
"http://mapper.acme.com/?ll={latdegdec},{londegdec}&z={osmzoom}&t=T&marker0={latdegdec},{londegdec},{titlee}";
+                               }
+                       ]
+               },
+               {
+                       "name": "apple-maps",
+                       "links": [
+                               {
+                                       "type": "map",
+                                       "url": 
"https://maps.apple.com/?q={latdegdec},{londegdec}";
+                               },
+                               {
+                                       "type": "satellite",
+                                       "url": 
"https://maps.apple.com/?q={latdegdec},{londegdec}&t=k";
+                               }
+                       ]
+               },
+               {
+                       "name": "arctic-io",
+                       "links": [
+                               {
+                                       "type": "satellite",
+                                       "url": 
"http://www.arctic.io/wikipedia/?lon={londegdec}&lat={latdegdec}&title={titlee}";
+                               }
+                       ]
+               },
+               {
+                       "name": "bing-maps",
+                       "featured": true,
+                       "links": [
+                               {
+                                       "type": "map",
+                                       "url": 
"https://www.bing.com/maps/?v=2&cp={latdegdec}~{londegdec}&style=r&lvl={osmzoom}&sp=Point.{latdegdec}_{londegdec}_{titlee}___";
+                               },
+                               {
+                                       "type": "aerial",
+                                       "url": 
"https://www.bing.com/maps/?v=2&cp={latdegdec}~{londegdec}&style=h&lvl={osmzoom}&sp=Point.{latdegdec}_{londegdec}_{titlee}___";
+                               },
+                               {
+                                       "type": "birds-eye",
+                                       "url": 
"https://www.bing.com/maps/?v=2&cp={latdegdec}~{londegdec}&style=o&lvl={osmzoom}&sp=Point.{latdegdec}_{londegdec}_{titlee}___";
+                               }
+                       ]
+               },
+               {
+                       "name": "blue-marble-navigator",
+                       "links": [
+                               {
+                                       "type": "satellite",
+                                       "url": 
"http://www.blue-marble.de?lon={londegdec}&nlat={latdegdec}&borders&geonames&townnames&zoom&overlay=14&base=7";
+                               },
+                               {
+                                       "type": "night-lights",
+                                       "url": 
"http://www.blue-marble.de/nightlights?ll={latdegdec},{londegdec}";
+                               }
+                       ]
+               },
+               {
+                       "name": "flash-earth",
+                       "links": [
+                               {
+                                       "type": "satellite",
+                                       "url": 
"http://www.flashearth.com/?lat={latdegdec}&lon={londegdec}&z=15&r=0&src=ggl";
+                               }
+                       ]
+               },
+               {
+                       "name": "geabios",
+                       "links": [
+                               {
+                                       "type": "satellite",
+                                       "url": 
"http://www.geabios.com/html/services/maps/PublicMap.htm?lat={latdegdec}&lon={londegdec}&fov={span}&title={titlee}";
+                               }
+                       ]
+               },
+               {
+                       "name": "geonames",
+                       "links": [
+                               {
+                                       "type": "satellite",
+                                       "url": 
"http://www.geonames.org/maps/google_{latdegdec}_{londegdec}.html";
+                               }
+                       ]
+               },
+               {
+                       "name": "google-maps",
+                       "featured": true,
+                       "links": [
+                               {
+                                       "type": "map",
+                                       "url": 
"https://maps.google.com/maps?ll={latdegdec},{londegdec}&q={latdegdec},{londegdec}&hl={language}&t=m&z={osmzoom}";
+                               },
+                               {
+                                       "type": "satellite",
+                                       "url": 
"https://maps.google.com/maps?ll={latdegdec},{londegdec}&q={latdegdec},{londegdec}&hl={language}&t=h&z={osmzoom}";
+                               },
+                               {
+                                       "type": "terrain",
+                                       "url": 
"https://www.google.com/maps/place//@{latdegdec},{londegdec},{osmzoom}z/data=!4m2!3m1!1s0x0:0x0!5m1!1e4?hl=en";
+                               }
+                       ]
+               },
+               {
+                       "name": "gps-visualizer",
+                       "links": [
+                               {
+                                       "type": "map",
+                                       "url": 
"http://www.gpsvisualizer.com/map_input?special=wikipedia&format=google&bg_map=google_map&sp_width=50km&google_zoom_level={zoom}&google_wpt_labels=1&form:data=name,latitude,longitude%0D%22{titlee}%22,{latdegdec},{londegdec}";
+                               },
+                               {
+                                       "type": "satellite",
+                                       "url": 
"http://www.gpsvisualizer.com/map_input?special=wikipedia&format=google&bg_map=google_hybrid&sp_width=50km&google_zoom_level={zoom}&google_wpt_labels=1&form:data=name,latitude,longitude%0D%22{titlee}%22,{latdegdec},{londegdec}";
+                               },
+                               {
+                                       "type": "topo",
+                                       "url": 
"http://www.gpsvisualizer.com/map_input?special=wikipedia&format=google&bg_map=google_arcgistopo_world&sp_width=50km&google_zoom_level={zoom}&google_wpt_labels=1&form:data=name,latitude,longitude%0D%22{titlee}%22,{latdegdec},{londegdec}";
+                               }
+                       ]
+               },
+               {
+                       "name": "here",
+                       "links": [
+                               {
+                                       "type": "map",
+                                       "url": 
"https://www.here.com/location/?map={latdegdec},{londegdec},{osmzoom},normal&msg={titlee}";
+                               },
+                               {
+                                       "type": "satellite",
+                                       "url": 
"https://www.here.com/location/?map={latdegdec},{londegdec},{osmzoom},satellite&msg={titlee}";
+                               },
+                               {
+                                       "type": "terrain",
+                                       "url": 
"https://www.here.com/location/?map={latdegdec},{londegdec},{osmzoom},terrain&msg={titlee}";
+                               }
+                       ]
+               },
+               {
+                       "name": "mapquest",
+                       "links": [
+                               {
+                                       "type": "map",
+                                       "url": 
"http://www.mapquest.com/?center={latdegdec},{londegdec}&zoom={osmzoom}&q={titlee}";
+                               }
+                       ]
+               },
+               {
+                       "name": "maptech",
+                       "links": [
+                               {
+                                       "type": "map",
+                                       "url": 
"http://mapserver.maptech.com/homepage/index.cfm?lat={latdegdec}&lon={londegdec}&scale=24000&zoom=50&type=1";
+                               }
+                       ]
+               },
+               {
+                       "name": "norkart-virtual-globe",
+                       "links": [
+                               {
+                                       "type": "satellite",
+                                       "url": 
"http://www.virtual-globe.info/VirtualGlobeStarter.php?request=page&dataset=http://www.virtual-globe.info/globe.vgml&lookat={londegdec},{latdegdec},{scale}";
+                               }
+                       ]
+               },
+               {
+                       "name": "open-street-map",
+                       "featured": true,
+                       "links": [
+                               {
+                                       "type": "map",
+                                       "url": 
"https://www.openstreetmap.org/?mlat={latdegdec}&mlon={londegdec}&zoom={osmzoom}&layers=M";
+                               }
+                       ]
+               },
+               {
+                       "name": "shaded-relief",
+                       "links": [
+                               {
+                                       "type": "terrain",
+                                       "url": 
"http://www.shaded-relief.com/?gt={latdegdec}&gl={londegdec}&z=9&t=4";
+                               }
+                       ]
+               },
+               {
+                       "name": "skyvector",
+                       "links": [
+                               {
+                                       "type": "aeronautical",
+                                       "url": 
"https://skyvector.com/?ll={latdegdec},{londegdec}&zoom=2";
+                               }
+                       ]
+               },
+               {
+                       "name": "terraserver",
+                       "links": [
+                               {
+                                       "type": "satellite",
+                                       "url": 
"https://www.terraserver.com/view?utf8=%E2%9C%93&search_text=&searchLat=&searchLng=&lat={latdegdec}&lng={londegdec}&bbox=&center=";
+                               }
+                       ]
+               },
+               {
+                       "name": "topomapper",
+                       "links": [
+                               {
+                                       "type": "topo",
+                                       "url": 
"http://www.topomapper.com/index.html?zoom={osmzoom}&lat={latdegdec}&lon={londegdec}";
+                               }
+                       ]
+               },
+               {
+                       "name": "vpike-com",
+                       "links": [
+                               {
+                                       "type": "map",
+                                       "url": 
"http://www.vpike.com?e={latdegdec},{londegdec}:168.5994445130002::sv:0";
+                               }
+                       ]
+               },
+               {
+                       "name": "waze",
+                       "links": [
+                               {
+                                       "type": "map",
+                                       "url": 
"https://www.waze.com/livemap/?zoom={osmzoom}&lat={latdegdec}&lon={londegdec}";
+                               }
+                       ]
+               },
+               {
+                       "name": "wikimapia",
+                       "featured": true,
+                       "links": [
+                               {
+                                       "type": "map",
+                                       "url": 
"http://wikimapia.org/#lang={language}&lat={latdegdec}&lon={londegdec}&z={osmzoom}&m=w";
+                               },
+                               {
+                                       "type": "map",
+                                       "mobile": true,
+                                       "url": 
"http://wikimapia.org/m/#lang={language}&lat={latdegdec}&lon={londegdec}&z={osmzoom}&m=w";
+                               },
+                               {
+                                       "type": "satellite",
+                                       "url": 
"http://wikimapia.org/#lang={language}&lat={latdegdec}&lon={londegdec}&z={osmzoom}&m=b";
+                               },
+                               {
+                                       "type": "satellite",
+                                       "mobile": true,
+                                       "url": 
"http://wikimapia.org/m/#lang={language}&lat={latdegdec}&lon={londegdec}&z={osmzoom}&m=b";
+                               }
+                       ]
+               },
+               {
+                       "name": "wikiminiatlas",
+                       "links": [
+                               {
+                                       "type": "map",
+                                       "url": 
"https://wma.wmflabs.org/iframe.html?wma={latdegdec}_{londegdec}_700_500_{language}_{zoom}_en&globe=Earth&lang={language}&page={pagenamee}";
+                               }
+                       ]
+               },
+               {
+                       "name": "yandex-maps",
+                       "links": [
+                               {
+                                       "type": "map",
+                                       "url": 
"https://maps.yandex.com/?ll={londegdec},{latdegdec}&spn={span},{span}&l=map&pt={londegdec},{latdegdec}";
+                               },
+                               {
+                                       "type": "satellite",
+                                       "url": 
"https://maps.yandex.com/?ll={londegdec},{latdegdec}&spn={span},{span}&l=sat&pt={londegdec},{latdegdec}";
+                               }
+                       ]
+               }
+       ]
+}
diff --git a/i18n/en.json b/i18n/en.json
index 6d05cf2..cf69512 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -36,6 +36,41 @@
        "kartographer-specialmap-invalid-coordinates": "Invalid coordinates 
supplied",
        "kartographer.css": "/* CSS placed here will be applied to all pages 
with maps */",
        "kartographer.js": "/* Any JavaScript here will be loaded for all users 
on load of the map-containing pages */",
+       "kartographer-linktype-map": "Map",
+       "kartographer-linktype-satellite": "Satellite",
+       "kartographer-linktype-terrain": "Terrain",
+       "kartographer-linktype-topo": "Topological",
+       "kartographer-linktype-aerial": "Aerial",
+       "kartographer-linktype-aeronautical": "Aeronautical",
+       "kartographer-linktype-birds-eye": "Bird's Eye",
+       "kartographer-linktype-night-lights": "Night Lights",
+       "kartographer-linktype-other": "Other",
+       "kartographer-link-acme-mapper": "ACME Mapper",
+       "kartographer-link-apple-maps": "Apple Maps",
+       "kartographer-link-arctic-io": "Arctic.io",
+       "kartographer-link-bing-maps": "Bing Maps",
+       "kartographer-link-blue-marble-navigator": "Blue Marble Navigator",
+       "kartographer-link-flash-earth": "Flash Earth",
+       "kartographer-link-geabios": "GeaBios",
+       "kartographer-link-geonames": "GeoNames",
+       "kartographer-link-google-earth": "Google Earth",
+       "kartographer-link-google-maps": "Google Maps",
+       "kartographer-link-gps-visualizer": "GPS Visualizer",
+       "kartographer-link-here": "HERE",
+       "kartographer-link-mapquest": "MapQuest",
+       "kartographer-link-maptech": "MapTech",
+       "kartographer-link-nasa-world-wind": "NASA World Wind",
+       "kartographer-link-norkart-virtual-globe": "Norkart Virtual Globe",
+       "kartographer-link-open-street-map": "Open Street Map",
+       "kartographer-link-shaded-relief": "Shaded Relief",
+       "kartographer-link-skyvector": "SkyVector",
+       "kartographer-link-terraserver": "TerraServer",
+       "kartographer-link-topomapper": "Topomapper",
+       "kartographer-link-vpike-com": "Vpike.com",
+       "kartographer-link-waze": "Waze",
+       "kartographer-link-wikimapia": "Wikimapia",
+       "kartographer-link-wikiminiatlas": "WikiMiniAtlas",
+       "kartographer-link-yandex-maps": "Yandex.Maps",
        "leafletdraw-draw-handlers-circle-radius": "Radius",
        "leafletdraw-draw-handlers-circle-tooltip-start": "Click and drag to 
draw a circle",
        "leafletdraw-draw-handlers-marker-tooltip-start": "Click map to place a 
marker",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 6fb1565..7b01d9c 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -39,6 +39,41 @@
        "kartographer-specialmap-invalid-coordinates": "Displayed by 
Special:Map when no valid coordinates are supplied",
        "kartographer.css": "{{optional}}",
        "kartographer.js": "{{optional}}",
+       "kartographer-linktype-map": "Full screen map info sidebar - type of 
external link - map",
+       "kartographer-linktype-satellite": "Full screen map info sidebar - type 
of external link - satellite",
+       "kartographer-linktype-terrain": "Full screen map info sidebar - type 
of external link - terrain",
+       "kartographer-linktype-topo": "Full screen map info sidebar - type of 
external link - topo",
+       "kartographer-linktype-aerial": "Full screen map info sidebar - type of 
external link - aerial",
+       "kartographer-linktype-aeronautical": "Full screen map info sidebar - 
type of external link - aeronautical",
+       "kartographer-linktype-birds-eye": "Full screen map info sidebar - type 
of external link - birds-eye",
+       "kartographer-linktype-night-lights": "Full screen map info sidebar - 
type of external link - night-lights",
+       "kartographer-linktype-other": "Full screen map info sidebar - type of 
external link - other",
+       "kartographer-link-acme-mapper": "{{optional}}Full screen map info 
sidebar - external service name",
+       "kartographer-link-apple-maps": "{{optional}}Full screen map info 
sidebar - external service name",
+       "kartographer-link-arctic-io": "{{optional}}Full screen map info 
sidebar - external service name",
+       "kartographer-link-bing-maps": "{{optional}}Full screen map info 
sidebar - external service name",
+       "kartographer-link-blue-marble-navigator": "{{optional}}Full screen map 
info sidebar - external service name",
+       "kartographer-link-flash-earth": "{{optional}}Full screen map info 
sidebar - external service name",
+       "kartographer-link-geabios": "{{optional}}Full screen map info sidebar 
- external service name",
+       "kartographer-link-geonames": "{{optional}}Full screen map info sidebar 
- external service name",
+       "kartographer-link-google-earth": "{{optional}}Full screen map info 
sidebar - external service name",
+       "kartographer-link-google-maps": "{{optional}}Full screen map info 
sidebar - external service name",
+       "kartographer-link-gps-visualizer": "{{optional}}Full screen map info 
sidebar - external service name",
+       "kartographer-link-here": "{{optional}}Full screen map info sidebar - 
external service name",
+       "kartographer-link-mapquest": "{{optional}}Full screen map info sidebar 
- external service name",
+       "kartographer-link-maptech": "{{optional}}Full screen map info sidebar 
- external service name",
+       "kartographer-link-nasa-world-wind": "{{optional}}Full screen map info 
sidebar - external service name",
+       "kartographer-link-norkart-virtual-globe": "{{optional}}Full screen map 
info sidebar - external service name",
+       "kartographer-link-open-street-map": "{{optional}}Full screen map info 
sidebar - external service name",
+       "kartographer-link-shaded-relief": "{{optional}}Full screen map info 
sidebar - external service name",
+       "kartographer-link-skyvector": "{{optional}}Full screen map info 
sidebar - external service name",
+       "kartographer-link-terraserver": "{{optional}}Full screen map info 
sidebar - external service name",
+       "kartographer-link-topomapper": "{{optional}}Full screen map info 
sidebar - external service name",
+       "kartographer-link-vpike-com": "{{optional}}Full screen map info 
sidebar - external service name",
+       "kartographer-link-waze": "{{optional}}Full screen map info sidebar - 
external service name",
+       "kartographer-link-wikimapia": "{{optional}}Full screen map info 
sidebar - external service name",
+       "kartographer-link-wikiminiatlas": "{{optional}}Full screen map info 
sidebar - external service name",
+       "kartographer-link-yandex-maps": "{{optional}}Full screen map info 
sidebar - external service name",
        "leafletdraw-draw-handlers-circle-radius": "Label for circle 
radius\n{{Identical|Radius}}",
        "leafletdraw-draw-handlers-circle-tooltip-start": "Tooltip for how to 
start drawing a circle",
        "leafletdraw-draw-handlers-marker-tooltip-start": "Tooltip for how to 
place a marker",
diff --git a/includes/DataModuleLinks.php b/includes/DataModuleLinks.php
new file mode 100644
index 0000000..ce7ba1f
--- /dev/null
+++ b/includes/DataModuleLinks.php
@@ -0,0 +1,68 @@
+<?php
+/**
+ * ResourceLoader module providing extra data to the client-side.
+ *
+ * @file
+ * @ingroup Extensions
+ */
+
+namespace Kartographer;
+
+use FormatJson;
+use Language;
+use Parser;
+use ParserOptions;
+use ResourceLoader;
+use ResourceLoaderContext;
+use ResourceLoaderModule;
+use stdClass;
+use Title;
+
+class DataModuleLinks extends ResourceLoaderModule {
+
+       protected $origin = self::ORIGIN_USER_SITEWIDE;
+       protected $targets = array( 'desktop', 'mobile' );
+
+       public function getScript( ResourceLoaderContext $context ) {
+               return ResourceLoader::makeConfigSetScript( array(
+                       'wgKartographerExternalLinks' => 
$this->getExternalLinks( $context )
+               ) );
+       }
+
+       public function getExternalLinks( ResourceLoaderContext $context ) {
+
+               $st = FormatJson::parse(
+                       file_get_contents( __DIR__ . '/../externalLinks.json' ),
+                       FormatJson::TRY_FIXING | FormatJson::STRIP_COMMENTS
+               );
+
+               if ( !$st->isOK() ) {
+                       wfWarn( 'Unable to parse externalLinks.json' );
+                       return [];
+               }
+
+               $data = $st->getValue();
+               foreach ( $data->services as &$service ) {
+                       $service->name = $context->msg( 'kartographer-link-' . 
$service->name )->plain();
+
+                       foreach ( $service->links as &$link ) {
+                               $link->type = $context->msg( 
'kartographer-linktype-' . $link->type )->plain();
+                       }
+               }
+
+               return $data;
+       }
+
+       public function enableModuleContentVersion() {
+               return true;
+       }
+
+       /**
+        * @see ResourceLoaderModule::supportsURLLoading
+        *
+        * @return bool
+        */
+       public function supportsURLLoading() {
+               return false; // always use getScript() to acquire JavaScript 
(even in debug mode)
+       }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/311316
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I99e7d67c9296fe2e1a48a644e60de1ae550f3e59
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Kartographer
Gerrit-Branch: master
Gerrit-Owner: Yurik <yu...@wikimedia.org>
Gerrit-Reviewer: MaxSem <maxsem.w...@gmail.com>
Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to