acts_as_graph_object 0.0.2 → 0.0.3
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 +23 -10
- data/lib/acts_as_graph_object/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,16 +1,19 @@
|
|
1
|
-
|
2
|
-
====================
|
1
|
+
# acts\_as\_graph\_object
|
3
2
|
|
4
3
|
ActiveRecord extension that maps models to Facebook Open Graph objects.
|
5
4
|
|
6
|
-
|
5
|
+
## Installation
|
6
|
+
|
7
7
|
```
|
8
8
|
gem install acts_as_graph_object
|
9
9
|
```
|
10
|
+
|
10
11
|
Then just add the dependancy to your `Gemfile`.
|
11
12
|
|
12
|
-
|
13
|
-
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
### Configuration
|
16
|
+
|
14
17
|
```ruby
|
15
18
|
# app/config/initializers/acts_as_graph_object.rb
|
16
19
|
ActsAsGraphObject.configure do |config|
|
@@ -20,27 +23,32 @@ ActsAsGraphObject.configure do |config|
|
|
20
23
|
end
|
21
24
|
```
|
22
25
|
|
23
|
-
|
26
|
+
#### Default URL Method
|
24
27
|
In order to use the built in `@model.url` method you need to set the following config option:
|
28
|
+
|
25
29
|
```ruby
|
26
30
|
# app/config/environments/production.rb
|
27
31
|
routes.default_url_options[:host] = 'my-app.com'
|
28
32
|
```
|
29
33
|
|
30
|
-
#### Add
|
34
|
+
#### Add acts\_as\_graph\_object...
|
35
|
+
|
31
36
|
```ruby
|
32
37
|
# app/models/movie.rb
|
33
38
|
class Movie < ActiveRecord::Base
|
34
39
|
acts_as_graph_object :custom => [:director, :writer, :cast]
|
35
|
-
|
40
|
+
|
36
41
|
def cast
|
37
42
|
...
|
38
43
|
end
|
39
44
|
end
|
40
45
|
```
|
46
|
+
|
41
47
|
#### Outputting meta tags
|
48
|
+
|
42
49
|
Use the `graph_object_tags_for(@movie)` helper to output the resulting `<meta>` tags. You can use this in combination with `content_for` to push the results into your `<head>`:
|
43
|
-
|
50
|
+
|
51
|
+
```erb
|
44
52
|
# app/views/layouts/application.html.erb
|
45
53
|
<head>
|
46
54
|
<%= yield :meta_tags %>
|
@@ -49,9 +57,11 @@ Use the `graph_object_tags_for(@movie)` helper to output the resulting `<meta>`
|
|
49
57
|
# app/views/movies/show.html.erb
|
50
58
|
<% content_for :meta_tags, graph_object_tags_for(@movie) %>
|
51
59
|
```
|
60
|
+
|
52
61
|
#### Overriding from view
|
53
62
|
If you want to override a value from the view (for example to use a `url_for` helper):
|
54
|
-
|
63
|
+
|
64
|
+
```erb
|
55
65
|
# app/views/movies/show.html.erb
|
56
66
|
<% content_for :meta_tags, graph_object_tags_for(@movie, :url => movie_url(@movie)) %>
|
57
67
|
```
|
@@ -70,6 +80,7 @@ This is my first gem so things are a bit rough around the edges, all feedback is
|
|
70
80
|
4\. Allow for easy configuration for constants such as `fb:app_id` & `fb:admins` as well as an *app namespace* to be used in `og:type` and any custom attributes.
|
71
81
|
|
72
82
|
5\. Automatically handle arrays, i.e. `:cast => ['Tom Cruise', 'Kelly McGillis', 'Val Kilmer']` becomes:
|
83
|
+
|
73
84
|
```html
|
74
85
|
<meta property="my-app:cast" content="Tom Cruise" />
|
75
86
|
<meta property="my-app:cast" content="Kelly McGillis" />
|
@@ -77,9 +88,11 @@ This is my first gem so things are a bit rough around the edges, all feedback is
|
|
77
88
|
```
|
78
89
|
|
79
90
|
6\. Keep it unobtrusive! no heavy configuration in models, something simple, e.g.
|
91
|
+
|
80
92
|
```ruby
|
81
93
|
class Movie < ActiveRecord::Base
|
82
94
|
acts_as_graph_object :custom => [:director, :writer, :cast]
|
83
95
|
end
|
84
96
|
```
|
97
|
+
|
85
98
|
This would map all standard properties `title`, `description`, `image`, `app_id` etc along with the custom properties `director`, `writer` & `cast`.
|
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.3
|
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-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|