sitemap_generator 2.0.0 → 2.0.1.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/VERSION +1 -1
- data/lib/sitemap_generator.rb +4 -1
- 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 +13 -0
- data/lib/sitemap_generator/builder/sitemap_file.rb +1 -16
- data/lib/sitemap_generator/link_set.rb +9 -3
- data/lib/sitemap_generator/sitemap_location.rb +12 -6
- data/tasks/sitemap_generator_tasks.rake +6 -5
- metadata +40 -33
data/Gemfile.lock
CHANGED
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.0.1: Minor improvements to verbose handling; prevent missing Timeout issue
|
29
30
|
- **v2.0.0: Introducing a new simpler API, Sitemap Groups, Sitemap Namers and more!**
|
30
31
|
- v1.5.0: New options `include_root`, `include_index`; Major testing & refactoring
|
31
32
|
- v1.4.0: [Geo sitemap][geo_tags] support, multiple sitemap support via CONFIG_FILE rake option
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.1.pre1
|
data/lib/sitemap_generator.rb
CHANGED
@@ -4,12 +4,15 @@ 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')
|
12
|
-
|
13
|
+
autoload(:FileAdapter, 'sitemap_generator/adapters/file_adapter')
|
14
|
+
autoload(:WaveAdapter, 'sitemap_generator/adapters/wave_adapter')
|
15
|
+
|
13
16
|
SitemapError = Class.new(StandardError)
|
14
17
|
SitemapFullError = Class.new(SitemapError)
|
15
18
|
SitemapFinalizedError = Class.new(SitemapError)
|
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,13 @@
|
|
1
|
+
require 'carrierwave'
|
2
|
+
|
3
|
+
module SitemapGenerator
|
4
|
+
class WaveAdapter < ::CarrierWave::Uploader::Base
|
5
|
+
attr_accessor :store_dir
|
6
|
+
|
7
|
+
def write(location, raw_data)
|
8
|
+
SitemapGenerator::FileAdapter.new.write(location, raw_data)
|
9
|
+
self.store_dir = File.dirname(location.path_in_public)
|
10
|
+
store!(open(location.path, 'rb'))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -93,22 +93,7 @@ module SitemapGenerator
|
|
93
93
|
def finalize!
|
94
94
|
raise SitemapGenerator::SitemapFinalizedError if finalized?
|
95
95
|
|
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
|
96
|
+
@location.write(@xml_wrapper_start + @xml_content + @xml_wrapper_end)
|
112
97
|
|
113
98
|
# Increment the namer (SitemapFile only)
|
114
99
|
@location.namer.next if @location.namer
|
@@ -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
|
#
|
@@ -165,6 +168,7 @@ module SitemapGenerator
|
|
165
168
|
# @see http://en.wikipedia.org/wiki/Sitemap_index
|
166
169
|
def ping_search_engines
|
167
170
|
require 'open-uri'
|
171
|
+
require 'timeout'
|
168
172
|
|
169
173
|
sitemap_index_url = CGI.escape(sitemap_index.location.url)
|
170
174
|
search_engines = {
|
@@ -393,7 +397,8 @@ module SitemapGenerator
|
|
393
397
|
:host => sitemaps_host,
|
394
398
|
:namer => sitemaps_namer,
|
395
399
|
:public_path => public_path,
|
396
|
-
:sitemaps_path => @sitemaps_path
|
400
|
+
:sitemaps_path => @sitemaps_path,
|
401
|
+
:adapter => @adapter
|
397
402
|
)
|
398
403
|
end
|
399
404
|
|
@@ -403,7 +408,8 @@ module SitemapGenerator
|
|
403
408
|
:host => sitemaps_host,
|
404
409
|
:namer => sitemap_index_namer,
|
405
410
|
:public_path => public_path,
|
406
|
-
:sitemaps_path => @sitemaps_path
|
411
|
+
:sitemaps_path => @sitemaps_path,
|
412
|
+
:adapter => @adapter
|
407
413
|
)
|
408
414
|
end
|
409
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
|
@@ -20,7 +20,7 @@ namespace :sitemap do
|
|
20
20
|
|
21
21
|
desc "Install a default config/sitemap.rb file"
|
22
22
|
task :install => ['sitemap:require'] do
|
23
|
-
SitemapGenerator::Utilities.install_sitemap_rb(verbose)
|
23
|
+
SitemapGenerator::Utilities.install_sitemap_rb(verbose.nil? ? true : false)
|
24
24
|
end
|
25
25
|
|
26
26
|
desc "Delete all Sitemap files in public/ directory"
|
@@ -28,15 +28,16 @@ namespace :sitemap do
|
|
28
28
|
SitemapGenerator::Utilities.clean_files
|
29
29
|
end
|
30
30
|
|
31
|
-
desc "
|
31
|
+
desc "Generate sitemaps and ping search engines."
|
32
32
|
task :refresh => ['sitemap:create'] do
|
33
33
|
SitemapGenerator::Sitemap.ping_search_engines
|
34
34
|
end
|
35
35
|
|
36
|
-
desc "
|
36
|
+
desc "Generate sitemaps but don't ping search engines."
|
37
37
|
task 'refresh:no_ping' => ['sitemap:create']
|
38
38
|
|
39
|
+
desc "Generate sitemaps but don't ping search engines. Alias for refresh:no_ping."
|
39
40
|
task :create => ['sitemap:require_environment'] do
|
40
|
-
SitemapGenerator::Interpreter.run(:config_file => ENV["CONFIG_FILE"], :verbose => verbose)
|
41
|
+
SitemapGenerator::Interpreter.run(:config_file => ENV["CONFIG_FILE"], :verbose => verbose.nil? ? true : false)
|
41
42
|
end
|
42
|
-
end
|
43
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sitemap_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 1923832035
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
|
9
|
+
- 1
|
10
|
+
- pre
|
11
|
+
- 1
|
12
|
+
version: 2.0.1.pre1
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- Karl Varga
|
@@ -16,12 +18,11 @@ autorequire:
|
|
16
18
|
bindir: bin
|
17
19
|
cert_chain: []
|
18
20
|
|
19
|
-
date: 2011-
|
21
|
+
date: 2011-06-11 00:00:00 -07:00
|
20
22
|
default_executable:
|
21
23
|
dependencies:
|
22
24
|
- !ruby/object:Gem::Dependency
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
25
26
|
none: false
|
26
27
|
requirements:
|
27
28
|
- - ">="
|
@@ -30,12 +31,12 @@ dependencies:
|
|
30
31
|
segments:
|
31
32
|
- 0
|
32
33
|
version: "0"
|
33
|
-
|
34
|
-
version_requirements: *id001
|
34
|
+
requirement: *id001
|
35
35
|
prerelease: false
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
36
|
type: :development
|
38
|
-
|
37
|
+
name: rspec
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
40
|
none: false
|
40
41
|
requirements:
|
41
42
|
- - ">="
|
@@ -44,12 +45,12 @@ dependencies:
|
|
44
45
|
segments:
|
45
46
|
- 0
|
46
47
|
version: "0"
|
47
|
-
|
48
|
-
version_requirements: *id002
|
48
|
+
requirement: *id002
|
49
49
|
prerelease: false
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
50
|
type: :development
|
52
|
-
|
51
|
+
name: nokogiri
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
53
54
|
none: false
|
54
55
|
requirements:
|
55
56
|
- - ">="
|
@@ -58,12 +59,12 @@ dependencies:
|
|
58
59
|
segments:
|
59
60
|
- 0
|
60
61
|
version: "0"
|
61
|
-
|
62
|
-
version_requirements: *id003
|
62
|
+
requirement: *id003
|
63
63
|
prerelease: false
|
64
|
-
- !ruby/object:Gem::Dependency
|
65
64
|
type: :development
|
66
|
-
|
65
|
+
name: sqlite3-ruby
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
67
68
|
none: false
|
68
69
|
requirements:
|
69
70
|
- - ">="
|
@@ -72,12 +73,12 @@ dependencies:
|
|
72
73
|
segments:
|
73
74
|
- 0
|
74
75
|
version: "0"
|
75
|
-
|
76
|
-
version_requirements: *id004
|
76
|
+
requirement: *id004
|
77
77
|
prerelease: false
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
78
|
type: :development
|
80
|
-
|
79
|
+
name: jeweler
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
81
82
|
none: false
|
82
83
|
requirements:
|
83
84
|
- - ">="
|
@@ -86,12 +87,12 @@ dependencies:
|
|
86
87
|
segments:
|
87
88
|
- 0
|
88
89
|
version: "0"
|
89
|
-
|
90
|
-
version_requirements: *id005
|
90
|
+
requirement: *id005
|
91
91
|
prerelease: false
|
92
|
-
- !ruby/object:Gem::Dependency
|
93
92
|
type: :development
|
94
|
-
|
93
|
+
name: github
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
95
96
|
none: false
|
96
97
|
requirements:
|
97
98
|
- - ">="
|
@@ -100,9 +101,10 @@ dependencies:
|
|
100
101
|
segments:
|
101
102
|
- 0
|
102
103
|
version: "0"
|
103
|
-
|
104
|
-
version_requirements: *id006
|
104
|
+
requirement: *id006
|
105
105
|
prerelease: false
|
106
|
+
type: :development
|
107
|
+
name: git
|
106
108
|
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
109
|
email: kjvarga@gmail.com
|
108
110
|
executables: []
|
@@ -119,6 +121,9 @@ files:
|
|
119
121
|
- Rakefile
|
120
122
|
- VERSION
|
121
123
|
- lib/sitemap_generator.rb
|
124
|
+
- lib/sitemap_generator/adapters.rb
|
125
|
+
- lib/sitemap_generator/adapters/file_adapter.rb
|
126
|
+
- lib/sitemap_generator/adapters/wave_adapter.rb
|
122
127
|
- lib/sitemap_generator/application.rb
|
123
128
|
- lib/sitemap_generator/builder.rb
|
124
129
|
- lib/sitemap_generator/builder/sitemap_file.rb
|
@@ -158,12 +163,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
158
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
164
|
none: false
|
160
165
|
requirements:
|
161
|
-
- - "
|
166
|
+
- - ">"
|
162
167
|
- !ruby/object:Gem::Version
|
163
|
-
hash:
|
168
|
+
hash: 25
|
164
169
|
segments:
|
165
|
-
-
|
166
|
-
|
170
|
+
- 1
|
171
|
+
- 3
|
172
|
+
- 1
|
173
|
+
version: 1.3.1
|
167
174
|
requirements: []
|
168
175
|
|
169
176
|
rubyforge_project:
|