sitemap_generator 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +13 -9
- data/README.md +41 -5
- data/VERSION +1 -1
- data/lib/sitemap_generator.rb +4 -0
- data/lib/sitemap_generator/adapters.rb +0 -0
- data/lib/sitemap_generator/adapters/file_adapter.rb +21 -0
- data/lib/sitemap_generator/adapters/wave_adapter.rb +17 -0
- data/lib/sitemap_generator/builder/sitemap_file.rb +13 -19
- data/lib/sitemap_generator/builder/sitemap_url.rb +30 -2
- data/lib/sitemap_generator/link_set.rb +8 -3
- data/lib/sitemap_generator/sitemap_location.rb +12 -6
- metadata +31 -28
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ./
|
3
3
|
specs:
|
4
|
-
sitemap_generator (2.
|
4
|
+
sitemap_generator (2.1.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
@@ -16,7 +16,7 @@ GEM
|
|
16
16
|
activeresource (2.3.8)
|
17
17
|
activesupport (= 2.3.8)
|
18
18
|
activesupport (2.3.8)
|
19
|
-
columnize (0.3.
|
19
|
+
columnize (0.3.4)
|
20
20
|
gemcutter (0.6.1)
|
21
21
|
git (1.2.5)
|
22
22
|
github (0.4.5)
|
@@ -28,9 +28,11 @@ GEM
|
|
28
28
|
gemcutter (>= 0.1.0)
|
29
29
|
git (>= 1.2.5)
|
30
30
|
rubyforge (>= 2.0.0)
|
31
|
-
json (1.5.
|
32
|
-
json_pure (1.4
|
33
|
-
|
31
|
+
json (1.5.4)
|
32
|
+
json_pure (1.5.4)
|
33
|
+
spruz (~> 0.2.8)
|
34
|
+
linecache (0.46)
|
35
|
+
rbx-require-relative (> 0.0.4)
|
34
36
|
mocha (0.9.10)
|
35
37
|
rake
|
36
38
|
nokogiri (1.4.4)
|
@@ -42,11 +44,12 @@ GEM
|
|
42
44
|
activeresource (= 2.3.8)
|
43
45
|
activesupport (= 2.3.8)
|
44
46
|
rake (>= 0.8.3)
|
45
|
-
rake (0.
|
47
|
+
rake (0.9.2)
|
48
|
+
rbx-require-relative (0.0.5)
|
46
49
|
rspec (1.3.1)
|
47
|
-
rspec-rails (1.3.
|
50
|
+
rspec-rails (1.3.4)
|
48
51
|
rack (>= 1.0.0)
|
49
|
-
rspec (
|
52
|
+
rspec (~> 1.3.1)
|
50
53
|
ruby-debug (0.10.3)
|
51
54
|
columnize (>= 0.1)
|
52
55
|
ruby-debug-base (~> 0.10.3.0)
|
@@ -54,6 +57,7 @@ GEM
|
|
54
57
|
linecache (>= 0.3)
|
55
58
|
rubyforge (2.0.4)
|
56
59
|
json_pure (>= 1.1.7)
|
60
|
+
spruz (0.2.13)
|
57
61
|
sqlite3-ruby (1.3.1)
|
58
62
|
text-format (1.0.0)
|
59
63
|
text-hyphen (~> 1.0.0)
|
@@ -70,7 +74,7 @@ DEPENDENCIES
|
|
70
74
|
mocha (= 0.9.10)
|
71
75
|
nokogiri (= 1.4.4)
|
72
76
|
rails (= 2.3.8)
|
73
|
-
rake (
|
77
|
+
rake (>= 0.8.7)
|
74
78
|
rspec (= 1.3.1)
|
75
79
|
rspec-rails (~> 1.3.2)
|
76
80
|
ruby-debug (= 0.10.3)
|
data/README.md
CHANGED
@@ -6,7 +6,8 @@ SitemapGenerator generates Sitemaps for your Rails application. The Sitemaps ad
|
|
6
6
|
Features
|
7
7
|
-------
|
8
8
|
|
9
|
-
- Supports [Video sitemaps][sitemap_video], [Image sitemaps][sitemap_images], and [Geo sitemaps][
|
9
|
+
- Supports [News sitemaps][sitemap_news], [Video sitemaps][sitemap_video], [Image sitemaps][sitemap_images], and [Geo sitemaps][sitemap_geo]
|
10
|
+
- Supports read-only filesystems like Heroku via uploading to a remote host like Amazon S3
|
10
11
|
- Compatible with Rails 2 & 3
|
11
12
|
- Adheres to the [Sitemap 0.9 protocol][sitemap_protocol]
|
12
13
|
- Handles millions of links
|
@@ -26,6 +27,9 @@ Does your website use SitemapGenerator to generate Sitemaps? Where would you be
|
|
26
27
|
Changelog
|
27
28
|
-------
|
28
29
|
|
30
|
+
- v2.1.0: [News sitemap][sitemap_news] support
|
31
|
+
- v2.0.1.pre2: Fix uploading to the (bucket) root on a remote server
|
32
|
+
- v2.0.1.pre1: Support read-only filesystems like Heroku by supporting uploading to remote host
|
29
33
|
- v2.0.1: Minor improvements to verbose handling; prevent missing Timeout issue
|
30
34
|
- **v2.0.0: Introducing a new simpler API, Sitemap Groups, Sitemap Namers and more!**
|
31
35
|
- v1.5.0: New options `include_root`, `include_index`; Major testing & refactoring
|
@@ -407,6 +411,35 @@ If you have changed your sitemaps physical location in a group, then the default
|
|
407
411
|
Sitemap Extensions
|
408
412
|
===========
|
409
413
|
|
414
|
+
News Sitemaps
|
415
|
+
-----------
|
416
|
+
|
417
|
+
A news item can be added to a sitemap URL by passing a `:news` hash to `add`. The hash must contain tags defined by the [News Sitemap][news_tags] specification. For example:
|
418
|
+
|
419
|
+
SitemapGenerator::Sitemap.create do
|
420
|
+
add('/index.html', :news => {
|
421
|
+
:publication_name => "Example",
|
422
|
+
:publication_language => "en",
|
423
|
+
:title => "My Article",
|
424
|
+
:keywords => "my article, articles about myself",
|
425
|
+
:stock_tickers => "SAO:PETR3",
|
426
|
+
:publication_date => "2011-08-22",
|
427
|
+
:access => "Subscription",
|
428
|
+
:genres => "PressRelease"
|
429
|
+
})
|
430
|
+
end
|
431
|
+
|
432
|
+
Supported news options include:
|
433
|
+
|
434
|
+
* `publication_name`
|
435
|
+
* `publication_language`
|
436
|
+
* `publication_date`
|
437
|
+
* `genres`
|
438
|
+
* `access`
|
439
|
+
* `title`
|
440
|
+
* `keywords`
|
441
|
+
* `stock_tickers`
|
442
|
+
|
410
443
|
Image Sitemaps
|
411
444
|
-----------
|
412
445
|
|
@@ -513,21 +546,21 @@ Known Bugs
|
|
513
546
|
Wishlist & Coming Soon
|
514
547
|
========
|
515
548
|
|
516
|
-
- Support for read-only filesystems like Heroku
|
517
549
|
- Rails framework agnosticism; support for other frameworks like Merb
|
518
550
|
|
519
551
|
Thanks (in no particular order)
|
520
552
|
========
|
521
553
|
|
522
|
-
- [
|
523
|
-
- [
|
554
|
+
- [Rodrigo Flores](https://github.com/rodrigoflores) for News sitemaps
|
555
|
+
- [Alex Soto](http://github.com/apsoto) for Video sitemaps
|
556
|
+
- [Alexadre Bini](http://github.com/alexandrebini) for Image sitemaps
|
524
557
|
- [Dan Pickett](http://github.com/dpickett)
|
525
558
|
- [Rob Biedenharn](http://github.com/rab)
|
526
559
|
- [Richie Vos](http://github.com/jerryvos)
|
527
560
|
- [Adrian Mugnolo](http://github.com/xymbol)
|
528
561
|
- [Jason Weathered](http://github.com/jasoncodes)
|
529
562
|
- [Andy Stewart](http://github.com/airblade)
|
530
|
-
- [Brian Armstrong](https://github.com/barmstrong) for
|
563
|
+
- [Brian Armstrong](https://github.com/barmstrong) for Geo sitemaps
|
531
564
|
|
532
565
|
Copyright (c) 2009 Karl Varga released under the MIT license
|
533
566
|
|
@@ -538,7 +571,10 @@ Copyright (c) 2009 Karl Varga released under the MIT license
|
|
538
571
|
[sitemap_generator_usage]:http://wiki.github.com/adamsalter/sitemap_generator/sitemapgenerator-usage "http://wiki.github.com/adamsalter/sitemap_generator/sitemapgenerator-usage"
|
539
572
|
[sitemap_images]:http://www.google.com/support/webmasters/bin/answer.py?answer=178636
|
540
573
|
[sitemap_video]:http://www.google.com/support/webmasters/bin/topic.py?topic=10079
|
574
|
+
[sitemap_news]:http://www.google.com/support/webmasters/bin/topic.py?hl=en&topic=10078
|
575
|
+
[sitemap_geo]:http://www.google.com/support/webmasters/bin/topic.py?hl=en&topic=14688
|
541
576
|
[sitemap_protocol]:http://sitemaps.org/protocol.php
|
542
577
|
[video_tags]:http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=80472#4
|
543
578
|
[image_tags]:http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=178636
|
544
579
|
[geo_tags]:http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=94555
|
580
|
+
[news_tags]:http://www.google.com/support/news_pub/bin/answer.py?answer=74288
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0
|
1
|
+
2.1.0
|
data/lib/sitemap_generator.rb
CHANGED
@@ -4,11 +4,14 @@ require 'sitemap_generator/link_set'
|
|
4
4
|
require 'sitemap_generator/templates'
|
5
5
|
require 'sitemap_generator/utilities'
|
6
6
|
require 'sitemap_generator/application'
|
7
|
+
require 'sitemap_generator/adapters'
|
7
8
|
require 'sitemap_generator/sitemap_location'
|
8
9
|
require 'active_support/core_ext/numeric'
|
9
10
|
|
10
11
|
module SitemapGenerator
|
11
12
|
autoload(:Interpreter, 'sitemap_generator/interpreter')
|
13
|
+
autoload(:FileAdapter, 'sitemap_generator/adapters/file_adapter')
|
14
|
+
autoload(:WaveAdapter, 'sitemap_generator/adapters/wave_adapter')
|
12
15
|
|
13
16
|
SitemapError = Class.new(StandardError)
|
14
17
|
SitemapFullError = Class.new(SitemapError)
|
@@ -19,6 +22,7 @@ module SitemapGenerator
|
|
19
22
|
MAX_SITEMAP_FILES = 50_000 # max sitemap links per index file
|
20
23
|
MAX_SITEMAP_LINKS = 50_000 # max links per sitemap
|
21
24
|
MAX_SITEMAP_IMAGES = 1_000 # max images per url
|
25
|
+
MAX_SITEMAP_NEWS = 1_000 # max news sitemap per index_file
|
22
26
|
MAX_SITEMAP_FILESIZE = 10.megabytes # bytes
|
23
27
|
|
24
28
|
# Lazy-initialize the LinkSet instance
|
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module SitemapGenerator
|
2
|
+
class FileAdapter
|
3
|
+
def write(location, raw_data)
|
4
|
+
# Ensure that the directory exists
|
5
|
+
dir = location.directory
|
6
|
+
if !File.exists?(dir)
|
7
|
+
FileUtils.mkdir_p(dir)
|
8
|
+
elsif !File.directory?(dir)
|
9
|
+
raise SitemapError.new("#{dir} should be a directory!")
|
10
|
+
end
|
11
|
+
|
12
|
+
gzip(open(location.path, 'wb'), raw_data)
|
13
|
+
end
|
14
|
+
|
15
|
+
def gzip(stream, data)
|
16
|
+
gz = Zlib::GzipWriter.new(stream)
|
17
|
+
gz.write data
|
18
|
+
gz.close
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'carrierwave'
|
2
|
+
|
3
|
+
module SitemapGenerator
|
4
|
+
class WaveAdapter < ::CarrierWave::Uploader::Base
|
5
|
+
attr_accessor :store_dir
|
6
|
+
|
7
|
+
# Call with a SitemapLocation and string data
|
8
|
+
def write(location, raw_data)
|
9
|
+
SitemapGenerator::FileAdapter.new.write(location, raw_data)
|
10
|
+
directory = File.dirname(location.path_in_public)
|
11
|
+
if directory != '.'
|
12
|
+
self.store_dir = directory
|
13
|
+
end
|
14
|
+
store!(open(location.path, 'rb'))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -14,7 +14,7 @@ module SitemapGenerator
|
|
14
14
|
class SitemapFile
|
15
15
|
include ActionView::Helpers::NumberHelper
|
16
16
|
include ActionView::Helpers::TextHelper # Rails 2.2.2 fails with missing 'pluralize' otherwise
|
17
|
-
attr_reader :link_count, :filesize, :location
|
17
|
+
attr_reader :link_count, :filesize, :location, :news_count
|
18
18
|
|
19
19
|
# === Options
|
20
20
|
#
|
@@ -23,6 +23,7 @@ module SitemapGenerator
|
|
23
23
|
def initialize(opts={})
|
24
24
|
@location = opts.is_a?(Hash) ? SitemapGenerator::SitemapLocation.new(opts) : opts
|
25
25
|
@link_count = 0
|
26
|
+
@news_count = 0
|
26
27
|
@xml_content = '' # XML urlset content
|
27
28
|
@xml_wrapper_start = <<-HTML
|
28
29
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -34,6 +35,7 @@ module SitemapGenerator
|
|
34
35
|
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
35
36
|
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"
|
36
37
|
xmlns:geo="http://www.google.com/geo/schemas/sitemap/1.0"
|
38
|
+
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9/"
|
37
39
|
>
|
38
40
|
HTML
|
39
41
|
@xml_wrapper_start.gsub!(/\s+/, ' ').gsub!(/ *> */, '>').strip!
|
@@ -54,7 +56,7 @@ module SitemapGenerator
|
|
54
56
|
# bytesize will be calculated for you.
|
55
57
|
def file_can_fit?(bytes)
|
56
58
|
bytes = bytes.is_a?(String) ? bytesize(bytes) : bytes
|
57
|
-
(@filesize + bytes) < SitemapGenerator::MAX_SITEMAP_FILESIZE && @link_count < SitemapGenerator::MAX_SITEMAP_LINKS
|
59
|
+
(@filesize + bytes) < SitemapGenerator::MAX_SITEMAP_FILESIZE && @link_count < SitemapGenerator::MAX_SITEMAP_LINKS && @news_count < SitemapGenerator::MAX_SITEMAP_NEWS
|
58
60
|
end
|
59
61
|
|
60
62
|
# Add a link to the sitemap file.
|
@@ -74,9 +76,16 @@ module SitemapGenerator
|
|
74
76
|
# path, options - a path for the URL and options hash
|
75
77
|
def add(link, options={})
|
76
78
|
raise SitemapGenerator::SitemapFinalizedError if finalized?
|
77
|
-
|
79
|
+
|
80
|
+
sitemap_url = (link.is_a?(SitemapUrl) ? link : SitemapUrl.new(link, options) )
|
81
|
+
|
82
|
+
xml = sitemap_url.to_xml
|
78
83
|
raise SitemapGenerator::SitemapFullError if !file_can_fit?(xml)
|
79
84
|
|
85
|
+
if sitemap_url.news?
|
86
|
+
@news_count += 1
|
87
|
+
end
|
88
|
+
|
80
89
|
# Add the XML to the sitemap
|
81
90
|
@xml_content << xml
|
82
91
|
@filesize += bytesize(xml)
|
@@ -93,22 +102,7 @@ module SitemapGenerator
|
|
93
102
|
def finalize!
|
94
103
|
raise SitemapGenerator::SitemapFinalizedError if finalized?
|
95
104
|
|
96
|
-
|
97
|
-
dir = @location.directory
|
98
|
-
if !File.exists?(dir)
|
99
|
-
FileUtils.mkdir_p(dir)
|
100
|
-
elsif !File.directory?(dir)
|
101
|
-
raise SitemapError.new("#{dir} should be a directory!")
|
102
|
-
end
|
103
|
-
|
104
|
-
# Write out the file
|
105
|
-
open(@location.path, 'wb') do |file|
|
106
|
-
gz = Zlib::GzipWriter.new(file)
|
107
|
-
gz.write @xml_wrapper_start
|
108
|
-
gz.write @xml_content
|
109
|
-
gz.write @xml_wrapper_end
|
110
|
-
gz.close
|
111
|
-
end
|
105
|
+
@location.write(@xml_wrapper_start + @xml_content + @xml_wrapper_end)
|
112
106
|
|
113
107
|
# Increment the namer (SitemapFile only)
|
114
108
|
@location.namer.next if @location.namer
|
@@ -14,8 +14,8 @@ module SitemapGenerator
|
|
14
14
|
path = sitemap.location.path_in_public
|
15
15
|
end
|
16
16
|
|
17
|
-
SitemapGenerator::Utilities.assert_valid_keys(options, :priority, :changefreq, :lastmod, :host, :images, :video, :geo)
|
18
|
-
options.reverse_merge!(:priority => 0.5, :changefreq => 'weekly', :lastmod => Time.now, :images => [])
|
17
|
+
SitemapGenerator::Utilities.assert_valid_keys(options, :priority, :changefreq, :lastmod, :host, :images, :video, :geo, :news)
|
18
|
+
options.reverse_merge!(:priority => 0.5, :changefreq => 'weekly', :lastmod => Time.now, :images => [], :news => {})
|
19
19
|
self.merge!(
|
20
20
|
:path => path,
|
21
21
|
:priority => options[:priority],
|
@@ -24,6 +24,7 @@ module SitemapGenerator
|
|
24
24
|
:host => options[:host],
|
25
25
|
:loc => URI.join(options[:host], path).to_s,
|
26
26
|
:images => prepare_images(options[:images], options[:host]),
|
27
|
+
:news => prepare_news(options[:news]),
|
27
28
|
:video => options[:video],
|
28
29
|
:geo => options[:geo]
|
29
30
|
)
|
@@ -38,6 +39,24 @@ module SitemapGenerator
|
|
38
39
|
builder.changefreq self[:changefreq] if self[:changefreq]
|
39
40
|
builder.priority self[:priority] if self[:priority]
|
40
41
|
|
42
|
+
unless self[:news].blank?
|
43
|
+
news_data = self[:news]
|
44
|
+
builder.news:news do
|
45
|
+
builder.news:publication do
|
46
|
+
builder.news :name, news_data[:publication_name] if news_data[:publication_name]
|
47
|
+
builder.news :language, news_data[:publication_language] if news_data[:publication_language]
|
48
|
+
end
|
49
|
+
|
50
|
+
builder.news :access, news_data[:access] if news_data[:access]
|
51
|
+
builder.news :genres, news_data[:genres] if news_data[:genres]
|
52
|
+
builder.news :publication_date, news_data[:publication_date] if news_data[:publication_date]
|
53
|
+
builder.news :title, news_data[:title] if news_data[:title]
|
54
|
+
builder.news :keywords, news_data[:keywords] if news_data[:keywords]
|
55
|
+
builder.news :stock_tickers, news_data[:stock_tickers] if news_data[:stock_tickers]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
|
41
60
|
unless self[:images].blank?
|
42
61
|
self[:images].each do |image|
|
43
62
|
builder.image:image do
|
@@ -88,8 +107,17 @@ module SitemapGenerator
|
|
88
107
|
builder << '' # Force to string
|
89
108
|
end
|
90
109
|
|
110
|
+
def news?
|
111
|
+
self[:news].present?
|
112
|
+
end
|
113
|
+
|
91
114
|
protected
|
92
115
|
|
116
|
+
def prepare_news(news)
|
117
|
+
SitemapGenerator::Utilities.assert_valid_keys(news, :publication_name, :publication_language, :publication_date, :genres, :access, :title, :keywords, :stock_tickers) unless news.empty?
|
118
|
+
news
|
119
|
+
end
|
120
|
+
|
93
121
|
# Return an Array of image option Hashes suitable to be parsed by SitemapGenerator::Builder::SitemapFile
|
94
122
|
def prepare_images(images, host)
|
95
123
|
images.delete_if { |key,value| key[:loc] == nil }
|
@@ -8,7 +8,7 @@ module SitemapGenerator
|
|
8
8
|
@@new_location_opts = [:filename, :sitemaps_path, :sitemaps_namer]
|
9
9
|
|
10
10
|
attr_reader :default_host, :sitemaps_path, :filename
|
11
|
-
attr_accessor :verbose, :yahoo_app_id, :include_root, :include_index, :sitemaps_host
|
11
|
+
attr_accessor :verbose, :yahoo_app_id, :include_root, :include_index, :sitemaps_host, :adapter
|
12
12
|
|
13
13
|
# Add links to the link set by evaluating the block. The block should
|
14
14
|
# contains calls to sitemap methods like:
|
@@ -47,6 +47,9 @@ module SitemapGenerator
|
|
47
47
|
# Constructor
|
48
48
|
#
|
49
49
|
# == Options:
|
50
|
+
# * <tt>:adapter</tt> - subclass of SitemapGenerator::Adapter used for persisting the
|
51
|
+
# sitemaps. Default adapter is a SitemapGenerator::FileAdapter
|
52
|
+
#
|
50
53
|
# * <tt>:default_host</tt> - host including protocol to use in all sitemap links
|
51
54
|
# e.g. http://en.google.ca
|
52
55
|
#
|
@@ -394,7 +397,8 @@ module SitemapGenerator
|
|
394
397
|
:host => sitemaps_host,
|
395
398
|
:namer => sitemaps_namer,
|
396
399
|
:public_path => public_path,
|
397
|
-
:sitemaps_path => @sitemaps_path
|
400
|
+
:sitemaps_path => @sitemaps_path,
|
401
|
+
:adapter => @adapter
|
398
402
|
)
|
399
403
|
end
|
400
404
|
|
@@ -404,7 +408,8 @@ module SitemapGenerator
|
|
404
408
|
:host => sitemaps_host,
|
405
409
|
:namer => sitemap_index_namer,
|
406
410
|
:public_path => public_path,
|
407
|
-
:sitemaps_path => @sitemaps_path
|
411
|
+
:sitemaps_path => @sitemaps_path,
|
412
|
+
:adapter => @adapter
|
408
413
|
)
|
409
414
|
end
|
410
415
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module SitemapGenerator
|
2
2
|
class SitemapLocation < Hash
|
3
3
|
|
4
|
-
[:host].each do |method|
|
4
|
+
[:host, :adapter].each do |method|
|
5
5
|
define_method(method) do
|
6
6
|
raise SitemapGenerator::SitemapError, "No value set for #{method}" unless self[method]
|
7
7
|
self[method]
|
@@ -18,18 +18,20 @@ module SitemapGenerator
|
|
18
18
|
# files this generates names like <tt>sitemap1.xml.gz</tt>, <tt>sitemap2.xml.gz</tt> and so on,
|
19
19
|
#
|
20
20
|
# === Options
|
21
|
+
# * <tt>adapter</tt> - SitemapGenerator::Adapter subclass
|
22
|
+
# * <tt>filename</tt> - full name of the file e.g. <tt>'sitemap1.xml.gz'<tt>
|
23
|
+
# * <tt>host</tt> - host name for URLs. The full URL to the file is then constructed from
|
24
|
+
# the <tt>host</tt>, <tt>sitemaps_path</tt> and <tt>filename</tt>
|
25
|
+
# * <tt>namer</tt> - a SitemapGenerator::SitemapNamer instance. Can be passed instead of +filename+.
|
21
26
|
# * <tt>public_path</tt> - path to the "public" directory, or the directory you want to
|
22
27
|
# write sitemaps in. Default is a directory <tt>public/</tt>
|
23
28
|
# in the current working directory, or relative to the Rails root
|
24
29
|
# directory if running under Rails.
|
25
30
|
# * <tt>sitemaps_path</tt> - gives the path relative to the <tt>public_path</tt> in which to
|
26
31
|
# write sitemaps e.g. <tt>sitemaps/</tt>.
|
27
|
-
# * <tt>host</tt> - host name for URLs. The full URL to the file is then constructed from
|
28
|
-
# the <tt>host</tt>, <tt>sitemaps_path</tt> and <tt>filename</tt>
|
29
|
-
# * <tt>filename</tt> - full name of the file e.g. <tt>'sitemap1.xml.gz'<tt>
|
30
|
-
# * <tt>namer</tt> - a SitemapGenerator::SitemapNamer instance. Can be passed instead of +filename+.
|
31
32
|
def initialize(opts={})
|
32
|
-
SitemapGenerator::Utilities.assert_valid_keys(opts, [:public_path, :sitemaps_path, :host, :filename, :namer])
|
33
|
+
SitemapGenerator::Utilities.assert_valid_keys(opts, [:adapter, :public_path, :sitemaps_path, :host, :filename, :namer])
|
34
|
+
opts[:adapter] ||= SitemapGenerator::FileAdapter.new
|
33
35
|
opts[:public_path] ||= SitemapGenerator.app.root + 'public/'
|
34
36
|
opts[:namer] = SitemapGenerator::SitemapNamer.new(:sitemap) if !opts[:filename] && !opts[:namer]
|
35
37
|
self.merge!(opts)
|
@@ -92,6 +94,10 @@ module SitemapGenerator
|
|
92
94
|
end
|
93
95
|
super(key, value)
|
94
96
|
end
|
97
|
+
|
98
|
+
def write(data)
|
99
|
+
adapter.write(self, data)
|
100
|
+
end
|
95
101
|
end
|
96
102
|
|
97
103
|
class SitemapIndexLocation < SitemapLocation
|
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:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 2.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Karl Varga
|
@@ -16,11 +16,12 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-08-31 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
|
-
|
23
|
+
type: :development
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
25
|
none: false
|
25
26
|
requirements:
|
26
27
|
- - ">="
|
@@ -29,12 +30,12 @@ dependencies:
|
|
29
30
|
segments:
|
30
31
|
- 0
|
31
32
|
version: "0"
|
32
|
-
requirement: *id001
|
33
|
-
prerelease: false
|
34
|
-
type: :development
|
35
33
|
name: rspec
|
34
|
+
version_requirements: *id001
|
35
|
+
prerelease: false
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
|
37
|
+
type: :development
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
39
|
none: false
|
39
40
|
requirements:
|
40
41
|
- - ">="
|
@@ -43,12 +44,12 @@ dependencies:
|
|
43
44
|
segments:
|
44
45
|
- 0
|
45
46
|
version: "0"
|
46
|
-
requirement: *id002
|
47
|
-
prerelease: false
|
48
|
-
type: :development
|
49
47
|
name: nokogiri
|
48
|
+
version_requirements: *id002
|
49
|
+
prerelease: false
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
|
-
|
51
|
+
type: :development
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
53
|
none: false
|
53
54
|
requirements:
|
54
55
|
- - ">="
|
@@ -57,12 +58,12 @@ dependencies:
|
|
57
58
|
segments:
|
58
59
|
- 0
|
59
60
|
version: "0"
|
60
|
-
requirement: *id003
|
61
|
-
prerelease: false
|
62
|
-
type: :development
|
63
61
|
name: sqlite3-ruby
|
62
|
+
version_requirements: *id003
|
63
|
+
prerelease: false
|
64
64
|
- !ruby/object:Gem::Dependency
|
65
|
-
|
65
|
+
type: :development
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
67
|
none: false
|
67
68
|
requirements:
|
68
69
|
- - ">="
|
@@ -71,12 +72,12 @@ dependencies:
|
|
71
72
|
segments:
|
72
73
|
- 0
|
73
74
|
version: "0"
|
74
|
-
requirement: *id004
|
75
|
-
prerelease: false
|
76
|
-
type: :development
|
77
75
|
name: jeweler
|
76
|
+
version_requirements: *id004
|
77
|
+
prerelease: false
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
|
-
|
79
|
+
type: :development
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
80
81
|
none: false
|
81
82
|
requirements:
|
82
83
|
- - ">="
|
@@ -85,12 +86,12 @@ dependencies:
|
|
85
86
|
segments:
|
86
87
|
- 0
|
87
88
|
version: "0"
|
88
|
-
requirement: *id005
|
89
|
-
prerelease: false
|
90
|
-
type: :development
|
91
89
|
name: github
|
90
|
+
version_requirements: *id005
|
91
|
+
prerelease: false
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
|
-
|
93
|
+
type: :development
|
94
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
94
95
|
none: false
|
95
96
|
requirements:
|
96
97
|
- - ">="
|
@@ -99,10 +100,9 @@ dependencies:
|
|
99
100
|
segments:
|
100
101
|
- 0
|
101
102
|
version: "0"
|
102
|
-
requirement: *id006
|
103
|
-
prerelease: false
|
104
|
-
type: :development
|
105
103
|
name: git
|
104
|
+
version_requirements: *id006
|
105
|
+
prerelease: false
|
106
106
|
description: SitemapGenerator is a Rails gem that makes it easy to generate enterprise-class Sitemaps readable by all search engines. Generated Sitemaps adhere to the Sitemap protocol specification. When you generate new Sitemaps, SitemapGenerator can automatically ping the major search engines (including Google, Yahoo and Bing) to notify them. SitemapGenerator includes rake tasks to easily manage your sitemaps.
|
107
107
|
email: kjvarga@gmail.com
|
108
108
|
executables: []
|
@@ -119,6 +119,9 @@ files:
|
|
119
119
|
- Rakefile
|
120
120
|
- VERSION
|
121
121
|
- lib/sitemap_generator.rb
|
122
|
+
- lib/sitemap_generator/adapters.rb
|
123
|
+
- lib/sitemap_generator/adapters/file_adapter.rb
|
124
|
+
- lib/sitemap_generator/adapters/wave_adapter.rb
|
122
125
|
- lib/sitemap_generator/application.rb
|
123
126
|
- lib/sitemap_generator/builder.rb
|
124
127
|
- lib/sitemap_generator/builder/sitemap_file.rb
|