metamagic 3.1.5 → 3.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/README.md +0 -28
- data/lib/metamagic/renderer.rb +3 -7
- data/lib/metamagic/version.rb +1 -1
- data/lib/metamagic/view_helper.rb +1 -5
- data/test/metamagic_test.rb +0 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57930b74a808316cefbeec3bbc64ef77b663fabb
|
4
|
+
data.tar.gz: c95622c22507fac0b58ce38d7621d552aea66711
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dd898c6711a29f723fac3f9863d36d494cb0d91eb79bfc8033d5d8063dc70a62f92e86c29f2a94c4728c4a61f55e7d078bc0a6c40b160b66f64360c9e397288
|
7
|
+
data.tar.gz: b245b1875056f118f934d9c119a41dc9df80d03c5dbb93d04d4f422868aa9f16706c67d862d236fa9b811374d7abae7e1c8044c267ba6ab2f535dcd86642c6f5
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## Version 3.1.6
|
4
|
+
|
5
|
+
* Revert changes from 3.1.5 because of regression errors.
|
6
|
+
|
3
7
|
## Version 3.1.5
|
4
8
|
|
5
|
-
* Adds support for duplicating tags, e.g. setting `twitter:image` to the value of `og:image`.
|
9
|
+
* Adds support for duplicating tags, e.g. setting `twitter:image` to the value of `og:image`. *(reverted in 3.1.6)*
|
6
10
|
|
7
11
|
## Version 3.1.4
|
8
12
|
|
data/README.md
CHANGED
@@ -162,34 +162,6 @@ Templates are supported on all tag types. You can access the values set in the
|
|
162
162
|
view by replacing colons (`:`) in your meta keys with underscores (`_`), so for
|
163
163
|
example `og:image` can be accessed with `og_image`.
|
164
164
|
|
165
|
-
### Duplicating tags
|
166
|
-
|
167
|
-
Sometimes you want tags to be the same for e.g. Twitter and Facebook (OpenGraph).
|
168
|
-
To circumvent the need to duplicate these tags every time you write them in your code, you can let Metamagic do this for you.
|
169
|
-
|
170
|
-
Given that you want to add the same tags for Twitter as you have for Facebook, you can do this, in your view:
|
171
|
-
|
172
|
-
```erb
|
173
|
-
<%
|
174
|
-
og title: "My Title",
|
175
|
-
image: "http://test.com/image.jpg",
|
176
|
-
description: "My description."
|
177
|
-
%>
|
178
|
-
```
|
179
|
-
|
180
|
-
And in your layout:
|
181
|
-
|
182
|
-
```erb
|
183
|
-
<%= metamagic twitter: {
|
184
|
-
card: "summary",
|
185
|
-
title: :og_title,
|
186
|
-
image: :og_image,
|
187
|
-
description: :og_description
|
188
|
-
}
|
189
|
-
```
|
190
|
-
|
191
|
-
Now you only need to set OpenGraph data and these will be copied to Twitter.
|
192
|
-
|
193
165
|
### Shortcut helpers
|
194
166
|
|
195
167
|
For easy setting of meta tags, you can use the shortcut helpers like this:
|
data/lib/metamagic/renderer.rb
CHANGED
@@ -69,7 +69,7 @@ module Metamagic
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def has_tag_type?(prefix)
|
72
|
-
self.class.tag_types.has_key?(prefix
|
72
|
+
self.class.tag_types.has_key?(prefix)
|
73
73
|
end
|
74
74
|
|
75
75
|
def title_template
|
@@ -94,12 +94,8 @@ module Metamagic
|
|
94
94
|
tags.sort.map(&:to_html).compact.join("\n").html_safe
|
95
95
|
end
|
96
96
|
|
97
|
-
def method_missing(
|
98
|
-
|
99
|
-
tags.find { |t| t.key == method.to_s.gsub("_", ":") }.try(:interpolated_values)
|
100
|
-
else
|
101
|
-
context.send(method, *args, &block)
|
102
|
-
end
|
97
|
+
def method_missing(*args)
|
98
|
+
context.send(*args)
|
103
99
|
end
|
104
100
|
|
105
101
|
private
|
data/lib/metamagic/version.rb
CHANGED
@@ -23,12 +23,8 @@ module Metamagic
|
|
23
23
|
|
24
24
|
def method_missing(method, *args, &block)
|
25
25
|
if metamagic_renderer.has_tag_type?(method)
|
26
|
-
|
27
|
-
value = args.first
|
26
|
+
args.first.tap do |value|
|
28
27
|
meta method => value
|
29
|
-
value
|
30
|
-
else
|
31
|
-
metamagic_renderer.send method
|
32
28
|
end
|
33
29
|
else
|
34
30
|
super
|
data/test/metamagic_test.rb
CHANGED
@@ -82,12 +82,4 @@ class MetamagicTest < ActionView::TestCase
|
|
82
82
|
assert_equal %{<title>My Title</title>\n<meta content="one, two, three" name="keywords" />\n<meta content="My description." name="description" />\n<meta content="http://test.com/image.png" property="og:image" />\n<meta content="summary" property="twitter:card" />},
|
83
83
|
metamagic
|
84
84
|
end
|
85
|
-
|
86
|
-
test "duplicating tags" do
|
87
|
-
og image: "http://test.com/image.png",
|
88
|
-
description: "My description."
|
89
|
-
|
90
|
-
assert_equal %{<meta content="http://test.com/image.png" property="og:image" />\n<meta content="http://test.com/default.png" property="og:image" />\n<meta content="My description." property="og:description" />\n<meta content="http://test.com/image.png" property="twitter:image" />\n<meta content="http://test.com/default.png" property="twitter:image" />\n<meta content="summary" property="twitter:card" />\n<meta content="My description." property="twitter:description" />},
|
91
|
-
metamagic(og: { image: [:value, "http://test.com/default.png"] }, twitter: { card: "summary", image: :og_image, description: :og_description, other: :og_nonexisting })
|
92
|
-
end
|
93
85
|
end
|