meta-tags 2.15.0 → 2.16.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 +7 -0
- data/Gemfile +3 -0
- data/README.md +9 -0
- data/Rakefile +31 -0
- data/Steepfile +13 -0
- data/lib/meta_tags/meta_tags_collection.rb +10 -3
- data/lib/meta_tags/renderer.rb +10 -4
- data/lib/meta_tags/tag.rb +1 -1
- data/lib/meta_tags/text_normalizer.rb +22 -19
- data/lib/meta_tags/version.rb +1 -1
- data/lib/meta_tags/view_helper.rb +4 -4
- data/meta-tags.gemspec +11 -3
- data/sig/lib/_rails.rbs +26 -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 +2 -1
- metadata +26 -9
- 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: 49694826540a1943557eb3ae5fa74f5405ad2649c300806ec1064e48842e99f4
|
4
|
+
data.tar.gz: 7687408b49c8791b2386152a50d8760f7f9b533ed4e222fa1c8588cb49f7c7d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bef5f94ed23181efe26b22f498e6162059c6454676f20244cf8f0f62664fe87e10d5aa00a0e16e69ee8e3326f4f368ac008ad6c3d3a4d81b4f19f7fa9925c44
|
7
|
+
data.tar.gz: 3474171a2614d3064d90a10e4760e20b837f3c57acf253e907de990165e141a9cd0eb3f2b0baa0f1ffb04454e86abc3f713cca0f564e004b030825277f6cf161
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 2.16.0 (September 24, 2021) [☰](https://github.com/kpumuk/meta-tags/compare/v2.15.0...v2.16.0)
|
4
|
+
|
5
|
+
Changes:
|
6
|
+
|
7
|
+
- Updated maximum dependency specified in gemspec (Getting Ready for Rails 7)
|
8
|
+
- Added RBS type definitions.
|
9
|
+
|
3
10
|
## 2.15.0 (August 2, 2021) [☰](https://github.com/kpumuk/meta-tags/compare/v2.14.0...v2.15.0)
|
4
11
|
|
5
12
|
Changes:
|
data/Gemfile
CHANGED
@@ -10,6 +10,9 @@ if ENV['RAILS_VERSION']
|
|
10
10
|
gem 'railties', "~> #{ENV['RAILS_VERSION']}"
|
11
11
|
end
|
12
12
|
|
13
|
+
# Ruby typings
|
14
|
+
gem 'steep', platform: :mri unless ENV["NO_STEEP"] == '1'
|
15
|
+
|
13
16
|
group :test do
|
14
17
|
# Lock rubocop to a specific version we use on CI. If you update this,
|
15
18
|
# don't forget to switch rubocop channel in the .codeclimate.yml
|
data/README.md
CHANGED
@@ -523,6 +523,15 @@ To link back to normal version, use `canonical`.
|
|
523
523
|
- [What Is AMP?](https://www.ampproject.org/learn/about-amp/)
|
524
524
|
- [Make Your Page Discoverable](https://www.ampproject.org/docs/guides/discovery)
|
525
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
|
+
|
526
535
|
### Refresh interval and redirect URL
|
527
536
|
|
528
537
|
Meta refresh is a method of instructing a web browser to automatically
|
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,13 @@
|
|
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
|
+
end
|
@@ -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
|
|
data/lib/meta_tags/renderer.rb
CHANGED
@@ -243,8 +243,13 @@ module MetaTags
|
|
243
243
|
else
|
244
244
|
key = "#{property}:#{key}"
|
245
245
|
end
|
246
|
-
|
247
|
-
|
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))
|
248
253
|
end
|
249
254
|
end
|
250
255
|
|
@@ -264,6 +269,7 @@ module MetaTags
|
|
264
269
|
# @param [String, Symbol] name a Hash or a String to render as meta tag.
|
265
270
|
# @param [String, Symbol] value text content or a symbol reference to
|
266
271
|
# top-level meta tag.
|
272
|
+
# @param [String, Symbol] itemprop value of the itemprop attribute.
|
267
273
|
#
|
268
274
|
def render_tag(tags, name, value, itemprop: nil)
|
269
275
|
name_key ||= configured_name_key(name)
|
@@ -273,8 +279,8 @@ module MetaTags
|
|
273
279
|
# Returns meta tag property name for a give meta tag based on the
|
274
280
|
# configured list of property tags in MetaTags::Configuration#property_tags.
|
275
281
|
#
|
276
|
-
# @param [String, Symbol]
|
277
|
-
# @return [
|
282
|
+
# @param [String, Symbol] name tag key.
|
283
|
+
# @return [Symbol] meta tag attribute name (:property or :name).
|
278
284
|
#
|
279
285
|
def configured_name_key(name)
|
280
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
|
#
|
@@ -120,7 +120,7 @@ module MetaTags
|
|
120
120
|
|
121
121
|
# Cleans multiple strings up.
|
122
122
|
#
|
123
|
-
# @param [Array<String>] strings input
|
123
|
+
# @param [String, Array<String>] strings input string(s).
|
124
124
|
# @return [Array<String>] clean strings.
|
125
125
|
# @see cleanup_string
|
126
126
|
#
|
@@ -149,13 +149,13 @@ module MetaTags
|
|
149
149
|
)
|
150
150
|
end
|
151
151
|
|
152
|
-
# Truncates
|
152
|
+
# Truncates an array of strings to a specific limit.
|
153
153
|
#
|
154
154
|
# @param [Array<String>] string_array input strings.
|
155
155
|
# @param [Integer,nil] limit characters number to truncate to.
|
156
156
|
# @param [String] separator separator that will be used to join array later.
|
157
157
|
# @param [String] natural_separator natural separator to truncate at.
|
158
|
-
# @return [String] truncated
|
158
|
+
# @return [Array<String>] truncated array of strings.
|
159
159
|
#
|
160
160
|
def truncate_array(string_array, limit = nil, separator = '', natural_separator = ' ')
|
161
161
|
return string_array if limit.nil? || limit <= 0
|
@@ -168,14 +168,14 @@ module MetaTags
|
|
168
168
|
|
169
169
|
if string.length > limit_left
|
170
170
|
result << truncate(string, limit_left, natural_separator)
|
171
|
-
break
|
171
|
+
break string_array
|
172
172
|
end
|
173
173
|
|
174
174
|
length += (result.any? ? separator.length : 0) + string.length
|
175
175
|
result << string
|
176
176
|
|
177
177
|
# No more strings will fit
|
178
|
-
break if length + separator.length >= limit
|
178
|
+
break string_array if length + separator.length >= limit
|
179
179
|
end
|
180
180
|
|
181
181
|
result
|
@@ -188,8 +188,11 @@ module MetaTags
|
|
188
188
|
end
|
189
189
|
|
190
190
|
def truncate_title(site_title, title, separator)
|
191
|
-
|
192
|
-
|
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
|
+
)
|
193
196
|
|
194
197
|
title = title_limited_length > 0 ? truncate_array(title, title_limited_length, separator) : []
|
195
198
|
site_title = site_title_limited_length > 0 ? truncate(site_title, site_title_limited_length) : nil
|
@@ -198,14 +201,14 @@ module MetaTags
|
|
198
201
|
[site_title, title]
|
199
202
|
end
|
200
203
|
|
201
|
-
def calculate_title_limits(site_title, title, separator)
|
204
|
+
def calculate_title_limits(site_title, title, separator, global_limit)
|
202
205
|
# What should we truncate first: site title or page title?
|
203
206
|
main_title = MetaTags.config.truncate_site_title_first ? title : [site_title]
|
204
207
|
|
205
208
|
main_length = main_title.map(&:length).sum + (main_title.size - 1) * separator.length
|
206
|
-
main_limited_length =
|
209
|
+
main_limited_length = global_limit
|
207
210
|
|
208
|
-
secondary_limited_length =
|
211
|
+
secondary_limited_length = global_limit - (main_length > 0 ? main_length + separator.length : 0)
|
209
212
|
secondary_limited_length = [0, secondary_limited_length].max
|
210
213
|
|
211
214
|
if MetaTags.config.truncate_site_title_first
|
data/lib/meta_tags/version.rb
CHANGED
@@ -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/meta-tags.gemspec
CHANGED
@@ -12,7 +12,7 @@ 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
18
|
spec.required_ruby_version = '>= 2.5.0'
|
@@ -22,13 +22,21 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
-
spec.add_dependency "actionpack", ">= 3.2.0", "<
|
25
|
+
spec.add_dependency "actionpack", ">= 3.2.0", "< 7.1"
|
26
26
|
|
27
|
-
spec.add_development_dependency "railties", ">= 3.2.0", "<
|
27
|
+
spec.add_development_dependency "railties", ">= 3.2.0", "< 7.1"
|
28
28
|
spec.add_development_dependency "rake", "~> 13.0"
|
29
29
|
spec.add_development_dependency "rspec", "~> 3.10.0"
|
30
30
|
spec.add_development_dependency "rspec-html-matchers", "~> 0.9.1"
|
31
31
|
|
32
32
|
spec.cert_chain = ["certs/kpumuk.pem"]
|
33
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
|
+
}
|
34
42
|
end
|
data/sig/lib/_rails.rbs
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
class ::Hash[unchecked out K, unchecked out V]
|
2
|
+
def with_indifferent_access: () -> instance
|
3
|
+
def deep_merge!: (instance other) -> self
|
4
|
+
end
|
5
|
+
|
6
|
+
class ::Object
|
7
|
+
def presence: () -> String?
|
8
|
+
def blank?: () -> bool
|
9
|
+
def present?: () -> bool
|
10
|
+
end
|
11
|
+
|
12
|
+
interface _ActionControllerBase
|
13
|
+
def render: (*untyped args) { () -> untyped } -> untyped
|
14
|
+
end
|
15
|
+
|
16
|
+
interface _ActionViewBase
|
17
|
+
def tag: (String name, ?Hash[String | Symbol, untyped] options, ?bool open) -> void
|
18
|
+
|
19
|
+
def content_tag: (String name, String content, ?Hash[String | Symbol, untyped] options, ?bool open) -> void
|
20
|
+
|
21
|
+
def safe_join: (Array[String], String) -> String
|
22
|
+
|
23
|
+
def truncate: (String text, ?Hash[Symbol, untyped] options) -> String
|
24
|
+
|
25
|
+
def strip_tags: (String html) -> String
|
26
|
+
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) -> Hash[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
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
��w:�l���D�y����TIJŹ�i,%K9����WS���Y�R�'S��M��������$E~ɯ(r��֙�`�HNb@yS-��e�m���6Y��?A�\1;jk�?*\2�ک���[SQ'�9�$ݯVw�,�i�[�}�0e�:1]��}M���q�R8ϡ+SY�2�ꋫ������3�}�܀�[�-z
|
2
|
+
��u��e��Z�R|���+��CZ����aU�����-E�W�m���P����(��_����K�
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meta-tags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmytro Shteflyuk
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
U97JEQmXCpruLEeSVT2UqR+iJAWEAxPzqzDbTzZBTSPKn+nXeuF6h81e4hsJtkeJ
|
30
30
|
HkYAoatF9iZrxT4E
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date: 2021-
|
32
|
+
date: 2021-09-23 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
|
@@ -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,10 +144,26 @@ 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/_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:
|
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/
|
150
167
|
post_install_message:
|
151
168
|
rdoc_options: []
|
152
169
|
require_paths:
|
@@ -162,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
179
|
- !ruby/object:Gem::Version
|
163
180
|
version: '0'
|
164
181
|
requirements: []
|
165
|
-
rubygems_version: 3.
|
182
|
+
rubygems_version: 3.2.22
|
166
183
|
signing_key:
|
167
184
|
specification_version: 4
|
168
185
|
summary: Collection of SEO helpers for Ruby on Rails.
|
metadata.gz.sig
CHANGED
Binary file
|