From 99fd0a585d95d5b5bd985c60530db8cd0c0beec2 Mon Sep 17 00:00:00 2001 From: evazion Date: Tue, 16 Feb 2021 01:25:00 -0600 Subject: [PATCH] ip addresses: replace Google Maps with Bing Maps. Replace the Google map on the IP address show page with a Bing map. Bing doesn't require an API key, which makes it easier to deploy. The Google Maps API requires to you to whitelist the IP addresses and domains you plan to use with your API key, which is inconvenient for development because it means maps won't display unless you whitelist your development IPs. --- app/helpers/ip_addresses_helper.rb | 6 ++++-- app/views/ip_addresses/_info.html.erb | 2 +- config/danbooru_default_config.rb | 6 ------ config/docker/docker-compose.test.yaml | 1 - 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/app/helpers/ip_addresses_helper.rb b/app/helpers/ip_addresses_helper.rb index 61a833f22..cee60fec9 100644 --- a/app/helpers/ip_addresses_helper.rb +++ b/app/helpers/ip_addresses_helper.rb @@ -1,11 +1,13 @@ module IpAddressesHelper - def embedded_google_map(location, width, height, api_key: Danbooru.config.google_maps_api_key) + # https://www.bing.com/maps/embed-a-map + # https://docs.microsoft.com/en-us/bingmaps/articles/create-a-custom-map-url + def embedded_map(lat, long, width, height, zoom: 10) tag.iframe( width: width, height: height, frameborder: 0, allowfullscreen: true, - src: "https://www.google.com/maps/embed/v1/search?q=#{location}&key=#{api_key}" + src: "https://www.bing.com/maps/embed?w=#{width}&h=#{height}&cp=#{lat}~#{long}&lvl=#{zoom}" ) end end diff --git a/app/views/ip_addresses/_info.html.erb b/app/views/ip_addresses/_info.html.erb index 968369499..7cc2f5657 100644 --- a/app/views/ip_addresses/_info.html.erb +++ b/app/views/ip_addresses/_info.html.erb @@ -71,5 +71,5 @@
- <%= embedded_google_map("#{ip_info.dig(:location, :latitude)},#{ip_info.dig(:location, :longitude)}", 300, 200) %> + <%= embedded_map(ip_info.dig(:location, :latitude), ip_info.dig(:location, :longitude), 300, 200) %>
diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index 9e890c39f..98a4d1710 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -486,12 +486,6 @@ module Danbooru [] end - # API key for Google Maps. Used for embedding maps on IP address lookup pages. - # Generate at https://console.developers.google.com/apis/credentials - def google_maps_api_key - nil - end - # Cloudflare API token. Used to purge URLs from Cloudflare's cache when a # post is replaced. The token must have 'zone.cache_purge' permissions. # https://support.cloudflare.com/hc/en-us/articles/200167836-Managing-API-Tokens-and-Keys diff --git a/config/docker/docker-compose.test.yaml b/config/docker/docker-compose.test.yaml index 1a14ce0f1..42903d578 100644 --- a/config/docker/docker-compose.test.yaml +++ b/config/docker/docker-compose.test.yaml @@ -34,7 +34,6 @@ services: - DANBOORU_RAKISMET_KEY - DANBOORU_RAKISMET_URL - DANBOORU_IP_REGISTRY_API_KEY - - DANBOORU_GOOGLE_MAPS_API_KEY depends_on: - postgres user: root