middleman-search_engine_sitemap 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -1
- data/lib/middleman/search_engine_sitemap.rb +2 -1
- data/lib/middleman/search_engine_sitemap/templates/sitemap.xml.builder +1 -1
- data/lib/middleman/search_engine_sitemap/version.rb +1 -1
- data/spec/dummy/source/ignored-by-proc.html +3 -0
- data/spec/features/sitemap_feature_spec.rb +15 -0
- metadata +21 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4164db2143eb8eb720c369f6afdf832256984bd7
|
4
|
+
data.tar.gz: 40aa7565fbb304a50cff7a570ef2a091f3e9f35c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 353eebf7471a31e5b6593ea93fc5d30e64e3220c008fce44ab950cea102deb0243d203962f89f72b73de797bf0cf782be7576520443428f95a6fb82f3f724bad
|
7
|
+
data.tar.gz: 89c2bf8f47763ace920328264586327e6b01d4cb2dbabaa6ff302536eda51e95bc68114f86e71811e9c699dc8dc2e0a6691d287677c94aef98975fce56a451f5
|
data/README.md
CHANGED
@@ -57,7 +57,7 @@ activate :search_engine_sitemap, exclude_attr: 'hidden'
|
|
57
57
|
|
58
58
|
You would then be able to use `hidden: true` in place of `hide_from_sitemap: true`.
|
59
59
|
|
60
|
-
|
60
|
+
## Settings
|
61
61
|
|
62
62
|
Pages have a priority of 0.5 and a change frequency of `monthly` by default.
|
63
63
|
|
@@ -102,6 +102,17 @@ Possible values are: `always`, `hourly`, `daily`, `weekly`, `monthly`, `yearly`,
|
|
102
102
|
|
103
103
|
The default value is `monthly`.
|
104
104
|
|
105
|
+
### Custom page exclusion
|
106
|
+
|
107
|
+
You can also use `exclude_if` to exclude pages based on more complex requirements. For example:
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
# Exclude all pages which have a date that's after today
|
111
|
+
activate :search_engine_sitemap, exclude_if: ->(resource) {
|
112
|
+
resource.data.date && resource.data.date > Date.today
|
113
|
+
}
|
114
|
+
```
|
115
|
+
|
105
116
|
### Customising the URL
|
106
117
|
|
107
118
|
Sometimes, you might want to perform some processing the URL:
|
@@ -12,6 +12,7 @@ module Middleman
|
|
12
12
|
option :sitemap_xml_path, 'sitemap.xml', 'Path to search engine sitemap'
|
13
13
|
option :exclude_attr, 'hide_from_sitemap'
|
14
14
|
option :process_url, nil, 'Proc for processing a URL'
|
15
|
+
option :exclude_if, ->(resource) { false }
|
15
16
|
|
16
17
|
def after_configuration
|
17
18
|
register_extension_templates
|
@@ -44,7 +45,7 @@ module Middleman
|
|
44
45
|
end
|
45
46
|
|
46
47
|
def not_excluded?(resource)
|
47
|
-
!resource.ignored? && !resource.data[options.exclude_attr]
|
48
|
+
!resource.ignored? && !resource.data[options.exclude_attr] && !options.exclude_if.call(resource)
|
48
49
|
end
|
49
50
|
|
50
51
|
def page_ext
|
@@ -3,7 +3,7 @@ xml.urlset 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9' do
|
|
3
3
|
resources_for_sitemap.each do |page|
|
4
4
|
xml.url do
|
5
5
|
xml.loc extensions[:search_engine_sitemap].process_url(File.join(url_root, page.url))
|
6
|
-
xml.lastmod
|
6
|
+
xml.lastmod(File.mtime(page.source_file).iso8601) if page.source_file
|
7
7
|
xml.changefreq page.data.change_frequency || default_change_frequency
|
8
8
|
xml.priority page.data.priority || default_priority
|
9
9
|
end
|
@@ -91,4 +91,19 @@ describe "Search engine sitemaps", :feature do
|
|
91
91
|
'changefreq' => 'monthly'
|
92
92
|
)
|
93
93
|
end
|
94
|
+
|
95
|
+
it "ignores resources based on exclude_if result" do
|
96
|
+
run_site 'dummy' do
|
97
|
+
set :url_root, 'http://example.com'
|
98
|
+
activate :search_engine_sitemap,
|
99
|
+
exclude_if: ->(resource) { resource.data.ignored_by_proc }
|
100
|
+
|
101
|
+
ignore '/ignored.html'
|
102
|
+
end
|
103
|
+
|
104
|
+
visit '/sitemap.xml'
|
105
|
+
doc = Nokogiri::XML(last_response.body)
|
106
|
+
|
107
|
+
expect(doc.to_s).not_to include('http://example.com/ignored-by-proc.html')
|
108
|
+
end
|
94
109
|
end
|
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-search_engine_sitemap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pete Nicholls
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman-core
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: builder
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.5'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.5'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: nokogiri
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
description: Adds a sitemap.xml file (following the sitemaps.org protocol) to your
|
@@ -102,8 +102,8 @@ executables: []
|
|
102
102
|
extensions: []
|
103
103
|
extra_rdoc_files: []
|
104
104
|
files:
|
105
|
-
-
|
106
|
-
-
|
105
|
+
- .gitignore
|
106
|
+
- .travis.yml
|
107
107
|
- Gemfile
|
108
108
|
- LICENSE.txt
|
109
109
|
- README.md
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- spec/dummy/source/about.html
|
117
117
|
- spec/dummy/source/blog.html
|
118
118
|
- spec/dummy/source/home.html
|
119
|
+
- spec/dummy/source/ignored-by-proc.html
|
119
120
|
- spec/dummy/source/ignored-in-frontmatter.html
|
120
121
|
- spec/dummy/source/ignored.html
|
121
122
|
- spec/dummy/source/layouts/layout.erb
|
@@ -133,17 +134,17 @@ require_paths:
|
|
133
134
|
- lib
|
134
135
|
required_ruby_version: !ruby/object:Gem::Requirement
|
135
136
|
requirements:
|
136
|
-
- -
|
137
|
+
- - '>='
|
137
138
|
- !ruby/object:Gem::Version
|
138
139
|
version: '0'
|
139
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
141
|
requirements:
|
141
|
-
- -
|
142
|
+
- - '>='
|
142
143
|
- !ruby/object:Gem::Version
|
143
144
|
version: '0'
|
144
145
|
requirements: []
|
145
146
|
rubyforge_project:
|
146
|
-
rubygems_version: 2.
|
147
|
+
rubygems_version: 2.0.14
|
147
148
|
signing_key:
|
148
149
|
specification_version: 4
|
149
150
|
summary: Adds a sitemap.xml file to your Middleman site for search engines.
|
@@ -151,6 +152,7 @@ test_files:
|
|
151
152
|
- spec/dummy/source/about.html
|
152
153
|
- spec/dummy/source/blog.html
|
153
154
|
- spec/dummy/source/home.html
|
155
|
+
- spec/dummy/source/ignored-by-proc.html
|
154
156
|
- spec/dummy/source/ignored-in-frontmatter.html
|
155
157
|
- spec/dummy/source/ignored.html
|
156
158
|
- spec/dummy/source/layouts/layout.erb
|