maplibre-preview 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +13 -13
- data/docs/README_RU.md +13 -13
- data/lib/maplibre-preview/version.rb +1 -1
- data/lib/maplibre-preview.rb +23 -59
- data/spec/maplibre_preview_spec.rb +1 -1
- metadata +4 -4
- /data/lib/maplibre-preview/views/{map_layout.slim → maplibre_layout.slim} +0 -0
- /data/lib/maplibre-preview/views/{map.slim → maplibre_map.slim} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eb134207de2f2a8569ae8cfed678aa2fff2bf1830445b1fcfbc91aa7425a31b
|
4
|
+
data.tar.gz: fe069e3cee94b2be2ccbca438b900829feb1e1bdbfa0f3223dacafde8f7d813f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff02d878106be03c989ceff9851832c2d42a3745b338ffc8491b47b7694a81f48632eb87211bb82d73306d8d5ba959b10b61ed0abd982c8d70307544aff98995
|
7
|
+
data.tar.gz: aca536c781206ce0d75234aa924e663429db495c84478b5742aa1074699bc2618aab48f34236006eb694c9599f3f52bf5b299e17751eb83ba2575bd266f738a9
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [1.1.0] - 2025-10-01
|
4
|
+
|
5
|
+
### Refactored
|
6
|
+
- **Simplified architecture** with streamlined Sinatra extension pattern
|
7
|
+
- **Consolidated code** into single `lib/maplibre-preview.rb` file
|
8
|
+
- **Removed helper methods** in favor of direct Slim template calls
|
9
|
+
- **Updated template names** to `maplibre_map` and `maplibre_layout` to avoid conflicts
|
10
|
+
- **Streamlined Sinatra extension** with prepend modules for static assets and templates
|
11
|
+
|
12
|
+
### Technical Changes
|
13
|
+
- **Removed StaticMiddleware** in favor of prepend-based static asset serving
|
14
|
+
- **Removed Helpers module** with helper methods
|
15
|
+
- **Direct route integration** using `slim :maplibre_map, layout: :maplibre_layout`
|
16
|
+
- **Simplified file structure** with all core functionality in main file
|
17
|
+
- **Improved template resolution** using `__dir__` context for gem paths
|
18
|
+
|
3
19
|
## [1.0.0] - 2025-09-29
|
4
20
|
|
5
21
|
### Added
|
data/README.md
CHANGED
@@ -58,7 +58,7 @@ class MyApp < Sinatra::Base
|
|
58
58
|
register MapLibrePreview::Extension
|
59
59
|
|
60
60
|
get '/map' do
|
61
|
-
|
61
|
+
slim :maplibre_map, layout: :maplibre_layout
|
62
62
|
end
|
63
63
|
end
|
64
64
|
```
|
@@ -76,7 +76,7 @@ http://localhost:9292/map?style_url=https://example.com/style.json
|
|
76
76
|
```ruby
|
77
77
|
get '/map' do
|
78
78
|
params[:style_url] = 'https://example.com/style.json'
|
79
|
-
|
79
|
+
slim :maplibre_map, layout: :maplibre_layout
|
80
80
|
end
|
81
81
|
```
|
82
82
|
|
@@ -134,14 +134,14 @@ The gem uses fixed configurations for optimal compatibility:
|
|
134
134
|
register MapLibrePreview::Extension
|
135
135
|
```
|
136
136
|
|
137
|
-
###
|
137
|
+
### Template Integration
|
138
138
|
|
139
|
-
|
140
|
-
|
141
|
-
|
|
142
|
-
|
143
|
-
| `
|
144
|
-
| `
|
139
|
+
The gem provides Slim templates that can be used directly in your routes:
|
140
|
+
|
141
|
+
| Template | Description | Usage |
|
142
|
+
|----------|-------------|-------|
|
143
|
+
| `maplibre_map` | Main map interface template | `slim :maplibre_map, layout: :maplibre_layout` |
|
144
|
+
| `maplibre_layout` | HTML layout with external dependencies | Used as layout for map template |
|
145
145
|
|
146
146
|
### Standalone Application
|
147
147
|
|
@@ -270,7 +270,7 @@ class MyApp < Sinatra::Base
|
|
270
270
|
register MapLibrePreview::Extension
|
271
271
|
|
272
272
|
get '/map' do
|
273
|
-
|
273
|
+
slim :maplibre_map, layout: :maplibre_layout
|
274
274
|
end
|
275
275
|
end
|
276
276
|
```
|
@@ -283,7 +283,7 @@ class MyApp < Sinatra::Base
|
|
283
283
|
|
284
284
|
get '/map' do
|
285
285
|
# Style URL passed via params[:style_url]
|
286
|
-
|
286
|
+
slim :maplibre_map, layout: :maplibre_layout
|
287
287
|
end
|
288
288
|
end
|
289
289
|
```
|
@@ -296,13 +296,13 @@ class MyApp < Sinatra::Base
|
|
296
296
|
|
297
297
|
get '/map' do
|
298
298
|
# Uses params[:style_url] if provided
|
299
|
-
|
299
|
+
slim :maplibre_map, layout: :maplibre_layout
|
300
300
|
end
|
301
301
|
|
302
302
|
get '/terrain' do
|
303
303
|
# Set style URL via params
|
304
304
|
params[:style_url] = 'https://example.com/terrain-style.json'
|
305
|
-
|
305
|
+
slim :maplibre_map, layout: :maplibre_layout
|
306
306
|
end
|
307
307
|
end
|
308
308
|
```
|
data/docs/README_RU.md
CHANGED
@@ -58,7 +58,7 @@ class MyApp < Sinatra::Base
|
|
58
58
|
register MapLibrePreview::Extension
|
59
59
|
|
60
60
|
get '/map' do
|
61
|
-
|
61
|
+
slim :maplibre_map, layout: :maplibre_layout
|
62
62
|
end
|
63
63
|
end
|
64
64
|
```
|
@@ -76,7 +76,7 @@ http://localhost:9292/map?style_url=https://example.com/style.json
|
|
76
76
|
```ruby
|
77
77
|
get '/map' do
|
78
78
|
params[:style_url] = 'https://example.com/style.json'
|
79
|
-
|
79
|
+
slim :maplibre_map, layout: :maplibre_layout
|
80
80
|
end
|
81
81
|
```
|
82
82
|
|
@@ -134,14 +134,14 @@ Gem использует фиксированные настройки:
|
|
134
134
|
register MapLibrePreview::Extension
|
135
135
|
```
|
136
136
|
|
137
|
-
###
|
137
|
+
### Интеграция шаблонов
|
138
138
|
|
139
|
-
|
140
|
-
|
141
|
-
|
|
142
|
-
|
143
|
-
| `
|
144
|
-
| `
|
139
|
+
Gem предоставляет Slim шаблоны, которые можно использовать напрямую в маршрутах:
|
140
|
+
|
141
|
+
| Шаблон | Описание | Использование |
|
142
|
+
|--------|----------|---------------|
|
143
|
+
| `maplibre_map` | Основной шаблон интерфейса карты | `slim :maplibre_map, layout: :maplibre_layout` |
|
144
|
+
| `maplibre_layout` | HTML макет с внешними зависимостями | Используется как макет для шаблона карты |
|
145
145
|
|
146
146
|
### Автономное приложение
|
147
147
|
|
@@ -270,7 +270,7 @@ class MyApp < Sinatra::Base
|
|
270
270
|
register MapLibrePreview::Extension
|
271
271
|
|
272
272
|
get '/map' do
|
273
|
-
|
273
|
+
slim :maplibre_map, layout: :maplibre_layout
|
274
274
|
end
|
275
275
|
end
|
276
276
|
```
|
@@ -283,7 +283,7 @@ class MyApp < Sinatra::Base
|
|
283
283
|
|
284
284
|
get '/map' do
|
285
285
|
# URL стиля передается через params[:style_url]
|
286
|
-
|
286
|
+
slim :maplibre_map, layout: :maplibre_layout
|
287
287
|
end
|
288
288
|
end
|
289
289
|
```
|
@@ -296,13 +296,13 @@ class MyApp < Sinatra::Base
|
|
296
296
|
|
297
297
|
get '/map' do
|
298
298
|
# Использует params[:style_url] если предоставлен
|
299
|
-
|
299
|
+
slim :maplibre_map, layout: :maplibre_layout
|
300
300
|
end
|
301
301
|
|
302
302
|
get '/terrain' do
|
303
303
|
# Устанавливаем URL стиля через params
|
304
304
|
params[:style_url] = 'https://example.com/terrain-style.json'
|
305
|
-
|
305
|
+
slim :maplibre_map, layout: :maplibre_layout
|
306
306
|
end
|
307
307
|
end
|
308
308
|
```
|
data/lib/maplibre-preview.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'sinatra/base'
|
4
4
|
require 'slim'
|
5
|
-
|
5
|
+
require_relative 'maplibre-preview/version'
|
6
6
|
|
7
7
|
module MapLibrePreview
|
8
8
|
# Fixed versions for guaranteed compatibility
|
@@ -10,72 +10,36 @@ module MapLibrePreview
|
|
10
10
|
CONTOUR_VERSION = '0.1.0'
|
11
11
|
D3_VERSION = '7'
|
12
12
|
|
13
|
-
#
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
serve_js_file(request.path)
|
25
|
-
else
|
26
|
-
@app.call(env)
|
13
|
+
# Sinatra extension for map development tools
|
14
|
+
module Extension
|
15
|
+
module AddPublic
|
16
|
+
def static!(options={})
|
17
|
+
super
|
18
|
+
path = File.expand_path "#{__dir__}/maplibre-preview/public/#{Sinatra::Base::URI_INSTANCE.unescape(request.path_info)}"
|
19
|
+
return unless File.file?(path)
|
20
|
+
|
21
|
+
env['sinatra.static_file'] = path
|
22
|
+
cache_control(*settings.static_cache_control) if settings.static_cache_control?
|
23
|
+
send_file path, options.merge(disposition: nil)
|
27
24
|
end
|
28
25
|
end
|
29
26
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
if File.exist?(file_path) && File.file?(file_path)
|
36
|
-
[200, {'Content-Type' => 'application/javascript'}, [File.read(file_path)]]
|
37
|
-
else
|
38
|
-
[404, {'Content-Type' => 'text/plain'}, ['File not found']]
|
27
|
+
module FindTemplate
|
28
|
+
def find_template(views, name, engine, &block)
|
29
|
+
super
|
30
|
+
yield File.expand_path "#{__dir__}/maplibre-preview/views/#{name}.#{@preferred_extension}"
|
39
31
|
end
|
40
32
|
end
|
41
|
-
end
|
42
33
|
|
43
|
-
# Sinatra extension for map development tools
|
44
|
-
module Extension
|
45
34
|
def self.registered(app)
|
46
|
-
|
47
|
-
|
35
|
+
Sinatra::Templates.prepend FindTemplate
|
36
|
+
Sinatra::Base.prepend AddPublic
|
37
|
+
app.set :static, true
|
48
38
|
app.set :maplibre_preview_options, {}
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# Helper methods for map development tools
|
53
|
-
module Helpers
|
54
|
-
def render_maplibre_preview
|
55
|
-
gem_views_path = File.expand_path('maplibre-preview/views', __dir__)
|
56
|
-
original_views = settings.views
|
57
|
-
settings.set :views, gem_views_path
|
58
|
-
slim(:map, layout: :map_layout)
|
59
|
-
ensure
|
60
|
-
settings.set :views, original_views
|
61
|
-
end
|
62
|
-
|
63
|
-
def render_map_layout
|
64
|
-
gem_views_path = File.expand_path('maplibre-preview/views', __dir__)
|
65
|
-
original_views = settings.views
|
66
39
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
settings.set :views, original_views
|
71
|
-
end
|
72
|
-
|
73
|
-
def style_url
|
74
|
-
params[:style_url]
|
75
|
-
end
|
76
|
-
|
77
|
-
def should_show_map?
|
78
|
-
!!(params[:style] || params[:style_url] || params[:source])
|
40
|
+
app.get '/maplibre_preview' do
|
41
|
+
slim :maplibre_map, layout: :maplibre_layout
|
42
|
+
end
|
79
43
|
end
|
80
44
|
end
|
81
45
|
|
@@ -93,7 +57,7 @@ module MapLibrePreview
|
|
93
57
|
end
|
94
58
|
|
95
59
|
get '/map' do
|
96
|
-
slim :
|
60
|
+
slim :maplibre_map, layout: :maplibre_layout, locals: { options: {} }
|
97
61
|
end
|
98
62
|
|
99
63
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maplibre-preview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Ludov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -162,8 +162,8 @@ files:
|
|
162
162
|
- lib/maplibre-preview/public/js/contour.js
|
163
163
|
- lib/maplibre-preview/public/js/filters.js
|
164
164
|
- lib/maplibre-preview/version.rb
|
165
|
-
- lib/maplibre-preview/views/
|
166
|
-
- lib/maplibre-preview/views/
|
165
|
+
- lib/maplibre-preview/views/maplibre_layout.slim
|
166
|
+
- lib/maplibre-preview/views/maplibre_map.slim
|
167
167
|
- spec/maplibre_preview_spec.rb
|
168
168
|
- spec/spec_helper.rb
|
169
169
|
homepage: https://github.com/artyomb/maplibre-preview
|
File without changes
|
File without changes
|