site_maps 0.1.1 → 0.1.2
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/.tool-versions +1 -1
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +3 -3
- data/README.md +16 -0
- data/lib/site_maps/middleware.rb +22 -1
- data/lib/site_maps/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e5ccf5d0f2a84dbe95a4848980ac22b8863244e05e5d0a93bd4007bce78e9c48
|
|
4
|
+
data.tar.gz: 71392ff9ab92e741bb58dfc190f2f29f012682b256347043ab7f686f3e631572
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4824b2c466af7db2f1e1ba521045a75dbf52dcbcb528cdcce7417cfa797b0c2aa3b516645963a375f9e82bc07d91cda1522eaabbaa80c67028c2fbf2b5131b58
|
|
7
|
+
data.tar.gz: fac8d331b39a52baafc9831aa424060da7d7e2666a54bfea14e2c2b776d661efd2e91aeb2149d11aa02a0ee1a52049986708c343380470d32e7189034fe14539
|
data/.tool-versions
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
ruby 3.
|
|
1
|
+
ruby 3.2.2
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## 0.1.2 - 2026-07-17
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- Middleware `aliases:` option: maps an incoming public request path to another public request path (applied before the prefix options), so the same content can be served at multiple locations without a redirect — e.g. `aliases: { "/sitemap.xml" => "/sitemap_index.xml" }`. Accepts a hash or a callable returning a hash.
|
|
11
|
+
|
|
7
12
|
## 0.1.1 - 2026-05-12
|
|
8
13
|
|
|
9
14
|
### Fixed
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
site_maps (0.1.
|
|
4
|
+
site_maps (0.1.2)
|
|
5
5
|
builder (~> 3.0)
|
|
6
6
|
concurrent-ruby (>= 1.1)
|
|
7
7
|
rack (>= 2.0)
|
|
@@ -37,7 +37,7 @@ GEM
|
|
|
37
37
|
bigdecimal (4.1.1)
|
|
38
38
|
builder (3.3.0)
|
|
39
39
|
coderay (1.1.3)
|
|
40
|
-
concurrent-ruby (1.3.
|
|
40
|
+
concurrent-ruby (1.3.7)
|
|
41
41
|
crack (1.0.1)
|
|
42
42
|
bigdecimal
|
|
43
43
|
rexml
|
|
@@ -126,7 +126,7 @@ GEM
|
|
|
126
126
|
addressable (>= 2.8.0)
|
|
127
127
|
crack (>= 0.3.2)
|
|
128
128
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
129
|
-
zeitwerk (2.
|
|
129
|
+
zeitwerk (2.8.2)
|
|
130
130
|
|
|
131
131
|
PLATFORMS
|
|
132
132
|
x86_64-linux
|
data/README.md
CHANGED
|
@@ -269,6 +269,7 @@ Use these when the public URL path and the storage path differ:
|
|
|
269
269
|
|---|---|---|
|
|
270
270
|
| `public_prefix:` | Public URL has an extra prefix → strip it to find the file | Stored at `/sitemap.xml`, served at `/sitemaps/tenant/sitemap.xml` |
|
|
271
271
|
| `storage_prefix:` | Storage has an extra prefix → prepend it to the public path | Stored at `/sitemaps/tenant/sitemap.xml`, served at `/sitemap.xml` |
|
|
272
|
+
| `aliases:` | Serve one public path's content at another public path (no redirect) | `/sitemap.xml` serves the content of `/sitemap_index.xml` |
|
|
272
273
|
|
|
273
274
|
```ruby
|
|
274
275
|
# Sitemaps stored at /sitemaps/{slug}/sitemap.xml, served at /sitemap.xml
|
|
@@ -283,6 +284,20 @@ Rails.application.middleware.insert_after MultitenancyMiddleware, SiteMaps::Midd
|
|
|
283
284
|
adapter: -> { ... }
|
|
284
285
|
```
|
|
285
286
|
|
|
287
|
+
`aliases:` maps an incoming public request path to another public request path,
|
|
288
|
+
applied before the prefix options. Use it to serve the same content at multiple
|
|
289
|
+
locations — for example, to answer the conventional `/sitemap.xml` with the
|
|
290
|
+
sitemap index that is stored/served as `/sitemap_index.xml`:
|
|
291
|
+
|
|
292
|
+
```ruby
|
|
293
|
+
Rails.application.middleware.insert_after MultitenancyMiddleware, SiteMaps::Middleware,
|
|
294
|
+
aliases: { "/sitemap.xml" => "/sitemap_index.xml" },
|
|
295
|
+
storage_prefix: -> { site = Current.site; "/sitemaps/#{site.slug}" if site },
|
|
296
|
+
adapter: -> { ... }
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
It accepts a hash or a callable (0-arg or 1-arg receiving `env`) returning a hash.
|
|
300
|
+
|
|
286
301
|
XSL stylesheet requests (`/_sitemap-stylesheet.xsl`, `/_sitemap-index-stylesheet.xsl`) are served directly without resolving the adapter or prefix.
|
|
287
302
|
|
|
288
303
|
### Thread safety
|
|
@@ -536,6 +551,7 @@ use SiteMaps::Middleware,
|
|
|
536
551
|
adapter: SiteMaps.current_adapter, # defaults to SiteMaps.current_adapter
|
|
537
552
|
public_prefix: nil, # strip this prefix from the public URL before lookup
|
|
538
553
|
storage_prefix: nil, # prepend this prefix to the public URL for storage lookup
|
|
554
|
+
aliases: nil, # map a public path to another public path, e.g. { "/sitemap.xml" => "/sitemap_index.xml" }
|
|
539
555
|
x_robots_tag: "noindex, follow", # default
|
|
540
556
|
cache_control: "public, max-age=3600" # default
|
|
541
557
|
```
|
data/lib/site_maps/middleware.rb
CHANGED
|
@@ -28,11 +28,21 @@ module SiteMaps
|
|
|
28
28
|
# Both options accept a callable (0-arg or 1-arg receiving env), which is useful
|
|
29
29
|
# in multi-tenant setups where the prefix depends on the current request/site.
|
|
30
30
|
#
|
|
31
|
+
# @param aliases [Hash{String=>String}, #call, nil] Maps an incoming **public
|
|
32
|
+
# request path** to another public request path, applied before prefix
|
|
33
|
+
# handling. Serves the target's content at the alias path (no redirect).
|
|
34
|
+
#
|
|
35
|
+
# Example: serve the sitemap index at both locations →
|
|
36
|
+
# `aliases: { "/sitemap.xml" => "/sitemap_index.xml" }`
|
|
37
|
+
#
|
|
38
|
+
# Accepts a callable (0-arg or 1-arg receiving env) returning such a hash.
|
|
39
|
+
#
|
|
31
40
|
def initialize(
|
|
32
41
|
app,
|
|
33
42
|
adapter: nil,
|
|
34
43
|
public_prefix: nil,
|
|
35
44
|
storage_prefix: nil,
|
|
45
|
+
aliases: nil,
|
|
36
46
|
x_robots_tag: DEFAULT_X_ROBOTS_TAG,
|
|
37
47
|
cache_control: DEFAULT_CACHE_CONTROL
|
|
38
48
|
)
|
|
@@ -40,12 +50,13 @@ module SiteMaps
|
|
|
40
50
|
@adapter = adapter
|
|
41
51
|
@public_prefix = public_prefix
|
|
42
52
|
@storage_prefix = storage_prefix
|
|
53
|
+
@aliases = aliases
|
|
43
54
|
@x_robots_tag = x_robots_tag
|
|
44
55
|
@cache_control = cache_control
|
|
45
56
|
end
|
|
46
57
|
|
|
47
58
|
def call(env)
|
|
48
|
-
path = env["PATH_INFO"]
|
|
59
|
+
path = resolve_alias(env["PATH_INFO"], env)
|
|
49
60
|
|
|
50
61
|
if xsl_request?(path)
|
|
51
62
|
serve_xsl(path)
|
|
@@ -74,6 +85,16 @@ module SiteMaps
|
|
|
74
85
|
|
|
75
86
|
private
|
|
76
87
|
|
|
88
|
+
# Rewrites the incoming public path through the alias map (if configured)
|
|
89
|
+
# before any prefix handling, so the aliased path takes the exact same code
|
|
90
|
+
# path as a real request for the target.
|
|
91
|
+
def resolve_alias(path, env)
|
|
92
|
+
aliases = @aliases.respond_to?(:call) ? call_with_env(@aliases, env) : @aliases
|
|
93
|
+
return path unless aliases
|
|
94
|
+
|
|
95
|
+
aliases[path] || path
|
|
96
|
+
end
|
|
97
|
+
|
|
77
98
|
def resolve_adapter(env)
|
|
78
99
|
if @adapter.respond_to?(:call)
|
|
79
100
|
call_with_env(@adapter, env)
|
data/lib/site_maps/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: site_maps
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marcos G. Zimmermann
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: exec
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date:
|
|
11
|
+
date: 2026-07-17 00:00:00.000000000 Z
|
|
11
12
|
dependencies:
|
|
12
13
|
- !ruby/object:Gem::Dependency
|
|
13
14
|
name: rack
|
|
@@ -165,6 +166,7 @@ metadata:
|
|
|
165
166
|
bug_tracker_uri: https://github.com/marcosgz/site_maps/issues
|
|
166
167
|
documentation_uri: https://github.com/marcosgz/site_maps
|
|
167
168
|
source_code_uri: https://github.com/marcosgz/site_maps
|
|
169
|
+
post_install_message:
|
|
168
170
|
rdoc_options: []
|
|
169
171
|
require_paths:
|
|
170
172
|
- lib
|
|
@@ -179,7 +181,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
179
181
|
- !ruby/object:Gem::Version
|
|
180
182
|
version: '0'
|
|
181
183
|
requirements: []
|
|
182
|
-
rubygems_version: 3.
|
|
184
|
+
rubygems_version: 3.4.10
|
|
185
|
+
signing_key:
|
|
183
186
|
specification_version: 4
|
|
184
187
|
summary: Concurrent and Incremental sitemap.xml builder for ruby applications
|
|
185
188
|
test_files: []
|