maplibre-preview 1.0.0 → 1.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df12e7c5527319ba509cd5640dd3af10977259fcfc1272aeb53511d298670caa
4
- data.tar.gz: eb0ef8cf653b812c7b29c99cbf69848b7f1ab71d34ba5718da5bf84ac0c6b9f1
3
+ metadata.gz: 5e4e645edbcdd94a6633c742b4e5f17a3e49939d5b62dd1775b2b792acba55d8
4
+ data.tar.gz: 56e81ddd213236c6f4aca3c62d2dc957ce7073fe7b94f0dd0c9a394e482a9ba8
5
5
  SHA512:
6
- metadata.gz: e7a98ded840731605fd20f1dd17fff9d0d2957f70c5f08aa24fd3cb4aa6b790f9b37445e23bb44096d85c2dfd6e77c5715c532dfb10332f1d0370273667bab9c
7
- data.tar.gz: e51939f434f6535a0ba22226fd9b3721cc3b953353d0401b87aab2536c6a059cfa95f1997f2be79cfeccc2e52b020f6c9f80504e0ec1dfbf9835d29b6fabade2
6
+ metadata.gz: 0d90632acaeef88dadbc8058e1499fe1dc204b79492c308076fe96ae472c37d0b51fafe118307d3804645899635cf8600bde73f2d9dc47690bfbedbeeebf2fb8
7
+ data.tar.gz: 45104ec1339511744bc7ae24be029368c7048661cd0484d7b0c8b928c183a894bb3582078048678d08576583406b215551e5fb5474f7977b61bac5480c8c7094
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
- render_maplibre_preview
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
- render_maplibre_preview
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
- ### Helper Methods
137
+ ### Template Integration
138
138
 
139
- | Method | Description | Parameters |
140
- |--------|-------------|------------|
141
- | `render_maplibre_preview` | Render complete map development interface | None |
142
- | `render_map_layout` | Render map layout only | None |
143
- | `style_url` | Get current style URL from params | None |
144
- | `should_show_map?` | Check if map should be displayed | None |
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
- render_maplibre_preview
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
- render_maplibre_preview
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
- render_maplibre_preview
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
- render_maplibre_preview
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
- render_maplibre_preview
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
- render_maplibre_preview
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
- | `render_maplibre_preview` | Рендеринг полного интерфейса разработки карт | Нет |
142
- | `render_map_layout` | Рендеринг только макета карты | Нет |
143
- | `style_url` | Получение текущего URL стиля из параметров | Нет |
144
- | `should_show_map?` | Проверка, должна ли отображаться карта | Нет |
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
- render_maplibre_preview
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
- render_maplibre_preview
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
- render_maplibre_preview
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
- render_maplibre_preview
305
+ slim :maplibre_map, layout: :maplibre_layout
306
306
  end
307
307
  end
308
308
  ```
@@ -1,3 +1,3 @@
1
1
  module MapLibrePreview
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.1'
3
3
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'sinatra/base'
4
4
  require 'slim'
5
- require 'rack'
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
- # Rack middleware for serving static JS files from gem
14
- class StaticMiddleware
15
- def initialize(app)
16
- @app = app
17
- @gem_public_path = File.expand_path('maplibre-preview/public', __dir__)
18
- end
19
-
20
- def call(env)
21
- request = Rack::Request.new(env)
22
-
23
- if request.path.match?(%r{^/js/})
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
- private
31
-
32
- def serve_js_file(path)
33
- file_path = File.join(@gem_public_path, path)
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
- app.helpers Helpers
47
- app.use StaticMiddleware
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
- settings.set :views, gem_views_path
68
- slim(:map_layout)
69
- ensure
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 :map, layout: :map_layout, locals: { options: {} }
60
+ slim :maplibre_map, layout: :maplibre_layout, locals: { options: {} }
97
61
  end
98
62
 
99
63
  private
@@ -49,4 +49,4 @@ RSpec.describe MapLibrePreview do
49
49
  expect(test_app.settings.maplibre_preview_options).to be_a(Hash)
50
50
  end
51
51
  end
52
- end
52
+ end
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.0.0
4
+ version: 1.1.1
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-09-29 00:00:00.000000000 Z
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/map.slim
166
- - lib/maplibre-preview/views/map_layout.slim
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
@@ -172,7 +172,7 @@ licenses:
172
172
  metadata:
173
173
  homepage_uri: https://github.com/artyomb/maplibre-preview
174
174
  source_code_uri: https://github.com/artyomb/maplibre-preview
175
- changelog_uri: https://github.com/artyomb/maplibre-preview/blob/main/CHANGELOG.md
175
+ changelog_uri: https://github.com/artyomb/maplibre-preview/blob/master/CHANGELOG.md
176
176
  post_install_message:
177
177
  rdoc_options: []
178
178
  require_paths: