jekyll-maplibre 1.0.pre.alpha.1 → 1.0.0.pre.beta.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ab808189fd4b1d54aab12429599ebf2cef5ef6579e315fb5eeb8e409324d0e7
4
- data.tar.gz: 64ee05a010230a5712494c45016fc400f871ad3211d64e576e0df66da780ca55
3
+ metadata.gz: bda1b326ba691f9fcdc40264755193382fa959e6f9eaf4f91b340436669efca9
4
+ data.tar.gz: e57cdae7389bbe93e10631ee311bdf54ce80577c738438346206ecdc2db67435
5
5
  SHA512:
6
- metadata.gz: b6c0ca7186c6e4fa6c8765faddf510bd38f44677e254431e8e1fe4a7214e8d8e0d9aa2cc5a445edbe8af934109fcd1167448d9aca8c547b994a16288bf3601e2
7
- data.tar.gz: 746f400184fd527e050f6bc35c299ff992079b4c1ce10ba6c2a7a49f1ba17931acdbd782724c75ced778fe5113afd2ebc2e2c5620d5852d597ae5177e11e5183
6
+ metadata.gz: b70fd7fc703cb5dba7ac03515447b7244b2dca47209b113a6fac794c521ea8a83aeb47845496e37e492fde5cd4c780a5b6084efeedc44e51f9611929c59b962c
7
+ data.tar.gz: 2f929ad4870f52bb9cc53ee80c7e7a629594488e003d60f33817cb3439f5f9a1014fa986eda94f59d5cbac91f94a721433947b469018a4cee43a3e44255b34bf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## HEAD
2
+
3
+ ## 1.0.0-beta.1
4
+
5
+ * fix in geojson method
6
+ * fix more bugs
7
+ * improve documentation
8
+ * document bugs in [README.md](./README.md)
9
+
1
10
  ## 1.0.0-alpha.1
2
11
 
3
12
  * fork jekyll-maps to create jekyll-maplibre
data/README.md CHANGED
@@ -27,7 +27,7 @@ plugins:
27
27
 
28
28
  3. Also prepare configuration specific for `jekyll-maplibre` in your site's `_config.yml`:
29
29
 
30
- ```
30
+ ```yml
31
31
  maplibre:
32
32
  width: 600
33
33
  height: 400
@@ -56,7 +56,7 @@ maplibre:
56
56
 
57
57
  4. Prepare assets to display maps with MapLibre GL JS:
58
58
 
59
- The required assets depend on your specific map configuration. With cloud hosting (untested), it may be sufficient to only configure the `style` property above.
59
+ The required assets depend on your specific map configuration. With cloud hosting, it is sufficient to only configure the `style` property above.
60
60
 
61
61
  For self-hosted maps, you need to host and configure the following resources:
62
62
 
@@ -110,12 +110,30 @@ Example assets sources:
110
110
  - [maplibre-gl.css](https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.css)
111
111
  - [OSM-Liberty-layers.json extracted from OSM Liberty style.json](https://github.com/maputnik/osm-liberty/blob/f2c798e80dc11d47613e3b093881b4d37a5fde8e/style.json)
112
112
 
113
+ Those files are distributed as part of the [assets on Github](https://github.com/rriemann/jekyll-maplibre/releases/tag/1.0-alpha.1).
114
+
115
+ It is also possible to self-host everything except the openmaptiles source and link the latter to mbtiles in the cloud, i.e.:
116
+
117
+ ~~~yml
118
+ maplibre:
119
+ sources:
120
+ openmaptiles:
121
+ type: vector
122
+ url: https://api.maptiler.com/tiles/v3-openmaptiles/tiles.json?key=[REPLACE WITH OWN API KEY]
123
+ attribution: © <a href='https://openstreetmap.org'>OpenStreetMap contributors</a>
124
+ ...
125
+ ~~~
126
+
113
127
  5. Load MapLibre GL JS CSS in `<head>`
114
128
 
115
129
  The file `maplibre-gl.css` should be linked in your `<head>` or included in another css file.
116
130
 
117
131
  Many Jeyll templates provide for a file `_includes/my-head.html` or `_includes/custom-head.html` (check the docs). If so, add a line such as `<link href="/assets/maps/maplibre-gl.css" rel="stylesheet">`.
118
132
 
133
+ 6. Check your Content Security Policy (CSP) headers
134
+
135
+ Read more about CSP here: <https://maplibre.org/maplibre-gl-js/docs/#csp-directives>
136
+
119
137
  ## Usage
120
138
 
121
139
  ### MapLibre Tag
@@ -145,6 +163,8 @@ Example with all attributes and flags:
145
163
  {% maplibre id="custom-id" width="100%" height="200" class="custom-class" style="clear: both;" zoom="10" center="4.300,50.800" description="<a href='#'>Popup Link</a>" longitude="4.300" latitude="50.800" no_cluster %}
146
164
  ```
147
165
 
166
+ **Hint:** Icons/sprites work with the dev server only with `localhost` but not with `127.0.0.1`!
167
+
148
168
  ### Data Source
149
169
 
150
170
  Jekyll MapLibre offers several ways to add markers to the map. While in principle MapLibre GL JS allows to add all kinds of data other than markers to the map, more configuration must be added to the style definition.
@@ -241,10 +261,6 @@ With `where` and `where_exp` (see [documentation](https://jekyllrb.com/docs/liqu
241
261
 
242
262
  Clusters are enabled by default. Use the flag `no_cluster` in the tag to disable clusters.
243
263
 
244
- ## Examples
245
-
246
- Want to see Jekyll MapLibre in action? Check out [Demo Page](https://ayastreb.me/jekyll-maps/#examples)!
247
-
248
264
  ## Contributing
249
265
 
250
266
  1. Fork it (https://github.com/rriemann/jekyll-maplibre/fork)
@@ -262,6 +278,7 @@ The following issues and limitation require contribution:
262
278
  - add more examples on how to generate geojson data from Jekyll collections/data.
263
279
  - Jekyll-Maps has spec tests (still in this repo) – make them work again with Jekyll MapLibre
264
280
  - add flag to switch popups to open by default (without click to open)
281
+ - fix bug: `Liquid Exception: stack level too deep in [your file].md/#excerpt` (current work around, use maplibre tags only after the excerpt `\<!--more--\>`
265
282
 
266
283
  ## Similar Software
267
284
 
@@ -44,11 +44,17 @@ module Jekyll
44
44
  zoom = @options[:attributes][:zoom] || context.registers[:site].config.dig('maplibre', 'zoom') || DEFAULT_ZOOM
45
45
 
46
46
  @options[:attributes][:id] ||= "maplibre-#{SecureRandom.uuid}"
47
-
48
- template = ERB.new File.read(File.expand_path("maplibre.html.erb", __dir__))
47
+
48
+ # binding.irb
49
49
  template.result(binding)
50
50
  end
51
51
 
52
+ private
53
+ # @return [Object] ERB instance
54
+ def template
55
+ @@template ||= ERB.new File.read(File.expand_path("maplibre.html.erb", __dir__))
56
+ end
57
+
52
58
  private
53
59
  # @return [String] absolute URL for sprite property pursuant to Mapbox Style Spec
54
60
  def sprite_url(context)
@@ -140,7 +146,7 @@ module Jekyll
140
146
  #
141
147
  # @return [Array,nil] LngLat array or nil
142
148
  def center(context)
143
- @options[:attributes][:center]&.map{|v| v.to_f} || geojson(context).dig(:features, 0, :geometry, :coordinates)
149
+ @options[:attributes][:center]&.map{|v| v.to_f} || geojson(context)&.dig(:features, 0, :geometry, :coordinates)
144
150
  end
145
151
 
146
152
  private
@@ -187,15 +193,16 @@ module Jekyll
187
193
  }
188
194
  }],
189
195
  }
190
- elsif (context.registers[:page]["geojson"]&.is_a?(String) and context.registers[:page]["geojson"]&.end_with?(".json")) or
191
- context.registers[:page]["geojson"]["type"] == "FeatureCollection" then
196
+ elsif context.registers[:page]["geojson"].is_a? String and context.registers[:page]["geojson"].end_with?(".json") then
197
+ context.registers[:page]["geojson"]
198
+ elsif context.registers[:page].to_hash.dig("geojson", "type") == "FeatureCollection" then
192
199
  context.registers[:page]["geojson"].deep_symbolize_keys
193
- elsif context.registers[:page]["geojson"]["type"] == "Feature" then
200
+ elsif context.registers[:page].to_hash.dig("geojson", "type") == "Feature" then
194
201
  {
195
202
  type: "FeatureCollection",
196
203
  features: [context.registers[:page]["geojson"].deep_symbolize_keys]
197
204
  }
198
- elsif context.registers[:page]["location"]["latitude"] and context.registers[:page]["location"]["longitude"] then
205
+ elsif ((lat = context.registers[:page].to_hash.dig("location", "latitude")) and (lon = context.registers[:page].to_hash.dig("location", "longitude"))) then
199
206
  {
200
207
  type: "FeatureCollection",
201
208
  features: [{
@@ -203,9 +210,9 @@ module Jekyll
203
210
  # properties: {}.select {|key, value| !value.nil? },
204
211
  geometry: {
205
212
  type: "Point",
206
- coordinates: [ # first long, that lat
207
- context.registers[:page]["location"]["longitude"].to_f,
208
- context.registers[:page]["location"]["latitude"].to_f,
213
+ coordinates: [
214
+ # first lon, that lat
215
+ lon.to_f, lat.to_f
209
216
  ]
210
217
  }
211
218
  }]
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module MapLibre
3
- VERSION = "1.0-alpha.1".freeze
3
+ VERSION = "1.0.0-beta.1".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-maplibre
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.pre.alpha.1
4
+ version: 1.0.0.pre.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatoliy Yastreb, Robert Riemann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-27 00:00:00.000000000 Z
11
+ date: 2024-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll