meta-tags 2.11.1 → 2.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +139 -74
- data/CONTRIBUTING.md +6 -6
- data/Gemfile +6 -4
- data/README.md +79 -60
- data/certs/kpumuk.pem +9 -9
- data/lib/meta_tags.rb +1 -6
- data/lib/meta_tags/configuration.rb +7 -0
- data/lib/meta_tags/controller_helper.rb +3 -3
- data/lib/meta_tags/meta_tags_collection.rb +31 -45
- data/lib/meta_tags/railtie.rb +17 -0
- data/lib/meta_tags/renderer.rb +29 -8
- data/lib/meta_tags/text_normalizer.rb +7 -5
- data/lib/meta_tags/version.rb +2 -1
- data/lib/meta_tags/view_helper.rb +0 -2
- data/meta-tags.gemspec +5 -3
- metadata +43 -23
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 623738e419a62299132050216fd53ae9e8c6bbc44cd1f17befd3e3560a1a4b98
|
4
|
+
data.tar.gz: 89e2a81fd16a51b31512adbcb732d76fa973c01d28f30fa92cdbec8961b9b88c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5a8ddfaa667a93609c15955690aadd8e6afa01a02f1d1c7a469a2e0621cb2f1def23efffca69bd2a1c7a2ee5bbf2a2ddf6304d29c49a1024ff36c7c4429185d
|
7
|
+
data.tar.gz: baa13d008e47c3fb9a49826435382256dc14c8395d2a3fe00adb0a80fab9ca1ae8e4f776ab20a21cbfd0f8cd8afb0ce8a12c2efbcdf0af4b7b86d65611035f54
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,243 +1,308 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 2.15.0 (August 2, 2021) [☰](https://github.com/kpumuk/meta-tags/compare/v2.14.0...v2.15.0)
|
4
|
+
|
5
|
+
Changes:
|
6
|
+
|
7
|
+
- Added Ruby 3.0 to supported versions
|
8
|
+
- Ruby 2.5 is now a required minimum version (we dropped official support for Ruby versions older than 2.5 about 8 months ago)
|
9
|
+
- Added `skip_canonical_links_on_noindex` configuration variable that allows to disable canonical links of the pages that are excluded from indexing ([214](https://github.com/kpumuk/meta-tags/pull/214))
|
10
|
+
- Added support for `itemprop` in `_` tag for custom tags ([203](https://github.com/kpumuk/meta-tags/pull/203))
|
11
|
+
|
12
|
+
Bugfixes:
|
13
|
+
|
14
|
+
- Fixed error "can't modify frozen String" in `strip_tags`.
|
15
|
+
- Fixed Ruby warning about an instance variable that is not initialized.
|
16
|
+
|
17
|
+
## 2.14.0 (December 10, 2020) [☰](https://github.com/kpumuk/meta-tags/compare/v2.13.0...v2.14.0)
|
18
|
+
|
19
|
+
Changes:
|
20
|
+
|
21
|
+
- Dropped official support for Rails older than 5.1 and Ruby older than 2.5 (both reached their End of Life)
|
22
|
+
- Added support for Rails 6.1
|
23
|
+
|
24
|
+
Bugfixes:
|
25
|
+
|
26
|
+
- Fixed Rails 6 deprecation warning.
|
27
|
+
|
28
|
+
## 2.13.0 (October 10, 2019) [☰](https://github.com/kpumuk/meta-tags/compare/v2.12.0...v2.13.0)
|
29
|
+
|
30
|
+
Bugfixes:
|
31
|
+
|
32
|
+
- Fixed Rails 6 deprecation warning.
|
33
|
+
|
34
|
+
## 2.12.0 (September 10, 2019) [☰](https://github.com/kpumuk/meta-tags/compare/v2.11.1...v2.12.0)
|
35
|
+
|
36
|
+
Features:
|
37
|
+
|
38
|
+
- Indexing directives (`noindex`, `nofollow`, etc. now support an array of robot names as a value).
|
39
|
+
- Added support for `link[rel='manifest']` ([199](https://github.com/kpumuk/meta-tags/pull/199))
|
40
|
+
|
41
|
+
Bugfixes:
|
42
|
+
|
43
|
+
- When `noindex` uses "robots" as a value, `nofollow` ignores a custom robot name, and switches to "robots" as well
|
44
|
+
|
1
45
|
## 2.11.1 (January 19, 2019) [☰](https://github.com/kpumuk/meta-tags/compare/v2.11.0...v2.11.1)
|
2
46
|
|
3
47
|
Features:
|
4
|
-
|
48
|
+
|
49
|
+
- Rails 6 is officially supported.
|
5
50
|
|
6
51
|
## 2.11.0 (November 16, 2018) [☰](https://github.com/kpumuk/meta-tags/compare/v2.10.0...v2.11.0)
|
7
52
|
|
8
53
|
Features:
|
9
|
-
|
10
|
-
|
54
|
+
|
55
|
+
- Added a configuration option `minify_output` to remove new line characters between meta tags ([182](https://github.com/kpumuk/meta-tags/pull/182))
|
56
|
+
- Title, description, and keywords can be an object responding to `#to_str` ([183](https://github.com/kpumuk/meta-tags/pull/183))
|
11
57
|
|
12
58
|
Bugfixes:
|
13
|
-
|
59
|
+
|
60
|
+
- Truncate title before escaping HTML characters ([180](https://github.com/kpumuk/meta-tags/pull/180))
|
14
61
|
|
15
62
|
## 2.10.0 (June 8, 2018) [☰](https://github.com/kpumuk/meta-tags/compare/v2.9.0...v2.10.0)
|
16
63
|
|
17
64
|
Features:
|
18
|
-
|
65
|
+
|
66
|
+
- Allow `MetaTagsCollection#update` to receive an object ([169](https://github.com/kpumuk/meta-tags/pull/169))
|
19
67
|
|
20
68
|
## 2.9.0 (March 29, 2018) [☰](https://github.com/kpumuk/meta-tags/compare/v2.8.0...v2.9.0)
|
21
69
|
|
22
70
|
Features:
|
23
|
-
|
71
|
+
|
72
|
+
- Added ability to add `index` robots meta tag (thanks to @rafallo)
|
24
73
|
|
25
74
|
## 2.8.0 (February 28, 2018) [☰](https://github.com/kpumuk/meta-tags/compare/v2.7.1...v2.8.0)
|
26
75
|
|
27
76
|
Features:
|
28
|
-
|
77
|
+
|
78
|
+
- Added noarchive support.
|
29
79
|
|
30
80
|
Changes:
|
31
|
-
|
81
|
+
|
82
|
+
- Updated default description size to 300 as a new recommended truncation limit.
|
32
83
|
|
33
84
|
## 2.7.1 (February 1, 2018) [☰](https://github.com/kpumuk/meta-tags/compare/v2.7.0...v2.7.1)
|
34
85
|
|
35
86
|
Changes:
|
36
|
-
|
87
|
+
|
88
|
+
- Properly generate Open Graph meta tags for object types that fail to provide a proper scope (e.g. `restaurant:contact_info` metadata for `restaurant:restaurant` object type).
|
37
89
|
|
38
90
|
Bugfixes:
|
39
|
-
|
91
|
+
|
92
|
+
- Description truncated to empty string and removed from meta tags when limit is set to `0` (while documentation suggests we should remove limits in this case).
|
40
93
|
|
41
94
|
## 2.7.0 (November 22, 2017) [☰](https://github.com/kpumuk/meta-tags/compare/v2.6.0...v2.7.0)
|
42
95
|
|
43
96
|
Changes:
|
44
|
-
|
97
|
+
|
98
|
+
- Generate open meta tags (`<meta ... >`) instead of closed meta tags (`<meta ... />`) by default, which is . Added a new option to switch back to self-closing meta tags, which are valid in HTML5, but unnecessary.
|
45
99
|
|
46
100
|
## 2.6.0 (August 24, 2017) [☰](https://github.com/kpumuk/meta-tags/compare/v2.5.0...v2.6.0)
|
47
101
|
|
48
102
|
Features:
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
103
|
+
|
104
|
+
- Optionally avoid downcasing keywords
|
105
|
+
- Added Rails generator to create an initializer with the default settings.
|
106
|
+
- Added a configuration option `truncate_site_title_first` which enables site title truncation when title limit is reached.
|
107
|
+
- When `Time`, `Date`, or `DateTime` passed as a meta tag value, it will be formatted according to ISO 8601.
|
53
108
|
|
54
109
|
Bugfixes:
|
55
|
-
|
56
|
-
|
110
|
+
|
111
|
+
- When title limit reached with `reverse` set to `true`, properly truncate the last item of the title array instead of the first one.
|
112
|
+
- Do not merge title and site title for OpenGraph, site title is available for reference as `:site`, and full title as `:full_title`.
|
57
113
|
|
58
114
|
Changes:
|
59
|
-
|
115
|
+
|
116
|
+
- Removed Google "author" and "publisher" links, as Google deprecated these options (https://support.google.com/webmasters/answer/6083347?hl=en)
|
60
117
|
|
61
118
|
## 2.5.0 (August 23, 2017) [☰](https://github.com/kpumuk/meta-tags/compare/v2.4.1...v2.5.0)
|
62
119
|
|
63
120
|
Features:
|
64
|
-
|
121
|
+
|
122
|
+
- Fully support [Open Graph objects](https://developers.facebook.com/docs/reference/opengraph) meta tags.
|
65
123
|
|
66
124
|
Changes:
|
67
|
-
|
125
|
+
|
126
|
+
- Dropped official support for Rails older than 4.2 and Ruby older than 2.2 (both reached their End of Life)
|
68
127
|
|
69
128
|
## 2.4.1 (May 15, 2017) [☰](https://github.com/kpumuk/meta-tags/compare/v2.4.0...v2.4.1)
|
70
129
|
|
71
130
|
Features:
|
72
|
-
|
131
|
+
|
132
|
+
- Rails 5.1 support added
|
73
133
|
|
74
134
|
## 2.4.0 (December 8, 2016) [☰](https://github.com/kpumuk/meta-tags/compare/v2.3.1...v2.4.0)
|
75
135
|
|
76
136
|
Features:
|
77
|
-
|
137
|
+
|
138
|
+
- Added amphtml links support
|
78
139
|
|
79
140
|
Bugfixes:
|
80
|
-
|
141
|
+
|
142
|
+
- Fixed `place` attribute meta tag generation
|
81
143
|
|
82
144
|
## 2.3.1 (September 13, 2016) [☰](https://github.com/kpumuk/meta-tags/compare/v2.2.0...v2.3.1)
|
83
145
|
|
84
146
|
Changes:
|
85
|
-
|
147
|
+
|
148
|
+
- Added follow meta tag support
|
86
149
|
|
87
150
|
Features:
|
88
|
-
|
151
|
+
|
152
|
+
- Added support for article meta tags
|
89
153
|
|
90
154
|
## 2.2.0 (August 24, 2016) [☰](https://github.com/kpumuk/meta-tags/compare/v2.1.0...v2.2.0)
|
91
155
|
|
92
156
|
Changes:
|
93
157
|
|
94
|
-
|
158
|
+
- Rails < 3.2 is not longer supported
|
95
159
|
|
96
160
|
Features:
|
97
161
|
|
98
|
-
|
99
|
-
|
100
|
-
|
162
|
+
- Added support for `<link rel="image_src" href="...">` tag
|
163
|
+
- Added support for App Links
|
164
|
+
- Added support for `follow` meta tag
|
101
165
|
|
102
166
|
Bugfixes:
|
103
167
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
168
|
+
- Fixed double escaping for ampersands (thanks to @srecnig)
|
169
|
+
- Removed usage of `alias_method_chain` to fix deprecation warnings with Rails 5
|
170
|
+
- Fixed the issue when title was truncated in some cases, when site_title was blank
|
171
|
+
- Fixed meta tag attributes for `fb:` meta tags
|
108
172
|
|
109
173
|
## 2.1.0 (October 6, 2015) [☰](https://github.com/kpumuk/meta-tags/compare/v2.0.0...v2.1.0)
|
110
174
|
|
111
175
|
Changes:
|
112
176
|
|
113
|
-
|
177
|
+
- Ruby < 2.0 is not longer supported
|
114
178
|
|
115
179
|
Features:
|
116
180
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
181
|
+
- Added charset meta tag
|
182
|
+
- Added ability to configure limits for title, description, keywords
|
183
|
+
- Added OpenSearch links support
|
184
|
+
- Added icon links support
|
185
|
+
- Alternate links can now be generated for RSS or mobile versions
|
122
186
|
|
123
187
|
Bugfixes
|
124
|
-
|
125
|
-
|
188
|
+
|
189
|
+
- Generate `<meta name=""/>` instead of `<meta property=""/>` for custom meta tags
|
190
|
+
- Double HTML escaping in meta tags
|
126
191
|
|
127
192
|
## 2.0.0 (April 15, 2014) [☰](https://github.com/kpumuk/meta-tags/compare/v1.6.0...v2.0.0)
|
128
193
|
|
129
194
|
Features:
|
130
195
|
|
131
|
-
|
196
|
+
- Fully refactored code base.
|
132
197
|
|
133
198
|
Bugfixes:
|
134
199
|
|
135
|
-
|
200
|
+
- Symlink references in nested hashes include use normalized meta tag values.
|
136
201
|
|
137
202
|
## 1.6.0 (April 14, 2014) [☰](https://github.com/kpumuk/meta-tags/compare/v1.5.0...v1.6.0)
|
138
203
|
|
139
204
|
Features:
|
140
205
|
|
141
|
-
|
142
|
-
|
143
|
-
|
206
|
+
- Added "alternate" links support
|
207
|
+
- Added Google "author" and "publisher" links
|
208
|
+
- Implemented mirrored values inside namespaces declared as hashes
|
144
209
|
|
145
210
|
Breaking changes:
|
146
211
|
|
147
|
-
|
212
|
+
- Removed support of Rails older than 3.0.0 due to the bug in `Hash#deep_merge` (does not support `HashWithIndifferentAccess`)
|
148
213
|
|
149
214
|
## 1.5.0 (May 7, 2013) [☰](https://github.com/kpumuk/meta-tags/compare/v1.4.1...v1.5.0)
|
150
215
|
|
151
216
|
Features:
|
152
217
|
|
153
|
-
|
154
|
-
|
218
|
+
- Added "prev" and "next" links support
|
219
|
+
- Added refresh meta tag support
|
155
220
|
|
156
221
|
## 1.4.1 (March 14, 2013) [☰](https://github.com/kpumuk/meta-tags/compare/v1.4.0...v1.4.1)
|
157
222
|
|
158
223
|
Bugfixes:
|
159
224
|
|
160
|
-
|
225
|
+
- Added support for Hash inside of an Array
|
161
226
|
|
162
227
|
## 1.4.0 (March 14, 2013) [☰](https://github.com/kpumuk/meta-tags/compare/v1.3.0...v1.4.0)
|
163
228
|
|
164
229
|
Features:
|
165
230
|
|
166
|
-
|
231
|
+
- Added support of custom meta tags
|
167
232
|
|
168
233
|
## 1.3.0 (February 13, 2013) [☰](https://github.com/kpumuk/meta-tags/compare/v1.2.6...v1.3.0)
|
169
234
|
|
170
235
|
Features:
|
171
236
|
|
172
|
-
|
173
|
-
|
174
|
-
|
237
|
+
- Added Hash and Array as possible contents for the meta tags. Check README for details
|
238
|
+
- Added support of string meta tag names
|
239
|
+
- Allow to disable noindex and nofollow using `false` as a value
|
175
240
|
|
176
241
|
Bugfixes:
|
177
242
|
|
178
|
-
|
179
|
-
|
243
|
+
- Do not display title HTML tag when title is blank
|
244
|
+
- Do not display OpenGraph tags when content is empty
|
180
245
|
|
181
246
|
## 1.2.6 (March 4, 2012) [☰](https://github.com/kpumuk/meta-tags/compare/v1.2.5...v1.2.6)
|
182
247
|
|
183
248
|
Features:
|
184
249
|
|
185
|
-
|
250
|
+
- jQuery.pjax support via `display_title` method. Check README for details
|
186
251
|
|
187
252
|
## 1.2.5 (March 3, 2012) [☰](https://github.com/kpumuk/meta-tags/compare/v1.2.4...v1.2.5)
|
188
253
|
|
189
254
|
Bugfixes:
|
190
255
|
|
191
|
-
|
192
|
-
|
193
|
-
|
256
|
+
- Fixed bug with overriding open graph attributes
|
257
|
+
- Fixed incorrect page title when `:site` is is blank
|
258
|
+
- Normalize `:og` attribute to `:open_graph`
|
194
259
|
|
195
260
|
## 1.2.4 (April 26, 2011) [☰](https://github.com/kpumuk/meta-tags/compare/v1.2.3...v1.2.4)
|
196
261
|
|
197
262
|
Features:
|
198
263
|
|
199
|
-
|
264
|
+
- Added support for Open Graph meta tags
|
200
265
|
|
201
266
|
Bugfixes:
|
202
267
|
|
203
|
-
|
204
|
-
|
268
|
+
- Fixed bug with double HTML escaping in title separator
|
269
|
+
- Allow to set meta title without a separator
|
205
270
|
|
206
271
|
## 1.2.2, 1.2.3 (June 10, 2010) [☰](https://github.com/kpumuk/meta-tags/compare/v1.2.1...v1.2.3)
|
207
272
|
|
208
273
|
Bugfixes:
|
209
274
|
|
210
|
-
|
211
|
-
|
275
|
+
- Fixed action_pack integration (welcome back `alias_method_chain`)
|
276
|
+
- Fixed bug when `@page_*` variables did not work
|
212
277
|
|
213
278
|
## 1.2.1 (June 2, 2010) [☰](https://github.com/kpumuk/meta-tags/compare/v1.2.0...v1.2.1)
|
214
279
|
|
215
280
|
Bugfixes:
|
216
281
|
|
217
|
-
|
282
|
+
- Fixed deprecation warning about `html_safe!`
|
218
283
|
|
219
284
|
## 1.2.0 (May 31, 2010) [☰](https://github.com/kpumuk/meta-tags/compare/v1.1.1...v1.2.0)
|
220
285
|
|
221
286
|
Bugfixes:
|
222
287
|
|
223
|
-
|
224
|
-
|
288
|
+
- Fixed bug when title is set through Array, and `:lowercase` is true
|
289
|
+
- Updated `display_meta_tags` to be compatible with rails_xss
|
225
290
|
|
226
291
|
## 1.1.1 (November 21, 2009) [☰](https://github.com/kpumuk/meta-tags/compare/v1.1.0...v1.1.1)
|
227
292
|
|
228
293
|
Features:
|
229
294
|
|
230
|
-
|
231
|
-
|
295
|
+
- Added support for canonical link element
|
296
|
+
- Added YARD documentation
|
232
297
|
|
233
298
|
## 1.1.0 (November 5, 2009) [☰](https://github.com/kpumuk/meta-tags/commits/v1.1.0)
|
234
299
|
|
235
300
|
Features:
|
236
301
|
|
237
|
-
|
238
|
-
|
239
|
-
|
302
|
+
- Added ability to specify title as an Array of parts
|
303
|
+
- Added helper for `noindex`
|
304
|
+
- Added `nofollow` meta tag support
|
240
305
|
|
241
306
|
Bugfixes:
|
242
307
|
|
243
|
-
|
308
|
+
- Fixed Rails 2.3 deprecation warnings
|
data/CONTRIBUTING.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Contributing
|
2
2
|
|
3
3
|
We love pull requests from everyone. By participating in this project, you
|
4
|
-
agree to abide by the [code of conduct](https://github.com/kpumuk/meta-tags/blob/
|
4
|
+
agree to abide by the [code of conduct](https://github.com/kpumuk/meta-tags/blob/main/CODE_OF_CONDUCT.md).
|
5
5
|
|
6
6
|
## Configuring Development Environment
|
7
7
|
|
@@ -29,13 +29,13 @@ Make your change. Add tests for your change. Make the tests pass:
|
|
29
29
|
argument for the meta tag name should be `name`:
|
30
30
|
|
31
31
|
```html
|
32
|
-
<meta name="keywords" content="HTML,CSS,XML,JavaScript"
|
32
|
+
<meta name="keywords" content="HTML,CSS,XML,JavaScript" />
|
33
33
|
```
|
34
34
|
|
35
35
|
Some social networks require to use `property` argument instead (Facebook Open Graph).
|
36
36
|
MetaTags supports the most popular meta tags, but there will be tags that are not covered
|
37
37
|
by default. If you found one, and you feel like the community would benefit from
|
38
|
-
MetaTags supporting it out of the box, feel free to add it to [the list](https://github.com/kpumuk/meta-tags/blob/
|
38
|
+
MetaTags supporting it out of the box, feel free to add it to [the list](https://github.com/kpumuk/meta-tags/blob/main/lib/meta_tags/configuration.rb#L23-L57)
|
39
39
|
and submit a pull request.
|
40
40
|
|
41
41
|
## Raising a Pull Request
|
@@ -47,6 +47,6 @@ within couple days. We may suggest some changes or improvements or alternatives.
|
|
47
47
|
|
48
48
|
Some things that will increase the chance that your pull request is accepted:
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
- Write tests.
|
51
|
+
- Make sure [CodeClimate](https://codeclimate.com/github/kpumuk/meta-tags/builds) build is clean.
|
52
|
+
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
|
data/Gemfile
CHANGED
@@ -1,23 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source '
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in meta-tags.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
8
|
if ENV['RAILS_VERSION']
|
9
9
|
# Install specified version of actionpack if requested
|
10
|
-
gem '
|
10
|
+
gem 'railties', "~> #{ENV['RAILS_VERSION']}"
|
11
11
|
end
|
12
12
|
|
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', '
|
16
|
+
gem 'rubocop', '~> 1.18.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.
|
20
|
-
gem 'simplecov'
|
22
|
+
gem 'simplecov', '>= 0.17.0', '< 0.18'
|
21
23
|
# Format RSpec output for CircleCI
|
22
24
|
gem 'rspec_junit_formatter'
|
23
25
|
end
|
data/README.md
CHANGED
@@ -5,19 +5,19 @@
|
|
5
5
|
[![Code Climate](https://codeclimate.com/github/kpumuk/meta-tags/badges/gpa.svg)](https://codeclimate.com/github/kpumuk/meta-tags)
|
6
6
|
[![Test Coverage](https://codeclimate.com/github/kpumuk/meta-tags/badges/coverage.svg)](https://codeclimate.com/github/kpumuk/meta-tags/coverage)
|
7
7
|
[![Gem Downloads](https://img.shields.io/gem/dt/meta-tags.svg)](https://badge.fury.io/rb/meta-tags)
|
8
|
-
[![Changelog](https://img.shields.io/badge/Changelog-latest-blue.svg)](https://github.com/kpumuk/meta-tags/blob/
|
8
|
+
[![Changelog](https://img.shields.io/badge/Changelog-latest-blue.svg)](https://github.com/kpumuk/meta-tags/blob/main/CHANGELOG.md)
|
9
9
|
|
10
10
|
Search Engine Optimization (SEO) plugin for Ruby on Rails applications.
|
11
11
|
|
12
12
|
## Ruby on Rails
|
13
13
|
|
14
|
-
MetaTags
|
15
|
-
major Rails releases up to 6.
|
14
|
+
MetaTags main branch fully supports Ruby on Rails 5.1+, and is tested against all
|
15
|
+
major Rails releases up to 6.1.
|
16
16
|
|
17
|
-
Ruby versions older than 2.
|
17
|
+
Ruby versions older than 2.5 are no longer officially supported.
|
18
18
|
|
19
|
-
_Please note_ that we are no longer support Ruby versions older than 2.
|
20
|
-
Ruby on Rails older than
|
19
|
+
_Please note_ that we are no longer support Ruby versions older than 2.4.0 and
|
20
|
+
Ruby on Rails older than 5.1, because they [reached their End of Life](https://github.com/kpumuk/meta-tags/pull/143).
|
21
21
|
|
22
22
|
## Installation
|
23
23
|
|
@@ -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
|
39
|
+
To override the defaults, create an initializer
|
40
40
|
`config/initializers/meta_tags.rb` using the following command:
|
41
41
|
|
42
42
|
```bash
|
@@ -152,30 +152,30 @@ If you want to set the title and display another text, use this:
|
|
152
152
|
|
153
153
|
Use these options to customize the title format:
|
154
154
|
|
155
|
-
| Option | Description
|
156
|
-
| -------------- |
|
157
|
-
| `:site` | site title
|
158
|
-
| `:title` | page title
|
159
|
-
| `:description` | page description
|
160
|
-
| `:keywords` | page keywords
|
161
|
-
| `:charset` | page character set
|
162
|
-
| `:prefix` | text between site name and separator
|
163
|
-
| `:separator` | text used to separate website name from page title
|
164
|
-
| `:suffix` | text between separator and page title
|
165
|
-
| `:lowercase` | when true, the page name will be lowercase
|
166
|
-
| `:reverse` | when true, the page and site names will be reversed
|
167
|
-
| `:noindex` | add noindex meta tag; when true, 'robots' will be used
|
168
|
-
| `:index` | add index meta tag; when true, 'robots' will be used
|
169
|
-
| `:nofollow` | add nofollow meta tag; when true, 'robots' will be used
|
170
|
-
| `:follow` | add follow meta tag; when true, 'robots' will be used
|
171
|
-
| `:noarchive` | add noarchive meta tag; when true, 'robots' will be used
|
172
|
-
| `:canonical` | add canonical link tag
|
173
|
-
| `:prev` | add prev link tag
|
174
|
-
| `:next` | add next link tag
|
175
|
-
| `:image_src` | add image_src link tag
|
176
|
-
| `:og` | add Open Graph tags (Hash)
|
177
|
-
| `:twitter` | add Twitter tags (Hash)
|
178
|
-
| `:refresh` | refresh interval and optionally url to redirect to
|
155
|
+
| Option | Description |
|
156
|
+
| -------------- | -------------------------------------------------------------------------------------------------------------------- |
|
157
|
+
| `:site` | site title |
|
158
|
+
| `:title` | page title |
|
159
|
+
| `:description` | page description |
|
160
|
+
| `:keywords` | page keywords |
|
161
|
+
| `:charset` | page character set |
|
162
|
+
| `:prefix` | text between site name and separator |
|
163
|
+
| `:separator` | text used to separate website name from page title |
|
164
|
+
| `:suffix` | text between separator and page title |
|
165
|
+
| `:lowercase` | when true, the page name will be lowercase |
|
166
|
+
| `:reverse` | when true, the page and site names will be reversed |
|
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
|
+
| `:canonical` | add canonical link tag |
|
173
|
+
| `:prev` | add prev link tag |
|
174
|
+
| `:next` | add next link tag |
|
175
|
+
| `:image_src` | add image_src link tag |
|
176
|
+
| `:og` | add Open Graph tags (Hash) |
|
177
|
+
| `:twitter` | add Twitter tags (Hash) |
|
178
|
+
| `:refresh` | refresh interval and optionally url to redirect to |
|
179
179
|
|
180
180
|
And here are a few examples to give you ideas.
|
181
181
|
|
@@ -307,7 +307,7 @@ Recommended title tag length: up to <b>70 characters</b>, <b>10 words</b>.
|
|
307
307
|
|
308
308
|
Further reading:
|
309
309
|
|
310
|
-
|
310
|
+
- [Title Tag](https://moz.com/learn/seo/title-tag)
|
311
311
|
|
312
312
|
### Description
|
313
313
|
|
@@ -325,8 +325,8 @@ Recommended description tag length: up to <b>300 characters</b>.
|
|
325
325
|
|
326
326
|
Further reading:
|
327
327
|
|
328
|
-
|
329
|
-
|
328
|
+
- [Meta Description](https://moz.com/learn/seo/meta-description)
|
329
|
+
- [How Long Should Your Meta Description Be? (2018 Edition)](https://moz.com/blog/how-long-should-your-meta-description-be-2018)
|
330
330
|
|
331
331
|
### Keywords
|
332
332
|
|
@@ -360,8 +360,8 @@ This is useful for pages like login, password reset, privacy policy, etc.
|
|
360
360
|
|
361
361
|
Further reading:
|
362
362
|
|
363
|
-
|
364
|
-
|
363
|
+
- [Blocking Google](http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=93708)
|
364
|
+
- [Using meta tags to block access to your site](http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=93710)
|
365
365
|
|
366
366
|
### Index
|
367
367
|
|
@@ -388,12 +388,12 @@ set_meta_tags nofollow: 'googlebot'
|
|
388
388
|
|
389
389
|
Further reading:
|
390
390
|
|
391
|
-
|
392
|
-
|
391
|
+
- [About rel="nofollow"](http://www.google.com/support/webmasters/bin/answer.py?answer=96569)
|
392
|
+
- [Meta tags](http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=79812)
|
393
393
|
|
394
394
|
### Follow
|
395
395
|
|
396
|
-
Follow will work with Noindex
|
396
|
+
Follow will work with Noindex meta tag
|
397
397
|
|
398
398
|
```ruby
|
399
399
|
set_meta_tags noindex: true, follow: true
|
@@ -409,6 +409,9 @@ Canonical link element tells a search engine what is the canonical or main URL
|
|
409
409
|
for a content which have multiple URLs. The search engine will always return
|
410
410
|
that URL, and link popularity and authority will be applied to that URL.
|
411
411
|
|
412
|
+
Note: If you like follow a hint of John Mueller that you shouldn't mix canonical with noindex, then you can
|
413
|
+
set `MetaTags.config.skip_canonical_links_on_noindex = true` and we'll handle it for you.
|
414
|
+
|
412
415
|
```ruby
|
413
416
|
set_meta_tags canonical: "http://yoursite.com/canonical/url"
|
414
417
|
# <link rel="canonical" href="http://yoursite.com/canonical/url">
|
@@ -416,8 +419,8 @@ set_meta_tags canonical: "http://yoursite.com/canonical/url"
|
|
416
419
|
|
417
420
|
Further reading:
|
418
421
|
|
419
|
-
|
420
|
-
|
422
|
+
- [About rel="canonical"](http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=139394)
|
423
|
+
- [Canonicalization](http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=139066)
|
421
424
|
|
422
425
|
### Icon
|
423
426
|
|
@@ -440,9 +443,8 @@ set_meta_tags icon: [
|
|
440
443
|
|
441
444
|
Further reading:
|
442
445
|
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
+
- [Favicon](https://www.wikiwand.com/en/Favicon)
|
447
|
+
- [Touch Icons](https://mathiasbynens.be/notes/touch-icons)
|
446
448
|
|
447
449
|
### Multi-regional and multilingual URLs, RSS and mobile links
|
448
450
|
|
@@ -471,9 +473,9 @@ set_meta_tags alternate: [
|
|
471
473
|
|
472
474
|
Further reading:
|
473
475
|
|
474
|
-
|
475
|
-
|
476
|
-
|
476
|
+
- [Multi-regional and multilingual sites](https://support.google.com/webmasters/answer/182192)
|
477
|
+
- [About rel="alternate" hreflang="x"](http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=189077)
|
478
|
+
- [Separate URLs](https://developers.google.com/webmasters/mobile-sites/mobile-seo/configurations/separate-urls#annotation-in-the-html)
|
477
479
|
|
478
480
|
### Pagination links
|
479
481
|
|
@@ -490,8 +492,8 @@ set_meta_tags next: "http://yoursite.com/url?page=3"
|
|
490
492
|
|
491
493
|
Further reading:
|
492
494
|
|
493
|
-
|
494
|
-
|
495
|
+
- [Pagination](http://support.google.com/webmasters/bin/answer.py?hl=en&answer=1663744)
|
496
|
+
- [Pagination with rel="next" and rel="prev"](http://googlewebmastercentral.blogspot.ca/2011/09/pagination-with-relnext-and-relprev.html)
|
495
497
|
|
496
498
|
### image_src links
|
497
499
|
|
@@ -518,8 +520,8 @@ set_meta_tags amphtml: url_for(format: :amp, only_path: false)
|
|
518
520
|
|
519
521
|
To link back to normal version, use `canonical`.
|
520
522
|
|
521
|
-
|
522
|
-
|
523
|
+
- [What Is AMP?](https://www.ampproject.org/learn/about-amp/)
|
524
|
+
- [Make Your Page Discoverable](https://www.ampproject.org/docs/guides/discovery)
|
523
525
|
|
524
526
|
### Refresh interval and redirect URL
|
525
527
|
|
@@ -539,9 +541,8 @@ set_meta_tags refresh: '5;url=http://example.com'
|
|
539
541
|
|
540
542
|
Further reading:
|
541
543
|
|
542
|
-
|
543
|
-
|
544
|
-
|
544
|
+
- [Meta refresh](http://en.wikipedia.org/wiki/Meta_refresh)
|
545
|
+
- [What is the Meta Refresh Tag](http://webdesign.about.com/od/metataglibraries/a/aa080300a.htm)
|
545
546
|
|
546
547
|
### Open Search
|
547
548
|
|
@@ -557,8 +558,8 @@ set_meta_tags open_search: {
|
|
557
558
|
|
558
559
|
Further reading:
|
559
560
|
|
560
|
-
|
561
|
-
|
561
|
+
- [OpenSearch specs](http://www.opensearch.org/Specifications/OpenSearch/1.1)
|
562
|
+
- [OpenSearch wiki](http://en.wikipedia.org/wiki/OpenSearch)
|
562
563
|
|
563
564
|
### Hashes
|
564
565
|
|
@@ -660,8 +661,8 @@ set_meta_tags article: {
|
|
660
661
|
|
661
662
|
Further reading:
|
662
663
|
|
663
|
-
|
664
|
-
|
664
|
+
- [Open Graph protocol](http://developers.facebook.com/docs/opengraph/)
|
665
|
+
- [Must-Have Social Meta Tags for Twitter, Google+, Facebook and More](https://moz.com/blog/meta-data-templates-123)
|
665
666
|
|
666
667
|
### Twitter Cards
|
667
668
|
|
@@ -696,9 +697,27 @@ set_meta_tags twitter: {
|
|
696
697
|
# <meta name="twitter:image:height" content="100">
|
697
698
|
```
|
698
699
|
|
700
|
+
Special parameter `itemprop` can be used on a "anonymous" tag "\_" to generate "itemprop" HTML attribute:
|
701
|
+
|
702
|
+
```ruby
|
703
|
+
set_meta_tags twitter: {
|
704
|
+
card: "photo",
|
705
|
+
image: {
|
706
|
+
_: "http://example.com/1.png",
|
707
|
+
width: 100,
|
708
|
+
height: 100,
|
709
|
+
itemprop: "image",
|
710
|
+
}
|
711
|
+
}
|
712
|
+
# <meta name="twitter:card" content="photo">
|
713
|
+
# <meta name="twitter:image" content="http://example.com/1.png" itemprop="image">
|
714
|
+
# <meta name="twitter:image:width" content="100">
|
715
|
+
# <meta name="twitter:image:height" content="100">
|
716
|
+
```
|
717
|
+
|
699
718
|
Further reading:
|
700
719
|
|
701
|
-
|
720
|
+
- [Twitter Cards Documentation](https://dev.twitter.com/cards/)
|
702
721
|
|
703
722
|
### App Links
|
704
723
|
|
@@ -719,7 +738,7 @@ set_meta_tags al: {
|
|
719
738
|
|
720
739
|
Further reading:
|
721
740
|
|
722
|
-
|
741
|
+
- [App Links Documentation](https://developers.facebook.com/docs/applinks)
|
723
742
|
|
724
743
|
### Custom meta tags
|
725
744
|
|
data/certs/kpumuk.pem
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
2
|
MIIDODCCAiCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBhrcHVt
|
3
|
-
|
4
|
-
|
3
|
+
dWsvREM9a3B1bXVrL0RDPWluZm8wHhcNMjAxMjEwMjA1MTE5WhcNMjExMjEwMjA1
|
4
|
+
MTE5WjAjMSEwHwYDVQQDDBhrcHVtdWsvREM9a3B1bXVrL0RDPWluZm8wggEiMA0G
|
5
5
|
CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC8NmK6GXPiE/q7PDbj7nNdw3pa8a6Q
|
6
6
|
IDxLtc7kW95e1mh0TVgOE8kvGegGtRtjvhXVGTTFtZ+yMD/0DCfTM2oUQYk5oYpO
|
7
7
|
ZGrCfbNIdZauf4WYsnJtKOTrRoqFMwpL5PlBDKczB2y5lUmQs2HIsjQ0Q21wdKyy
|
@@ -10,11 +10,11 @@ ZGrCfbNIdZauf4WYsnJtKOTrRoqFMwpL5PlBDKczB2y5lUmQs2HIsjQ0Q21wdKyy
|
|
10
10
|
RryRTj5NVZbq9p1/WRc5zxD9QhAEPjRa5ikbd+eWebIDpAKI0hpyC/9bAgMBAAGj
|
11
11
|
dzB1MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBT2uFRXNWDpVdbv
|
12
12
|
+xBk8DAgJPGBPTAdBgNVHREEFjAUgRJrcHVtdWtAa3B1bXVrLmluZm8wHQYDVR0S
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
BBYwFIESa3B1bXVrQGtwdW11ay5pbmZvMA0GCSqGSIb3DQEBCwUAA4IBAQBdcrpl
|
14
|
+
32OlNaf68v38yzqYkviLELtbzRvEpRuQWZZyxOwU1OWSFAWkkALuseLWHDLYRDE8
|
15
|
+
lOzQHewKodqaSPEo63vMZ28UQ3kDP1YE+cXR12fOg4YbCH8VETrTJa3X0AOOAbgA
|
16
|
+
ZLMcZD6wu9Zu2rPhxLxs6Q/PaGGEc8bonOirCZrwVDzHFA1cPjcSoApdsyGdRiyj
|
17
|
+
1f+XHXjCE5A1A6b8o4ffpAI6gkuaQOIrgGCyLS9oos6DSuofkvXI9g62G+2ZOmKJ
|
18
|
+
U97JEQmXCpruLEeSVT2UqR+iJAWEAxPzqzDbTzZBTSPKn+nXeuF6h81e4hsJtkeJ
|
19
|
+
HkYAoatF9iZrxT4E
|
20
20
|
-----END CERTIFICATE-----
|
data/lib/meta_tags.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'English'
|
4
|
-
require 'action_controller'
|
5
|
-
require 'action_view'
|
6
|
-
|
7
3
|
# MetaTags gem namespace.
|
8
4
|
module MetaTags
|
9
5
|
# Returns MetaTags gem configuration.
|
@@ -36,5 +32,4 @@ require 'meta_tags/content_tag'
|
|
36
32
|
require 'meta_tags/text_normalizer'
|
37
33
|
require 'meta_tags/view_helper'
|
38
34
|
|
39
|
-
|
40
|
-
ActionController::Base.include MetaTags::ControllerHelper
|
35
|
+
require 'meta_tags/railtie' if defined?(Rails)
|
@@ -33,6 +33,12 @@ module MetaTags
|
|
33
33
|
# - an array of strings or symbols representing their names or name-prefixes.
|
34
34
|
attr_reader :property_tags
|
35
35
|
|
36
|
+
# Configure whenever Meta-Tags should skip canonicals on pages with noindex: true
|
37
|
+
# "shouldn't mix noindex & rel=canonical comes from: they're very contradictory pieces of information for us."
|
38
|
+
# - John Mueller (Webmaster Trends Analyst at Google)
|
39
|
+
# https://www.reddit.com/r/TechSEO/comments/8yahdr/2_questions_about_the_canonical_tag/e2dey9i/
|
40
|
+
attr_accessor :skip_canonical_links_on_noindex
|
41
|
+
|
36
42
|
# Initializes a new instance of Configuration class.
|
37
43
|
def initialize
|
38
44
|
reset_defaults!
|
@@ -77,6 +83,7 @@ module MetaTags
|
|
77
83
|
@property_tags = default_property_tags.dup
|
78
84
|
@open_meta_tags = true
|
79
85
|
@minify_output = false
|
86
|
+
@skip_canonical_links_on_noindex = false
|
80
87
|
end
|
81
88
|
end
|
82
89
|
end
|
@@ -15,9 +15,9 @@ module MetaTags
|
|
15
15
|
# Processes the <tt>@page_title</tt>, <tt>@page_keywords</tt>, and
|
16
16
|
# <tt>@page_description</tt> instance variables and calls +render+.
|
17
17
|
def render(*args, &block)
|
18
|
-
meta_tags[:title] = @page_title if @page_title
|
19
|
-
meta_tags[:keywords] = @page_keywords if @page_keywords
|
20
|
-
meta_tags[:description] = @page_description if @page_description
|
18
|
+
meta_tags[:title] = @page_title if defined?(@page_title) && @page_title
|
19
|
+
meta_tags[:keywords] = @page_keywords if defined?(@page_keywords) && @page_keywords
|
20
|
+
meta_tags[:description] = @page_description if defined?(@page_description) && @page_description
|
21
21
|
|
22
22
|
super
|
23
23
|
end
|
@@ -142,28 +142,20 @@ module MetaTags
|
|
142
142
|
#
|
143
143
|
# @return [Hash<String,String>] noindex attributes.
|
144
144
|
#
|
145
|
-
def
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
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
|
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
|
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
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
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
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
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
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MetaTags
|
4
|
+
class Railtie < Rails::Railtie
|
5
|
+
initializer 'meta_tags.setup_action_controller' do
|
6
|
+
ActiveSupport.on_load :action_controller do
|
7
|
+
ActionController::Base.include MetaTags::ControllerHelper
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
initializer 'meta_tags.setup_action_view' do
|
12
|
+
ActiveSupport.on_load :action_view do
|
13
|
+
ActionView::Base.include MetaTags::ViewHelper
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/meta_tags/renderer.rb
CHANGED
@@ -26,6 +26,7 @@ module MetaTags
|
|
26
26
|
render_with_normalization(tags, :description)
|
27
27
|
render_with_normalization(tags, :keywords)
|
28
28
|
render_refresh(tags)
|
29
|
+
render_canonical_link(tags)
|
29
30
|
render_noindex(tags)
|
30
31
|
render_alternate(tags)
|
31
32
|
render_open_search(tags)
|
@@ -97,7 +98,7 @@ module MetaTags
|
|
97
98
|
# @param [Array<Tag>] tags a buffer object to store tag in.
|
98
99
|
#
|
99
100
|
def render_noindex(tags)
|
100
|
-
meta_tags.
|
101
|
+
meta_tags.extract_robots.each do |name, content|
|
101
102
|
tags << Tag.new(:meta, name: name, content: content) if content.present?
|
102
103
|
end
|
103
104
|
end
|
@@ -150,7 +151,7 @@ module MetaTags
|
|
150
151
|
# @param [Array<Tag>] tags a buffer object to store tag in.
|
151
152
|
#
|
152
153
|
def render_links(tags)
|
153
|
-
[ :amphtml, :
|
154
|
+
[ :amphtml, :prev, :next, :image_src, :manifest ].each do |tag_name|
|
154
155
|
href = meta_tags.extract(tag_name)
|
155
156
|
if href.present?
|
156
157
|
@normalized_meta_tags[tag_name] = href
|
@@ -159,6 +160,19 @@ module MetaTags
|
|
159
160
|
end
|
160
161
|
end
|
161
162
|
|
163
|
+
# Renders canonical link
|
164
|
+
#
|
165
|
+
# @param [Array<Tag>] tags a buffer object to store tag in.
|
166
|
+
#
|
167
|
+
def render_canonical_link(tags)
|
168
|
+
href = meta_tags.extract(:canonical) # extract, so its not used anywhere else
|
169
|
+
return if MetaTags.config.skip_canonical_links_on_noindex && meta_tags[:noindex]
|
170
|
+
return if href.blank?
|
171
|
+
|
172
|
+
@normalized_meta_tags[:canonical] = href
|
173
|
+
tags << Tag.new(:link, rel: :canonical, href: href)
|
174
|
+
end
|
175
|
+
|
162
176
|
# Renders complex hash objects.
|
163
177
|
#
|
164
178
|
# @param [Array<Tag>] tags a buffer object to store tag in.
|
@@ -201,16 +215,17 @@ module MetaTags
|
|
201
215
|
# @param [Hash, Array, String, Symbol] content text content or a symbol reference to
|
202
216
|
# top-level meta tag.
|
203
217
|
#
|
204
|
-
def process_tree(tags, property, content, **opts)
|
218
|
+
def process_tree(tags, property, content, itemprop: nil, **opts)
|
205
219
|
method = case content
|
206
220
|
when Hash
|
207
221
|
:process_hash
|
208
222
|
when Array
|
209
223
|
:process_array
|
210
224
|
else
|
225
|
+
iprop = itemprop
|
211
226
|
:render_tag
|
212
227
|
end
|
213
|
-
__send__(method, tags, property, content, **opts)
|
228
|
+
__send__(method, tags, property, content, itemprop: iprop, **opts)
|
214
229
|
end
|
215
230
|
|
216
231
|
# Recursive method to process a hash with meta tags
|
@@ -220,10 +235,16 @@ module MetaTags
|
|
220
235
|
# @param [Hash] content nested meta tag attributes.
|
221
236
|
#
|
222
237
|
def process_hash(tags, property, content, **opts)
|
238
|
+
itemprop = content.delete(:itemprop)
|
223
239
|
content.each do |key, value|
|
224
|
-
|
240
|
+
if key.to_s == '_'
|
241
|
+
iprop = itemprop
|
242
|
+
key = property
|
243
|
+
else
|
244
|
+
key = "#{property}:#{key}"
|
245
|
+
end
|
225
246
|
value = normalized_meta_tags[value] if value.kind_of?(Symbol)
|
226
|
-
process_tree(tags, key, value, **opts)
|
247
|
+
process_tree(tags, key, value, **opts.merge(itemprop: iprop))
|
227
248
|
end
|
228
249
|
end
|
229
250
|
|
@@ -244,9 +265,9 @@ module MetaTags
|
|
244
265
|
# @param [String, Symbol] value text content or a symbol reference to
|
245
266
|
# top-level meta tag.
|
246
267
|
#
|
247
|
-
def render_tag(tags, name, value,
|
268
|
+
def render_tag(tags, name, value, itemprop: nil)
|
248
269
|
name_key ||= configured_name_key(name)
|
249
|
-
tags << Tag.new(:meta, name_key => name.to_s,
|
270
|
+
tags << Tag.new(:meta, name_key => name.to_s, content: value, itemprop: itemprop) if value.present?
|
250
271
|
end
|
251
272
|
|
252
273
|
# Returns meta tag property name for a give meta tag based on the
|
@@ -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
|
6
|
+
extend self
|
7
7
|
|
8
8
|
# Normalize title value.
|
9
9
|
#
|
@@ -110,10 +110,12 @@ module MetaTags
|
|
110
110
|
return '' if string.nil?
|
111
111
|
raise ArgumentError, 'Expected a string or an object that implements #to_str' unless string.respond_to?(:to_str)
|
112
112
|
|
113
|
-
strip_tags(string.to_str)
|
114
|
-
|
115
|
-
|
116
|
-
|
113
|
+
s = strip_tags(string.to_str)
|
114
|
+
s = s.dup if s.frozen?
|
115
|
+
s.gsub!(/\s+/, ' ')
|
116
|
+
s.strip! if strip
|
117
|
+
|
118
|
+
s
|
117
119
|
end
|
118
120
|
|
119
121
|
# Cleans multiple strings up.
|
data/lib/meta_tags/version.rb
CHANGED
data/meta-tags.gemspec
CHANGED
@@ -15,16 +15,18 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.homepage = "http://github.com/kpumuk/meta-tags"
|
16
16
|
spec.license = "MIT"
|
17
17
|
spec.platform = Gem::Platform::RUBY
|
18
|
+
spec.required_ruby_version = '>= 2.5.0'
|
18
19
|
|
19
20
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(\.|(bin|test|spec|features)/)}) }
|
20
21
|
spec.bindir = "exe"
|
21
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
23
|
spec.require_paths = ["lib"]
|
23
24
|
|
24
|
-
spec.add_dependency "actionpack", ">= 3.2.0", "< 6.
|
25
|
+
spec.add_dependency "actionpack", ">= 3.2.0", "< 6.2"
|
25
26
|
|
26
|
-
spec.add_development_dependency "
|
27
|
-
spec.add_development_dependency "
|
27
|
+
spec.add_development_dependency "railties", ">= 3.2.0", "< 6.2"
|
28
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.10.0"
|
28
30
|
spec.add_development_dependency "rspec-html-matchers", "~> 0.9.1"
|
29
31
|
|
30
32
|
spec.cert_chain = ["certs/kpumuk.pem"]
|
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meta-tags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmytro Shteflyuk
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIDODCCAiCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBhrcHVt
|
14
|
-
|
15
|
-
|
14
|
+
dWsvREM9a3B1bXVrL0RDPWluZm8wHhcNMjAxMjEwMjA1MTE5WhcNMjExMjEwMjA1
|
15
|
+
MTE5WjAjMSEwHwYDVQQDDBhrcHVtdWsvREM9a3B1bXVrL0RDPWluZm8wggEiMA0G
|
16
16
|
CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC8NmK6GXPiE/q7PDbj7nNdw3pa8a6Q
|
17
17
|
IDxLtc7kW95e1mh0TVgOE8kvGegGtRtjvhXVGTTFtZ+yMD/0DCfTM2oUQYk5oYpO
|
18
18
|
ZGrCfbNIdZauf4WYsnJtKOTrRoqFMwpL5PlBDKczB2y5lUmQs2HIsjQ0Q21wdKyy
|
@@ -21,15 +21,15 @@ cert_chain:
|
|
21
21
|
RryRTj5NVZbq9p1/WRc5zxD9QhAEPjRa5ikbd+eWebIDpAKI0hpyC/9bAgMBAAGj
|
22
22
|
dzB1MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBT2uFRXNWDpVdbv
|
23
23
|
+xBk8DAgJPGBPTAdBgNVHREEFjAUgRJrcHVtdWtAa3B1bXVrLmluZm8wHQYDVR0S
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
BBYwFIESa3B1bXVrQGtwdW11ay5pbmZvMA0GCSqGSIb3DQEBCwUAA4IBAQBdcrpl
|
25
|
+
32OlNaf68v38yzqYkviLELtbzRvEpRuQWZZyxOwU1OWSFAWkkALuseLWHDLYRDE8
|
26
|
+
lOzQHewKodqaSPEo63vMZ28UQ3kDP1YE+cXR12fOg4YbCH8VETrTJa3X0AOOAbgA
|
27
|
+
ZLMcZD6wu9Zu2rPhxLxs6Q/PaGGEc8bonOirCZrwVDzHFA1cPjcSoApdsyGdRiyj
|
28
|
+
1f+XHXjCE5A1A6b8o4ffpAI6gkuaQOIrgGCyLS9oos6DSuofkvXI9g62G+2ZOmKJ
|
29
|
+
U97JEQmXCpruLEeSVT2UqR+iJAWEAxPzqzDbTzZBTSPKn+nXeuF6h81e4hsJtkeJ
|
30
|
+
HkYAoatF9iZrxT4E
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
32
|
+
date: 2021-08-02 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: actionpack
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
version: 3.2.0
|
41
41
|
- - "<"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '6.
|
43
|
+
version: '6.2'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
46
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -50,35 +50,55 @@ dependencies:
|
|
50
50
|
version: 3.2.0
|
51
51
|
- - "<"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '6.
|
53
|
+
version: '6.2'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: railties
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 3.2.0
|
61
|
+
- - "<"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '6.2'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 3.2.0
|
71
|
+
- - "<"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '6.2'
|
54
74
|
- !ruby/object:Gem::Dependency
|
55
75
|
name: rake
|
56
76
|
requirement: !ruby/object:Gem::Requirement
|
57
77
|
requirements:
|
58
78
|
- - "~>"
|
59
79
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
80
|
+
version: '13.0'
|
61
81
|
type: :development
|
62
82
|
prerelease: false
|
63
83
|
version_requirements: !ruby/object:Gem::Requirement
|
64
84
|
requirements:
|
65
85
|
- - "~>"
|
66
86
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
87
|
+
version: '13.0'
|
68
88
|
- !ruby/object:Gem::Dependency
|
69
89
|
name: rspec
|
70
90
|
requirement: !ruby/object:Gem::Requirement
|
71
91
|
requirements:
|
72
92
|
- - "~>"
|
73
93
|
- !ruby/object:Gem::Version
|
74
|
-
version: 3.
|
94
|
+
version: 3.10.0
|
75
95
|
type: :development
|
76
96
|
prerelease: false
|
77
97
|
version_requirements: !ruby/object:Gem::Requirement
|
78
98
|
requirements:
|
79
99
|
- - "~>"
|
80
100
|
- !ruby/object:Gem::Version
|
81
|
-
version: 3.
|
101
|
+
version: 3.10.0
|
82
102
|
- !ruby/object:Gem::Dependency
|
83
103
|
name: rspec-html-matchers
|
84
104
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,6 +136,7 @@ files:
|
|
116
136
|
- lib/meta_tags/content_tag.rb
|
117
137
|
- lib/meta_tags/controller_helper.rb
|
118
138
|
- lib/meta_tags/meta_tags_collection.rb
|
139
|
+
- lib/meta_tags/railtie.rb
|
119
140
|
- lib/meta_tags/renderer.rb
|
120
141
|
- lib/meta_tags/tag.rb
|
121
142
|
- lib/meta_tags/text_normalizer.rb
|
@@ -126,7 +147,7 @@ homepage: http://github.com/kpumuk/meta-tags
|
|
126
147
|
licenses:
|
127
148
|
- MIT
|
128
149
|
metadata: {}
|
129
|
-
post_install_message:
|
150
|
+
post_install_message:
|
130
151
|
rdoc_options: []
|
131
152
|
require_paths:
|
132
153
|
- lib
|
@@ -134,16 +155,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
134
155
|
requirements:
|
135
156
|
- - ">="
|
136
157
|
- !ruby/object:Gem::Version
|
137
|
-
version:
|
158
|
+
version: 2.5.0
|
138
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
160
|
requirements:
|
140
161
|
- - ">="
|
141
162
|
- !ruby/object:Gem::Version
|
142
163
|
version: '0'
|
143
164
|
requirements: []
|
144
|
-
|
145
|
-
|
146
|
-
signing_key:
|
165
|
+
rubygems_version: 3.1.2
|
166
|
+
signing_key:
|
147
167
|
specification_version: 4
|
148
168
|
summary: Collection of SEO helpers for Ruby on Rails.
|
149
169
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|