sitemap_generator 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ./
3
3
  specs:
4
- sitemap_generator (2.1.2)
4
+ sitemap_generator (2.1.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/README.md CHANGED
@@ -26,6 +26,7 @@ Does your website use SitemapGenerator to generate Sitemaps? Where would you be
26
26
  Changelog
27
27
  -------
28
28
 
29
+ - v2.1.3: Fix calling create with both `filename` and `sitemaps_namer` options
29
30
  - v2.1.2: Support multiple videos per url using the new `videos` option to `add()`.
30
31
  - v2.1.1: Support calling `create()` multiple times in a sitemap config. Support host names with path segments so you can use a `default_host` like `'http://mysite.com/subdirectory/'`. Turn off `include_index` when the `sitemaps_host` differs from `default_host`. Add docs about how to upload to remote hosts.
31
32
  - v2.1.0: [News sitemap][sitemap_news] support
@@ -197,6 +198,65 @@ the `sitemaps_host` does not match the `default_host`. The link to the sitemap
197
198
  that would otherwise be included would point to a different host than the rest of the links
198
199
  in the sitemap, something that the sitemap rules forbid.
199
200
 
201
+ Generating Multiple Sitemaps
202
+ ----------
203
+
204
+ Each call to `create` creates a new sitemap index and associated sitemaps. You can call `create` as many times as you want within your sitemap configuration.
205
+
206
+ You must remember to use a different filename or location for each set of sitemaps, otherwise they will
207
+ overwrite each other. You can use the `filename`, `sitemaps_namer` and `sitemaps_path` options for this.
208
+
209
+ In the following example we generate three sitemaps each in its own subdirectory:
210
+
211
+ %w(google yahoo apple).each do |subdomain|
212
+ SitemapGenerator::Sitemap.default_host = "https://#{subdomain}.mysite.com"
213
+ SitemapGenerator::Sitemap.sitemaps_path = "sitemaps/#{subdomain}"
214
+ SitemapGenerator::Sitemap.create do
215
+ add '/home'
216
+ end
217
+ end
218
+
219
+ Outputs:
220
+
221
+ + sitemaps/google/sitemap1.xml.gz 2 links / 822 Bytes / 328 Bytes gzipped
222
+ + sitemaps/google/sitemap_index.xml.gz 1 sitemaps / 389 Bytes / 217 Bytes gzipped
223
+ Sitemap stats: 2 links / 1 sitemaps / 0m00s
224
+ + sitemaps/yahoo/sitemap1.xml.gz 2 links / 820 Bytes / 330 Bytes gzipped
225
+ + sitemaps/yahoo/sitemap_index.xml.gz 1 sitemaps / 388 Bytes / 217 Bytes gzipped
226
+ Sitemap stats: 2 links / 1 sitemaps / 0m00s
227
+ + sitemaps/apple/sitemap1.xml.gz 2 links / 820 Bytes / 330 Bytes gzipped
228
+ + sitemaps/apple/sitemap_index.xml.gz 1 sitemaps / 388 Bytes / 214 Bytes gzipped
229
+ Sitemap stats: 2 links / 1 sitemaps / 0m00s
230
+
231
+ If you don't want to have to generate all the sitemaps at once, or you want to refresh some more often than others, you can split them up into their own configuration files. Using the above example we would have:
232
+
233
+ # config/google_sitemap.rb
234
+ SitemapGenerator::Sitemap.default_host = "https://google.mysite.com"
235
+ SitemapGenerator::Sitemap.sitemaps_path = "sitemaps/google"
236
+ SitemapGenerator::Sitemap.create do
237
+ add '/home'
238
+ end
239
+
240
+ # config/apple_sitemap.rb
241
+ SitemapGenerator::Sitemap.default_host = "https://apple.mysite.com"
242
+ SitemapGenerator::Sitemap.sitemaps_path = "sitemaps/apple"
243
+ SitemapGenerator::Sitemap.create do
244
+ add '/home'
245
+ end
246
+
247
+ # config/yahoo_sitemap.rb
248
+ SitemapGenerator::Sitemap.default_host = "https://yahoo.mysite.com"
249
+ SitemapGenerator::Sitemap.sitemaps_path = "sitemaps/yahoo"
250
+ SitemapGenerator::Sitemap.create do
251
+ add '/home'
252
+ end
253
+
254
+ To generate each one specify the configuration file to run by passing the `CONFIG_FILE` option to `rake sitemap:refresh`, e.g.:
255
+
256
+ rake sitemap:refresh CONFIG_FILE="config/google_sitemap.rb"
257
+ rake sitemap:refresh CONFIG_FILE="config/apple_sitemap.rb"
258
+ rake sitemap:refresh CONFIG_FILE="config/yahoo_sitemap.rb"
259
+
200
260
  Sitemap Configuration
201
261
  ======
202
262
 
@@ -335,13 +395,6 @@ Speeding Things Up
335
395
 
336
396
  For large ActiveRecord collections with thousands of records it is advisable to iterate through them in batches to avoid loading all records into memory at once. For this reason in the example above we use `Content.find_each` which is a batched iterator available since Rails 2.3.2, rather than `Content.all`.
337
397
 
338
- Generating Multiple Sitemap Indexes
339
- ----------
340
-
341
- Each sitemap configuration corresponds to one sitemap index. To generate multiple sets of sitemaps you can create multiple configuration files. Each should specify a different location or filename to avoid overwriting each other. To generate your sitemaps, specify the configuration file to run in your call to `rake sitemap:refresh` using the `CONFIG_FILE` argument like in the following example:
342
-
343
- rake sitemap:refresh CONFIG_FILE="config/geo_sitemap.rb"
344
-
345
398
  Customizing your Sitemaps
346
399
  =======
347
400
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.2
1
+ 2.1.3
@@ -271,7 +271,15 @@ module SitemapGenerator
271
271
 
272
272
  # Set each option on this instance using accessor methods. This will affect
273
273
  # both the sitemap and the sitemap index.
274
+ #
275
+ # If both `filename` and `sitemaps_namer` are passed, set filename first so it
276
+ # doesn't override the latter.
274
277
  def set_options(opts={})
278
+ %w(filename sitemaps_namer).each do |key|
279
+ if value = opts.delete(key.to_sym)
280
+ send("#{key}=", value)
281
+ end
282
+ end
275
283
  opts.each_pair do |key, value|
276
284
  send("#{key}=", value)
277
285
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sitemap_generator
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
- - 2
10
- version: 2.1.2
9
+ - 3
10
+ version: 2.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Karl Varga
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-09-20 00:00:00 -07:00
19
+ date: 2011-09-23 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency