acts_as_graph_object 0.0.6 → 0.0.7
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.
- data/README.md +27 -1
- data/lib/acts_as_graph_object/base.rb +27 -9
- data/lib/acts_as_graph_object/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -66,6 +66,30 @@ If you want to override a value from the view (for example to use a `url_for` he
|
|
66
66
|
<% content_for :meta_tags, graph_object_tags_for(@movie, :url => movie_url(@movie)) %>
|
67
67
|
```
|
68
68
|
|
69
|
+
#### Alternative attribute names (v0.0.7)
|
70
|
+
You can now use non-default names for the standard Open Graph properties and the Gem will attempt to pick these up. Here are the properties and their alternative names:
|
71
|
+
```ruby
|
72
|
+
# standard object properties & alternative names
|
73
|
+
default_properties = {
|
74
|
+
:title => [:name, :label],
|
75
|
+
:type => [:kind, :group, :class],
|
76
|
+
:image => [:picture, :photo],
|
77
|
+
:url => [:permalink, :link],
|
78
|
+
:description => [:info, :details],
|
79
|
+
:site_name => [:site],
|
80
|
+
:latitude => [:lat],
|
81
|
+
:longitude => [:long],
|
82
|
+
:street_address => [:address],
|
83
|
+
:locality => [:locale, :area],
|
84
|
+
:region => [:province, :territory],
|
85
|
+
:postal_code => [:post_code, :zip_code, :zip],
|
86
|
+
:country_name => [:country],
|
87
|
+
:email => [:email_address],
|
88
|
+
:phone_number => [:phone],
|
89
|
+
:fax_number => [:fax]
|
90
|
+
}
|
91
|
+
```
|
92
|
+
|
69
93
|
#### Notes
|
70
94
|
This is my first gem so things are a bit rough around the edges, all feedback is happily welcomed :) - please fork/fix to your heart's content.
|
71
95
|
|
@@ -95,4 +119,6 @@ class Movie < ActiveRecord::Base
|
|
95
119
|
end
|
96
120
|
```
|
97
121
|
|
98
|
-
This would map all standard properties `title`, `description`, `image`, `app_id` etc along with the custom properties `director`, `writer` & `cast`.
|
122
|
+
This would map all standard properties `title`, `description`, `image`, `app_id` etc along with the custom properties `director`, `writer` & `cast`.
|
123
|
+
|
124
|
+
7\. **Write proper tests and documentation!**
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module ActsAsGraphObject
|
2
2
|
module Base
|
3
|
-
def acts_as_graph_object(options = {})
|
3
|
+
def acts_as_graph_object(options = {})
|
4
4
|
# url helpers for fallback url method
|
5
5
|
delegate :url_helpers, to: 'Rails.application.routes'
|
6
6
|
delegate :configuration, to: 'ActsAsGraphObject'
|
@@ -23,12 +23,28 @@ module ActsAsGraphObject
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def graph_properties
|
26
|
-
# standard object properties
|
27
|
-
default_properties =
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
# standard object properties & alternative names
|
27
|
+
default_properties = {
|
28
|
+
:title => [:name, :label],
|
29
|
+
:type => [:kind, :group, :class],
|
30
|
+
:image => [:picture, :photo],
|
31
|
+
:url => [:permalink, :link],
|
32
|
+
:description => [:info, :details],
|
33
|
+
:site_name => [:site],
|
34
|
+
:latitude => [:lat],
|
35
|
+
:longitude => [:long],
|
36
|
+
:street_address => [:address],
|
37
|
+
:locality => [:locale, :area],
|
38
|
+
:region => [:province, :territory],
|
39
|
+
:postal_code => [:post_code, :zip_code, :zip],
|
40
|
+
:country_name => [:country],
|
41
|
+
:email => [:email_address],
|
42
|
+
:phone_number => [:phone],
|
43
|
+
:fax_number => [:fax]
|
44
|
+
}
|
45
|
+
|
31
46
|
# property/content pairs
|
47
|
+
# we build this up to contain our final values
|
32
48
|
properties = {
|
33
49
|
:og => {},
|
34
50
|
:fb => {
|
@@ -38,9 +54,11 @@ module ActsAsGraphObject
|
|
38
54
|
}
|
39
55
|
|
40
56
|
# try all the default og properties first
|
41
|
-
default_properties.each do |
|
42
|
-
|
43
|
-
|
57
|
+
default_properties.each do |property_name, alternatives|
|
58
|
+
([property_name] + alternatives).each do |property|
|
59
|
+
if self.respond_to?(property)
|
60
|
+
properties[:og][property_name] = self.send(property)
|
61
|
+
end
|
44
62
|
end
|
45
63
|
end
|
46
64
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_graph_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|