sitemap 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -0
- data/lib/sitemap/generator.rb +23 -1
- data/lib/sitemap/version.rb +1 -1
- data/lib/views/fragment.xml.builder +1 -1
- metadata +45 -21
data/README.md
CHANGED
@@ -30,6 +30,7 @@ In your sitemap config file, paths can be indexed as follows:
|
|
30
30
|
Sitemap::Generator.instance.load :host => "mywebsite.com" do
|
31
31
|
path :root, :priority => 1
|
32
32
|
path :faq, :priority => 0.5, :change_frequency => "weekly"
|
33
|
+
literal "/my_blog" #helpful for vanity urls layering search results
|
33
34
|
resources :activities, :params => { :format => "html" }
|
34
35
|
resources :articles, :objects => proc { Article.published }
|
35
36
|
end
|
data/lib/sitemap/generator.rb
CHANGED
@@ -10,12 +10,13 @@ module Sitemap
|
|
10
10
|
:priority => "priority"
|
11
11
|
}
|
12
12
|
|
13
|
-
attr_accessor :store, :host, :routes, :fragments
|
13
|
+
attr_accessor :store, :protocol, :host, :routes, :fragments
|
14
14
|
|
15
15
|
# Instantiates a new object.
|
16
16
|
# Should never be called directly.
|
17
17
|
def initialize
|
18
18
|
self.class.send(:include, Rails.application.routes.url_helpers)
|
19
|
+
self.protocol = "http"
|
19
20
|
self.fragments = []
|
20
21
|
self.store = Store.new(:max_entries => Sitemap.configuration.max_urls)
|
21
22
|
self.store.before_reset do |entries|
|
@@ -31,6 +32,12 @@ module Sitemap
|
|
31
32
|
# ...
|
32
33
|
# end
|
33
34
|
#
|
35
|
+
# Literal paths can be added as follows:
|
36
|
+
#
|
37
|
+
# Sitemap::Generator.instance.load :host => "mywebsite.com" do
|
38
|
+
# literal "/some_fancy_url"
|
39
|
+
# end
|
40
|
+
#
|
34
41
|
# Simple paths can be added as follows:
|
35
42
|
#
|
36
43
|
# Sitemap::Generator.instance.load :host => "mywebsite.com" do
|
@@ -58,6 +65,20 @@ module Sitemap
|
|
58
65
|
self.routes = block
|
59
66
|
end
|
60
67
|
|
68
|
+
# Adds the literal url (for consistency, starting with a "/" as in "/my_url")
|
69
|
+
# accepts similar options to path and resources
|
70
|
+
def literal(target_url, options = {})
|
71
|
+
search = Sitemap.configuration.search.clone.merge!(options.select { |k, v| SEARCH_ATTRIBUTES.keys.include?(k) })
|
72
|
+
search.merge!(search) { |type, value| get_data(nil, value) }
|
73
|
+
|
74
|
+
output_host = options[:host] || host
|
75
|
+
output_protocol = options[:protocol] || protocol
|
76
|
+
self.store << {
|
77
|
+
:url =>"#{output_protocol}://#{output_host}#{target_url}",
|
78
|
+
:search => search
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
61
82
|
# Adds the specified url or object (such as an ActiveRecord model instance).
|
62
83
|
# In either case the data is being looked up in the current application routes.
|
63
84
|
#
|
@@ -73,6 +94,7 @@ module Sitemap
|
|
73
94
|
#
|
74
95
|
def path(object, options = {})
|
75
96
|
params = Sitemap.configuration.params.clone.merge!(options[:params] || {})
|
97
|
+
params[:protocol] ||= protocol # Use global protocol if none was specified.
|
76
98
|
params[:host] ||= host # Use global host if none was specified.
|
77
99
|
params.merge!(params) { |type, value| get_data(object, value) }
|
78
100
|
|
data/lib/sitemap/version.rb
CHANGED
@@ -3,7 +3,7 @@ xml.urlset :xmlns => "http://www.sitemaps.org/schemas/sitemap/0.9" do
|
|
3
3
|
|
4
4
|
store.entries.each do |entry|
|
5
5
|
xml.url do
|
6
|
-
xml.loc polymorphic_url(entry[:object], entry[:params])
|
6
|
+
xml.loc entry[:url] ? entry[:url] : polymorphic_url(entry[:object], entry[:params])
|
7
7
|
entry[:search].each do |type, value|
|
8
8
|
next if !value || value.blank?
|
9
9
|
xml.tag! SEARCH_ATTRIBUTES[type], value.to_s
|
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.3.
|
4
|
+
version: 0.3.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sqlite3
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: nokogiri
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: minitest
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: rails
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: 3.0.0
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 3.0.0
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: nokogiri
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,7 +85,12 @@ dependencies:
|
|
65
85
|
version: '0'
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
69
94
|
description: A simple ruby on rails sitemap generator
|
70
95
|
email: daniel@viseztrance.com
|
71
96
|
executables: []
|
@@ -73,18 +98,18 @@ extensions: []
|
|
73
98
|
extra_rdoc_files: []
|
74
99
|
files:
|
75
100
|
- lib/sitemap.rb
|
76
|
-
- lib/generators/sitemap/install_generator.rb
|
77
|
-
- lib/generators/sitemap/templates/sitemap.rb
|
78
|
-
- lib/generators/sitemap/USAGE
|
79
|
-
- lib/sitemap/store.rb
|
80
|
-
- lib/sitemap/ping.rb
|
81
101
|
- lib/sitemap/configuration.rb
|
102
|
+
- lib/sitemap/ping.rb
|
103
|
+
- lib/sitemap/railtie.rb
|
82
104
|
- lib/sitemap/generator.rb
|
83
105
|
- lib/sitemap/version.rb
|
84
|
-
- lib/sitemap/
|
106
|
+
- lib/sitemap/store.rb
|
85
107
|
- lib/tasks/sitemap.rake
|
86
|
-
- lib/views/index.xml.builder
|
87
108
|
- lib/views/fragment.xml.builder
|
109
|
+
- lib/views/index.xml.builder
|
110
|
+
- lib/generators/sitemap/USAGE
|
111
|
+
- lib/generators/sitemap/install_generator.rb
|
112
|
+
- lib/generators/sitemap/templates/sitemap.rb
|
88
113
|
- README.md
|
89
114
|
- LICENSE
|
90
115
|
- Rakefile
|
@@ -109,9 +134,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
134
|
version: '0'
|
110
135
|
requirements: []
|
111
136
|
rubyforge_project:
|
112
|
-
rubygems_version: 1.8.
|
137
|
+
rubygems_version: 1.8.24
|
113
138
|
signing_key:
|
114
139
|
specification_version: 3
|
115
140
|
summary: Sitemap
|
116
141
|
test_files: []
|
117
|
-
has_rdoc:
|