page_meta 1.3.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby-tests.yml +2 -3
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +7 -1
- data/README.md +9 -0
- data/gemfiles/{6_1.gemfile → 7_2.gemfile} +1 -1
- data/lib/page_meta/base.rb +17 -1
- data/lib/page_meta/translator.rb +9 -4
- data/lib/page_meta/version.rb +1 -1
- data/page_meta.gemspec +1 -2
- metadata +5 -23
- data/gemfiles/7_0.gemfile +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30f096278376e70c56074428c6ec88f786a6a1ac893a8da66829884efc9e34dc
|
4
|
+
data.tar.gz: 4d635e8a75a48be6acedd134df338e73085f0f7f8326143b9bcfc8436ffc12e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24cf0db7b385568fcc471bc390b85b3d6c5e24972c5d54bd0cce251f9ee1058f917c096534f4bccd7f66f220e9efdcfa3d87c75c4dbf9c0a3d6ac0afe576a758
|
7
|
+
data.tar.gz: bcdefe6bbc2b57010848b2466023b3f1da305e9d745715f2373aeac33c9bf2ff9220edfb9c298772d11dd49f443c7985f91a0c431156e7917009ca7505b1d9d2
|
@@ -19,12 +19,11 @@ jobs:
|
|
19
19
|
strategy:
|
20
20
|
fail-fast: false
|
21
21
|
matrix:
|
22
|
-
ruby: ["3.
|
22
|
+
ruby: ["3.2", "3.3", "3.4"]
|
23
23
|
gemfile:
|
24
24
|
- Gemfile
|
25
|
+
- gemfiles/7_2.gemfile
|
25
26
|
- gemfiles/7_1.gemfile
|
26
|
-
- gemfiles/7_0.gemfile
|
27
|
-
- gemfiles/6_1.gemfile
|
28
27
|
|
29
28
|
steps:
|
30
29
|
- uses: actions/checkout@v4
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -11,10 +11,16 @@ Prefix your message with one of the following:
|
|
11
11
|
- [Security] in case of vulnerabilities.
|
12
12
|
-->
|
13
13
|
|
14
|
+
## Unreleased
|
15
|
+
|
16
|
+
- [Added] Add support for placeholders in base title.
|
17
|
+
- [Changed] Set minimum ruby version to 3.2.
|
18
|
+
- [Added] Add method to delete items by their name.
|
19
|
+
|
14
20
|
## 1.3.0
|
15
21
|
|
16
22
|
- [Added] `page_meta.base` will now set the base url.
|
17
|
-
- [Changed] Some tags will be enforced to show up first. It loosely follows
|
23
|
+
- [Changed] Some tags will be enforced to show up first. It loosely follows
|
18
24
|
https://rviscomi.github.io/capo.js/user/rules/.
|
19
25
|
|
20
26
|
## 1.2.0
|
data/README.md
CHANGED
@@ -231,6 +231,15 @@ would do.
|
|
231
231
|
[Please read Rails docs](http://guides.rubyonrails.org/i18n.html#using-safe-html-translations)
|
232
232
|
for more info.
|
233
233
|
|
234
|
+
### Removing meta tags
|
235
|
+
|
236
|
+
You can use `PageMeta::Base#delete` to remove meta tags. All matching tags will
|
237
|
+
be removed.
|
238
|
+
|
239
|
+
```ruby
|
240
|
+
page_meta.delete(:description)
|
241
|
+
```
|
242
|
+
|
234
243
|
## Maintainer
|
235
244
|
|
236
245
|
- [Nando Vieira](https://github.com/fnando)
|
data/lib/page_meta/base.rb
CHANGED
@@ -54,6 +54,11 @@ module PageMeta
|
|
54
54
|
}
|
55
55
|
end
|
56
56
|
|
57
|
+
# Delete all matching meta tags by name.
|
58
|
+
def delete(name)
|
59
|
+
items.delete_if { _1[:name] == name }
|
60
|
+
end
|
61
|
+
|
57
62
|
# Add a new meta tag.
|
58
63
|
def tag(name, value = nil, order: nil, **kwargs)
|
59
64
|
order = order || META_TAG_ORDER[name] || DEFAULT_ORDER
|
@@ -130,6 +135,7 @@ module PageMeta
|
|
130
135
|
end
|
131
136
|
|
132
137
|
private def compute_default_title
|
138
|
+
return if has?(:title)
|
133
139
|
return if title.to_s.blank?
|
134
140
|
|
135
141
|
html(:title, title.to_s, order: 3)
|
@@ -137,21 +143,31 @@ module PageMeta
|
|
137
143
|
end
|
138
144
|
|
139
145
|
private def compute_default_charset
|
146
|
+
return if has?(:charset)
|
147
|
+
|
140
148
|
tag(:charset, Rails.configuration.encoding, order: 0)
|
141
149
|
end
|
142
150
|
|
143
151
|
private def compute_default_keywords
|
152
|
+
return if has?(:keywords)
|
153
|
+
|
144
154
|
tag(:keywords, keywords.to_s) unless keywords.to_s.blank?
|
145
155
|
end
|
146
156
|
|
147
157
|
private def compute_default_description
|
158
|
+
return if has?(:description)
|
159
|
+
|
148
160
|
tag(:description, description.to_s) unless description.to_s.blank?
|
149
161
|
end
|
150
162
|
|
151
163
|
private def compute_default_viewport
|
152
|
-
return if
|
164
|
+
return if has?(:viewport)
|
153
165
|
|
154
166
|
tag(:viewport, "width=device-width,initial-scale=1", order: 1)
|
155
167
|
end
|
168
|
+
|
169
|
+
private def has?(name)
|
170
|
+
items.any? { _1[:name] == name }
|
171
|
+
end
|
156
172
|
end
|
157
173
|
end
|
data/lib/page_meta/translator.rb
CHANGED
@@ -24,9 +24,12 @@ module PageMeta
|
|
24
24
|
def to_s
|
25
25
|
return "" if simple.blank?
|
26
26
|
|
27
|
+
value = simple
|
28
|
+
|
27
29
|
[
|
28
|
-
t("page_meta.#{scope}.base", value
|
29
|
-
t("page_meta.#{singular_scope}_base", value
|
30
|
+
t("page_meta.#{scope}.base", value:, **override_options),
|
31
|
+
t("page_meta.#{singular_scope}_base", value:, **override_options,
|
32
|
+
default: value)
|
30
33
|
].reject(&:blank?).first || ""
|
31
34
|
end
|
32
35
|
|
@@ -37,9 +40,11 @@ module PageMeta
|
|
37
40
|
]
|
38
41
|
end
|
39
42
|
|
40
|
-
def
|
41
|
-
|
43
|
+
def override_options
|
44
|
+
options.merge(default: "")
|
45
|
+
end
|
42
46
|
|
47
|
+
def simple
|
43
48
|
translation = ""
|
44
49
|
|
45
50
|
translation_scope.each do |scope|
|
data/lib/page_meta/version.rb
CHANGED
data/page_meta.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.version = PageMeta::VERSION
|
8
8
|
spec.authors = ["Nando Vieira"]
|
9
9
|
spec.email = ["me@fnando.com"]
|
10
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 3.
|
10
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.2.0")
|
11
11
|
spec.metadata = {
|
12
12
|
"rubygems_mfa_required" => "true"
|
13
13
|
}
|
@@ -29,7 +29,6 @@ Gem::Specification.new do |spec|
|
|
29
29
|
|
30
30
|
spec.add_development_dependency "bundler"
|
31
31
|
spec.add_development_dependency "minitest-utils"
|
32
|
-
spec.add_development_dependency "pry-meta"
|
33
32
|
spec.add_development_dependency "rake"
|
34
33
|
spec.add_development_dependency "rubocop"
|
35
34
|
spec.add_development_dependency "rubocop-fnando"
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: page_meta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date: 2024-
|
10
|
+
date: 2024-12-29 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rails
|
@@ -52,20 +51,6 @@ dependencies:
|
|
52
51
|
- - ">="
|
53
52
|
- !ruby/object:Gem::Version
|
54
53
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: pry-meta
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
54
|
- !ruby/object:Gem::Dependency
|
70
55
|
name: rake
|
71
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,9 +133,8 @@ files:
|
|
148
133
|
- Rakefile
|
149
134
|
- bin/console
|
150
135
|
- bin/setup
|
151
|
-
- gemfiles/6_1.gemfile
|
152
|
-
- gemfiles/7_0.gemfile
|
153
136
|
- gemfiles/7_1.gemfile
|
137
|
+
- gemfiles/7_2.gemfile
|
154
138
|
- lib/page_meta.rb
|
155
139
|
- lib/page_meta/action.rb
|
156
140
|
- lib/page_meta/base.rb
|
@@ -176,7 +160,6 @@ licenses:
|
|
176
160
|
- MIT
|
177
161
|
metadata:
|
178
162
|
rubygems_mfa_required: 'true'
|
179
|
-
post_install_message:
|
180
163
|
rdoc_options: []
|
181
164
|
require_paths:
|
182
165
|
- lib
|
@@ -184,15 +167,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
184
167
|
requirements:
|
185
168
|
- - ">="
|
186
169
|
- !ruby/object:Gem::Version
|
187
|
-
version: 3.
|
170
|
+
version: 3.2.0
|
188
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
172
|
requirements:
|
190
173
|
- - ">="
|
191
174
|
- !ruby/object:Gem::Version
|
192
175
|
version: '0'
|
193
176
|
requirements: []
|
194
|
-
rubygems_version: 3.
|
195
|
-
signing_key:
|
177
|
+
rubygems_version: 3.6.2
|
196
178
|
specification_version: 4
|
197
179
|
summary: Easily define <meta> and <link> tags. I18n support for descriptions, keywords
|
198
180
|
and titles.
|