meta-tags 2.14.0 → 2.17.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/CHANGELOG.md +30 -0
- data/CONTRIBUTING.md +6 -6
- data/Gemfile +6 -1
- data/README.md +36 -6
- data/Rakefile +31 -0
- data/Steepfile +15 -0
- data/certs/kpumuk.pem +9 -9
- 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 +13 -6
- data/lib/meta_tags/renderer.rb +37 -10
- data/lib/meta_tags/tag.rb +1 -1
- data/lib/meta_tags/text_normalizer.rb +29 -24
- data/lib/meta_tags/version.rb +1 -1
- data/lib/meta_tags/view_helper.rb +5 -5
- data/lib/meta_tags.rb +4 -1
- data/meta-tags.gemspec +14 -4
- data/sig/lib/_internal/rails.rbs +56 -0
- data/sig/lib/meta_tags/configuration.rbs +19 -0
- data/sig/lib/meta_tags/content_tag.rbs +5 -0
- data/sig/lib/meta_tags/controller_helper.rbs +13 -0
- data/sig/lib/meta_tags/meta_tags_collection.rbs +41 -0
- data/sig/lib/meta_tags/renderer.rbs +50 -0
- data/sig/lib/meta_tags/tag.rbs +12 -0
- data/sig/lib/meta_tags/text_normalizer.rbs +36 -0
- data/sig/lib/meta_tags/version.rbs +4 -0
- data/sig/lib/meta_tags/view_helper.rbs +55 -0
- data/sig/lib/meta_tags.rbs +16 -0
- data.tar.gz.sig +0 -0
- metadata +42 -24
- 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: b5d6a918c74ab34bf285b01fd38c0c490745e0ee51f958d8bf2bf405dd26b287
|
4
|
+
data.tar.gz: eee0a81f5b209b140ff27ec0cad12852c672ab1f035d930a1ab1ae5b82b8bfa8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc19a58a8e0c30867e1019a1e78bc502b6e6efff3edfa1494699ad8701a51bd0f80a345a51b86dbf7ab1924f7f7e211cf9965234f51ae005ae4376af4ab6e1d5
|
7
|
+
data.tar.gz: edd7b528239c11d3f8fe1275270bd46b9584696b73415bd86fe4cda5549f9a05cd0c02c44c69ecd955e4964cfaa413fc14956c7c67ca478d491b7a4078128b53
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,33 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 2.17.0 (July 5, 2022) [☰](https://github.com/kpumuk/meta-tags/compare/v2.16.0...v2.17.0)
|
4
|
+
|
5
|
+
Changes:
|
6
|
+
|
7
|
+
- Separate RBS files to _internal directory to avoid exposing RBS ([237](https://github.com/kpumuk/meta-tags/pull/237))
|
8
|
+
- Added Ruby 3.1 to supported versions, Ruby 2.6 is minimum supported version ([235](https://github.com/kpumuk/meta-tags/pull/235/))
|
9
|
+
|
10
|
+
## 2.16.0 (September 24, 2021) [☰](https://github.com/kpumuk/meta-tags/compare/v2.15.0...v2.16.0)
|
11
|
+
|
12
|
+
Changes:
|
13
|
+
|
14
|
+
- Updated maximum dependency specified in gemspec (Getting Ready for Rails 7)
|
15
|
+
- Added RBS type definitions.
|
16
|
+
|
17
|
+
## 2.15.0 (August 2, 2021) [☰](https://github.com/kpumuk/meta-tags/compare/v2.14.0...v2.15.0)
|
18
|
+
|
19
|
+
Changes:
|
20
|
+
|
21
|
+
- Added Ruby 3.0 to supported versions
|
22
|
+
- Ruby 2.5 is now a required minimum version (we dropped official support for Ruby versions older than 2.5 about 8 months ago)
|
23
|
+
- 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))
|
24
|
+
- Added support for `itemprop` in `_` tag for custom tags ([203](https://github.com/kpumuk/meta-tags/pull/203))
|
25
|
+
|
26
|
+
Bugfixes:
|
27
|
+
|
28
|
+
- Fixed error "can't modify frozen String" in `strip_tags`.
|
29
|
+
- Fixed Ruby warning about an instance variable that is not initialized.
|
30
|
+
|
1
31
|
## 2.14.0 (December 10, 2020) [☰](https://github.com/kpumuk/meta-tags/compare/v2.13.0...v2.14.0)
|
2
32
|
|
3
33
|
Changes:
|
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
@@ -10,10 +10,15 @@ if ENV['RAILS_VERSION']
|
|
10
10
|
gem 'railties', "~> #{ENV['RAILS_VERSION']}"
|
11
11
|
end
|
12
12
|
|
13
|
+
unless ENV["NO_STEEP"] == '1'
|
14
|
+
# Ruby typings
|
15
|
+
gem 'steep', '~> 1.0.1', platform: :mri
|
16
|
+
end
|
17
|
+
|
13
18
|
group :test do
|
14
19
|
# Lock rubocop to a specific version we use on CI. If you update this,
|
15
20
|
# don't forget to switch rubocop channel in the .codeclimate.yml
|
16
|
-
gem 'rubocop', '
|
21
|
+
gem 'rubocop', '= 1.31.0'
|
17
22
|
# Cops for rails apps
|
18
23
|
gem 'rubocop-rails'
|
19
24
|
# Apply RSpec rubocop cops
|
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
|
14
|
+
MetaTags main branch fully supports Ruby on Rails 5.1+, and is tested against all
|
15
|
+
major Rails releases up to 7.0.
|
16
16
|
|
17
|
-
Ruby versions older than 2.
|
17
|
+
Ruby versions older than 2.6 are no longer officially supported.
|
18
18
|
|
19
|
-
_Please note_ that we
|
20
|
-
Ruby on Rails older than 5.1, because they
|
19
|
+
_Please note_ that we no longer support Ruby versions older than 2.6.0 and
|
20
|
+
Ruby on Rails older than 5.1, because they reached their [End of Life](https://endoflife.date/ruby).
|
21
21
|
|
22
22
|
## Installation
|
23
23
|
|
@@ -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">
|
@@ -520,6 +523,15 @@ To link back to normal version, use `canonical`.
|
|
520
523
|
- [What Is AMP?](https://www.ampproject.org/learn/about-amp/)
|
521
524
|
- [Make Your Page Discoverable](https://www.ampproject.org/docs/guides/discovery)
|
522
525
|
|
526
|
+
### Manifest links
|
527
|
+
|
528
|
+
```ruby
|
529
|
+
set_meta_tags manifest: 'manifest.json'
|
530
|
+
# <link rel="manifest" href="manifest.json">
|
531
|
+
```
|
532
|
+
|
533
|
+
- [What is manifest?](https://developer.mozilla.org/en-US/docs/Web/Manifest)
|
534
|
+
|
523
535
|
### Refresh interval and redirect URL
|
524
536
|
|
525
537
|
Meta refresh is a method of instructing a web browser to automatically
|
@@ -694,6 +706,24 @@ set_meta_tags twitter: {
|
|
694
706
|
# <meta name="twitter:image:height" content="100">
|
695
707
|
```
|
696
708
|
|
709
|
+
Special parameter `itemprop` can be used on a "anonymous" tag "\_" to generate "itemprop" HTML attribute:
|
710
|
+
|
711
|
+
```ruby
|
712
|
+
set_meta_tags twitter: {
|
713
|
+
card: "photo",
|
714
|
+
image: {
|
715
|
+
_: "http://example.com/1.png",
|
716
|
+
width: 100,
|
717
|
+
height: 100,
|
718
|
+
itemprop: "image",
|
719
|
+
}
|
720
|
+
}
|
721
|
+
# <meta name="twitter:card" content="photo">
|
722
|
+
# <meta name="twitter:image" content="http://example.com/1.png" itemprop="image">
|
723
|
+
# <meta name="twitter:image:width" content="100">
|
724
|
+
# <meta name="twitter:image:height" content="100">
|
725
|
+
```
|
726
|
+
|
697
727
|
Further reading:
|
698
728
|
|
699
729
|
- [Twitter Cards Documentation](https://dev.twitter.com/cards/)
|
data/Rakefile
CHANGED
@@ -16,3 +16,34 @@ task :circleci do
|
|
16
16
|
config_path = File.expand_path('.circleci/config.yml', __dir__)
|
17
17
|
File.write config_path, ERB.new(File.read(template_path)).result
|
18
18
|
end
|
19
|
+
|
20
|
+
module SteepRunner
|
21
|
+
def self.run(*command)
|
22
|
+
require "steep"
|
23
|
+
require "steep/cli"
|
24
|
+
|
25
|
+
Steep::CLI.new(argv: command, stdout: $stdout, stderr: $stderr, stdin: $stdin).run
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
task :steep do
|
30
|
+
SteepRunner.run("check")
|
31
|
+
end
|
32
|
+
|
33
|
+
namespace :steep do
|
34
|
+
task :stats do
|
35
|
+
SteepRunner.run("stats", "--log-level=fatal")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
namespace :rbs do
|
40
|
+
task :spec do
|
41
|
+
exec(
|
42
|
+
{
|
43
|
+
'RBS_TEST_TARGET' => 'MetaTags::*',
|
44
|
+
'RUBYOPT' => '-rrbs/test/setup',
|
45
|
+
},
|
46
|
+
'bundle exec rspec',
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
data/Steepfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
target :lib do
|
4
|
+
signature "sig"
|
5
|
+
|
6
|
+
check "lib"
|
7
|
+
# check "Gemfile"
|
8
|
+
|
9
|
+
# We don't want to type check Rails/RSpec related code
|
10
|
+
# (because we don't have RBS files for it)
|
11
|
+
ignore "lib/meta_tags/railtie.rb"
|
12
|
+
ignore "lib/generators"
|
13
|
+
|
14
|
+
library "set"
|
15
|
+
end
|
data/certs/kpumuk.pem
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
2
|
MIIDODCCAiCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBhrcHVt
|
3
|
-
|
4
|
-
|
3
|
+
dWsvREM9a3B1bXVrL0RDPWluZm8wHhcNMjIwNzA1MjIyODU4WhcNMjMwNzA1MjIy
|
4
|
+
ODU4WjAjMSEwHwYDVQQDDBhrcHVtdWsvREM9a3B1bXVrL0RDPWluZm8wggEiMA0G
|
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
|
+
BBYwFIESa3B1bXVrQGtwdW11ay5pbmZvMA0GCSqGSIb3DQEBCwUAA4IBAQBa5fMh
|
14
|
+
JcbhWBoP3kA32g3yM238fyJlre/ZeE6WIFxcuETff8AgPmk550qpAF/WBtP23X8Q
|
15
|
+
khIFv+bFiuBURvNbuFevs23to7NeNA7XMmEJqjB6fRzO/i/a3bkLG07u+o74MyXe
|
16
|
+
3/VAxl4Ce+C3aLwXccsbD+Fe3kQ6ku4ceIh2WebBSkpG3WRANReEAf7lcOt4aGEt
|
17
|
+
nkYjyHgDz6/gYamK15XtOivglkTJDwAVGBzF9o6j5IQ9nXho8Vd2P+hiawx76CoT
|
18
|
+
ANVO3I4ZwTKD12DMFqjalLwbSVVO4wpuMO3tcAgO4q7Fqh2tXTXom/YYl0SFvmx4
|
19
|
+
evTPD0iY8lmGP3ZM
|
20
20
|
-----END CERTIFICATE-----
|
@@ -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
|
@@ -9,7 +9,7 @@ module MetaTags
|
|
9
9
|
# Initializes a new instance of MetaTagsCollection.
|
10
10
|
#
|
11
11
|
def initialize
|
12
|
-
@meta_tags = HashWithIndifferentAccess.new
|
12
|
+
@meta_tags = ActiveSupport::HashWithIndifferentAccess.new
|
13
13
|
end
|
14
14
|
|
15
15
|
# Returns meta tag value by name.
|
@@ -38,7 +38,13 @@ module MetaTags
|
|
38
38
|
# @return [Hash] result of the merge.
|
39
39
|
#
|
40
40
|
def update(object = {})
|
41
|
-
meta_tags = object.respond_to?(:to_meta_tags)
|
41
|
+
meta_tags = if object.respond_to?(:to_meta_tags)
|
42
|
+
# @type var object: (_MetaTagish & Object)
|
43
|
+
object.to_meta_tags
|
44
|
+
else
|
45
|
+
# @type var object: Hash[String | Symbol, untyped]
|
46
|
+
object
|
47
|
+
end
|
42
48
|
@meta_tags.deep_merge! normalize_open_graph(meta_tags)
|
43
49
|
end
|
44
50
|
|
@@ -99,7 +105,7 @@ module MetaTags
|
|
99
105
|
#
|
100
106
|
def extract_full_title
|
101
107
|
site_title = extract(:site) || ''
|
102
|
-
title = extract_title
|
108
|
+
title = extract_title
|
103
109
|
separator = extract_separator
|
104
110
|
reverse = extract(:reverse) == true
|
105
111
|
|
@@ -112,8 +118,9 @@ module MetaTags
|
|
112
118
|
#
|
113
119
|
def extract_title
|
114
120
|
title = extract(:title).presence
|
115
|
-
return unless title
|
121
|
+
return [] unless title
|
116
122
|
|
123
|
+
# @type var title: Array[String]
|
117
124
|
title = Array(title)
|
118
125
|
return title.map(&:downcase) if extract(:lowercase) == true
|
119
126
|
|
@@ -163,10 +170,10 @@ module MetaTags
|
|
163
170
|
# Converts input hash to HashWithIndifferentAccess and renames :open_graph to :og.
|
164
171
|
#
|
165
172
|
# @param [Hash] meta_tags list of meta tags.
|
166
|
-
# @return [HashWithIndifferentAccess] normalized meta tags list.
|
173
|
+
# @return [ActiveSupport::HashWithIndifferentAccess] normalized meta tags list.
|
167
174
|
#
|
168
175
|
def normalize_open_graph(meta_tags)
|
169
|
-
meta_tags = meta_tags.
|
176
|
+
meta_tags = meta_tags.with_indifferent_access
|
170
177
|
meta_tags[:og] = meta_tags.delete(:open_graph) if meta_tags.key?(:open_graph)
|
171
178
|
meta_tags
|
172
179
|
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)
|
@@ -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,21 @@ 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
|
-
|
225
|
-
|
226
|
-
|
240
|
+
if key.to_s == '_'
|
241
|
+
iprop = itemprop
|
242
|
+
key = property
|
243
|
+
else
|
244
|
+
key = "#{property}:#{key}"
|
245
|
+
end
|
246
|
+
|
247
|
+
normalized_value = if value.kind_of?(Symbol)
|
248
|
+
normalized_meta_tags[value]
|
249
|
+
else
|
250
|
+
value
|
251
|
+
end
|
252
|
+
process_tree(tags, key, normalized_value, **opts.merge(itemprop: iprop))
|
227
253
|
end
|
228
254
|
end
|
229
255
|
|
@@ -243,17 +269,18 @@ module MetaTags
|
|
243
269
|
# @param [String, Symbol] name a Hash or a String to render as meta tag.
|
244
270
|
# @param [String, Symbol] value text content or a symbol reference to
|
245
271
|
# top-level meta tag.
|
272
|
+
# @param [String, Symbol] itemprop value of the itemprop attribute.
|
246
273
|
#
|
247
|
-
def render_tag(tags, name, value,
|
274
|
+
def render_tag(tags, name, value, itemprop: nil)
|
248
275
|
name_key ||= configured_name_key(name)
|
249
|
-
tags << Tag.new(:meta, name_key => name.to_s,
|
276
|
+
tags << Tag.new(:meta, name_key => name.to_s, content: value, itemprop: itemprop) if value.present?
|
250
277
|
end
|
251
278
|
|
252
279
|
# Returns meta tag property name for a give meta tag based on the
|
253
280
|
# configured list of property tags in MetaTags::Configuration#property_tags.
|
254
281
|
#
|
255
|
-
# @param [String, Symbol]
|
256
|
-
# @return [
|
282
|
+
# @param [String, Symbol] name tag key.
|
283
|
+
# @return [Symbol] meta tag attribute name (:property or :name).
|
257
284
|
#
|
258
285
|
def configured_name_key(name)
|
259
286
|
is_property_tag = MetaTags.config.property_tags.any? do |tag_name|
|
data/lib/meta_tags/tag.rb
CHANGED
@@ -8,29 +8,29 @@ module MetaTags
|
|
8
8
|
# Normalize title value.
|
9
9
|
#
|
10
10
|
# @param [String] site_title site title.
|
11
|
-
# @param [
|
11
|
+
# @param [Array<String>] title title string.
|
12
12
|
# @param [String] separator a string to join title parts with.
|
13
13
|
# @param [true,false] reverse whether title should be reversed.
|
14
|
-
# @return [
|
14
|
+
# @return [String] title with HTML tags removed.
|
15
15
|
#
|
16
16
|
def normalize_title(site_title, title, separator, reverse = false)
|
17
|
-
|
18
|
-
|
17
|
+
clean_title = cleanup_strings(title)
|
18
|
+
clean_title.reverse! if reverse
|
19
19
|
|
20
20
|
site_title = cleanup_string(site_title)
|
21
21
|
separator = cleanup_string(separator, strip: false)
|
22
22
|
|
23
23
|
# Truncate title and site title
|
24
|
-
site_title,
|
24
|
+
site_title, clean_title = truncate_title(site_title, clean_title, separator)
|
25
25
|
|
26
26
|
if site_title.present?
|
27
27
|
if reverse
|
28
|
-
|
28
|
+
clean_title.push(site_title)
|
29
29
|
else
|
30
|
-
|
30
|
+
clean_title.unshift(site_title)
|
31
31
|
end
|
32
32
|
end
|
33
|
-
safe_join(
|
33
|
+
safe_join(clean_title, separator)
|
34
34
|
end
|
35
35
|
|
36
36
|
# Normalize description value.
|
@@ -102,7 +102,7 @@ module MetaTags
|
|
102
102
|
|
103
103
|
# Removes HTML tags and squashes down all the spaces.
|
104
104
|
#
|
105
|
-
# @param [String] string input string.
|
105
|
+
# @param [String, nil] string input string.
|
106
106
|
# @return [String] input string with no HTML tags and consequent white
|
107
107
|
# space characters squashed into a single space.
|
108
108
|
#
|
@@ -110,15 +110,17 @@ 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.
|
120
122
|
#
|
121
|
-
# @param [Array<String>] strings input
|
123
|
+
# @param [String, Array<String>] strings input string(s).
|
122
124
|
# @return [Array<String>] clean strings.
|
123
125
|
# @see cleanup_string
|
124
126
|
#
|
@@ -147,13 +149,13 @@ module MetaTags
|
|
147
149
|
)
|
148
150
|
end
|
149
151
|
|
150
|
-
# Truncates
|
152
|
+
# Truncates an array of strings to a specific limit.
|
151
153
|
#
|
152
154
|
# @param [Array<String>] string_array input strings.
|
153
155
|
# @param [Integer,nil] limit characters number to truncate to.
|
154
156
|
# @param [String] separator separator that will be used to join array later.
|
155
157
|
# @param [String] natural_separator natural separator to truncate at.
|
156
|
-
# @return [String] truncated
|
158
|
+
# @return [Array<String>] truncated array of strings.
|
157
159
|
#
|
158
160
|
def truncate_array(string_array, limit = nil, separator = '', natural_separator = ' ')
|
159
161
|
return string_array if limit.nil? || limit <= 0
|
@@ -166,14 +168,14 @@ module MetaTags
|
|
166
168
|
|
167
169
|
if string.length > limit_left
|
168
170
|
result << truncate(string, limit_left, natural_separator)
|
169
|
-
break
|
171
|
+
break string_array
|
170
172
|
end
|
171
173
|
|
172
174
|
length += (result.any? ? separator.length : 0) + string.length
|
173
175
|
result << string
|
174
176
|
|
175
177
|
# No more strings will fit
|
176
|
-
break if length + separator.length >= limit
|
178
|
+
break string_array if length + separator.length >= limit
|
177
179
|
end
|
178
180
|
|
179
181
|
result
|
@@ -186,8 +188,11 @@ module MetaTags
|
|
186
188
|
end
|
187
189
|
|
188
190
|
def truncate_title(site_title, title, separator)
|
189
|
-
|
190
|
-
|
191
|
+
global_limit = MetaTags.config.title_limit.to_i # rubocop:disable Lint/NumberConversion
|
192
|
+
if global_limit > 0
|
193
|
+
site_title_limited_length, title_limited_length = calculate_title_limits(
|
194
|
+
site_title, title, separator, global_limit,
|
195
|
+
)
|
191
196
|
|
192
197
|
title = title_limited_length > 0 ? truncate_array(title, title_limited_length, separator) : []
|
193
198
|
site_title = site_title_limited_length > 0 ? truncate(site_title, site_title_limited_length) : nil
|
@@ -196,14 +201,14 @@ module MetaTags
|
|
196
201
|
[site_title, title]
|
197
202
|
end
|
198
203
|
|
199
|
-
def calculate_title_limits(site_title, title, separator)
|
204
|
+
def calculate_title_limits(site_title, title, separator, global_limit)
|
200
205
|
# What should we truncate first: site title or page title?
|
201
206
|
main_title = MetaTags.config.truncate_site_title_first ? title : [site_title]
|
202
207
|
|
203
|
-
main_length = main_title.map(&:length).sum + (main_title.size - 1) * separator.length
|
204
|
-
main_limited_length =
|
208
|
+
main_length = main_title.map(&:length).sum + ((main_title.size - 1) * separator.length)
|
209
|
+
main_limited_length = global_limit
|
205
210
|
|
206
|
-
secondary_limited_length =
|
211
|
+
secondary_limited_length = global_limit - (main_length > 0 ? main_length + separator.length : 0)
|
207
212
|
secondary_limited_length = [0, secondary_limited_length].max
|
208
213
|
|
209
214
|
if MetaTags.config.truncate_site_title_first
|
data/lib/meta_tags/version.rb
CHANGED
@@ -27,7 +27,7 @@ module MetaTags
|
|
27
27
|
#
|
28
28
|
# @see #display_meta_tags
|
29
29
|
#
|
30
|
-
def set_meta_tags(meta_tags = {})
|
30
|
+
def set_meta_tags(meta_tags = {})
|
31
31
|
self.meta_tags.update(meta_tags)
|
32
32
|
end
|
33
33
|
|
@@ -97,8 +97,8 @@ module MetaTags
|
|
97
97
|
|
98
98
|
# Set the noindex meta tag
|
99
99
|
#
|
100
|
-
# @param [Boolean, String] noindex a noindex value.
|
101
|
-
# @return [Boolean, String] passed value.
|
100
|
+
# @param [Boolean, String, Array<String>] noindex a noindex value.
|
101
|
+
# @return [Boolean, String, Array<String>] passed value.
|
102
102
|
#
|
103
103
|
# @example
|
104
104
|
# noindex true
|
@@ -113,8 +113,8 @@ module MetaTags
|
|
113
113
|
|
114
114
|
# Set the nofollow meta tag
|
115
115
|
#
|
116
|
-
# @param [Boolean, String] nofollow a nofollow value.
|
117
|
-
# @return [Boolean, String] passed value.
|
116
|
+
# @param [Boolean, String, Array<String>] nofollow a nofollow value.
|
117
|
+
# @return [Boolean, String, Array<String>] passed value.
|
118
118
|
#
|
119
119
|
# @example
|
120
120
|
# nofollow true
|
data/lib/meta_tags.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'set'
|
4
|
+
require 'active_support/core_ext/hash/indifferent_access'
|
5
|
+
|
3
6
|
# MetaTags gem namespace.
|
4
7
|
module MetaTags
|
5
8
|
# Returns MetaTags gem configuration.
|
@@ -32,4 +35,4 @@ require 'meta_tags/content_tag'
|
|
32
35
|
require 'meta_tags/text_normalizer'
|
33
36
|
require 'meta_tags/view_helper'
|
34
37
|
|
35
|
-
require 'meta_tags/railtie
|
38
|
+
require 'meta_tags/railtie' if defined?(Rails)
|
data/meta-tags.gemspec
CHANGED
@@ -12,22 +12,32 @@ Gem::Specification.new do |spec|
|
|
12
12
|
|
13
13
|
spec.summary = "Collection of SEO helpers for Ruby on Rails."
|
14
14
|
spec.description = "Search Engine Optimization (SEO) plugin for Ruby on Rails applications."
|
15
|
-
spec.homepage = "
|
15
|
+
spec.homepage = "https://github.com/kpumuk/meta-tags"
|
16
16
|
spec.license = "MIT"
|
17
17
|
spec.platform = Gem::Platform::RUBY
|
18
|
+
spec.required_ruby_version = '>= 2.6.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", "<
|
25
|
+
spec.add_dependency "actionpack", ">= 3.2.0", "< 7.1"
|
25
26
|
|
26
|
-
spec.add_development_dependency "railties", ">= 3.2.0", "<
|
27
|
+
spec.add_development_dependency "railties", ">= 3.2.0", "< 7.1"
|
27
28
|
spec.add_development_dependency "rake", "~> 13.0"
|
28
|
-
spec.add_development_dependency "rspec", "~> 3.
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.10.0"
|
29
30
|
spec.add_development_dependency "rspec-html-matchers", "~> 0.9.1"
|
30
31
|
|
31
32
|
spec.cert_chain = ["certs/kpumuk.pem"]
|
32
33
|
spec.signing_key = File.expand_path("~/.ssh/gem-kpumuk.pem") if $PROGRAM_NAME.end_with?('gem')
|
34
|
+
|
35
|
+
spec.metadata = {
|
36
|
+
"bug_tracker_uri" => "https://github.com/kpumuk/meta-tags/issues/",
|
37
|
+
"changelog_uri" => "https://github.com/kpumuk/meta-tags/blob/main/CHANGELOG.md",
|
38
|
+
"documentation_uri" => "https://rubydoc.info/github/kpumuk/meta-tags/",
|
39
|
+
"homepage_uri" => "https://github.com/kpumuk/meta-tags/",
|
40
|
+
"source_code_uri" => "https://github.com/kpumuk/meta-tags/",
|
41
|
+
"rubygems_mfa_required" => "true",
|
42
|
+
}
|
33
43
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
class ::Hash[unchecked out K, unchecked out V]
|
2
|
+
def with_indifferent_access: () -> ActiveSupport::HashWithIndifferentAccess[K, V]
|
3
|
+
def deep_merge!: (instance | ActiveSupport::HashWithIndifferentAccess[K, V] other) -> self
|
4
|
+
end
|
5
|
+
|
6
|
+
class ::Object
|
7
|
+
def presence: () -> String?
|
8
|
+
def blank?: () -> bool
|
9
|
+
def present?: () -> bool
|
10
|
+
end
|
11
|
+
|
12
|
+
class ::Loofah
|
13
|
+
module TextBehavior
|
14
|
+
def text: (?Hash[Symbol, untyped]? options) -> String
|
15
|
+
end
|
16
|
+
|
17
|
+
class DocumentFragment
|
18
|
+
include TextBehavior
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.fragment: (String tags, ?String? encoding) -> DocumentFragment
|
22
|
+
end
|
23
|
+
|
24
|
+
class ::Rails
|
25
|
+
end
|
26
|
+
|
27
|
+
module ActionController
|
28
|
+
class Base
|
29
|
+
include _ActionControllerBase
|
30
|
+
|
31
|
+
def self.helpers: () -> _ActionViewBase
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
module ActiveSupport
|
36
|
+
class HashWithIndifferentAccess[unchecked out K, unchecked out V] < Hash[K, V]
|
37
|
+
def with_indifferent_access: () -> self
|
38
|
+
def deep_merge!: (instance | Hash[K, V] other) -> self
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
interface _ActionControllerBase
|
43
|
+
def render: (*untyped args) { () -> untyped } -> untyped
|
44
|
+
end
|
45
|
+
|
46
|
+
interface _ActionViewBase
|
47
|
+
def tag: (String name, ?Hash[String | Symbol, untyped] options, ?bool open) -> void
|
48
|
+
|
49
|
+
def content_tag: (String name, String content, ?Hash[String | Symbol, untyped] options, ?bool open) -> void
|
50
|
+
|
51
|
+
def safe_join: (Array[String], String) -> String
|
52
|
+
|
53
|
+
def truncate: (String text, ?Hash[Symbol, untyped] options) -> String
|
54
|
+
|
55
|
+
def strip_tags: (String html) -> String
|
56
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module MetaTags
|
2
|
+
class Configuration
|
3
|
+
attr_accessor title_limit: Integer?
|
4
|
+
attr_accessor truncate_site_title_first: bool
|
5
|
+
attr_accessor description_limit: Integer
|
6
|
+
attr_accessor keywords_limit: Integer
|
7
|
+
attr_accessor keywords_separator: String
|
8
|
+
attr_accessor keywords_lowercase: bool
|
9
|
+
attr_accessor open_meta_tags: bool
|
10
|
+
attr_accessor minify_output: bool
|
11
|
+
attr_reader property_tags: Array[String | Symbol]
|
12
|
+
attr_accessor skip_canonical_links_on_noindex: bool
|
13
|
+
|
14
|
+
def initialize: () -> void
|
15
|
+
def default_property_tags: () -> Array[String | Symbol]
|
16
|
+
def open_meta_tags?: () -> bool
|
17
|
+
def reset_defaults!: () -> void
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module MetaTags
|
2
|
+
module ControllerHelper : _ActionControllerBase
|
3
|
+
@page_title: String?
|
4
|
+
@page_description: String?
|
5
|
+
@page_keywords: String? | Array[String]
|
6
|
+
|
7
|
+
def render: (*untyped args) { () -> untyped } -> untyped
|
8
|
+
|
9
|
+
def set_meta_tags: (ViewHelper::meta_tags | (_MetaTagish & Object) meta_tags) -> void
|
10
|
+
|
11
|
+
def meta_tags: () -> MetaTagsCollection
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module MetaTags
|
2
|
+
class MetaTagsCollection
|
3
|
+
attr_reader meta_tags: Hash[String | Symbol, untyped]
|
4
|
+
|
5
|
+
def initialize: () -> void
|
6
|
+
|
7
|
+
def []: (String | Symbol name) -> untyped
|
8
|
+
|
9
|
+
def []=: (String | Symbol name, untyped value) -> untyped
|
10
|
+
|
11
|
+
def update: (?::Hash[String | Symbol, untyped] | (_MetaTagish & Object) object) -> Hash[String | Symbol, untyped]
|
12
|
+
|
13
|
+
def with_defaults: (?::Hash[String | Symbol, untyped] defaults) { () -> untyped } -> untyped
|
14
|
+
|
15
|
+
def full_title: (?::Hash[String | Symbol, untyped] defaults) -> String
|
16
|
+
|
17
|
+
def page_title: (?::Hash[String | Symbol, untyped] defaults) -> String
|
18
|
+
|
19
|
+
def extract: (String | Symbol name) -> untyped
|
20
|
+
|
21
|
+
def delete: (*String | Symbol names) -> void
|
22
|
+
|
23
|
+
def extract_full_title: () -> String
|
24
|
+
|
25
|
+
def extract_title: () -> Array[String | (_Stringish & Object)]
|
26
|
+
|
27
|
+
def extract_separator: () -> String
|
28
|
+
|
29
|
+
def extract_robots: () -> Hash[String, String]
|
30
|
+
|
31
|
+
def normalize_open_graph: (Hash[String | Symbol, untyped] meta_tags) -> ActiveSupport::HashWithIndifferentAccess[String | Symbol, untyped]
|
32
|
+
|
33
|
+
def extract_separator_section: (String | Symbol name, String default) -> String
|
34
|
+
|
35
|
+
def extract_robots_attribute: (String | Symbol name) -> [String | Array[String | Symbol], String?]
|
36
|
+
|
37
|
+
def calculate_robots_attributes: (untyped result, untyped attributes) -> untyped
|
38
|
+
|
39
|
+
def apply_robots_value: (untyped result, untyped name, untyped value, untyped processed) -> (nil | untyped)
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module MetaTags
|
2
|
+
class Renderer
|
3
|
+
type meta_key = String | Symbol
|
4
|
+
type meta_value = Hash[meta_key, meta_value] | Array[meta_value] | meta_content
|
5
|
+
type meta_content = String? | Symbol | Integer | bool | (_Timish & Object) | (_Stringish & Object)
|
6
|
+
|
7
|
+
attr_reader meta_tags: MetaTagsCollection
|
8
|
+
attr_reader normalized_meta_tags: Hash[Symbol, meta_value]
|
9
|
+
|
10
|
+
def initialize: (MetaTagsCollection meta_tags) -> void
|
11
|
+
|
12
|
+
def render: (_ActionViewBase view) -> String
|
13
|
+
|
14
|
+
def render_charset: (Array[Tag] tags) -> void
|
15
|
+
|
16
|
+
def render_title: (Array[Tag] tags) -> void
|
17
|
+
|
18
|
+
def render_icon: (Array[Tag] tags) -> void
|
19
|
+
|
20
|
+
def render_with_normalization: (Array[Tag] tags, Symbol name) -> void
|
21
|
+
|
22
|
+
def render_noindex: (Array[Tag] tags) -> void
|
23
|
+
|
24
|
+
def render_refresh: (Array[Tag] tags) -> void
|
25
|
+
|
26
|
+
def render_alternate: (Array[Tag] tags) -> void
|
27
|
+
|
28
|
+
def render_open_search: (Array[Tag] tags) -> void
|
29
|
+
|
30
|
+
def render_links: (Array[Tag] tags) -> void
|
31
|
+
|
32
|
+
def render_canonical_link: (Array[Tag] tags) -> void
|
33
|
+
|
34
|
+
def render_hashes: (Array[Tag] tags, **untyped opts) -> void
|
35
|
+
|
36
|
+
def render_hash: (Array[Tag] tags, untyped key, **untyped opts) -> void
|
37
|
+
|
38
|
+
def render_custom: (Array[Tag] tags) -> void
|
39
|
+
|
40
|
+
def process_tree: (Array[Tag] tags, meta_key property, meta_value content, ?itemprop: meta_key? itemprop, **untyped opts) -> void
|
41
|
+
|
42
|
+
def process_hash: (Array[Tag] tags, meta_key property, Hash[meta_key, meta_value] content, **untyped opts) -> void
|
43
|
+
|
44
|
+
def process_array: (Array[Tag] tags, meta_key property, Array[meta_value] content, **untyped opts) -> void
|
45
|
+
|
46
|
+
def render_tag: (Array[Tag] tags, meta_key name, meta_content value, ?itemprop: meta_key? itemprop) -> void
|
47
|
+
|
48
|
+
def configured_name_key: (meta_key name) -> Symbol
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module MetaTags
|
2
|
+
class Tag
|
3
|
+
attr_reader name: String
|
4
|
+
attr_reader attributes: Hash[String | Symbol, untyped]
|
5
|
+
|
6
|
+
def initialize: (String | Symbol name, ?Hash[String | Symbol, untyped] attributes) -> void
|
7
|
+
|
8
|
+
def render: (_ActionViewBase view) -> void
|
9
|
+
|
10
|
+
def prepare_attributes: (Hash[String | Symbol, untyped] attributes) -> Hash[String | Symbol, untyped]
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module MetaTags
|
2
|
+
module TextNormalizer
|
3
|
+
extend ::MetaTags::TextNormalizer
|
4
|
+
|
5
|
+
type keyword = String? | (_Stringish & Object)
|
6
|
+
type keywords = keyword | Array[keywords]
|
7
|
+
|
8
|
+
def normalize_title: (String? site_title, keywords title, String separator, ?bool reverse) -> String
|
9
|
+
|
10
|
+
def normalize_description: (keyword description) -> String
|
11
|
+
|
12
|
+
def normalize_keywords: (keywords keywords) -> String
|
13
|
+
|
14
|
+
def helpers: () -> _ActionViewBase
|
15
|
+
|
16
|
+
def strip_tags: (String string) -> String
|
17
|
+
|
18
|
+
def safe_join: (Array[String] array, ?String sep) -> String
|
19
|
+
|
20
|
+
def cleanup_string: (keyword string, ?strip: bool strip) -> String
|
21
|
+
|
22
|
+
def cleanup_strings: (keywords? strings, ?strip: bool strip) -> Array[String]
|
23
|
+
|
24
|
+
def truncate: (String string, ?Integer? limit, ?String natural_separator) -> String
|
25
|
+
|
26
|
+
def truncate_array: (Array[String] string_array, ?Integer? limit, ?String separator, ?String natural_separator) -> Array[String]
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def calculate_limit_left: (Integer limit, Integer length, Array[String] result, String separator) -> untyped
|
31
|
+
|
32
|
+
def truncate_title: (String site_title, Array[String] title, String separator) -> ::Array[untyped]
|
33
|
+
|
34
|
+
def calculate_title_limits: (String site_title, Array[String] title, String separator, Integer global_limit) -> untyped
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module MetaTags
|
2
|
+
module ViewHelper : Module, _ActionViewBase
|
3
|
+
# type meta_tags = {
|
4
|
+
# site: String?,
|
5
|
+
# title: Array[String] | String?,
|
6
|
+
# description: String?,
|
7
|
+
# keywords: Array[String] | String?,
|
8
|
+
# charset: String,
|
9
|
+
# prefix: String,
|
10
|
+
# separator: String,
|
11
|
+
# suffix: String,
|
12
|
+
# lowercase: bool,
|
13
|
+
# reverse: bool,
|
14
|
+
# noindex: bool | String | Array[String],
|
15
|
+
# index: bool | String | Array[String],
|
16
|
+
# nofollow: bool | String | Array[String],
|
17
|
+
# follow: bool | String | Array[String],
|
18
|
+
# noarchive: bool | String | Array[String],
|
19
|
+
# canonical: String,
|
20
|
+
# prev: String,
|
21
|
+
# next: String,
|
22
|
+
# image_src: String,
|
23
|
+
# alternate: String,
|
24
|
+
# amphtml: String,
|
25
|
+
# manifest: String,
|
26
|
+
# og: Hash[Renderer::meta_key, Renderer::meta_value],
|
27
|
+
# twitter: Hash[Renderer::meta_key, Renderer::meta_value],
|
28
|
+
# open_search: Hash[Renderer::meta_key, Renderer::meta_value],
|
29
|
+
# article: Hash[Renderer::meta_key, Renderer::meta_value],
|
30
|
+
# al: Hash[Renderer::meta_key, Renderer::meta_value],
|
31
|
+
# refresh: Integer | String | nil,
|
32
|
+
# } & Hash[Renderer::meta_key, Renderer::meta_value]
|
33
|
+
type meta_tags = Hash[Renderer::meta_key, Renderer::meta_value]
|
34
|
+
|
35
|
+
def meta_tags: () -> MetaTagsCollection
|
36
|
+
|
37
|
+
def set_meta_tags: (?meta_tags | (_MetaTagish&Object) meta_tags) -> void
|
38
|
+
|
39
|
+
def title: (?String? title, ?::String? headline) -> String
|
40
|
+
|
41
|
+
def keywords: (Array[String] | String? keywords) -> (Array[String] | String?)
|
42
|
+
|
43
|
+
def description: (String? description) -> String?
|
44
|
+
|
45
|
+
def noindex: (?String | Array[String] | bool noindex) -> (String | bool | Array[String])
|
46
|
+
|
47
|
+
def nofollow: (?String | Array[String] | bool nofollow) -> (String | bool | Array[String])
|
48
|
+
|
49
|
+
def refresh: (String? | Integer? refresh) -> (String? | Integer?)
|
50
|
+
|
51
|
+
def display_meta_tags: (?meta_tags defaults) -> String
|
52
|
+
|
53
|
+
def display_title: (?meta_tags defaults) -> String
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module MetaTags
|
2
|
+
def self.config: () -> Configuration
|
3
|
+
def self.configure: () { (Configuration) -> void } -> void
|
4
|
+
|
5
|
+
interface _Stringish
|
6
|
+
def to_str: () -> String
|
7
|
+
end
|
8
|
+
|
9
|
+
interface _Timish
|
10
|
+
def iso8601: () -> String
|
11
|
+
end
|
12
|
+
|
13
|
+
interface _MetaTagish
|
14
|
+
def to_meta_tags: () -> Hash[String | Symbol, untyped]
|
15
|
+
end
|
16
|
+
end
|
data.tar.gz.sig
CHANGED
Binary file
|
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.17.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
|
+
dWsvREM9a3B1bXVrL0RDPWluZm8wHhcNMjIwNzA1MjIyODU4WhcNMjMwNzA1MjIy
|
15
|
+
ODU4WjAjMSEwHwYDVQQDDBhrcHVtdWsvREM9a3B1bXVrL0RDPWluZm8wggEiMA0G
|
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
|
+
BBYwFIESa3B1bXVrQGtwdW11ay5pbmZvMA0GCSqGSIb3DQEBCwUAA4IBAQBa5fMh
|
25
|
+
JcbhWBoP3kA32g3yM238fyJlre/ZeE6WIFxcuETff8AgPmk550qpAF/WBtP23X8Q
|
26
|
+
khIFv+bFiuBURvNbuFevs23to7NeNA7XMmEJqjB6fRzO/i/a3bkLG07u+o74MyXe
|
27
|
+
3/VAxl4Ce+C3aLwXccsbD+Fe3kQ6ku4ceIh2WebBSkpG3WRANReEAf7lcOt4aGEt
|
28
|
+
nkYjyHgDz6/gYamK15XtOivglkTJDwAVGBzF9o6j5IQ9nXho8Vd2P+hiawx76CoT
|
29
|
+
ANVO3I4ZwTKD12DMFqjalLwbSVVO4wpuMO3tcAgO4q7Fqh2tXTXom/YYl0SFvmx4
|
30
|
+
evTPD0iY8lmGP3ZM
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
32
|
+
date: 2022-07-05 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: '
|
43
|
+
version: '7.1'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
46
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
version: 3.2.0
|
51
51
|
- - "<"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '7.1'
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
55
|
name: railties
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,7 +60,7 @@ dependencies:
|
|
60
60
|
version: 3.2.0
|
61
61
|
- - "<"
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: '
|
63
|
+
version: '7.1'
|
64
64
|
type: :development
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -70,7 +70,7 @@ dependencies:
|
|
70
70
|
version: 3.2.0
|
71
71
|
- - "<"
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: '
|
73
|
+
version: '7.1'
|
74
74
|
- !ruby/object:Gem::Dependency
|
75
75
|
name: rake
|
76
76
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,14 +91,14 @@ dependencies:
|
|
91
91
|
requirements:
|
92
92
|
- - "~>"
|
93
93
|
- !ruby/object:Gem::Version
|
94
|
-
version: 3.
|
94
|
+
version: 3.10.0
|
95
95
|
type: :development
|
96
96
|
prerelease: false
|
97
97
|
version_requirements: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
99
|
- - "~>"
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: 3.
|
101
|
+
version: 3.10.0
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: rspec-html-matchers
|
104
104
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- MIT-LICENSE
|
128
128
|
- README.md
|
129
129
|
- Rakefile
|
130
|
+
- Steepfile
|
130
131
|
- certs/kpumuk.pem
|
131
132
|
- lib/generators/meta_tags/install_generator.rb
|
132
133
|
- lib/generators/meta_tags/templates/config/initializers/meta_tags.rb
|
@@ -143,11 +144,28 @@ files:
|
|
143
144
|
- lib/meta_tags/version.rb
|
144
145
|
- lib/meta_tags/view_helper.rb
|
145
146
|
- meta-tags.gemspec
|
146
|
-
|
147
|
+
- sig/lib/_internal/rails.rbs
|
148
|
+
- sig/lib/meta_tags.rbs
|
149
|
+
- sig/lib/meta_tags/configuration.rbs
|
150
|
+
- sig/lib/meta_tags/content_tag.rbs
|
151
|
+
- sig/lib/meta_tags/controller_helper.rbs
|
152
|
+
- sig/lib/meta_tags/meta_tags_collection.rbs
|
153
|
+
- sig/lib/meta_tags/renderer.rbs
|
154
|
+
- sig/lib/meta_tags/tag.rbs
|
155
|
+
- sig/lib/meta_tags/text_normalizer.rbs
|
156
|
+
- sig/lib/meta_tags/version.rbs
|
157
|
+
- sig/lib/meta_tags/view_helper.rbs
|
158
|
+
homepage: https://github.com/kpumuk/meta-tags
|
147
159
|
licenses:
|
148
160
|
- MIT
|
149
|
-
metadata:
|
150
|
-
|
161
|
+
metadata:
|
162
|
+
bug_tracker_uri: https://github.com/kpumuk/meta-tags/issues/
|
163
|
+
changelog_uri: https://github.com/kpumuk/meta-tags/blob/main/CHANGELOG.md
|
164
|
+
documentation_uri: https://rubydoc.info/github/kpumuk/meta-tags/
|
165
|
+
homepage_uri: https://github.com/kpumuk/meta-tags/
|
166
|
+
source_code_uri: https://github.com/kpumuk/meta-tags/
|
167
|
+
rubygems_mfa_required: 'true'
|
168
|
+
post_install_message:
|
151
169
|
rdoc_options: []
|
152
170
|
require_paths:
|
153
171
|
- lib
|
@@ -155,15 +173,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
155
173
|
requirements:
|
156
174
|
- - ">="
|
157
175
|
- !ruby/object:Gem::Version
|
158
|
-
version:
|
176
|
+
version: 2.6.0
|
159
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
178
|
requirements:
|
161
179
|
- - ">="
|
162
180
|
- !ruby/object:Gem::Version
|
163
181
|
version: '0'
|
164
182
|
requirements: []
|
165
|
-
rubygems_version: 3.1.
|
166
|
-
signing_key:
|
183
|
+
rubygems_version: 3.1.6
|
184
|
+
signing_key:
|
167
185
|
specification_version: 4
|
168
186
|
summary: Collection of SEO helpers for Ruby on Rails.
|
169
187
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|