meta-tags 2.13.0 → 2.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/Appraisals +25 -0
  4. data/CHANGELOG.md +158 -78
  5. data/CONTRIBUTING.md +6 -6
  6. data/Gemfile +5 -19
  7. data/README.md +174 -137
  8. data/Rakefile +44 -6
  9. data/Steepfile +13 -0
  10. data/certs/kpumuk.pem +19 -18
  11. data/gemfiles/rails_5.1.gemfile +8 -0
  12. data/gemfiles/rails_5.1.gemfile.lock +200 -0
  13. data/gemfiles/rails_5.2.gemfile +8 -0
  14. data/gemfiles/rails_5.2.gemfile.lock +200 -0
  15. data/gemfiles/rails_6.0.gemfile +8 -0
  16. data/gemfiles/rails_6.0.gemfile.lock +202 -0
  17. data/gemfiles/rails_6.1.gemfile +8 -0
  18. data/gemfiles/rails_6.1.gemfile.lock +201 -0
  19. data/gemfiles/rails_7.0.gemfile +8 -0
  20. data/gemfiles/rails_7.0.gemfile.lock +201 -0
  21. data/gemfiles/rails_7.1.gemfile +8 -0
  22. data/gemfiles/rails_7.1.gemfile.lock +231 -0
  23. data/lib/generators/meta_tags/install_generator.rb +1 -1
  24. data/lib/meta-tags.rb +1 -1
  25. data/lib/meta_tags/configuration.rb +23 -16
  26. data/lib/meta_tags/controller_helper.rb +4 -4
  27. data/lib/meta_tags/meta_tags_collection.rb +31 -22
  28. data/lib/meta_tags/railtie.rb +4 -4
  29. data/lib/meta_tags/renderer.rb +55 -28
  30. data/lib/meta_tags/tag.rb +1 -1
  31. data/lib/meta_tags/text_normalizer.rb +44 -39
  32. data/lib/meta_tags/version.rb +1 -1
  33. data/lib/meta_tags/view_helper.rb +7 -7
  34. data/lib/meta_tags.rb +13 -10
  35. data/meta-tags.gemspec +41 -22
  36. data/sig/lib/_internal/rails.rbs +58 -0
  37. data/sig/lib/meta_tags/configuration.rbs +19 -0
  38. data/sig/lib/meta_tags/content_tag.rbs +5 -0
  39. data/sig/lib/meta_tags/controller_helper.rbs +14 -0
  40. data/sig/lib/meta_tags/meta_tags_collection.rbs +41 -0
  41. data/sig/lib/meta_tags/renderer.rbs +50 -0
  42. data/sig/lib/meta_tags/tag.rbs +12 -0
  43. data/sig/lib/meta_tags/text_normalizer.rbs +36 -0
  44. data/sig/lib/meta_tags/version.rbs +4 -0
  45. data/sig/lib/meta_tags/view_helper.rbs +57 -0
  46. data/sig/lib/meta_tags.rbs +18 -0
  47. data.tar.gz.sig +0 -0
  48. metadata +165 -35
  49. metadata.gz.sig +0 -0
@@ -8,29 +8,29 @@ module MetaTags
8
8
  # Normalize title value.
9
9
  #
10
10
  # @param [String] site_title site title.
11
- # @param [String, Array<String>] title title string.
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 [Array<String>] array of title parts with tags removed.
14
+ # @return [String] title with HTML tags removed.
15
15
  #
16
16
  def normalize_title(site_title, title, separator, reverse = false)
17
- title = cleanup_strings(title)
18
- title.reverse! if reverse
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, title = truncate_title(site_title, title, separator)
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
- title.push(site_title)
28
+ clean_title.push(site_title)
29
29
  else
30
- title.unshift(site_title)
30
+ clean_title.unshift(site_title)
31
31
  end
32
32
  end
33
- safe_join(title, separator)
33
+ safe_join(clean_title, separator)
34
34
  end
35
35
 
36
36
  # Normalize description value.
@@ -44,7 +44,7 @@ module MetaTags
44
44
  # serves the same purpose we could just as it to convert itself to str
45
45
  # and continue from there
46
46
  description = cleanup_string(description)
47
- return '' if description.blank?
47
+ return "" if description.blank?
48
48
 
49
49
  truncate(description, MetaTags.config.description_limit)
50
50
  end
@@ -56,7 +56,7 @@ module MetaTags
56
56
  #
57
57
  def normalize_keywords(keywords)
58
58
  keywords = cleanup_strings(keywords)
59
- return '' if keywords.blank?
59
+ return "" if keywords.blank?
60
60
 
61
61
  keywords.each(&:downcase!) if MetaTags.config.keywords_lowercase
62
62
  separator = cleanup_string MetaTags.config.keywords_separator, strip: false
@@ -102,23 +102,25 @@ 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
  #
109
109
  def cleanup_string(string, strip: true)
110
- return '' if string.nil?
111
- raise ArgumentError, 'Expected a string or an object that implements #to_str' unless string.respond_to?(:to_str)
110
+ return "" if string.nil?
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).tap do |s|
114
- s.gsub!(/\s+/, ' ')
115
- s.strip! if strip
116
- end
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 strings.
123
+ # @param [String, Array<String>] strings input string(s).
122
124
  # @return [Array<String>] clean strings.
123
125
  # @see cleanup_string
124
126
  #
@@ -135,27 +137,27 @@ module MetaTags
135
137
  # @param [String] natural_separator natural separator to truncate at.
136
138
  # @return [String] truncated string.
137
139
  #
138
- def truncate(string, limit = nil, natural_separator = ' ')
139
- return string if limit.to_i == 0 # rubocop:disable Lint/NumberConversion
140
+ def truncate(string, limit = nil, natural_separator = " ")
141
+ return string if limit.to_i == 0
140
142
 
141
143
  helpers.truncate(
142
144
  string,
143
- length: limit,
145
+ length: limit,
144
146
  separator: natural_separator,
145
- omission: '',
146
- escape: true,
147
+ omission: "",
148
+ escape: true
147
149
  )
148
150
  end
149
151
 
150
- # Truncates a string to a specific limit.
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 string.
158
+ # @return [Array<String>] truncated array of strings.
157
159
  #
158
- def truncate_array(string_array, limit = nil, separator = '', natural_separator = ' ')
160
+ def truncate_array(string_array, limit = nil, separator = "", natural_separator = " ")
159
161
  return string_array if limit.nil? || limit <= 0
160
162
 
161
163
  length = 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,30 +188,33 @@ module MetaTags
186
188
  end
187
189
 
188
190
  def truncate_title(site_title, title, separator)
189
- if MetaTags.config.title_limit.to_i > 0 # rubocop:disable Lint/NumberConversion
190
- site_title_limited_length, title_limited_length = calculate_title_limits(site_title, title, separator)
191
-
192
- title = title_limited_length > 0 ? truncate_array(title, title_limited_length, separator) : []
193
- site_title = site_title_limited_length > 0 ? truncate(site_title, site_title_limited_length) : nil
191
+ global_limit = MetaTags.config.title_limit.to_i
192
+ if global_limit > 0
193
+ site_title_limited_length, title_limited_length = calculate_title_limits(
194
+ site_title, title, separator, global_limit
195
+ )
196
+
197
+ title = (title_limited_length > 0) ? truncate_array(title, title_limited_length, separator) : []
198
+ site_title = (site_title_limited_length > 0) ? truncate(site_title, site_title_limited_length) : nil
194
199
  end
195
200
 
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 = MetaTags.config.title_limit
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 = MetaTags.config.title_limit - (main_length > 0 ? main_length + separator.length : 0)
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
210
- [ secondary_limited_length, main_limited_length ]
215
+ [secondary_limited_length, main_limited_length]
211
216
  else
212
- [ main_limited_length, secondary_limited_length ]
217
+ [main_limited_length, secondary_limited_length]
213
218
  end
214
219
  end
215
220
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module MetaTags
4
4
  # Gem version.
5
- VERSION = '2.13.0'
5
+ VERSION = "2.19.0"
6
6
  public_constant :VERSION
7
7
  end
@@ -27,7 +27,7 @@ module MetaTags
27
27
  #
28
28
  # @see #display_meta_tags
29
29
  #
30
- def set_meta_tags(meta_tags = {}) # rubocop:disable Naming/AccessorMethodName
30
+ def set_meta_tags(meta_tags = {})
31
31
  self.meta_tags.update(meta_tags)
32
32
  end
33
33
 
@@ -55,7 +55,7 @@ module MetaTags
55
55
  #
56
56
  # @see #display_meta_tags
57
57
  #
58
- def title(title = nil, headline = '')
58
+ def title(title = nil, headline = "")
59
59
  set_meta_tags(title: title) unless title.nil?
60
60
  headline.presence || meta_tags[:title]
61
61
  end
@@ -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
@@ -203,7 +203,7 @@ module MetaTags
203
203
  # <div data-page-container="true" title="<%= display_title title: 'My Page', site: 'PJAX Site' %>">
204
204
  #
205
205
  def display_title(defaults = {})
206
- @meta_tags.full_title(defaults)
206
+ meta_tags.full_title(defaults)
207
207
  end
208
208
  end
209
209
  end
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.
@@ -21,15 +24,15 @@ module MetaTags
21
24
  end
22
25
  end
23
26
 
24
- require 'meta_tags/version'
27
+ require "meta_tags/version"
25
28
 
26
- require 'meta_tags/configuration'
27
- require 'meta_tags/controller_helper'
28
- require 'meta_tags/meta_tags_collection'
29
- require 'meta_tags/renderer'
30
- require 'meta_tags/tag'
31
- require 'meta_tags/content_tag'
32
- require 'meta_tags/text_normalizer'
33
- require 'meta_tags/view_helper'
29
+ require "meta_tags/configuration"
30
+ require "meta_tags/controller_helper"
31
+ require "meta_tags/meta_tags_collection"
32
+ require "meta_tags/renderer"
33
+ require "meta_tags/tag"
34
+ require "meta_tags/content_tag"
35
+ require "meta_tags/text_normalizer"
36
+ require "meta_tags/view_helper"
34
37
 
35
- require 'meta_tags/railtie.rb' if defined?(Rails)
38
+ require "meta_tags/railtie" if defined?(Rails)
data/meta-tags.gemspec CHANGED
@@ -1,33 +1,52 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', __dir__)
3
+ lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'meta_tags/version'
5
+ require "meta_tags/version"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = "meta-tags"
9
- spec.version = MetaTags::VERSION
10
- spec.authors = ["Dmytro Shteflyuk"]
11
- spec.email = ["kpumuk@kpumuk.info"]
12
-
13
- spec.summary = "Collection of SEO helpers for Ruby on Rails."
14
- spec.description = "Search Engine Optimization (SEO) plugin for Ruby on Rails applications."
15
- spec.homepage = "http://github.com/kpumuk/meta-tags"
16
- spec.license = "MIT"
17
- spec.platform = Gem::Platform::RUBY
18
-
19
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(\.|(bin|test|spec|features)/)}) }
20
- spec.bindir = "exe"
21
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
8
+ spec.name = "meta-tags"
9
+ spec.version = MetaTags::VERSION
10
+ spec.authors = ["Dmytro Shteflyuk"]
11
+ spec.email = ["kpumuk@kpumuk.info"]
12
+
13
+ spec.summary = "Collection of SEO helpers for Ruby on Rails."
14
+ spec.description = "Search Engine Optimization (SEO) plugin for Ruby on Rails applications."
15
+ spec.homepage = "https://github.com/kpumuk/meta-tags"
16
+ spec.license = "MIT"
17
+ spec.platform = Gem::Platform::RUBY
18
+ spec.required_ruby_version = ">= 2.7.0"
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(\.|(bin|test|spec|features)/)}) }
21
+ spec.bindir = "exe"
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.1"
25
+ spec.add_runtime_dependency "actionpack", ">= 3.2.0", "< 7.2"
25
26
 
26
- spec.add_development_dependency "railties", ">= 3.2.0", "< 6.1"
27
+ spec.add_development_dependency "railties", ">= 3.2.0", "< 7.2"
27
28
  spec.add_development_dependency "rake", "~> 13.0"
28
- spec.add_development_dependency "rspec", "~> 3.9.0"
29
- spec.add_development_dependency "rspec-html-matchers", "~> 0.9.1"
29
+ spec.add_development_dependency "rspec", "~> 3.12.0"
30
+ spec.add_development_dependency "rspec-html-matchers", "~> 0.10.0"
31
+ spec.add_development_dependency "appraisal", "~> 2.5.0"
32
+ spec.add_development_dependency "simplecov", "~> 0.22.0"
33
+ # Code style
34
+ spec.add_development_dependency "standard", "~> 1.29"
35
+ spec.add_development_dependency "rubocop-rails", "~> 2.20.2"
36
+ spec.add_development_dependency "rubocop-rake", "~> 0.6.0"
37
+ spec.add_development_dependency "rubocop-rspec", "~> 2.23.0"
38
+ # Format RSpec output for CircleCI
39
+ spec.add_development_dependency "rspec_junit_formatter", "~> 0.6.0"
40
+
41
+ spec.cert_chain = ["certs/kpumuk.pem"]
42
+ spec.signing_key = File.expand_path("~/.ssh/gem-kpumuk.pem") if $PROGRAM_NAME.end_with?("gem")
30
43
 
31
- spec.cert_chain = ["certs/kpumuk.pem"]
32
- spec.signing_key = File.expand_path("~/.ssh/gem-kpumuk.pem") if $PROGRAM_NAME.end_with?('gem')
44
+ spec.metadata = {
45
+ "bug_tracker_uri" => "https://github.com/kpumuk/meta-tags/issues/",
46
+ "changelog_uri" => "https://github.com/kpumuk/meta-tags/blob/main/CHANGELOG.md",
47
+ "documentation_uri" => "https://rubydoc.info/github/kpumuk/meta-tags/",
48
+ "homepage_uri" => "https://github.com/kpumuk/meta-tags/",
49
+ "source_code_uri" => "https://github.com/kpumuk/meta-tags/",
50
+ "rubygems_mfa_required" => "true"
51
+ }
33
52
  end
@@ -0,0 +1,58 @@
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
+ $OFS: String
8
+
9
+ def presence: () -> self?
10
+ def blank?: () -> bool
11
+ def present?: () -> bool
12
+ end
13
+
14
+ class ::Loofah
15
+ module TextBehavior
16
+ def text: (?Hash[Symbol, untyped]? options) -> String
17
+ end
18
+
19
+ class DocumentFragment
20
+ include TextBehavior
21
+ end
22
+
23
+ def self.fragment: (String tags, ?String? encoding) -> DocumentFragment
24
+ end
25
+
26
+ class ::Rails
27
+ end
28
+
29
+ module ActionController
30
+ class Base
31
+ include _ActionControllerBase
32
+
33
+ def self.helpers: () -> _ActionViewBase
34
+ end
35
+ end
36
+
37
+ module ActiveSupport
38
+ class HashWithIndifferentAccess[unchecked out K, unchecked out V] < Hash[K, V]
39
+ def with_indifferent_access: () -> self
40
+ def deep_merge!: (instance | Hash[K, V] other) -> self
41
+ end
42
+ end
43
+
44
+ interface _ActionControllerBase
45
+ def render: (*untyped args) { () -> untyped } -> untyped
46
+ end
47
+
48
+ interface _ActionViewBase
49
+ def tag: (String name, ?Hash[String | Symbol, untyped] options, ?bool open) -> void
50
+
51
+ def content_tag: (String name, String content, ?Hash[String | Symbol, untyped] options, ?bool open) -> void
52
+
53
+ def safe_join: (Array[String], String) -> String
54
+
55
+ def truncate: (String text, ?Hash[Symbol, untyped] options) -> String
56
+
57
+ def strip_tags: (String html) -> String
58
+ 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,5 @@
1
+ module MetaTags
2
+ class ContentTag < Tag
3
+ def render: (_ActionViewBase view) -> untyped
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+ module MetaTags
2
+ module ControllerHelper : _ActionControllerBase
3
+ @meta_tags: MetaTagsCollection?
4
+ @page_title: String?
5
+ @page_description: String?
6
+ @page_keywords: String? | Array[String]
7
+
8
+ def render: (*untyped args) { () -> untyped } -> untyped
9
+
10
+ def set_meta_tags: (ViewHelper::meta_tags | (_MetaTagish & Object) meta_tags) -> void
11
+
12
+ def meta_tags: () -> MetaTagsCollection
13
+ end
14
+ 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,4 @@
1
+ module MetaTags
2
+ # Gem version.
3
+ VERSION: ::String
4
+ end
@@ -0,0 +1,57 @@
1
+ module MetaTags
2
+ module ViewHelper : Module, _ActionViewBase
3
+ @meta_tags: MetaTagsCollection?
4
+
5
+ # type meta_tags = {
6
+ # site: String?,
7
+ # title: Array[String] | String?,
8
+ # description: String?,
9
+ # keywords: Array[String] | String?,
10
+ # charset: String,
11
+ # prefix: String,
12
+ # separator: String,
13
+ # suffix: String,
14
+ # lowercase: bool,
15
+ # reverse: bool,
16
+ # noindex: bool | String | Array[String],
17
+ # index: bool | String | Array[String],
18
+ # nofollow: bool | String | Array[String],
19
+ # follow: bool | String | Array[String],
20
+ # noarchive: bool | String | Array[String],
21
+ # canonical: String,
22
+ # prev: String,
23
+ # next: String,
24
+ # image_src: String,
25
+ # alternate: String,
26
+ # amphtml: String,
27
+ # manifest: String,
28
+ # og: Hash[Renderer::meta_key, Renderer::meta_value],
29
+ # twitter: Hash[Renderer::meta_key, Renderer::meta_value],
30
+ # open_search: Hash[Renderer::meta_key, Renderer::meta_value],
31
+ # article: Hash[Renderer::meta_key, Renderer::meta_value],
32
+ # al: Hash[Renderer::meta_key, Renderer::meta_value],
33
+ # refresh: Integer | String | nil,
34
+ # } & Hash[Renderer::meta_key, Renderer::meta_value]
35
+ type meta_tags = Hash[Renderer::meta_key, Renderer::meta_value]
36
+
37
+ def meta_tags: () -> MetaTagsCollection
38
+
39
+ def set_meta_tags: (?meta_tags | (_MetaTagish&Object) meta_tags) -> void
40
+
41
+ def title: (?String? title, ?::String? headline) -> String
42
+
43
+ def keywords: (Array[String] | String? keywords) -> (Array[String] | String?)
44
+
45
+ def description: (String? description) -> String?
46
+
47
+ def noindex: (?String | Array[String] | bool noindex) -> (String | bool | Array[String])
48
+
49
+ def nofollow: (?String | Array[String] | bool nofollow) -> (String | bool | Array[String])
50
+
51
+ def refresh: (String? | Integer? refresh) -> (String? | Integer?)
52
+
53
+ def display_meta_tags: (?meta_tags defaults) -> String
54
+
55
+ def display_title: (?meta_tags defaults) -> String
56
+ end
57
+ end