aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhellekin <how@cepheide.org>2024-03-17 11:59:08 +0100
committerhellekin <how@cepheide.org>2024-03-17 11:59:08 +0100
commit87751ff172c110b18616d56ae9808979ef8f9b08 (patch)
tree02af7a1c785e1cd0345c06449ee014d29849176c
parent362ba18d975b7241222881441c1f0f6bbcedae1f (diff)
downloaddiscourse-umap-87751ff172c110b18616d56ae9808979ef8f9b08.tar.gz
Adapt plugin for UMAP
-rw-r--r--README.md12
-rw-r--r--plugin.rb4
2 files changed, 10 insertions, 6 deletions
diff --git a/README.md b/README.md
index 52cd9c9..feab932 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,9 @@
-discourse-openstreetmap
+discourse-umap
=======================
-> Discourse plugin to support OSM via URL Oneboxing
+> Discourse plugin to support OSM via UMAP URL Oneboxing
+
+_This is inspired by discourse-openstreetmap, but it covers umap URIs._
## Installation on top of Docker image
@@ -14,7 +16,7 @@ hooks:
cd: $home/plugins
cmd:
- mkdir -p plugins
- - git clone https://github.com/lidel/discourse-openstreetmap.git
+ - git clone https://code.cepheide.org/discourse-umap.git
```
Rebuild Discourse: `/var/discourse/launcher rebuild app`
@@ -23,7 +25,7 @@ Rebuild Discourse: `/var/discourse/launcher rebuild app`
### What URLs are oneboxed by this plugin?
- https://www.openstreetmap.org/?mlat=[Marker Latitude]&mlon=[Marker Longitude]#map=[Zoom Level]/[Latitude]/[Longitude]&layers=[Layer code]
+ https://umap.openstreetmap.{fr,org}/{fr,en}/map/[map-name]?mlat=[Marker Latitude]&mlon=[Marker Longitude]#map=[Zoom Level]/[Latitude]/[Longitude]&layers=[Layer code]
will be onboxed as a mini-map:
@@ -36,6 +38,8 @@ Sure you can! In past it was done by this plugin, but there is now an `allowed i
Something to keep in mind: embedding of OSM `iframe` is enabled by default only for HTTPS URL. This means if it does not work for you, change `<iframe src=http://www.openstreetmap.org/export/embed.html?(..)` to have `src=https://` instead.
+
+
> ![iframe-example](https://user-images.githubusercontent.com/157609/31852829-4c23c4f2-b67f-11e7-8cd3-f0d4c14bf93c.png)
### Is this all there is? I want more OSM integration!
diff --git a/plugin.rb b/plugin.rb
index 0d15c87..57c9270 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -9,14 +9,14 @@ class Onebox::Engine::OpenStreetMapOnebox
@@width = 425
@@height = 350
@@tile_size = 256
- @@REGEX = /^https?:\/\/(?:www\.)openstreetmap\.org\/.*#map=([\d\.]+)\/([-\d\.]+)\/([-\d\.]+)/
+ @@REGEX = /^https?:\/\/umap\.openstreetmap\.fr/.*#map=([\d\.]+)\/([-\d\.]+)\/([-\d\.]+)/
# enable oneboxing permalinks (http://wiki.openstreetmap.org/wiki/Permalink) into iframes
matches_regexp(@@REGEX)
def to_html
zoom, lat, lon = @url.match(@@REGEX).captures
- iframe_url = "//www.openstreetmap.org/export/embed.html?bbox=#{get_bbox(lat.to_f, lon.to_f, zoom.to_i)}"
+ iframe_url = "//umap.openstreetmap.fr/fr/map?bbox=#{get_bbox(lat.to_f, lon.to_f, zoom.to_i)}"
if marker = @url.match(/mlat=([-\d\.]+).+mlon=([-\d\.]+)/)
mlat, mlon = marker.captures