sitemap_generator 4.0.alpha → 4.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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.0.alpha
1
+ 4.0
@@ -83,20 +83,20 @@ module SitemapGenerator
83
83
  # Call with:
84
84
  # sitemap_url - a SitemapUrl instance
85
85
  # sitemap, options - a Sitemap instance and options hash
86
- # path, options - a path for the URL and options hash
86
+ # path, options - a path for the URL and options hash. For supported options
87
+ # see the SitemapGenerator::Builder::SitemapUrl class.
87
88
  #
88
- # KJV: We should be using the host from the Location object if no host is
89
- # specified in the call to add(). The issue is noticeable when we add links
90
- # to a sitemap direct as in the following example:
91
- # ls = SitemapGenerator::LinkSet.new(:default_host => 'http://abc.com')
92
- # ls.sitemap_index.add('/link')
93
- # This raises a RuntimeError: Cannot generate a url without a host
94
- # Expected: the link added to the sitemap should use the host from its
95
- # location object if no host has been specified.
89
+ # The link added to the sitemap will use the host from its location object
90
+ # if no host has been specified.
96
91
  def add(link, options={})
97
92
  raise SitemapGenerator::SitemapFinalizedError if finalized?
98
93
 
99
- sitemap_url = (link.is_a?(SitemapUrl) ? link : SitemapUrl.new(link, options) )
94
+ sitemap_url = if link.is_a?(SitemapUrl)
95
+ link
96
+ else
97
+ options[:host] ||= @location.host
98
+ SitemapUrl.new(link, options)
99
+ end
100
100
 
101
101
  xml = sitemap_url.to_xml
102
102
  raise SitemapGenerator::SitemapFullError if !file_can_fit?(xml)
@@ -178,8 +178,8 @@ module SitemapGenerator
178
178
  # Replace the last 3 characters of string with ... if the string is as big
179
179
  # or bigger than max.
180
180
  def ellipsis(string, max)
181
- if string.size >= max
182
- string[0, max - 3] + '...'
181
+ if string.size > max
182
+ (string[0, max - 3] || '') + '...'
183
183
  else
184
184
  string
185
185
  end
@@ -36,6 +36,10 @@ module SitemapGenerator
36
36
  # index, and go and write out the first sitemap. If it's the third or
37
37
  # greater sitemap, just finalize and write it out as usual, nothing more
38
38
  # needs to be done.
39
+ #
40
+ # If a link is being added to the index manually as a string, then we
41
+ # can assume that the index is required (unless create_index is false of course).
42
+ # This seems like the logical thing to do.
39
43
  alias_method :super_add, :add
40
44
  def add(link, options={})
41
45
  if file = link.is_a?(SitemapFile) && link
@@ -51,17 +55,24 @@ module SitemapGenerator
51
55
  # for there to be an index.
52
56
  if @link_count == 0
53
57
  @first_sitemap = SitemapGenerator::Builder::LinkHolder.new(file, options)
54
- @link_count += 1 # pretend it's added
55
- elsif @link_count == 1 # adding second link, need an index so reserve names & write out first sitemap
56
- reserve_name unless @location.create_index == false # index gets first name
57
- write_first_sitemap
58
- file.write
59
- super(SitemapGenerator::Builder::SitemapIndexUrl.new(file, options))
58
+ @link_count += 1 # pretend it's added, but don't add it yet
60
59
  else
60
+ # need an index so make sure name is reserved and first sitemap is written out
61
+ reserve_name unless @location.create_index == false
62
+ write_first_sitemap
61
63
  file.write
62
64
  super(SitemapGenerator::Builder::SitemapIndexUrl.new(file, options))
63
65
  end
64
66
  else
67
+ # A link is being added manually. Obviously the user wants an index.
68
+ # This overrides the create_index setting.
69
+ unless @location.create_index == false
70
+ @create_index = true
71
+ reserve_name
72
+ end
73
+
74
+ # Use the host from the location if none provided
75
+ options[:host] ||= @location.host
65
76
  super(SitemapGenerator::Builder::SitemapIndexUrl.new(link, options))
66
77
  end
67
78
  end
@@ -104,9 +115,12 @@ module SitemapGenerator
104
115
  super if create_index?
105
116
  end
106
117
 
107
- # Whether or not we need to create an index file.
118
+ # Whether or not we need to create an index file. True if create_index is true
119
+ # or if create_index is :auto and we have more than one link in the index.
120
+ # If a link is added manually and create_index is not false, we force index
121
+ # creation because they obviously intend for there to be an index. False otherwise.
108
122
  def create_index?
109
- @location.create_index == true || @location.create_index == :auto && @link_count > 1
123
+ @create_index || @location.create_index == true || @location.create_index == :auto && @link_count > 1
110
124
  end
111
125
 
112
126
  protected
@@ -19,6 +19,7 @@ module SitemapGenerator
19
19
  # Requires a host to be set. If passing a sitemap, the sitemap must have a +default_host+
20
20
  # configured. If calling with a path and options, you must include the <tt>:host</tt> option.
21
21
  #
22
+ # * +host+
22
23
  # * +priority+
23
24
  # * +changefreq+
24
25
  # * +lastmod+
@@ -81,7 +82,7 @@ module SitemapGenerator
81
82
 
82
83
  builder.news :access, news_data[:access] if news_data[:access]
83
84
  builder.news :genres, news_data[:genres] if news_data[:genres]
84
- builder.news :publication_date, news_data[:publication_date] if news_data[:publication_date]
85
+ builder.news :publication_date, w3c_date(news_data[:publication_date]) if news_data[:publication_date]
85
86
  builder.news :title, news_data[:title] if news_data[:title]
86
87
  builder.news :keywords, news_data[:keywords] if news_data[:keywords]
87
88
  builder.news :stock_tickers, news_data[:stock_tickers] if news_data[:stock_tickers]
@@ -126,7 +127,8 @@ module SitemapGenerator
126
127
  end
127
128
 
128
129
  self[:alternates].each do |alternate|
129
- builder.xhtml :link, :rel => 'alternate', :hreflang => alternate[:lang], :href => alternate[:href]
130
+ rel = alternate[:nofollow] ? 'alternate nofollow' : 'alternate'
131
+ builder.xhtml :link, :rel => rel, :hreflang => alternate[:lang], :href => alternate[:href]
130
132
  end
131
133
 
132
134
  unless SitemapGenerator::Utilities.blank?(self[:geo])
@@ -4,13 +4,13 @@ require 'builder'
4
4
  # which lists all the sitemap files written.
5
5
  module SitemapGenerator
6
6
  class LinkSet
7
- @@requires_finalization_opts = [:filename, :sitemaps_path, :sitemaps_namer, :sitemaps_host]
8
- @@new_location_opts = [:filename, :sitemaps_path, :sitemaps_namer]
7
+ @@requires_finalization_opts = [:filename, :sitemaps_path, :sitemaps_namer, :sitemaps_host, :namer]
8
+ @@new_location_opts = [:filename, :sitemaps_path, :sitemaps_namer, :namer]
9
9
 
10
- attr_reader :default_host, :sitemaps_path, :filename
11
- attr_accessor :verbose, :yahoo_app_id, :include_root, :include_index, :sitemaps_host, :adapter, :yield_sitemap, :create_index
10
+ attr_reader :default_host, :sitemaps_path, :filename, :create_index
11
+ attr_accessor :verbose, :yahoo_app_id, :include_root, :include_index, :sitemaps_host, :adapter, :yield_sitemap
12
12
 
13
- # Create a new sitemap index and sitemap files. Pass a block calls to the following
13
+ # Create a new sitemap index and sitemap files. Pass a block with calls to the following
14
14
  # methods:
15
15
  # * +add+ - Add a link to the current sitemap
16
16
  # * +group+ - Start a new group of sitemaps
@@ -81,15 +81,15 @@ module SitemapGenerator
81
81
  # to e.g. 'en/'. Sitemaps are written to <tt>public_path</tt> + <tt>sitemaps_path</tt>
82
82
  #
83
83
  # * <tt>:filename</tt> - symbol giving the base name for files (default <tt>:sitemap</tt>).
84
- # The sitemap names are generated like "#{filename}1.xml.gz", "#{filename}2.xml.gz"
85
- # and the index name is like "#{filename}_index.xml.gz".
84
+ # The names are generated like "#{filename}.xml.gz", "#{filename}1.xml.gz", "#{filename}2.xml.gz"
85
+ # with the first file being the index if you have more than one sitemap file.
86
86
  #
87
- # * <tt>:sitemaps_namer</tt> - A +SitemapNamer+ instance for generating the sitemap names.
88
- #
89
- # * <tt>:include_index</tt> - Boolean. Whether to <b>add a link to the sitemap index<b>
87
+ # * <tt>:include_index</tt> - Boolean. Whether to <b>add a link pointing to the sitemap index<b>
90
88
  # to the current sitemap. This points search engines to your Sitemap Index to
91
89
  # include it in the indexing of your site. Default is `false`. Turned off when
92
- # `sitemaps_host` is set or within a `group()` block.
90
+ # `sitemaps_host` is set or within a `group()` block. Turned off because Google can complain
91
+ # about nested indexing and because if a robot is already reading your sitemap, they
92
+ # probably know about the index.
93
93
  #
94
94
  # * <tt>:include_root</tt> - Boolean. Whether to **add the root** url i.e. '/' to the
95
95
  # current sitemap. Default is `true`. Turned off within a `group()` block.
@@ -100,11 +100,20 @@ module SitemapGenerator
100
100
  # * <tt>:verbose</tt> - If +true+, output a summary line for each sitemap and sitemap
101
101
  # index that is created. Default is +false+.
102
102
  #
103
- # * <tt>:create_index</tt> - Supported values: `true`, `false`, `:auto`. Default: `true`.
103
+ # * <tt>:create_index</tt> - Supported values: `true`, `false`, `:auto`. Default: `:auto`.
104
104
  # Whether to create a sitemap index file. If `true` an index file is always created,
105
105
  # regardless of how many links are in your sitemap. If `false` an index file is never
106
106
  # created. If `:auto` an index file is created only if your sitemap has more than
107
- # 50,000 (or SitemapGenerator::MAX_SITEMAP_LINKS) links.
107
+ # one sitemap file.
108
+ #
109
+ # * <tt>:namer</tt> - A <tt>SitemapGenerator::SimpleNamer</tt> instance for generating the sitemap
110
+ # and index file names. See <tt>:filename</tt> if you don't need to do anything fancy, and can
111
+ # accept the default naming conventions.
112
+ #
113
+ # === Deprecated
114
+ #
115
+ # * <tt>:sitemaps_namer</tt> - Deprecated, use <tt>:namer</tt>. A <tt>SitemapGenerator::SitemapNamer</tt> instance for generating the sitemap names.
116
+ # * <tt>:sitemap_index_namer</tt> - Deprecated, use <tt>:namer</tt>. A <tt>SitemapGenerator::SitemapIndexNamer</tt> instance for generating the sitemap index name.
108
117
  #
109
118
  # KJV: When adding a new option be sure to include it in `options_for_group()` if
110
119
  # the option should be inherited by groups.
@@ -118,7 +127,7 @@ module SitemapGenerator
118
127
  :bing => "http://www.bing.com/webmaster/ping.aspx?siteMap=%s",
119
128
  :sitemap_writer => "http://www.sitemapwriter.com/notify.php?crawler=all&url=%s"
120
129
  },
121
- :create_index => true
130
+ :create_index => :auto
122
131
  )
123
132
  options.each_pair { |k, v| instance_variable_set("@#{k}".to_sym, v) }
124
133
 
@@ -172,10 +181,13 @@ module SitemapGenerator
172
181
  # be finalized when the block returns.
173
182
  #
174
183
  # If you are not changing any of the location settings like <tt>filename<tt>,
175
- # <tt>sitemaps_path</tt>, <tt>sitemaps_host</tt> or <tt>sitemaps_namer</tt>
176
- # links you add within the group will be added to the current sitemap file (e.g. sitemap1.xml).
177
- # If one of these options is specified, the current sitemap file is finalized
178
- # and a new sitemap file started.
184
+ # <tt>sitemaps_path</tt>, <tt>sitemaps_host</tt> or <tt>namer</tt>,
185
+ # links you add within the group will be added to the current sitemap.
186
+ # Otherwise the current sitemap file is finalized and a new sitemap file started,
187
+ # using the options you specified.
188
+ #
189
+ # Most commonly, you'll want to give the group's files a distinct name using
190
+ # the <tt>filename</tt> option.
179
191
  #
180
192
  # Options like <tt>:default_host</tt> can be used and it will only affect the links
181
193
  # within the group. Links added outside of the group will revert to the previous
@@ -187,15 +199,15 @@ module SitemapGenerator
187
199
  if (@@requires_finalization_opts & original_opts.keys).empty?
188
200
  # If no new filename or path is specified reuse the default sitemap file.
189
201
  # A new location object will be set on it for the duration of the group.
190
- opts[:sitemap] = sitemap
202
+ original_opts[:sitemap] = sitemap
191
203
  elsif original_opts.key?(:sitemaps_host) && (@@new_location_opts & original_opts.keys).empty?
192
204
  # If no location options are provided we are creating the next sitemap in the
193
205
  # current series, so finalize and inherit the namer.
194
206
  finalize_sitemap!
195
- opts[:sitemaps_namer] = sitemaps_namer
207
+ original_opts[:namer] = namer
196
208
  end
197
209
 
198
- opts = options_for_group(opts)
210
+ opts = options_for_group(original_opts)
199
211
  @group = SitemapGenerator::LinkSet.new(opts)
200
212
  if opts.key?(:sitemap)
201
213
  # If the group is sharing the current sitemap, set the
@@ -206,9 +218,24 @@ module SitemapGenerator
206
218
  @group.interpreter.eval(:yield_sitemap => @yield_sitemap || SitemapGenerator.yield_sitemap?, &block)
207
219
  @sitemap.location.merge!(@original_location)
208
220
  end
209
- elsif block_given?
210
- @group.interpreter.eval(:yield_sitemap => @yield_sitemap || SitemapGenerator.yield_sitemap?, &block)
211
- @group.finalize_sitemap!
221
+ else
222
+ # Handle the case where a user only has one group, and it's being written
223
+ # to a new sitemap file. They would expect there to be an index. So force
224
+ # index creation. If there is more than one group, we would have an index anyways,
225
+ # so it's safe to force index creation in these other cases. In the case that
226
+ # the groups reuse the current sitemap, don't force index creation because
227
+ # we want the default behaviour i.e. only an index if more than one sitemap file.
228
+ # Don't force index creation if the user specifically requested no index. This
229
+ # unfortunately means that if they set it to :auto they may be getting an index
230
+ # when they didn't expect one, but you shouldn't be using groups if you only have
231
+ # one sitemap and don't want an index. Rather, just add the links directly in the create()
232
+ # block.
233
+ @group.send(:create_index=, true, true) if @group.create_index != false
234
+
235
+ if block_given?
236
+ @group.interpreter.eval(:yield_sitemap => @yield_sitemap || SitemapGenerator.yield_sitemap?, &block)
237
+ @group.finalize_sitemap!
238
+ end
212
239
  end
213
240
  @group
214
241
  end
@@ -234,20 +261,20 @@ module SitemapGenerator
234
261
  # a string interpolation that will be replaced by the CGI escaped sitemap
235
262
  # index URL. If you have any literal percent characters in your URL you
236
263
  # need to escape them with `%%`. For example if your sitemap index URL
237
- # is `http://example.com/sitemap_index.xml.gz` and your
264
+ # is `http://example.com/sitemap.xml.gz` and your
238
265
  # ping url is `http://example.com/100%%/ping?url=%s`
239
- # then the final URL that is pinged will be `http://example.com/100%/ping?url=http%3A%2F%2Fexample.com%2Fsitemap_index.xml.gz`
266
+ # then the final URL that is pinged will be `http://example.com/100%/ping?url=http%3A%2F%2Fexample.com%2Fsitemap.xml.gz`
240
267
  #
241
268
  # == Examples
242
269
  #
243
- # Both of these examples will ping the default search engines in addition to `http://superengine.com/ping?url=http%3A%2F%2Fexample.com%2Fsitemap_index.xml.gz`
270
+ # Both of these examples will ping the default search engines in addition to `http://superengine.com/ping?url=http%3A%2F%2Fexample.com%2Fsitemap.xml.gz`
244
271
  #
245
272
  # SitemapGenerator::Sitemap.host('http://example.com/')
246
273
  # SitemapGenerator::Sitemap.ping_search_engines(:super_engine => 'http://superengine.com/ping?url=%s')
247
274
  #
248
275
  # Is equivalent to:
249
276
  #
250
- # SitemapGenerator::Sitemap.ping_search_engines('http://example.com/sitemap_index.xml.gz', :super_engine => 'http://superengine.com/ping?url=%s')
277
+ # SitemapGenerator::Sitemap.ping_search_engines('http://example.com/sitemap.xml.gz', :super_engine => 'http://superengine.com/ping?url=%s')
251
278
  def ping_search_engines(*args)
252
279
  require 'cgi/session'
253
280
  require 'open-uri'
@@ -341,11 +368,11 @@ module SitemapGenerator
341
368
  # Set each option on this instance using accessor methods. This will affect
342
369
  # both the sitemap and the sitemap index.
343
370
  #
344
- # If both `filename` and `sitemaps_namer` are passed, set filename first so it
371
+ # If both `filename` and `namer` are passed, set filename first so it
345
372
  # doesn't override the latter.
346
373
  def set_options(opts={})
347
374
  opts = opts.dup
348
- %w(filename sitemaps_namer).each do |key|
375
+ %w(filename namer sitemaps_namer).each do |key|
349
376
  if value = opts.delete(key.to_sym)
350
377
  send("#{key}=", value)
351
378
  end
@@ -355,7 +382,7 @@ module SitemapGenerator
355
382
  end
356
383
  end
357
384
 
358
- # Given +opts+, return a hash of options prepped for creating a new group from this LinkSet.
385
+ # Given +opts+, modify it and return it prepped for creating a new group from this LinkSet.
359
386
  # If <tt>:public_path</tt> is present in +opts+ it is removed because groups cannot
360
387
  # change the public path.
361
388
  def options_for_group(opts)
@@ -405,8 +432,7 @@ module SitemapGenerator
405
432
  # Finalize a sitemap by including it in the index and outputting a summary line.
406
433
  # Do nothing if it has already been finalized.
407
434
  #
408
- # Don't finalize if the sitemap is empty and a group has been created. The reason
409
- # being that the group will have written out its sitemap.
435
+ # Don't finalize if the sitemap is empty.
410
436
  #
411
437
  # Add the default links if they have not been added yet and no groups have been created.
412
438
  # If the default links haven't been added we know that the sitemap is empty,
@@ -420,7 +446,7 @@ module SitemapGenerator
420
446
  # the index keeps track of how many links are in our sitemaps and we need this info
421
447
  # for the summary line. Also the index determines which file gets the first name
422
448
  # so everything has to go via the index.
423
- add_to_index(sitemap)
449
+ add_to_index(sitemap) unless sitemap.empty?
424
450
  end
425
451
 
426
452
  # Finalize a sitemap index and output a summary line. Do nothing if it has already
@@ -438,11 +464,12 @@ module SitemapGenerator
438
464
  end
439
465
 
440
466
  # Reset this instance. Keep the same options, but return to the same state
441
- # as before an sitemaps were created.
467
+ # as before any sitemaps were created.
442
468
  def reset!
443
469
  @sitemap_index = nil if @sitemap_index && @sitemap_index.finalized? && !@protect_index
444
470
  @sitemap = nil if @sitemap && @sitemap.finalized?
445
- self.sitemaps_namer.reset # start from 1
471
+ self.namer.reset
472
+ self.sitemaps_namer.reset if self.sitemaps_namer
446
473
  @added_default_links = false
447
474
  end
448
475
 
@@ -502,14 +529,16 @@ module SitemapGenerator
502
529
  update_location_info(:host, value)
503
530
  end
504
531
 
505
- # Set the filename base to use when generating sitemaps and sitemap indexes.
506
- # The index name will be +value+ with <tt>_index.xml.gz</tt> appended.
532
+ # Set the filename base to use when generating sitemaps (and the sitemap index).
533
+ #
507
534
  # === Example
508
535
  # <tt>filename = :sitemap</tt>
536
+ #
537
+ # === Generates
538
+ # <tt>sitemap.xml.gz, sitemap1.xml.gz, sitemap2.xml.gz, ...</tt>
509
539
  def filename=(value)
510
540
  @filename = value
511
- self.sitemaps_namer = SitemapGenerator::SitemapNamer.new(@filename)
512
- self.sitemap_index_namer = SitemapGenerator::SitemapIndexNamer.new("#{@filename}_index")
541
+ self.namer = SitemapGenerator::SimpleNamer.new(@filename)
513
542
  end
514
543
 
515
544
  # Set the search engines hash to a new hash of search engine names mapped to
@@ -526,36 +555,11 @@ module SitemapGenerator
526
555
  @search_engines || {}
527
556
  end
528
557
 
529
- # Set the namer to use when generating SitemapFiles (does not apply to the
530
- # SitemapIndexFile)
531
- def sitemaps_namer=(value)
532
- @sitemaps_namer = value
533
- @sitemap.location[:namer] = value if @sitemap && !@sitemap.finalized?
534
- end
535
-
536
- # Return the current sitemaps namer object. If it not set, looks for it on
537
- # the current sitemap and if there is no sitemap, creates a new one using
538
- # the current filename.
539
- def sitemaps_namer
540
- @sitemaps_namer ||= @sitemap && @sitemap.location.namer || SitemapGenerator::SitemapNamer.new(@filename)
541
- end
542
-
543
- # Set the namer to use when generating SitemapFiles (does not apply to the
544
- # SitemapIndexFile)
545
- def sitemap_index_namer=(value)
546
- @sitemap_index_namer = value
547
- @sitemap_index.location[:namer] = value if @sitemap_index && !@sitemap_index.finalized? && !@protect_index
548
- end
549
-
550
- def sitemap_index_namer
551
- @sitemap_index_namer ||= @sitemap_index && @sitemap_index.location.namer || SitemapGenerator::SitemapIndexNamer.new("#{@filename}_index")
552
- end
553
-
554
558
  # Return a new +SitemapLocation+ instance with the current options included
555
559
  def sitemap_location
556
560
  SitemapGenerator::SitemapLocation.new(
557
561
  :host => sitemaps_host,
558
- :namer => sitemaps_namer,
562
+ :namer => sitemaps_namer || namer, # sitemaps_namer is deprecated
559
563
  :public_path => public_path,
560
564
  :sitemaps_path => @sitemaps_path,
561
565
  :adapter => @adapter,
@@ -567,7 +571,7 @@ module SitemapGenerator
567
571
  def sitemap_index_location
568
572
  SitemapGenerator::SitemapLocation.new(
569
573
  :host => sitemaps_host,
570
- :namer => sitemap_index_namer,
574
+ :namer => sitemap_index_namer || namer, # sitemap_index_namer is deprecated
571
575
  :public_path => public_path,
572
576
  :sitemaps_path => @sitemaps_path,
573
577
  :adapter => @adapter,
@@ -576,6 +580,31 @@ module SitemapGenerator
576
580
  )
577
581
  end
578
582
 
583
+ # Set the value of +create_index+ on the SitemapIndexLocation object of the
584
+ # SitemapIndexFile.
585
+ def create_index=(value, force=false)
586
+ @create_index = value
587
+ # Allow overriding the protected status of the index when we are creating a group.
588
+ # Because sometimes we need to force an index in that case. But generally we don't
589
+ # want to allow people to mess with this value if the index is protected.
590
+ @sitemap_index.location[:create_index] = value if @sitemap_index && ((!@sitemap_index.finalized? && !@protect_index) || force)
591
+ end
592
+
593
+ # Set the namer to use to generate the sitemap (and index) file names.
594
+ # This should be an instance of <tt>SitemapGenerator::SimpleNamer</tt>
595
+ def namer=(value)
596
+ @namer = value
597
+ @sitemap.location[:namer] = value if @sitemap && !@sitemap.finalized?
598
+ @sitemap_index.location[:namer] = value if @sitemap_index && !@sitemap_index.finalized? && !@protect_index
599
+ end
600
+
601
+ # Return the namer object. If it is not set, looks for it on
602
+ # the current sitemap and if there is no sitemap, creates a new one using
603
+ # the current filename.
604
+ def namer
605
+ @namer ||= @sitemap && @sitemap.location.namer || SitemapGenerator::SimpleNamer.new(@filename)
606
+ end
607
+
579
608
  protected
580
609
 
581
610
  # Update the given attribute on the current sitemap index and sitemap file location objects.
@@ -587,5 +616,48 @@ module SitemapGenerator
587
616
  end
588
617
  end
589
618
  include LocationHelpers
619
+
620
+ module Deprecated
621
+ # *Deprecated*
622
+ #
623
+ # Set the namer to use when generating SitemapFiles (does not apply to the
624
+ # SitemapIndexFile)
625
+ #
626
+ # As of version 4, use the <tt>namer<tt> option.
627
+ def sitemaps_namer=(value)
628
+ @sitemaps_namer = value
629
+ @sitemap.location[:namer] = value if @sitemap && !@sitemap.finalized?
630
+ end
631
+
632
+ # *Deprecated*
633
+ #
634
+ # Return the current sitemaps namer object. If it not set, looks for it on
635
+ # the current sitemap and if there is no sitemap, creates a new one using
636
+ # the current filename.
637
+ #
638
+ # As of version 4, use the <tt>namer<tt> option.
639
+ def sitemaps_namer
640
+ @sitemaps_namer ||= @sitemap && @sitemap.location.namer
641
+ end
642
+
643
+ # *Deprecated*
644
+ #
645
+ # Set the namer to use when generating the index file.
646
+ # The namer should be a <tt>SitemapGenerator::SitemapIndexNamer</tt> instance.
647
+ #
648
+ # As of version 4, use the <tt>namer<tt> option.
649
+ def sitemap_index_namer=(value)
650
+ @sitemap_index_namer = value
651
+ @sitemap_index.location[:namer] = value if @sitemap_index && !@sitemap_index.finalized? && !@protect_index
652
+ end
653
+
654
+ # *Deprecated*
655
+ #
656
+ # As of version 4, use the <tt>namer<tt> option.
657
+ def sitemap_index_namer
658
+ @sitemap_index_namer ||= @sitemap_index && @sitemap_index.location.namer
659
+ end
660
+ end
661
+ include Deprecated
590
662
  end
591
663
  end