sitemap_generator-cache_adapter 1.0.1 → 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 +7 -0
- data/README.md +62 -3
- data/lib/sitemap_generator/cache_adapter/version.rb +1 -1
- metadata +10 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 46eb1cee35957f7b3adee339003753db7b8249ffbd72fa9edf05d19d1f7cfb7a
|
|
4
|
+
data.tar.gz: d197c7707631130dcb7768e29288e8243b57b65c2ea9b4a0f494127b5c418c52
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 87accb0207d2d2b23f285f5a290b620164906b9a20096a8ccffa586ed138121dfdec59e3a61e41d0a45a5ab128bcf3d5cb79261708ccf874e9ba894bfe48ee4d
|
|
7
|
+
data.tar.gz: c759901e01c9b84c05e29bfea435493f38abde4048c63d912a621f1bf0211575a2bac750c534d3df784d0744b642f241e607d235b49aa7e01d552cbe8822a5fa
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.1.0] - 2026-09-22
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Allow sitemap_generator 7.x (`>= 6.0, < 8`). The `~> 6.0` constraint forced apps using this adapter back to sitemap_generator 6.3.0. The adapter's `write(location, raw_data)` interface is unchanged in 7.x, and the specs plus an end-to-end `LinkSet#create` pass against 7.1.1.
|
|
13
|
+
- Run CI on Ruby 4.0 as well.
|
|
14
|
+
|
|
8
15
|
## [1.0.1] - 2026-01-10
|
|
9
16
|
|
|
10
17
|
### Fixed
|
data/README.md
CHANGED
|
@@ -50,7 +50,9 @@ SitemapGenerator::Sitemap.create do
|
|
|
50
50
|
end
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
### Serving Sitemaps
|
|
53
|
+
### Serving Sitemaps (Single File)
|
|
54
|
+
|
|
55
|
+
For most sites, a single sitemap file is sufficient (up to 50,000 URLs).
|
|
54
56
|
|
|
55
57
|
Create a controller to serve sitemaps from the cache:
|
|
56
58
|
|
|
@@ -59,8 +61,9 @@ Create a controller to serve sitemaps from the cache:
|
|
|
59
61
|
class SitemapsController < ApplicationController
|
|
60
62
|
def show
|
|
61
63
|
xml = SitemapGenerator::CacheAdapter.fetch("sitemap.xml") do
|
|
62
|
-
#
|
|
63
|
-
|
|
64
|
+
# Load the sitemap config, which runs create and caches the result
|
|
65
|
+
load Rails.root.join("config", "sitemap.rb")
|
|
66
|
+
SitemapGenerator::Sitemap.ping_search_engines # Optional
|
|
64
67
|
end
|
|
65
68
|
|
|
66
69
|
if xml.present?
|
|
@@ -79,6 +82,62 @@ Add the route:
|
|
|
79
82
|
get "sitemap.xml", to: "sitemaps#show", defaults: { format: :xml }
|
|
80
83
|
```
|
|
81
84
|
|
|
85
|
+
**Note**: Loading `config/sitemap.rb` executes the entire file, including the `create` block. This is how sitemap_generator is designed to work.
|
|
86
|
+
|
|
87
|
+
### Serving Sitemaps (Multiple Files)
|
|
88
|
+
|
|
89
|
+
For large sites with more than 50,000 URLs, sitemap_generator creates multiple files with an index:
|
|
90
|
+
|
|
91
|
+
```ruby
|
|
92
|
+
# config/sitemap.rb
|
|
93
|
+
SitemapGenerator::Sitemap.default_host = "https://example.com"
|
|
94
|
+
SitemapGenerator::Sitemap.adapter = SitemapGenerator::CacheAdapter.new
|
|
95
|
+
SitemapGenerator::Sitemap.compress = false
|
|
96
|
+
# Don't set create_index = false
|
|
97
|
+
|
|
98
|
+
SitemapGenerator::Sitemap.create do
|
|
99
|
+
# Your URLs here - will be split across multiple files if needed
|
|
100
|
+
end
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Update the controller to serve any sitemap file:
|
|
104
|
+
|
|
105
|
+
```ruby
|
|
106
|
+
# app/controllers/sitemaps_controller.rb
|
|
107
|
+
class SitemapsController < ApplicationController
|
|
108
|
+
def show
|
|
109
|
+
filename = if params[:id].present?
|
|
110
|
+
"sitemap#{params[:id]}.xml"
|
|
111
|
+
else
|
|
112
|
+
"sitemap.xml"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
xml = SitemapGenerator::CacheAdapter.fetch(filename) do
|
|
116
|
+
load Rails.root.join("config", "sitemap.rb")
|
|
117
|
+
SitemapGenerator::Sitemap.ping_search_engines
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
if xml.present?
|
|
121
|
+
render xml: xml
|
|
122
|
+
else
|
|
123
|
+
head :not_found
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Update the routes:
|
|
130
|
+
|
|
131
|
+
```ruby
|
|
132
|
+
# config/routes.rb
|
|
133
|
+
get "sitemap.xml", to: "sitemaps#show", defaults: { format: :xml }
|
|
134
|
+
get "sitemap:id.xml", to: "sitemaps#show", defaults: { format: :xml }, constraints: { id: /[0-9]+/ }
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
This serves:
|
|
138
|
+
- `/sitemap.xml` - The sitemap index
|
|
139
|
+
- `/sitemap1.xml`, `/sitemap2.xml`, etc. - Individual sitemap files
|
|
140
|
+
|
|
82
141
|
### Configuration Options
|
|
83
142
|
|
|
84
143
|
```ruby
|
metadata
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sitemap_generator-cache_adapter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Steve Hill
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-09-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: sitemap_generator
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: '6.0'
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '8'
|
|
20
23
|
type: :runtime
|
|
21
24
|
prerelease: false
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
26
|
requirements:
|
|
24
|
-
- - "
|
|
27
|
+
- - ">="
|
|
25
28
|
- !ruby/object:Gem::Version
|
|
26
29
|
version: '6.0'
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '8'
|
|
27
33
|
- !ruby/object:Gem::Dependency
|
|
28
34
|
name: rake
|
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|