dynamic_sitemaps 2.0.0.beta2 → 2.0.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 918400614ebe09f1635dfed4f30d9d80459b084e
|
4
|
+
data.tar.gz: 1f0f3df4fddd3d6d6de765bd33da680f5c012af5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e47989bdc4540a62cb5cb3816880ea9603e5aa78a2a2553e84a68a917a62f77be3e936152c6bbd87986d753a9c5323eed132e10183e2119a6081e0ab54849757
|
7
|
+
data.tar.gz: 75dd53c52cc9d49fcd117f63039f99b613f94b613976bc103f38f85b8179f66147bb7cddb8a95395585d514fd70d3c9fbb8e7aefe639cc86a6b0c0e7d01b9ba3
|
@@ -31,10 +31,12 @@ module DynamicSitemaps
|
|
31
31
|
|
32
32
|
def move_to_destination
|
33
33
|
sitemaps.map(&:folder).uniq.each do |folder|
|
34
|
-
destination =
|
34
|
+
destination = File.join(DynamicSitemaps.path, folder)
|
35
35
|
FileUtils.mkdir_p destination
|
36
|
-
FileUtils.rm_rf Dir.glob(
|
37
|
-
|
36
|
+
FileUtils.rm_rf Dir.glob(File.join(destination, "*"))
|
37
|
+
|
38
|
+
temp_files = File.join(DynamicSitemaps.temp_path, folder, "*.xml")
|
39
|
+
FileUtils.mv Dir.glob(temp_files), destination
|
38
40
|
end
|
39
41
|
remove_temp_dir
|
40
42
|
end
|
@@ -58,7 +60,7 @@ module DynamicSitemaps
|
|
58
60
|
def sitemap_for(collection, options = {}, &block)
|
59
61
|
raise ArgumentError, "The collection given to `sitemap_for` must respond to #find_each. This is for performance. Use `Model.scoped` to get an ActiveRecord relation that responds to #find_each." unless collection.respond_to?(:find_each)
|
60
62
|
|
61
|
-
name = options.delete(:name) || collection.model_name.underscore.pluralize.to_sym
|
63
|
+
name = options.delete(:name) || collection.model_name.to_s.underscore.pluralize.to_sym
|
62
64
|
options[:collection] = collection
|
63
65
|
|
64
66
|
sitemap(name, options, &block)
|
@@ -1,10 +1,40 @@
|
|
1
|
+
# Change this to your host. See the readme at https://github.com/lassebunk/dynamic_sitemaps
|
2
|
+
# for examples of multiple hosts and folders.
|
1
3
|
host "www.example.com"
|
2
4
|
|
3
5
|
sitemap :site do
|
4
6
|
url root_url, last_mod: Time.now, change_freq: "daily", priority: 1.0
|
7
|
+
end
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
# You can have multiple sitemaps like the above – just make sure their names are different.
|
10
|
+
|
11
|
+
# Automatically link to all pages using the routes specified
|
12
|
+
# using "resources :pages" in config/routes.rb. This will also
|
13
|
+
# automatically set <lastmod> to the date and time in page.updated_at:
|
14
|
+
#
|
15
|
+
# sitemap_for Page.scoped
|
16
|
+
|
17
|
+
# For products with special sitemap name and priority, and link to comments:
|
18
|
+
#
|
19
|
+
# sitemap_for Product.published, name: :published_products do |product|
|
20
|
+
# url product, last_mod: product.updated_at, priority: (product.featured? ? 1.0 : 0.7)
|
21
|
+
# url product_comments_url(product)
|
22
|
+
# end
|
23
|
+
|
24
|
+
# If you want to generate multiple sitemaps in different folders (for example if you have
|
25
|
+
# more than one domain, you can specify a folder before the sitemap definitions:
|
26
|
+
#
|
27
|
+
# Site.all.each do |site|
|
28
|
+
# folder "sitemaps/#{site.domain}"
|
29
|
+
# host site.domain
|
30
|
+
#
|
31
|
+
# sitemap :site do
|
32
|
+
# url root_url
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# sitemap_for site.products.scoped
|
36
|
+
# end
|
37
|
+
|
38
|
+
# Ping search engines after sitemap generation:
|
39
|
+
#
|
40
|
+
# ping_with "http://#{host}/sitemap.xml"
|
data/test/generator_test.rb
CHANGED
@@ -341,6 +341,30 @@ class GeneratorTest < ActiveSupport::TestCase
|
|
341
341
|
assert !Dir.exists?(DynamicSitemaps.temp_path)
|
342
342
|
end
|
343
343
|
|
344
|
+
test "subfolders" do
|
345
|
+
DynamicSitemaps.per_page = 5
|
346
|
+
DynamicSitemaps.generate_sitemap do
|
347
|
+
host "www.example.com"
|
348
|
+
|
349
|
+
sitemap :site do
|
350
|
+
url root_url, :last_mod => Time.now, change_freq: "weekly", priority: 1.0
|
351
|
+
end
|
352
|
+
|
353
|
+
folder "sitemaps/subfolder"
|
354
|
+
sitemap :articles do
|
355
|
+
14.times do |i|
|
356
|
+
url "http://#{host}/articles/#{i}"
|
357
|
+
end
|
358
|
+
end
|
359
|
+
end
|
360
|
+
assert_equal ["sitemaps/sitemap.xml",
|
361
|
+
"sitemaps/subfolder/articles.xml",
|
362
|
+
"sitemaps/subfolder/articles2.xml",
|
363
|
+
"sitemaps/subfolder/articles3.xml",
|
364
|
+
"sitemaps/subfolder/sitemap.xml"],
|
365
|
+
Dir[Rails.root.join("public/sitemaps/**/*.xml")].map { |p| Pathname.new(p).relative_path_from(Pathname.new(DynamicSitemaps.path)).to_s }.sort
|
366
|
+
end
|
367
|
+
|
344
368
|
test "large sitemap" do
|
345
369
|
DynamicSitemaps.generate_sitemap do
|
346
370
|
host "www.mydomain.com"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamic_sitemaps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lasse Bunk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -166,9 +166,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
166
166
|
version: '0'
|
167
167
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
168
|
requirements:
|
169
|
-
- - '
|
169
|
+
- - '>='
|
170
170
|
- !ruby/object:Gem::Version
|
171
|
-
version:
|
171
|
+
version: '0'
|
172
172
|
requirements: []
|
173
173
|
rubyforge_project:
|
174
174
|
rubygems_version: 2.0.3
|