sitemap_generator 3.1.1 → 3.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.1
1
+ 3.2
@@ -10,6 +10,7 @@ require 'sitemap_generator/sitemap_location'
10
10
  module SitemapGenerator
11
11
  autoload(:Interpreter, 'sitemap_generator/interpreter')
12
12
  autoload(:FileAdapter, 'sitemap_generator/adapters/file_adapter')
13
+ autoload(:S3Adapter, 'sitemap_generator/adapters/s3_adapter')
13
14
  autoload(:WaveAdapter, 'sitemap_generator/adapters/wave_adapter')
14
15
  autoload(:BigDecimal, 'sitemap_generator/core_ext/big_decimal')
15
16
  autoload(:Numeric, 'sitemap_generator/core_ext/numeric')
@@ -0,0 +1,25 @@
1
+ require 'fog'
2
+
3
+ module SitemapGenerator
4
+ class S3Adapter
5
+
6
+ # Call with a SitemapLocation and string data
7
+ def write(location, raw_data)
8
+ SitemapGenerator::FileAdapter.new.write(location, raw_data)
9
+
10
+ credentials = {
11
+ :aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'],
12
+ :aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'],
13
+ :provider => ENV['FOG_PROVIDER'],
14
+ }
15
+
16
+ storage = Fog::Storage.new(credentials)
17
+ directory = storage.directories.get(ENV['FOG_DIRECTORY'])
18
+ directory.files.create(
19
+ :key => location.path_in_public,
20
+ :body => File.open(location.path),
21
+ :public => true,
22
+ )
23
+ end
24
+ end
25
+ end
@@ -34,7 +34,8 @@ module SitemapGenerator
34
34
  xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
35
35
  xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"
36
36
  xmlns:geo="http://www.google.com/geo/schemas/sitemap/1.0"
37
- xmlns:news="http://www.google.com/schemas/sitemap-news/0.9/"
37
+ xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
38
+ xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0"
38
39
  >
39
40
  HTML
40
41
  @xml_wrapper_start.gsub!(/\s+/, ' ').gsub!(/ *> */, '>').strip!
@@ -26,6 +26,7 @@ module SitemapGenerator
26
26
  # * +video+/+videos+
27
27
  # * +geo+
28
28
  # * +news+
29
+ # * +mobile+
29
30
  def initialize(path, options={})
30
31
  options = options.dup
31
32
  if sitemap = path.is_a?(SitemapGenerator::Builder::SitemapFile) && path
@@ -33,8 +34,8 @@ module SitemapGenerator
33
34
  path = sitemap.location.path_in_public
34
35
  end
35
36
 
36
- SitemapGenerator::Utilities.assert_valid_keys(options, :priority, :changefreq, :lastmod, :host, :images, :video, :geo, :news, :videos)
37
- SitemapGenerator::Utilities.reverse_merge!(options, :priority => 0.5, :changefreq => 'weekly', :lastmod => Time.now, :images => [], :news => {}, :videos => [])
37
+ SitemapGenerator::Utilities.assert_valid_keys(options, :priority, :changefreq, :lastmod, :host, :images, :video, :geo, :news, :videos, :mobile)
38
+ SitemapGenerator::Utilities.reverse_merge!(options, :priority => 0.5, :changefreq => 'weekly', :lastmod => Time.now, :images => [], :news => {}, :videos => [], :mobile => false)
38
39
  raise "Cannot generate a url without a host" unless SitemapGenerator::Utilities.present?(options[:host])
39
40
  if video = options.delete(:video)
40
41
  options[:videos] = video.is_a?(Array) ? options[:videos].concat(video) : options[:videos] << video
@@ -51,7 +52,8 @@ module SitemapGenerator
51
52
  :images => prepare_images(options[:images], options[:host]),
52
53
  :news => prepare_news(options[:news]),
53
54
  :videos => options[:videos],
54
- :geo => options[:geo]
55
+ :geo => options[:geo],
56
+ :mobile => options[:mobile]
55
57
  )
56
58
  end
57
59
 
@@ -98,7 +100,9 @@ module SitemapGenerator
98
100
  builder.video :description, video[:description]
99
101
  builder.video :content_loc, video[:content_loc] if video[:content_loc]
100
102
  if video[:player_loc]
101
- builder.video :player_loc, video[:player_loc], :allow_embed => yes_or_no_with_default(video[:allow_embed], true), :autoplay => video[:autoplay]
103
+ loc_attributes = { :allow_embed => yes_or_no_with_default(video[:allow_embed], true) }
104
+ loc_attributes[:autoplay] = video[:autoplay] if SitemapGenerator::Utilities.present?(video[:autoplay])
105
+ builder.video :player_loc, video[:player_loc], loc_attributes
102
106
  end
103
107
  builder.video :duration, video[:duration] if video[:duration]
104
108
  builder.video :expiration_date, w3c_date(video[:expiration_date]) if video[:expiration_date]
@@ -122,6 +126,10 @@ module SitemapGenerator
122
126
  builder.geo :format, geo[:format] if geo[:format]
123
127
  end
124
128
  end
129
+
130
+ unless SitemapGenerator::Utilities.blank?(self[:mobile])
131
+ builder.mobile :mobile
132
+ end
125
133
  end
126
134
  builder << '' # Force to string
127
135
  end
@@ -88,7 +88,7 @@ module SitemapGenerator
88
88
  #
89
89
  # * <tt>:include_index</tt> - Boolean. Whether to <b>add a link to the sitemap index<b>
90
90
  # to the current sitemap. This points search engines to your Sitemap Index to
91
- # include it in the indexing of your site. Default is `true`. Turned off when
91
+ # include it in the indexing of your site. Default is `false`. Turned off when
92
92
  # `sitemaps_host` is set or within a `group()` block.
93
93
  #
94
94
  # * <tt>:include_root</tt> - Boolean. Whether to **add the root** url i.e. '/' to the
@@ -102,11 +102,10 @@ module SitemapGenerator
102
102
  def initialize(options={})
103
103
  options = SitemapGenerator::Utilities.reverse_merge(options,
104
104
  :include_root => true,
105
- :include_index => true,
105
+ :include_index => false,
106
106
  :filename => :sitemap,
107
107
  :search_engines => {
108
108
  :google => "http://www.google.com/webmasters/sitemaps/ping?sitemap=%s",
109
- :ask => "http://submissions.ask.com/ping?sitemap=%s",
110
109
  :bing => "http://www.bing.com/webmaster/ping.aspx?siteMap=%s",
111
110
  :sitemap_writer => "http://www.sitemapwriter.com/notify.php?crawler=all&url=%s"
112
111
  }
@@ -24,7 +24,7 @@ describe SitemapGenerator::LinkSet do
24
24
  :sitemaps_path => nil,
25
25
  :public_path => SitemapGenerator.app.root + 'public/',
26
26
  :default_host => nil,
27
- :include_index => true,
27
+ :include_index => false,
28
28
  :include_root => true
29
29
  }
30
30
 
@@ -36,12 +36,20 @@ describe SitemapGenerator::LinkSet do
36
36
  end
37
37
 
38
38
  describe "include_root include_index option" do
39
+ it "should include the root url and the sitemap index url" do
40
+ ls = SitemapGenerator::LinkSet.new(:default_host => default_host, :include_root => true, :include_index => true)
41
+ ls.include_root.should be_true
42
+ ls.include_index.should be_true
43
+ ls.add_links { |sitemap| }
44
+ ls.sitemap.link_count.should == 2
45
+ end
46
+
39
47
  it "should not include the root url" do
40
48
  ls = SitemapGenerator::LinkSet.new(:default_host => default_host, :include_root => false)
41
49
  ls.include_root.should be_false
42
- ls.include_index.should be_true
50
+ ls.include_index.should be_false
43
51
  ls.add_links { |sitemap| }
44
- ls.sitemap.link_count.should == 1
52
+ ls.sitemap.link_count.should == 0
45
53
  end
46
54
 
47
55
  it "should not include the sitemap index url" do
@@ -102,12 +110,12 @@ describe SitemapGenerator::LinkSet do
102
110
  describe "search_engines" do
103
111
  it "should have search engines by default" do
104
112
  ls.search_engines.should be_a(Hash)
105
- ls.search_engines.size.should == 4
113
+ ls.search_engines.size.should == 3
106
114
  end
107
115
 
108
116
  it "should support being modified" do
109
117
  ls.search_engines[:newengine] = 'abc'
110
- ls.search_engines.size.should == 5
118
+ ls.search_engines.size.should == 4
111
119
  end
112
120
 
113
121
  it "should support being set to nil" do
@@ -576,11 +584,6 @@ describe SitemapGenerator::LinkSet do
576
584
  ls = SitemapGenerator::LinkSet.new(:default_host => default_host, :sitemaps_host => sitemaps_host)
577
585
  ls.include_index?.should be_false
578
586
  end
579
-
580
- it "should return true" do
581
- ls = SitemapGenerator::LinkSet.new(:default_host => default_host, :sitemaps_host => default_host)
582
- ls.include_index?.should be_true
583
- end
584
587
  end
585
588
 
586
589
  describe "output" do
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe "SitemapGenerator" do
4
+
5
+ it "should add the mobile sitemap element" do
6
+ loc = 'http://www.example.com/mobile_page.html'
7
+ format = 'html'
8
+
9
+ mobile_xml_fragment = SitemapGenerator::Builder::SitemapUrl.new('mobile_page.html',
10
+ :host => 'http://www.example.com',
11
+ :mobile => true
12
+ ).to_xml
13
+
14
+ # Check that the options were parsed correctly
15
+ doc = Nokogiri::XML.parse("<root xmlns:mobile='http://www.google.com/schemas/sitemap-mobile/1.0'>#{mobile_xml_fragment}</root>")
16
+ url = doc.at_xpath("//url")
17
+ url.should_not be_nil
18
+ url.at_xpath("loc").text.should == loc
19
+
20
+ mobile = url.at_xpath("mobile:mobile")
21
+ mobile.should_not be_nil
22
+
23
+ # Google's documentation and published schema don't match some valid elements may
24
+ # not validate.
25
+ xml_fragment_should_validate_against_schema(mobile, 'http://www.google.com/schemas/sitemap-mobile/1.0', 'sitemap-mobile')
26
+ end
27
+ end
@@ -56,8 +56,8 @@ describe "SitemapGenerator" do
56
56
  file_should_not_exist(rails_path('public/sitemap3.xml.gz'))
57
57
  end
58
58
 
59
- it "should have 14 links" do
60
- SitemapGenerator::Sitemap.link_count.should == 14
59
+ it "should have 13 links" do
60
+ SitemapGenerator::Sitemap.link_count.should == 13
61
61
  end
62
62
 
63
63
  it "index XML should validate" do
@@ -104,7 +104,7 @@ describe "SitemapGenerator" do
104
104
  file_should_not_exist(rails_path('public/fr/abc5.xml.gz'))
105
105
  end
106
106
 
107
- it "should have 14 links" do
107
+ it "should have 13 links" do
108
108
  SitemapGenerator::Sitemap.link_count.should == 13
109
109
  end
110
110
 
@@ -30,7 +30,7 @@ describe "Sitemap Groups" do
30
30
  it "should add default links if no groups are created" do
31
31
  @sm.create do
32
32
  end
33
- @sm.link_count.should == 2
33
+ @sm.link_count.should == 1
34
34
  file_should_exist(SitemapGenerator.app.root + 'public/sitemap_index.xml.gz')
35
35
  file_should_exist(SitemapGenerator.app.root + 'public/sitemap1.xml.gz')
36
36
  end
@@ -41,7 +41,7 @@ describe "Sitemap Groups" do
41
41
  group(:filename => :sitemap_en) { }
42
42
  add '/after'
43
43
  end
44
- @sm.link_count.should == 4
44
+ @sm.link_count.should == 3
45
45
  file_should_exist(SitemapGenerator.app.root + 'public/sitemap_index.xml.gz')
46
46
  file_should_exist(SitemapGenerator.app.root + 'public/sitemap1.xml.gz')
47
47
  file_should_exist(SitemapGenerator.app.root + 'public/sitemap_en1.xml.gz')
@@ -93,7 +93,7 @@ describe "Sitemap Groups" do
93
93
  group(:filename => :second) { add '/four' }
94
94
  add 'five'
95
95
  end
96
- @sm.link_count.should == 7
96
+ @sm.link_count.should == 6
97
97
  file_should_exist(SitemapGenerator.app.root + 'public/sitemap_index.xml.gz')
98
98
  file_should_exist(SitemapGenerator.app.root + 'public/sitemap1.xml.gz')
99
99
  file_should_exist(SitemapGenerator.app.root + 'public/first1.xml.gz')
@@ -108,7 +108,7 @@ describe "Sitemap Groups" do
108
108
  group(:default_host => 'http://betterhost.com') { add '/four' }
109
109
  add 'five'
110
110
  end
111
- @sm.link_count.should == 7
111
+ @sm.link_count.should == 6
112
112
  file_should_exist(SitemapGenerator.app.root + 'public/sitemap_index.xml.gz')
113
113
  file_should_exist(SitemapGenerator.app.root + 'public/sitemap1.xml.gz')
114
114
  file_should_not_exist(SitemapGenerator.app.root + 'public/sitemap2.xml.gz')
@@ -122,7 +122,7 @@ describe "Sitemap Groups" do
122
122
  group(:sitemaps_host => 'http://newhost.com') { add '/four' }
123
123
  add 'five'
124
124
  end
125
- @sm.link_count.should == 7
125
+ @sm.link_count.should == 6
126
126
  file_should_exist(SitemapGenerator.app.root + 'public/sitemap_index.xml.gz')
127
127
  file_should_exist(SitemapGenerator.app.root + 'public/sitemap1.xml.gz')
128
128
  file_should_exist(SitemapGenerator.app.root + 'public/sitemap2.xml.gz')
@@ -100,4 +100,10 @@ describe "SitemapGenerator" do
100
100
  doc.at_xpath("//url/video:video/video:#{element}").should be_nil
101
101
  end
102
102
  end
103
+
104
+ it "should not include autoplay param if blank" do
105
+ xml = video_xml(video_options.tap {|v| v.delete(:autoplay) })
106
+ doc = video_doc(xml)
107
+ doc.at_xpath("//url/video:video/video:player_loc").attribute('autoplay').should be_nil
108
+ end
103
109
  end
@@ -0,0 +1,32 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <xsd:schema
3
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
4
+ targetNamespace="http://www.google.com/schemas/sitemap-mobile/1.0"
5
+ xmlns="http://www.google.com/schemas/sitemap-mobile/1.0"
6
+ elementFormDefault="qualified">
7
+
8
+ <xsd:annotation>
9
+ <xsd:documentation>
10
+ XML Schema for the Mobile Sitemap extension. This schema defines the
11
+ Mobile-specific elements only; the core Sitemap elements are defined
12
+ separately.
13
+
14
+ Help Center documentation for the Mobile Sitemap extension:
15
+
16
+ http://www.google.com/support/webmasters/bin/topic.py?topic=8493
17
+
18
+ Copyright 2010 Google Inc. All Rights Reserved.
19
+ </xsd:documentation>
20
+ </xsd:annotation>
21
+
22
+ <xsd:element name="mobile">
23
+ <xsd:annotation>
24
+ <xsd:documentation>
25
+ Mobile sitemaps just contain an empty "mobile" tag to identify a
26
+ URL as having mobile content.
27
+ </xsd:documentation>
28
+ </xsd:annotation>
29
+ <xsd:complexType/>
30
+ </xsd:element>
31
+
32
+ </xsd:schema>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sitemap_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: '3.2'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-03-23 00:00:00.000000000Z
13
+ date: 2012-08-09 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mocha
17
- requirement: &70275948886900 !ruby/object:Gem::Requirement
17
+ requirement: &70093962414600 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *70275948886900
25
+ version_requirements: *70093962414600
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: nokogiri
28
- requirement: &70275948886460 !ruby/object:Gem::Requirement
28
+ requirement: &70093962414160 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *70275948886460
36
+ version_requirements: *70093962414160
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rspec
39
- requirement: &70275948886040 !ruby/object:Gem::Requirement
39
+ requirement: &70093962413740 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70275948886040
47
+ version_requirements: *70093962413740
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: builder
50
- requirement: &70275948885620 !ruby/object:Gem::Requirement
50
+ requirement: &70093962413320 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,7 +55,7 @@ dependencies:
55
55
  version: '0'
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *70275948885620
58
+ version_requirements: *70093962413320
59
59
  description: SitemapGenerator is an XML Sitemap generator written in Ruby with automatic
60
60
  Rails integration. It supports Video, News, Image and Geo sitemaps and includes
61
61
  Rake tasks for managing your sitemaps.
@@ -71,6 +71,7 @@ files:
71
71
  - README.md
72
72
  - VERSION
73
73
  - lib/sitemap_generator/adapters/file_adapter.rb
74
+ - lib/sitemap_generator/adapters/s3_adapter.rb
74
75
  - lib/sitemap_generator/adapters/wave_adapter.rb
75
76
  - lib/sitemap_generator/adapters.rb
76
77
  - lib/sitemap_generator/application.rb
@@ -111,6 +112,7 @@ files:
111
112
  - spec/sitemap_generator/helpers/number_helper_spec.rb
112
113
  - spec/sitemap_generator/interpreter_spec.rb
113
114
  - spec/sitemap_generator/link_set_spec.rb
115
+ - spec/sitemap_generator/mobile_sitemap_spec.rb
114
116
  - spec/sitemap_generator/news_sitemap_spec.rb
115
117
  - spec/sitemap_generator/sitemap_generator_spec.rb
116
118
  - spec/sitemap_generator/sitemap_groups_spec.rb
@@ -126,6 +128,7 @@ files:
126
128
  - spec/support/file_macros.rb
127
129
  - spec/support/schemas/siteindex.xsd
128
130
  - spec/support/schemas/sitemap-geo.xsd
131
+ - spec/support/schemas/sitemap-mobile.xsd
129
132
  - spec/support/schemas/sitemap-news.xsd
130
133
  - spec/support/schemas/sitemap-video.xsd
131
134
  - spec/support/schemas/sitemap.xsd
@@ -144,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
147
  version: '0'
145
148
  segments:
146
149
  - 0
147
- hash: 3037685693484208211
150
+ hash: 2266016413658369845
148
151
  required_rubygems_version: !ruby/object:Gem::Requirement
149
152
  none: false
150
153
  requirements:
@@ -153,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
156
  version: '0'
154
157
  segments:
155
158
  - 0
156
- hash: 3037685693484208211
159
+ hash: 2266016413658369845
157
160
  requirements: []
158
161
  rubyforge_project:
159
162
  rubygems_version: 1.8.10
@@ -176,6 +179,7 @@ test_files:
176
179
  - spec/sitemap_generator/helpers/number_helper_spec.rb
177
180
  - spec/sitemap_generator/interpreter_spec.rb
178
181
  - spec/sitemap_generator/link_set_spec.rb
182
+ - spec/sitemap_generator/mobile_sitemap_spec.rb
179
183
  - spec/sitemap_generator/news_sitemap_spec.rb
180
184
  - spec/sitemap_generator/sitemap_generator_spec.rb
181
185
  - spec/sitemap_generator/sitemap_groups_spec.rb
@@ -191,6 +195,7 @@ test_files:
191
195
  - spec/support/file_macros.rb
192
196
  - spec/support/schemas/siteindex.xsd
193
197
  - spec/support/schemas/sitemap-geo.xsd
198
+ - spec/support/schemas/sitemap-mobile.xsd
194
199
  - spec/support/schemas/sitemap-news.xsd
195
200
  - spec/support/schemas/sitemap-video.xsd
196
201
  - spec/support/schemas/sitemap.xsd