meta-tags 2.11.1 → 2.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3f02cd65ae6c44a66cb24946f5198d04769eb24125ec48a0fcbb10af8cd7eac
4
- data.tar.gz: 621a8fc87dd414609a35787c41c4520fb3ef5f622fe80435885d832641e27147
3
+ metadata.gz: ae6b586b3caea1141de4d7cfb8b9416225cdfda41984b7701252ca24dc3f72b7
4
+ data.tar.gz: ca6f213ed867a6e823a313f71bea1f19df6276455363e4ff294282f127e65e67
5
5
  SHA512:
6
- metadata.gz: 2247883ab51dbeaf6878fc111ef7bdbe5a05aed2072621fc8ab9ef8d8ac4628c80300f7d6c6897e5785c68a8d75dcda2b1e0c7ef90a76fc33435b09f598da5f7
7
- data.tar.gz: 0165a44b70582be3beee1addbd085e4fe21fc4b35467e74f311d1ef33a5e73856e7d9120ed023031ebb1d2782370ae8ae3f87a3939f4ed8055314d03ffb4ff45
6
+ metadata.gz: ff1e6c26b63aa876c92034f4846a4058da17b2e6ae49e07640b75a9f6a2cf97eaf0bff6c48a715c13798c5de8e3334781c6f11313e19a9edd084e8fa84272c20
7
+ data.tar.gz: efc21b0da382e96fca80c78fdfaac56c3e3320e38223bd07f0157f85e91bf1aed92df090721d67600871e705a1718779b45fc01daf4cabf2bc6180b82bd9de76
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,12 @@
1
+ ## 2.12.0 (September 10, 2019) [☰](https://github.com/kpumuk/meta-tags/compare/v2.11.1...v2.12.0)
2
+
3
+ Features:
4
+ - Indexing directives (`noindex`, `nofollow`, etc. now support an array of robot names as a value).
5
+ - Added support for `link[rel='manifest']` ([199](https://github.com/kpumuk/meta-tags/pull/199))
6
+
7
+ Bugfixes:
8
+ - When `noindex` uses "robots" as a value, `nofollow` ignores a custom robot name, and switches to "robots" as well
9
+
1
10
  ## 2.11.1 (January 19, 2019) [☰](https://github.com/kpumuk/meta-tags/compare/v2.11.0...v2.11.1)
2
11
 
3
12
  Features:
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'http://rubygems.org'
3
+ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in meta-tags.gemspec
6
6
  gemspec
@@ -13,7 +13,9 @@ end
13
13
  group :test do
14
14
  # Lock rubocop to a specific version we use on CI. If you update this,
15
15
  # don't forget to switch rubocop channel in the .codeclimate.yml
16
- gem 'rubocop', '0.60.0'
16
+ gem 'rubocop', '~> 0.74.0'
17
+ # Cops for rails apps
18
+ gem 'rubocop-rails'
17
19
  # Apply RSpec rubocop cops
18
20
  gem 'rubocop-rspec', require: false
19
21
  # We use this gem on CI to calculate code coverage.
data/README.md CHANGED
@@ -36,7 +36,7 @@ truncation have recommended values, you can change them to reflect your own
36
36
  preferences. Keywords are converted to lowercase by default, but this is also
37
37
  configurable.
38
38
 
39
- To overide the defaults, create an initializer
39
+ To override the defaults, create an initializer
40
40
  `config/initializers/meta_tags.rb` using the following command:
41
41
 
42
42
  ```bash
@@ -164,11 +164,11 @@ Use these options to customize the title format:
164
164
  | `:suffix` | text between separator and page title |
165
165
  | `:lowercase` | when true, the page name will be lowercase |
166
166
  | `:reverse` | when true, the page and site names will be reversed |
167
- | `:noindex` | add noindex meta tag; when true, 'robots' will be used, otherwise the string will be used |
168
- | `:index` | add index meta tag; when true, 'robots' will be used, otherwise the string will be used |
169
- | `:nofollow` | add nofollow meta tag; when true, 'robots' will be used, otherwise the string will be used |
170
- | `:follow` | add follow meta tag; when true, 'robots' will be used, otherwise the string will be used |
171
- | `:noarchive` | add noarchive meta tag; when true, 'robots' will be used, otherwise the string will be used |
167
+ | `:noindex` | add noindex meta tag; when true, 'robots' will be used; accepts a string with a robot name, or an array of strings |
168
+ | `:index` | add index meta tag; when true, 'robots' will be used; accepts a string with a robot name, or an array of strings |
169
+ | `:nofollow` | add nofollow meta tag; when true, 'robots' will be used; accepts a string with a robot name, or an array of strings |
170
+ | `:follow` | add follow meta tag; when true, 'robots' will be used; accepts a string with a robot name, or an array of strings |
171
+ | `:noarchive` | add noarchive meta tag; when true, 'robots' will be used; accepts a string with a robot name, or an array of strings |
172
172
  | `:canonical` | add canonical link tag |
173
173
  | `:prev` | add prev link tag |
174
174
  | `:next` | add next link tag |
@@ -142,28 +142,20 @@ module MetaTags
142
142
  #
143
143
  # @return [Hash<String,String>] noindex attributes.
144
144
  #
145
- def extract_noindex
146
- noindex_name, noindex_value = extract_noindex_attribute(:noindex)
147
- index_name, index_value = extract_noindex_attribute(:index)
148
-
149
- nofollow_name, nofollow_value = extract_noindex_attribute(:nofollow)
150
- follow_name, follow_value = extract_noindex_attribute(:follow)
151
-
152
- noindex_attributes = if noindex_name == follow_name && (noindex_value || follow_value)
153
- # noindex has higher priority than index and follow has higher priority than nofollow
154
- [
155
- [noindex_name, noindex_value || index_value],
156
- [follow_name, follow_value || nofollow_value],
157
- ]
158
- else
159
- [
160
- [index_name, index_value],
161
- [follow_name, follow_value],
162
- [noindex_name, noindex_value],
163
- [nofollow_name, nofollow_value],
164
- ]
165
- end
166
- append_noarchive_attribute group_attributes_by_key noindex_attributes
145
+ def extract_robots
146
+ result = Hash.new { |h, k| h[k] = [] }
147
+
148
+ [
149
+ # noindex has higher priority than index
150
+ [:noindex, :index],
151
+ # follow has higher priority than nofollow
152
+ [:follow, :nofollow],
153
+ :noarchive,
154
+ ].each do |attributes|
155
+ calculate_robots_attributes(result, attributes)
156
+ end
157
+
158
+ result.transform_values { |v| v.join(', ') }
167
159
  end
168
160
 
169
161
  protected
@@ -190,43 +182,37 @@ module MetaTags
190
182
  meta_tags[name] == false ? '' : (meta_tags[name] || default)
191
183
  end
192
184
 
193
- # Extracts noindex attribute name and value without deleting it from meta tags list.
185
+ # Extracts robots attribute (noindex, nofollow, etc) name and value.
194
186
  #
195
187
  # @param [String, Symbol] name noindex attribute name.
196
188
  # @return [Array<String>] pair of noindex attribute name and value.
197
189
  #
198
- def extract_noindex_attribute(name)
190
+ def extract_robots_attribute(name)
199
191
  noindex = extract(name)
200
- noindex_name = noindex.kind_of?(String) ? noindex : 'robots'
192
+ noindex_name = noindex.kind_of?(String) || noindex.kind_of?(Array) ? noindex : 'robots'
201
193
  noindex_value = noindex ? name.to_s : nil
202
194
 
203
195
  [ noindex_name, noindex_value ]
204
196
  end
205
197
 
206
- # Append noarchive attribute if it present.
207
- #
208
- # @param [Hash<String, String>] noindex noindex attributes.
209
- # @return [Hash<String, String>] modified noindex attributes.
210
- #
211
- def append_noarchive_attribute(noindex)
212
- noarchive_name, noarchive_value = extract_noindex_attribute :noarchive
213
- if noarchive_value
214
- if noindex[noarchive_name].blank?
215
- noindex[noarchive_name] = noarchive_value
216
- else
217
- noindex[noarchive_name] += ", #{noarchive_value}"
198
+ def calculate_robots_attributes(result, attributes)
199
+ processed = Set.new
200
+ Array(attributes).each do |attribute|
201
+ names, value = extract_robots_attribute(attribute)
202
+ next unless value
203
+
204
+ Array(names).each do |name|
205
+ apply_robots_value(result, name, value, processed)
218
206
  end
219
207
  end
220
- noindex
221
208
  end
222
209
 
223
- # Convert array of arrays to hashes and concatenate values
224
- #
225
- # @param [Array<Array>] attributes list of noindex keys and values
226
- # @return [Hash<String, String>] hash of grouped noindex keys and values
227
- #
228
- def group_attributes_by_key(attributes)
229
- Hash[attributes.group_by(&:first).map { |k, v| [k, v.map(&:last).tap(&:compact!).join(', ')] }]
210
+ def apply_robots_value(result, name, value, processed)
211
+ name = name.to_s
212
+ return if processed.include?(name)
213
+
214
+ result[name] << value
215
+ processed << name
230
216
  end
231
217
  end
232
218
  end
@@ -97,7 +97,7 @@ module MetaTags
97
97
  # @param [Array<Tag>] tags a buffer object to store tag in.
98
98
  #
99
99
  def render_noindex(tags)
100
- meta_tags.extract_noindex.each do |name, content|
100
+ meta_tags.extract_robots.each do |name, content|
101
101
  tags << Tag.new(:meta, name: name, content: content) if content.present?
102
102
  end
103
103
  end
@@ -150,7 +150,7 @@ module MetaTags
150
150
  # @param [Array<Tag>] tags a buffer object to store tag in.
151
151
  #
152
152
  def render_links(tags)
153
- [ :amphtml, :canonical, :prev, :next, :image_src ].each do |tag_name|
153
+ [ :amphtml, :canonical, :prev, :next, :image_src, :manifest ].each do |tag_name|
154
154
  href = meta_tags.extract(tag_name)
155
155
  if href.present?
156
156
  @normalized_meta_tags[tag_name] = href
@@ -3,7 +3,7 @@
3
3
  module MetaTags
4
4
  # Module contains helpers that normalize text meta tag values.
5
5
  module TextNormalizer
6
- extend self # rubocop:disable Style/ModuleFunction
6
+ extend self
7
7
 
8
8
  # Normalize title value.
9
9
  #
@@ -2,5 +2,6 @@
2
2
 
3
3
  module MetaTags
4
4
  # Gem version.
5
- VERSION = '2.11.1'
5
+ VERSION = '2.12.0'
6
+ public_constant :VERSION
6
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meta-tags
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.1
4
+ version: 2.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmytro Shteflyuk
@@ -29,7 +29,7 @@ cert_chain:
29
29
  j0ZkOZOMk6hzny9+AnYZ7eiUqp/XX7Hn+hqtl/AebKhbFapnTu0n7KcfM0oDaLUr
30
30
  Fc+FAHErSClMb7YN
31
31
  -----END CERTIFICATE-----
32
- date: 2019-01-19 00:00:00.000000000 Z
32
+ date: 2019-09-11 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: actionpack
@@ -141,8 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  - !ruby/object:Gem::Version
142
142
  version: '0'
143
143
  requirements: []
144
- rubyforge_project:
145
- rubygems_version: 2.7.6
144
+ rubygems_version: 3.0.4
146
145
  signing_key:
147
146
  specification_version: 4
148
147
  summary: Collection of SEO helpers for Ruby on Rails.
metadata.gz.sig CHANGED
Binary file