meta-tags 2.11.0 → 2.18.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,6 +26,7 @@ module MetaTags
26
26
  render_with_normalization(tags, :description)
27
27
  render_with_normalization(tags, :keywords)
28
28
  render_refresh(tags)
29
+ render_canonical_link(tags)
29
30
  render_noindex(tags)
30
31
  render_alternate(tags)
31
32
  render_open_search(tags)
@@ -97,7 +98,7 @@ module MetaTags
97
98
  # @param [Array<Tag>] tags a buffer object to store tag in.
98
99
  #
99
100
  def render_noindex(tags)
100
- meta_tags.extract_noindex.each do |name, content|
101
+ meta_tags.extract_robots.each do |name, content|
101
102
  tags << Tag.new(:meta, name: name, content: content) if content.present?
102
103
  end
103
104
  end
@@ -150,7 +151,7 @@ module MetaTags
150
151
  # @param [Array<Tag>] tags a buffer object to store tag in.
151
152
  #
152
153
  def render_links(tags)
153
- [ :amphtml, :canonical, :prev, :next, :image_src ].each do |tag_name|
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
- key = key.to_s == '_' ? property : "#{property}:#{key}"
225
- value = normalized_meta_tags[value] if value.kind_of?(Symbol)
226
- process_tree(tags, key, value, **opts)
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, name_key: nil, value_key: :content)
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, value_key => value) if value.present?
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] meta tag key.
256
- # @return [String] meta tag attribute name ("property" or "name").
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
@@ -11,7 +11,7 @@ module MetaTags
11
11
  # @param [Hash] attributes list of HTML tag attributes
12
12
  #
13
13
  def initialize(name, attributes = {})
14
- @name = name
14
+ @name = name.to_s
15
15
  @attributes = attributes
16
16
  end
17
17
 
@@ -3,34 +3,34 @@
3
3
  module MetaTags
4
4
  # Module contains helpers that normalize text meta tag values.
5
5
  module TextNormalizer
6
- extend self # rubocop:disable Style/ModuleFunction
6
+ extend self
7
7
 
8
8
  # Normalize title value.
9
9
  #
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.
@@ -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).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
  #
@@ -147,13 +149,13 @@ module MetaTags
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
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
- 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
+ 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 = 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
@@ -2,5 +2,6 @@
2
2
 
3
3
  module MetaTags
4
4
  # Gem version.
5
- VERSION = '2.11.0'
5
+ VERSION = '2.18.0'
6
+ public_constant :VERSION
6
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
 
@@ -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
@@ -205,7 +205,5 @@ module MetaTags
205
205
  def display_title(defaults = {})
206
206
  @meta_tags.full_title(defaults)
207
207
  end
208
-
209
- # safe_helper :display_meta_tags if defined?(:safe_helper)
210
208
  end
211
209
  end
data/lib/meta_tags.rb CHANGED
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'English'
4
- require 'action_controller'
5
- require 'action_view'
3
+ require 'set'
4
+ require 'active_support/core_ext/hash/indifferent_access'
6
5
 
7
6
  # MetaTags gem namespace.
8
7
  module MetaTags
@@ -36,5 +35,4 @@ require 'meta_tags/content_tag'
36
35
  require 'meta_tags/text_normalizer'
37
36
  require 'meta_tags/view_helper'
38
37
 
39
- ActionView::Base.include MetaTags::ViewHelper
40
- ActionController::Base.include MetaTags::ControllerHelper
38
+ require 'meta_tags/railtie' if defined?(Rails)
data/meta-tags.gemspec CHANGED
@@ -12,21 +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 = "http://github.com/kpumuk/meta-tags"
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", "< 5.3"
25
+ spec.add_dependency "actionpack", ">= 3.2.0", "< 7.1"
25
26
 
26
- spec.add_development_dependency "rake", "~> 12.0"
27
- spec.add_development_dependency "rspec", "~> 3.8.0"
27
+ spec.add_development_dependency "railties", ">= 3.2.0", "< 7.1"
28
+ spec.add_development_dependency "rake", "~> 13.0"
29
+ spec.add_development_dependency "rspec", "~> 3.11.0"
28
30
  spec.add_development_dependency "rspec-html-matchers", "~> 0.9.1"
29
31
 
30
32
  spec.cert_chain = ["certs/kpumuk.pem"]
31
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
+ }
32
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: () -> self?
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,5 @@
1
+ module MetaTags
2
+ class ContentTag < Tag
3
+ def render: (_ActionViewBase view) -> untyped
4
+ end
5
+ 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,4 @@
1
+ module MetaTags
2
+ # Gem version.
3
+ VERSION: ::String
4
+ 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