sitemap 0.1b → 0.1b2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +10 -2
- data/lib/sitemap.rb +6 -6
- data/sitemap.gemspec +1 -1
- data/test/sitemap_test.rb +10 -10
- metadata +5 -5
data/README.rdoc
CHANGED
@@ -6,15 +6,23 @@ A simple ruby on rails sitemap generator.
|
|
6
6
|
|
7
7
|
Create a sitemap.rb file in your config directory. Paths can be indexed as follows:
|
8
8
|
|
9
|
-
Sitemap.instance.
|
9
|
+
Sitemap::Generator.instance.load :host => "mywebsite.com" do
|
10
10
|
path :root, :priority => 1
|
11
11
|
path :faq, :priority => 0.5, :change_frequency => "weekly"
|
12
|
-
resources :activities, :format => "html"
|
12
|
+
resources :activities, :params => { :format => "html" }
|
13
13
|
resources :articles, :objects => proc { Article.published }
|
14
14
|
end
|
15
15
|
|
16
16
|
Please read the docs for a more comprehensive list of options.
|
17
17
|
|
18
|
+
Building the sitemap:
|
19
|
+
|
20
|
+
rake sitemap:generate
|
21
|
+
|
22
|
+
Ping search engines:
|
23
|
+
|
24
|
+
rake sitemap:ping
|
25
|
+
|
18
26
|
== License
|
19
27
|
|
20
28
|
This package is licensed under the MIT license and/or the Creative
|
data/lib/sitemap.rb
CHANGED
@@ -46,31 +46,31 @@ module Sitemap
|
|
46
46
|
#
|
47
47
|
# The +host+, or any other global option can be set here:
|
48
48
|
#
|
49
|
-
# Sitemap.instance.
|
49
|
+
# Sitemap::Generator.instance.load :host => "mywebsite.com" do
|
50
50
|
# ...
|
51
51
|
# end
|
52
52
|
#
|
53
53
|
# Simple paths can be added as follows:
|
54
54
|
#
|
55
|
-
# Sitemap.instance.
|
55
|
+
# Sitemap::Generator.instance.load :host => "mywebsite.com" do
|
56
56
|
# path :faq
|
57
57
|
# end
|
58
58
|
#
|
59
59
|
# Object collections are supported too:
|
60
60
|
#
|
61
|
-
# Sitemap.instance.
|
61
|
+
# Sitemap::Generator.instance.load :host => "mywebsite.com" do
|
62
62
|
# resources :activities
|
63
63
|
# end
|
64
64
|
#
|
65
65
|
# Search options such as frequency and priority can be declared as an options hash:
|
66
66
|
#
|
67
|
-
# Sitemap.instance.
|
67
|
+
# Sitemap::Generator.instance.load :host => "mywebsite.com" do
|
68
68
|
# path :root, :priority => 1
|
69
69
|
# path :faq, :priority => 0.8, :change_frequency => "daily"
|
70
70
|
# resources :activities, :change_frequency => "weekly"
|
71
71
|
# end
|
72
72
|
#
|
73
|
-
def
|
73
|
+
def load(options = {}, &block)
|
74
74
|
options.each do |k, v|
|
75
75
|
self.send("#{k}=", v)
|
76
76
|
end
|
@@ -160,7 +160,7 @@ module Sitemap
|
|
160
160
|
private
|
161
161
|
|
162
162
|
def get_data(object, data)
|
163
|
-
data.
|
163
|
+
data.is_a?(Proc) ? data.call(object) : data
|
164
164
|
end
|
165
165
|
|
166
166
|
end
|
data/sitemap.gemspec
CHANGED
data/test/sitemap_test.rb
CHANGED
@@ -27,7 +27,7 @@ class SitemapTest < Test::Unit::TestCase
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_xml_response
|
30
|
-
Sitemap::Generator.instance.
|
30
|
+
Sitemap::Generator.instance.load(:host => "someplace.com") {}
|
31
31
|
doc = Nokogiri::XML(Sitemap::Generator.instance.build)
|
32
32
|
assert doc.errors.empty?
|
33
33
|
assert_equal doc.root.name, "urlset"
|
@@ -35,7 +35,7 @@ class SitemapTest < Test::Unit::TestCase
|
|
35
35
|
|
36
36
|
def test_path_route
|
37
37
|
urls = ["http://someplace.com/", "http://someplace.com/questions"]
|
38
|
-
Sitemap::Generator.instance.
|
38
|
+
Sitemap::Generator.instance.load(:host => "someplace.com") do
|
39
39
|
path :root
|
40
40
|
path :faq
|
41
41
|
end
|
@@ -48,7 +48,7 @@ class SitemapTest < Test::Unit::TestCase
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_resources_route
|
51
|
-
Sitemap::Generator.instance.
|
51
|
+
Sitemap::Generator.instance.load(:host => "someplace.com") do
|
52
52
|
resources :activities
|
53
53
|
end
|
54
54
|
doc = Nokogiri::HTML(Sitemap::Generator.instance.build)
|
@@ -62,7 +62,7 @@ class SitemapTest < Test::Unit::TestCase
|
|
62
62
|
|
63
63
|
def test_custom_resource_objects
|
64
64
|
activities = [Activity.first, Activity.last]
|
65
|
-
Sitemap::Generator.instance.
|
65
|
+
Sitemap::Generator.instance.load(:host => "someplace.com") do
|
66
66
|
resources :activities, :objects => proc { activities }, :skip_index => true
|
67
67
|
end
|
68
68
|
doc = Nokogiri::HTML(Sitemap::Generator.instance.build)
|
@@ -74,7 +74,7 @@ class SitemapTest < Test::Unit::TestCase
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def test_params_options
|
77
|
-
Sitemap::Generator.instance.
|
77
|
+
Sitemap::Generator.instance.load(:host => "someplace.com") do
|
78
78
|
path :faq, :params => { :host => "anotherplace.com", :format => "html", :filter => "recent" }
|
79
79
|
end
|
80
80
|
doc = Nokogiri::HTML(Sitemap::Generator.instance.build)
|
@@ -83,7 +83,7 @@ class SitemapTest < Test::Unit::TestCase
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def test_params_blocks
|
86
|
-
Sitemap::Generator.instance.
|
86
|
+
Sitemap::Generator.instance.load(:host => "someplace.com") do
|
87
87
|
resources :activities, :skip_index => true, :params => { :host => proc { |obj| [obj.location, host].join(".") } }
|
88
88
|
end
|
89
89
|
activities = Activity.all
|
@@ -95,7 +95,7 @@ class SitemapTest < Test::Unit::TestCase
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def test_search_attribute_options
|
98
|
-
Sitemap::Generator.instance.
|
98
|
+
Sitemap::Generator.instance.load(:host => "someplace.com") do
|
99
99
|
path :faq, :priority => 1, :change_frequency => "always"
|
100
100
|
resources :activities, :change_frequency => "weekly"
|
101
101
|
end
|
@@ -109,7 +109,7 @@ class SitemapTest < Test::Unit::TestCase
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def test_search_attribute_blocks
|
112
|
-
Sitemap::Generator.instance.
|
112
|
+
Sitemap::Generator.instance.load(:host => "someplace.com") do
|
113
113
|
resources :activities, :priority => proc { |obj| obj.id <= 2 ? 1 : 0.5 }, :skip_index => true
|
114
114
|
end
|
115
115
|
activities = Activity.all
|
@@ -122,7 +122,7 @@ class SitemapTest < Test::Unit::TestCase
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def test_discards_empty_search_attributes # Empty or false (boolean).
|
125
|
-
Sitemap::Generator.instance.
|
125
|
+
Sitemap::Generator.instance.load(:host => "someplace.com") do
|
126
126
|
path :faq, :priority => "", :change_frequency => lambda { |e| return false}, :updated_at => Date.today
|
127
127
|
end
|
128
128
|
doc = Nokogiri::HTML(Sitemap::Generator.instance.build)
|
@@ -132,7 +132,7 @@ class SitemapTest < Test::Unit::TestCase
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def test_file_url
|
135
|
-
Sitemap::Generator.instance.
|
135
|
+
Sitemap::Generator.instance.load(:host => "someplace.com") {}
|
136
136
|
assert_equal Sitemap::Generator.instance.file_url, "http://someplace.com/sitemap.xml"
|
137
137
|
end
|
138
138
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sitemap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1b2
|
5
5
|
prerelease: 3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-09-03 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sqlite3
|
16
|
-
requirement: &
|
16
|
+
requirement: &14319520 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *14319520
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: nokogiri
|
27
|
-
requirement: &
|
27
|
+
requirement: &14319100 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *14319100
|
36
36
|
description: A simple ruby on rails sitemap generator
|
37
37
|
email: daniel@viseztrance.com
|
38
38
|
executables: []
|