site_maps 0.1.0 → 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 +10 -0
- data/Gemfile.lock +3 -3
- data/README.md +21 -0
- data/docs/README.md +67 -0
- data/docs/adapters.md +143 -0
- data/docs/api.md +154 -0
- data/docs/cli.md +93 -0
- data/docs/events.md +79 -0
- data/docs/extensions.md +141 -0
- data/docs/getting-started.md +138 -0
- data/docs/middleware.md +85 -0
- data/docs/processes.md +156 -0
- data/docs/rails.md +128 -0
- data/lib/site_maps/adapters/aws_sdk/storage.rb +5 -2
- data/lib/site_maps/middleware.rb +22 -1
- data/lib/site_maps/version.rb +1 -1
- metadata +16 -3
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
|
|
@@ -105,6 +106,16 @@ files:
|
|
|
105
106
|
- Rakefile
|
|
106
107
|
- bin/console
|
|
107
108
|
- bin/setup
|
|
109
|
+
- docs/README.md
|
|
110
|
+
- docs/adapters.md
|
|
111
|
+
- docs/api.md
|
|
112
|
+
- docs/cli.md
|
|
113
|
+
- docs/events.md
|
|
114
|
+
- docs/extensions.md
|
|
115
|
+
- docs/getting-started.md
|
|
116
|
+
- docs/middleware.md
|
|
117
|
+
- docs/processes.md
|
|
118
|
+
- docs/rails.md
|
|
108
119
|
- exec/site_maps
|
|
109
120
|
- lib/site-maps.rb
|
|
110
121
|
- lib/site_maps.rb
|
|
@@ -155,6 +166,7 @@ metadata:
|
|
|
155
166
|
bug_tracker_uri: https://github.com/marcosgz/site_maps/issues
|
|
156
167
|
documentation_uri: https://github.com/marcosgz/site_maps
|
|
157
168
|
source_code_uri: https://github.com/marcosgz/site_maps
|
|
169
|
+
post_install_message:
|
|
158
170
|
rdoc_options: []
|
|
159
171
|
require_paths:
|
|
160
172
|
- lib
|
|
@@ -169,7 +181,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
169
181
|
- !ruby/object:Gem::Version
|
|
170
182
|
version: '0'
|
|
171
183
|
requirements: []
|
|
172
|
-
rubygems_version: 3.
|
|
184
|
+
rubygems_version: 3.4.10
|
|
185
|
+
signing_key:
|
|
173
186
|
specification_version: 4
|
|
174
187
|
summary: Concurrent and Incremental sitemap.xml builder for ruby applications
|
|
175
188
|
test_files: []
|