open-meta-tags 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.markdown +269 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/init.rb +1 -0
- data/lib/open_meta_tags.rb +10 -0
- data/lib/open_meta_tags/controller_helper.rb +51 -0
- data/lib/open_meta_tags/view_helper.rb +101 -0
- data/open-meta-tags.gemspec +57 -0
- data/spec/open_meta_tags_spec.rb +636 -0
- data/spec/spec_helper.rb +5 -0
- metadata +87 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Intridea
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,269 @@
|
|
1
|
+
## Open Meta Tags: Integrate Web page metadata into the Facebook social graph.
|
2
|
+
|
3
|
+
* **Homepage**: [http://intridea.com](http://intridea.com)
|
4
|
+
* **Git**: [http://github.com/intridea/open-meta](http://github.com/intridea/open-meta)
|
5
|
+
* **Author**: Jonathan Nelson
|
6
|
+
* **Contributors**: See Contributors section below
|
7
|
+
* **Copyright**: 2010
|
8
|
+
* **License**: MIT License
|
9
|
+
* **Latest Version**: 0.4.0
|
10
|
+
* **Release Date**: August 13th 2010
|
11
|
+
|
12
|
+
## Synopsis
|
13
|
+
|
14
|
+
Open Meta Tags is an Open Graph tool for the Ruby programming language. It enables you to turn normal web pages into meta objects in the graph. Once pages become objects in the graph, users can establish connections to your pages as they do on Facebook Pages. The value of providing structured data through the Open Graph means that your pages will show up richly across Facebook: in user profiles, within search results and in News Feed.
|
15
|
+
|
16
|
+
## Requirements
|
17
|
+
|
18
|
+
In order to turn web pages into Open Graph objects, you'll need the following in your Rails app:
|
19
|
+
|
20
|
+
* Install the Open Meta Tags gem
|
21
|
+
* `gem 'open-meta-tags', :require => 'open_meta_tags'`
|
22
|
+
* Add the following html tag:
|
23
|
+
* `<html xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml">`
|
24
|
+
* Add Open Meta Tags to your web pages
|
25
|
+
* See examples below
|
26
|
+
* [Add the Facebook Like button to your web pages](http://developers.facebook.com/docs/reference/plugins/like)
|
27
|
+
|
28
|
+
Feature List
|
29
|
+
------------
|
30
|
+
|
31
|
+
**1.** Turn any web page into meta objects in the Open Graph
|
32
|
+
|
33
|
+
These Open Graph tags allow you to specify structured information about your web pages. The more information you provide, the more opportunities your web pages can be surfaced within Facebook today and in the future. Here's an example for a music page:
|
34
|
+
|
35
|
+
<html xmlns:og="http://opengraphprotocol.org/schema/"
|
36
|
+
xmlns:fb="http://www.facebook.com/2008/fbml">
|
37
|
+
<head>
|
38
|
+
<title>Day & Age (2008)</title>
|
39
|
+
<meta property="og:title" content="Day & Age"/>
|
40
|
+
<meta property="og:type" content="music"/>
|
41
|
+
<meta property="og:url" content="http://www.amazon.com/Day-Age-Killers/dp/B001FWRZ46/"/>
|
42
|
+
<meta property="og:image" content="http://ecx.images-amazon.com/images/I/61CK4wp-HTL._SL500_AA300_.jpg"/>
|
43
|
+
<meta property="og:site_name" content="Amazon"/>
|
44
|
+
<meta property="fb:admins" content="USER_ID"/>
|
45
|
+
<meta property="og:description"
|
46
|
+
content="Day & Age is the third studio album by
|
47
|
+
American rock band The Killers, released
|
48
|
+
on November 24, 2008 in the UK, Canada and
|
49
|
+
the US."/>
|
50
|
+
...
|
51
|
+
</head>
|
52
|
+
...
|
53
|
+
</html>
|
54
|
+
|
55
|
+
**2.** Define Open Meta Tags in your controller using instance variables:
|
56
|
+
|
57
|
+
# Example: example_controller.rb
|
58
|
+
@page_title = 'Day & Age'
|
59
|
+
@page_type = 'music'
|
60
|
+
@page_site_name = 'Amazon'
|
61
|
+
@page_image = 'http://ecx.images-amazon.com/images/I/61CK4wp-HTL._SL500_AA300_.jpg'
|
62
|
+
@page_admins = 'USER_ID_GOES_HERE'
|
63
|
+
@page_app_id_ = 'APP_ID_GOES_HERE'
|
64
|
+
@page_description = 'Day & Age is the third studio album by American rock band The Killers, released on November 24, 2008 in the UK, Canada and the US.'
|
65
|
+
|
66
|
+
**3.** Use Open Meta Tags in your views using the following methods:
|
67
|
+
|
68
|
+
# Example: single.html.haml
|
69
|
+
- content_for :head do
|
70
|
+
= title 'Day & Age'
|
71
|
+
= type 'music'
|
72
|
+
= description 'Day & Age is the third studio album by American rock band The Killers, released on November 24, 2008 in the UK, Canada and the US.'
|
73
|
+
|
74
|
+
**4.** Use Open Meta Tags in your view using the `single_meta_tags` method:
|
75
|
+
|
76
|
+
# Example: single.html.haml
|
77
|
+
- content_for :head do
|
78
|
+
= single_meta_tags :title => 'Day & Age', :type => 'music', :description => 'Day & Age is the third studio album by American rock band The Killers, released on November 24, 2008 in the UK, Canada and the US.'
|
79
|
+
|
80
|
+
**5.** Use Open Meta Tags in your view using the `global_meta_tags` method:
|
81
|
+
|
82
|
+
# Example: application.html.haml
|
83
|
+
= global_meta_tags :title => 'The Killers', :type => 'music', :description => 'The Killers are an American Indie band from Las Vegas, Nevada, which formed in 2002. The band consists of Brandon Flowers (vocals, keyboards), Dave Keuning (guitar, backing vocals), Mark Stoermer (bass guitar, backing vocals) and Ronnie Vannucci Jr. (drums, percussion).'
|
84
|
+
|
85
|
+
## Options
|
86
|
+
|
87
|
+
You can use these options to create Open Graph objects using the `global_meta_tags` or `single_meta_tags` method.
|
88
|
+
|
89
|
+
### Basic metadata
|
90
|
+
|
91
|
+
* title - The title of your object as it should appear within the graph, e.g., "The Rock".
|
92
|
+
* type - The type of your object, e.g., "movie". Depending on the type you specify, other properties may also be required.
|
93
|
+
* image - An image URL which should represent your object within the graph.
|
94
|
+
* url - The canonical URL of your object that will be used as its permanent ID in the graph, e.g., "http://www.imdb.com/title/tt0117500/".
|
95
|
+
* description - A one to two sentence description of your object. Limited to 150 characters.
|
96
|
+
* site_name - If your object is part of a larger web site, the name which should be displayed for the overall site. e.g., "IMDb".
|
97
|
+
* admins - A comma-separated list of Facebook user IDs that administer the page.
|
98
|
+
* app_id - A Facebook Platform application ID that administers the page.
|
99
|
+
|
100
|
+
### Specifying locations
|
101
|
+
|
102
|
+
The Open Graph protocol supports the ability for you to specify location information for your object. This is useful if your object is for a business or anything else with a real-world location. You can specify location via latitude and longitude, a full address, or both. The property names used are defined within the [Microformat hCard](http://microformats.org/wiki/hcard).
|
103
|
+
|
104
|
+
In order to specify latitude and longitude, include the following two properties:
|
105
|
+
|
106
|
+
* latitude - e.g., "37.33182".
|
107
|
+
* longitude - e.g., "-122.03118".
|
108
|
+
|
109
|
+
If you wish to specify a human readable address, include the following five properties:
|
110
|
+
|
111
|
+
* street-address - e.g., "1 Infinite Loop"
|
112
|
+
* locality - e.g, "Cupertino"
|
113
|
+
* region - e.g., "CA"
|
114
|
+
* postal-code e.g., "95014"
|
115
|
+
* country-name - e.g., "USA"
|
116
|
+
|
117
|
+
**This:**
|
118
|
+
|
119
|
+
# Example: single.html.haml
|
120
|
+
- content_for :head do
|
121
|
+
= single_meta_tags :street-address => '1 Infinite Loop', :locality => 'Cupertino', :region => 'CA', :postal_code => '95014', :country_name => 'USA'
|
122
|
+
|
123
|
+
**Produces:**
|
124
|
+
|
125
|
+
<meta property="og:street-address" content="john@doe.com" />
|
126
|
+
|
127
|
+
<meta property="og:locality" content="1-800-555-1234" />
|
128
|
+
|
129
|
+
<meta property="og:region" content="1-800-555-5678" />
|
130
|
+
|
131
|
+
<meta property="og:postal-code" content="1-800-555-5678" />
|
132
|
+
|
133
|
+
<meta property="og:country-name" content="1-800-555-5678" />
|
134
|
+
|
135
|
+
### Specifying contact information
|
136
|
+
|
137
|
+
The Open Graph protocol supports the ability for you to specify contact information for your object. It's likely that future versions of the protocol will support extracting this information from the body of your page. In order to specify contact information, include at least one of the following three properties:
|
138
|
+
|
139
|
+
* email - e.g., "john@doe.com".
|
140
|
+
* phone_number - e.g., "1-800-555-1234".
|
141
|
+
* fax_number - e.g., "1-800-555-5678".
|
142
|
+
|
143
|
+
**This:**
|
144
|
+
|
145
|
+
# Example: single.html.haml
|
146
|
+
- content_for :head do
|
147
|
+
= single_meta_tags :email => 'john@doe.com', :phone_number => '1-800-555-1234', :fax_number => '1-800-555-5678'
|
148
|
+
|
149
|
+
**Produces:**
|
150
|
+
|
151
|
+
<meta property="og:email" content="john@doe.com" />
|
152
|
+
|
153
|
+
<meta property="og:phone-number" content="1-800-555-1234" />
|
154
|
+
|
155
|
+
<meta property="og:fax-number" content="1-800-555-5678" />
|
156
|
+
|
157
|
+
## Object Types
|
158
|
+
|
159
|
+
In order for your object to be represented within the graph, you need to specify its type. This is done using the `:type` property:
|
160
|
+
|
161
|
+
**This:**
|
162
|
+
|
163
|
+
# Example: single.html.haml
|
164
|
+
- content_for :head do
|
165
|
+
= single_meta_tags :type => 'product'
|
166
|
+
|
167
|
+
**Produces:**
|
168
|
+
|
169
|
+
<meta property="og:type" content="product" />
|
170
|
+
|
171
|
+
The base schema includes the following types. It's possible that social networks will choose to support only a subset of these types or create additional types based on their niche.
|
172
|
+
|
173
|
+
### Activities
|
174
|
+
* activity
|
175
|
+
* sport
|
176
|
+
|
177
|
+
### Businesses
|
178
|
+
* bar
|
179
|
+
* company
|
180
|
+
* cafe
|
181
|
+
* hotel
|
182
|
+
* restaurant
|
183
|
+
|
184
|
+
### Groups
|
185
|
+
* cause
|
186
|
+
* sports_league
|
187
|
+
* sports_team
|
188
|
+
|
189
|
+
### Organizations
|
190
|
+
* band
|
191
|
+
* government
|
192
|
+
* non_profit
|
193
|
+
* school
|
194
|
+
* university
|
195
|
+
|
196
|
+
### People
|
197
|
+
* actor
|
198
|
+
* athlete
|
199
|
+
* author
|
200
|
+
* director
|
201
|
+
* musician
|
202
|
+
* politician
|
203
|
+
* public_figure
|
204
|
+
|
205
|
+
### Places
|
206
|
+
* city
|
207
|
+
* country
|
208
|
+
* landmark
|
209
|
+
* state_province
|
210
|
+
|
211
|
+
### Products and Entertainment
|
212
|
+
* album
|
213
|
+
* book
|
214
|
+
* drink
|
215
|
+
* food
|
216
|
+
* game
|
217
|
+
* movie
|
218
|
+
* product
|
219
|
+
* song
|
220
|
+
* tv_show
|
221
|
+
|
222
|
+
For products which have a UPC code or ISBN number, you can specify them using the `:upc` and `:isbn` properties. These properties help to make more concrete connections between graphs.
|
223
|
+
|
224
|
+
**This:**
|
225
|
+
|
226
|
+
# Example: single.html.haml
|
227
|
+
- content_for :head do
|
228
|
+
= single_meta_tags :upc => '123456789012', :isbn => '90-70002-34-5'
|
229
|
+
|
230
|
+
**Produces:**
|
231
|
+
|
232
|
+
<meta property="og:upc" content="123456789012" />
|
233
|
+
|
234
|
+
<meta property="og:isbn" content="90-70002-34-5" />
|
235
|
+
|
236
|
+
### Websites
|
237
|
+
* article
|
238
|
+
* blog
|
239
|
+
* website
|
240
|
+
|
241
|
+
**This:**
|
242
|
+
|
243
|
+
# Example: single.html.haml
|
244
|
+
- content_for :head do
|
245
|
+
= single_meta_tags :article => 'http://mashable.com/2010/07/16/apple-free-iphone-4-cases/', :blog => 'http://mashable.com'
|
246
|
+
|
247
|
+
**Produces:**
|
248
|
+
|
249
|
+
<meta property="og:article" content="http://mashable.com/2010/07/16/apple-free-iphone-4-cases/" />
|
250
|
+
|
251
|
+
<meta property="og:blog" content="http://mashable.com" />
|
252
|
+
|
253
|
+
## Contributors
|
254
|
+
* [Jonathan Nelson](http://intridea.com/about/people/jonathan)
|
255
|
+
* [Jeremy McAnally](http://intridea.com/about/people/jeremy)
|
256
|
+
|
257
|
+
## Note on Patches/Pull Requests
|
258
|
+
|
259
|
+
* Fork the project.
|
260
|
+
* Make your feature addition or bug fix.
|
261
|
+
* Add tests for it. This is important so I don't break it in a
|
262
|
+
future version unintentionally.
|
263
|
+
* Commit, do not mess with rakefile, version, or history.
|
264
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
265
|
+
* Send me a pull request. Bonus points for topic branches.
|
266
|
+
|
267
|
+
## Copyright
|
268
|
+
|
269
|
+
Copyright (c) 2010 Intridea. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'jeweler'
|
5
|
+
Jeweler::Tasks.new do |gem|
|
6
|
+
gem.name = "open-meta-tags"
|
7
|
+
gem.summary = %Q{A}
|
8
|
+
gem.description = %Q{something}
|
9
|
+
gem.email = "jonathan@intridea.com"
|
10
|
+
gem.homepage = "http://github.com/jonathannelson/open-meta"
|
11
|
+
gem.authors = ["Intridea"]
|
12
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
13
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
14
|
+
end
|
15
|
+
Jeweler::GemcutterTasks.new
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
18
|
+
end
|
19
|
+
|
20
|
+
begin
|
21
|
+
require 'spec/rake/spectask'
|
22
|
+
|
23
|
+
desc 'Default: run specs'
|
24
|
+
task :default => :spec
|
25
|
+
|
26
|
+
desc 'Test the sphinx plugin'
|
27
|
+
Spec::Rake::SpecTask.new do |t|
|
28
|
+
t.libs << 'lib'
|
29
|
+
t.pattern = 'spec/*_spec.rb'
|
30
|
+
t.verbose = true
|
31
|
+
t.spec_opts = ['-cfs']
|
32
|
+
end
|
33
|
+
rescue LoadError
|
34
|
+
puts 'RSpec not available. Install it with: sudo gem install rspec'
|
35
|
+
end
|
36
|
+
|
37
|
+
begin
|
38
|
+
require 'yard'
|
39
|
+
YARD::Rake::YardocTask.new(:yard) do |t|
|
40
|
+
t.options = ['--title', 'MetaTags Documentation']
|
41
|
+
if ENV['PRIVATE']
|
42
|
+
t.options.concat ['--protected', '--private']
|
43
|
+
else
|
44
|
+
t.options.concat ['--protected', '--no-private']
|
45
|
+
end
|
46
|
+
end
|
47
|
+
rescue LoadError
|
48
|
+
puts 'Yard not available. Install it with: sudo gem install yard'
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.4.0
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'open_meta_tags'
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'action_controller'
|
2
|
+
require 'action_view'
|
3
|
+
|
4
|
+
module OpenMetaTags
|
5
|
+
autoload :ViewHelper, 'open_meta_tags/view_helper'
|
6
|
+
autoload :ControllerHelper, 'open_meta_tags/controller_helper'
|
7
|
+
end
|
8
|
+
|
9
|
+
ActionView::Base.send :include, OpenMetaTags::ViewHelper
|
10
|
+
ActionController::Base.send :include, OpenMetaTags::ControllerHelper
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module OpenMetaTags
|
2
|
+
##### methods to use in controllers
|
3
|
+
module ControllerHelper
|
4
|
+
def self.included(base)
|
5
|
+
base.send :include, InstanceMethods
|
6
|
+
base.alias_method_chain :render, :open_meta_tags
|
7
|
+
end
|
8
|
+
|
9
|
+
module InstanceMethods
|
10
|
+
##### processes instance variables and calls +render+
|
11
|
+
def render_with_open_meta_tags(*args, &block)
|
12
|
+
open_meta_tags = {}
|
13
|
+
# Specify basic metadata information
|
14
|
+
open_meta_tags[:title] = @page_title if @page_title
|
15
|
+
open_meta_tags[:type] = @page_type if @page_type
|
16
|
+
open_meta_tags[:url] = @page_url if @page_url
|
17
|
+
open_meta_tags[:image] = @page_image if @page_image
|
18
|
+
open_meta_tags[:description] = @page_description if @page_description
|
19
|
+
open_meta_tags[:site_name] = @page_site_name if @page_site_name
|
20
|
+
open_meta_tags[:admins] = @page_admins if @page_admins
|
21
|
+
open_meta_tags[:app_id] = @page_app_id if @page_app_id
|
22
|
+
# Specify location information
|
23
|
+
open_meta_tags[:latitude] = @page_latitude if @page_latitude
|
24
|
+
open_meta_tags[:longitude] = @page_longitude if @page_longitude
|
25
|
+
open_meta_tags[:street_address] = @page_street_address if @page_street_address
|
26
|
+
open_meta_tags[:locality] = @page_locality if @page_locality
|
27
|
+
open_meta_tags[:region] = @page_region if @page_region
|
28
|
+
open_meta_tags[:postal_code] = @page_postal_code if @page_postal_code
|
29
|
+
open_meta_tags[:country_name] = @page_country_name if @page_country_name
|
30
|
+
# Specify contact information
|
31
|
+
open_meta_tags[:email] = @page_email if @page_email
|
32
|
+
open_meta_tags[:phone_number] = @phone_number if @phone_number
|
33
|
+
open_meta_tags[:fax_number] = @fax_number if @fax_number
|
34
|
+
# Specify shipping information
|
35
|
+
open_meta_tags[:upc] = @upc if @upc
|
36
|
+
open_meta_tags[:isbn] = @isbn if @isbn
|
37
|
+
single_meta_tags(open_meta_tags)
|
38
|
+
|
39
|
+
render_without_open_meta_tags(*args, &block)
|
40
|
+
end
|
41
|
+
|
42
|
+
##### set open graph metadata for single page
|
43
|
+
def single_meta_tags(open_meta_tags)
|
44
|
+
@open_meta_tags ||= {}
|
45
|
+
@open_meta_tags.merge!(open_meta_tags || {})
|
46
|
+
end
|
47
|
+
|
48
|
+
protected :single_meta_tags
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
module OpenMetaTags
|
2
|
+
# Methods to use in views and helpers.
|
3
|
+
module ViewHelper
|
4
|
+
|
5
|
+
def single_meta_tags(open_meta_tags = {})
|
6
|
+
@open_meta_tags ||= {}
|
7
|
+
@open_meta_tags.merge!(open_meta_tags || {})
|
8
|
+
end
|
9
|
+
|
10
|
+
def description(description)
|
11
|
+
single_meta_tags(:description => description)
|
12
|
+
description
|
13
|
+
end
|
14
|
+
|
15
|
+
def admins(admins)
|
16
|
+
single_meta_tags(:admins => admins)
|
17
|
+
admins
|
18
|
+
end
|
19
|
+
|
20
|
+
def app_id(app_id)
|
21
|
+
single_meta_tags(:app_id => app_id)
|
22
|
+
app_id
|
23
|
+
end
|
24
|
+
|
25
|
+
def street_address(street_address)
|
26
|
+
single_meta_tags(:street_address => street_address)
|
27
|
+
street_address
|
28
|
+
end
|
29
|
+
|
30
|
+
def postal_code(postal_code)
|
31
|
+
single_meta_tags(:postal_code => postal_code)
|
32
|
+
postal_code
|
33
|
+
end
|
34
|
+
|
35
|
+
def country_name(country_name)
|
36
|
+
single_meta_tags(:country_name => country_name)
|
37
|
+
country_name
|
38
|
+
end
|
39
|
+
|
40
|
+
# metaprogramming
|
41
|
+
def self.meta_methods(*attribute_names)
|
42
|
+
attribute_names.each do |attribute_name|
|
43
|
+
define_method(attribute_name) do |value|
|
44
|
+
single_meta_tags(attribute_name => value)
|
45
|
+
value
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
meta_methods :title, :type, :url, :image, :site_name, :latitude, :longitude, :locality, :region, :email, :phone_number, :fax_number, :upc, :isbn
|
51
|
+
|
52
|
+
##### set default metadata values and display metadata
|
53
|
+
|
54
|
+
def global_meta_tags(default = {})
|
55
|
+
open_meta_tags = (default || {}).merge(@open_meta_tags || {})
|
56
|
+
|
57
|
+
result = []
|
58
|
+
|
59
|
+
##### metadata options
|
60
|
+
|
61
|
+
description = normalize_description(open_meta_tags[:description])
|
62
|
+
result << tag(:meta, :property => 'og:description', :content => description) unless description.blank?
|
63
|
+
|
64
|
+
admins = normalize_admins(open_meta_tags[:admins])
|
65
|
+
result << tag(:meta, :property => 'fb:admins', :content => admins) unless admins.blank?
|
66
|
+
|
67
|
+
app_id = open_meta_tags[:app_id]
|
68
|
+
result << tag(:meta, :property => 'fb:app_id', :content => app_id) unless app_id.blank?
|
69
|
+
|
70
|
+
street_address = open_meta_tags[:street_address]
|
71
|
+
result << tag(:meta, :property => 'og:street-address', :content => street_address) unless street_address.blank?
|
72
|
+
|
73
|
+
postal_code = open_meta_tags[:postal_code]
|
74
|
+
result << tag(:meta, :property => 'og:postal-code', :content => postal_code) unless postal_code.blank?
|
75
|
+
|
76
|
+
country_name = open_meta_tags[:country_name]
|
77
|
+
result << tag(:meta, :property => 'og:country-name', :content => country_name) unless country_name.blank?
|
78
|
+
|
79
|
+
# metaprogramming
|
80
|
+
[:title, :type, :url, :image, :site_name, :latitude, :longitude, :locality, :region, :email, :phone_number, :fax_number, :upc, :isbn].each do |attr|
|
81
|
+
result << tag(:meta, :property => "og:#{attr}", :content => open_meta_tags[attr]) unless open_meta_tags[attr].blank?
|
82
|
+
end
|
83
|
+
|
84
|
+
result = result.join("\n")
|
85
|
+
result.respond_to?(:html_safe) ? result.html_safe : result
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def normalize_description(description)
|
91
|
+
return '' unless description
|
92
|
+
truncate(strip_tags(description).gsub(/\s+/, ' '), :length => 150)
|
93
|
+
end
|
94
|
+
|
95
|
+
def normalize_admins(admins)
|
96
|
+
return '' unless admins
|
97
|
+
admins = admins.flatten.join(', ') if admins.is_a?(Array)
|
98
|
+
strip_tags(admins).mb_chars.downcase
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{open-meta-tags}
|
8
|
+
s.version = "0.4.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Intridea"]
|
12
|
+
s.date = %q{2010-08-23}
|
13
|
+
s.description = %q{something}
|
14
|
+
s.email = %q{jonathan@intridea.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.markdown",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"init.rb",
|
27
|
+
"lib/open_meta_tags.rb",
|
28
|
+
"lib/open_meta_tags/controller_helper.rb",
|
29
|
+
"lib/open_meta_tags/view_helper.rb",
|
30
|
+
"open-meta-tags.gemspec",
|
31
|
+
"spec/open_meta_tags_spec.rb",
|
32
|
+
"spec/spec_helper.rb"
|
33
|
+
]
|
34
|
+
s.homepage = %q{http://github.com/jonathannelson/open-meta}
|
35
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = %q{1.3.6}
|
38
|
+
s.summary = %q{A}
|
39
|
+
s.test_files = [
|
40
|
+
"spec/open_meta_tags_spec.rb",
|
41
|
+
"spec/spec_helper.rb"
|
42
|
+
]
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
+
s.specification_version = 3
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
50
|
+
else
|
51
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
52
|
+
end
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
@@ -0,0 +1,636 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe OpenMetaTags::ViewHelper do
|
4
|
+
before :each do
|
5
|
+
@view = ActionView::Base.new
|
6
|
+
end
|
7
|
+
|
8
|
+
context 'module' do
|
9
|
+
it 'should be mixed into ActionView::Base' do
|
10
|
+
ActionView::Base.included_modules.should include(OpenMetaTags::ViewHelper)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should respond to "title" helper' do
|
14
|
+
@view.should respond_to(:title)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should respond to "type" helper' do
|
18
|
+
@view.should respond_to(:type)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should respond to "url" helper' do
|
22
|
+
@view.should respond_to(:url)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should respond to "image" helper' do
|
26
|
+
@view.should respond_to(:image)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should respond to "description" helper' do
|
30
|
+
@view.should respond_to(:description)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should respond to "site_name" helper' do
|
34
|
+
@view.should respond_to(:site_name)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should respond to "admins" helper' do
|
38
|
+
@view.should respond_to(:admins)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should respond to "app_id" helper' do
|
42
|
+
@view.should respond_to(:app_id)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should respond to "latitude" helper' do
|
46
|
+
@view.should respond_to(:latitude)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should respond to "longitude" helper' do
|
50
|
+
@view.should respond_to(:longitude)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should respond to "street_address" helper' do
|
54
|
+
@view.should respond_to(:street_address)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should respond to "locality" helper' do
|
58
|
+
@view.should respond_to(:locality)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should respond to "region" helper' do
|
62
|
+
@view.should respond_to(:region)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should respond to "postal_code" helper' do
|
66
|
+
@view.should respond_to(:postal_code)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should respond to "country_name" helper' do
|
70
|
+
@view.should respond_to(:country_name)
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should respond to "email" helper' do
|
74
|
+
@view.should respond_to(:email)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should respond to "phone_number" helper' do
|
78
|
+
@view.should respond_to(:phone_number)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should respond to "fax_number" helper' do
|
82
|
+
@view.should respond_to(:fax_number)
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should respond to "upc" helper' do
|
86
|
+
@view.should respond_to(:upc)
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should respond to "isbn" helper' do
|
90
|
+
@view.should respond_to(:isbn)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should respond to "single_meta_tags" helper' do
|
94
|
+
@view.should respond_to(:single_meta_tags)
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should respond to "global_meta_tags" helper' do
|
98
|
+
@view.should respond_to(:global_meta_tags)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context 'returning values' do
|
103
|
+
it 'should return title' do
|
104
|
+
@view.title('some-title').should == 'some-title'
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should return type' do
|
108
|
+
@view.type('some-type').should == 'some-type'
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'should return url' do
|
112
|
+
@view.url('some-url').should == 'some-url'
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'should return image' do
|
116
|
+
@view.image('some-image').should == 'some-image'
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'should return description' do
|
120
|
+
@view.description('some-description').should == 'some-description'
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'should return site_name' do
|
124
|
+
@view.site_name('some-site_name').should == 'some-site_name'
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'should return admins' do
|
128
|
+
@view.admins('some-admins').should == 'some-admins'
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'should return app_id' do
|
132
|
+
@view.app_id('some-app_id').should == 'some-app_id'
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'should return latitude' do
|
136
|
+
@view.latitude('some-latitude').should == 'some-latitude'
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'should return longitude' do
|
140
|
+
@view.longitude('some-longitude').should == 'some-longitude'
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'should return street_address' do
|
144
|
+
@view.street_address('some-street_address').should == 'some-street_address'
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'should return locality' do
|
148
|
+
@view.locality('some-locality').should == 'some-locality'
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'should return region' do
|
152
|
+
@view.region('some-region').should == 'some-region'
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'should return postal_code' do
|
156
|
+
@view.postal_code('some-postal_code').should == 'some-postal_code'
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'should return country_name' do
|
160
|
+
@view.country_name('some-country_name').should == 'some-country_name'
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'should return email' do
|
164
|
+
@view.email('some-email').should == 'some-email'
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'should return phone_number' do
|
168
|
+
@view.phone_number('some-phone_number').should == 'some-phone_number'
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'should return fax_number' do
|
172
|
+
@view.fax_number('some-fax_number').should == 'some-fax_number'
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'should return upc' do
|
176
|
+
@view.fax_number('some-upc').should == 'some-upc'
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'should return isbn' do
|
180
|
+
@view.fax_number('some-isbn').should == 'some-isbn'
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
# title
|
185
|
+
context 'displaying title' do
|
186
|
+
it 'should display title when "title" used' do
|
187
|
+
@view.title('some-title')
|
188
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-title" property="og:title" />')
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'should display title when "single_meta_tags" used' do
|
192
|
+
@view.single_meta_tags(:title => 'some-title')
|
193
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-title" property="og:title" />')
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'should display default title' do
|
197
|
+
@view.global_meta_tags(:site => 'someSite', :title => 'some-title').should include('<meta content="some-title" property="og:title" />')
|
198
|
+
end
|
199
|
+
|
200
|
+
it 'should use custom title if given' do
|
201
|
+
@view.title('some-title')
|
202
|
+
@view.global_meta_tags(:site => 'someSite', :title => 'some-title').should include('<meta content="some-title" property="og:title" />')
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
# type
|
207
|
+
context 'displaying type' do
|
208
|
+
it 'should display type when "type" used' do
|
209
|
+
@view.type('some-type')
|
210
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-type" property="og:type" />')
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'should display type when "single_meta_tags" used' do
|
214
|
+
@view.single_meta_tags(:type => 'some-type')
|
215
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-type" property="og:type" />')
|
216
|
+
end
|
217
|
+
|
218
|
+
it 'should display default type' do
|
219
|
+
@view.global_meta_tags(:site => 'someSite', :type => 'some-type').should include('<meta content="some-type" property="og:type" />')
|
220
|
+
end
|
221
|
+
|
222
|
+
it 'should use custom type if given' do
|
223
|
+
@view.type('some-type')
|
224
|
+
@view.global_meta_tags(:site => 'someSite', :type => 'some-type').should include('<meta content="some-type" property="og:type" />')
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
# url
|
229
|
+
context 'displaying url' do
|
230
|
+
it 'should display url when "url" used' do
|
231
|
+
@view.url('some-url')
|
232
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-url" property="og:url" />')
|
233
|
+
end
|
234
|
+
|
235
|
+
it 'should display url when "single_meta_tags" used' do
|
236
|
+
@view.single_meta_tags(:url => 'some-url')
|
237
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-url" property="og:url" />')
|
238
|
+
end
|
239
|
+
|
240
|
+
it 'should display default url' do
|
241
|
+
@view.global_meta_tags(:site => 'someSite', :url => 'some-url').should include('<meta content="some-url" property="og:url" />')
|
242
|
+
end
|
243
|
+
|
244
|
+
it 'should use custom url if given' do
|
245
|
+
@view.url('some-url')
|
246
|
+
@view.global_meta_tags(:site => 'someSite', :url => 'some-url').should include('<meta content="some-url" property="og:url" />')
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
# image
|
251
|
+
context 'displaying image' do
|
252
|
+
it 'should display image when "image" used' do
|
253
|
+
@view.image('some-image')
|
254
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-image" property="og:image" />')
|
255
|
+
end
|
256
|
+
|
257
|
+
it 'should display image when "single_meta_tags" used' do
|
258
|
+
@view.single_meta_tags(:image => 'some-image')
|
259
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-image" property="og:image" />')
|
260
|
+
end
|
261
|
+
|
262
|
+
it 'should display default image' do
|
263
|
+
@view.global_meta_tags(:site => 'someSite', :image => 'some-image').should include('<meta content="some-image" property="og:image" />')
|
264
|
+
end
|
265
|
+
|
266
|
+
it 'should use custom image if given' do
|
267
|
+
@view.image('some-image')
|
268
|
+
@view.global_meta_tags(:site => 'someSite', :image => 'some-image').should include('<meta content="some-image" property="og:image" />')
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
# description
|
273
|
+
context 'displaying description' do
|
274
|
+
it 'should display description when "description" used' do
|
275
|
+
@view.description('some-description')
|
276
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-description" property="og:description" />')
|
277
|
+
end
|
278
|
+
|
279
|
+
it 'should display description when "description" used' do
|
280
|
+
@view.single_meta_tags(:description => 'some-description')
|
281
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-description" property="og:description" />')
|
282
|
+
end
|
283
|
+
|
284
|
+
it 'should display default description' do
|
285
|
+
@view.global_meta_tags(:site => 'someSite', :description => 'some-description').should include('<meta content="some-description" property="og:description" />')
|
286
|
+
end
|
287
|
+
|
288
|
+
it 'should use custom description if given' do
|
289
|
+
@view.description('some-description')
|
290
|
+
@view.global_meta_tags(:site => 'someSite', :description => 'some-description').should include('<meta content="some-description" property="og:description" />')
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
# site_name
|
295
|
+
context 'displaying site_name' do
|
296
|
+
it 'should display site_name when "site_name" used' do
|
297
|
+
@view.site_name('some-site_name')
|
298
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-site_name" property="og:site_name" />')
|
299
|
+
end
|
300
|
+
|
301
|
+
it 'should display site_name when "single_meta_tags" used' do
|
302
|
+
@view.single_meta_tags(:site_name => 'some-site_name')
|
303
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-site_name" property="og:site_name" />')
|
304
|
+
end
|
305
|
+
|
306
|
+
it 'should display default site_name' do
|
307
|
+
@view.global_meta_tags(:site => 'someSite', :site_name => 'some-site_name').should include('<meta content="some-site_name" property="og:site_name" />')
|
308
|
+
end
|
309
|
+
|
310
|
+
it 'should use custom site_name if given' do
|
311
|
+
@view.site_name('some-site_name')
|
312
|
+
@view.global_meta_tags(:site => 'someSite', :site_name => 'some-site_name').should include('<meta content="some-site_name" property="og:site_name" />')
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
# admins
|
317
|
+
context 'displaying admins' do
|
318
|
+
it 'should display admins when "admins" used' do
|
319
|
+
@view.admins('some-admins')
|
320
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-admins" property="fb:admins" />')
|
321
|
+
end
|
322
|
+
|
323
|
+
it 'should display admins when "single_meta_tags" used' do
|
324
|
+
@view.single_meta_tags(:admins => 'some-admins')
|
325
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-admins" property="fb:admins" />')
|
326
|
+
end
|
327
|
+
|
328
|
+
it 'should display default admins' do
|
329
|
+
@view.global_meta_tags(:site => 'someSite', :admins => 'some-admins').should include('<meta content="some-admins" property="fb:admins" />')
|
330
|
+
end
|
331
|
+
|
332
|
+
it 'should use custom admins if given' do
|
333
|
+
@view.admins('some-admins')
|
334
|
+
@view.global_meta_tags(:site => 'someSite', :admins => 'some-admins').should include('<meta content="some-admins" property="fb:admins" />')
|
335
|
+
end
|
336
|
+
|
337
|
+
it 'should lowercase admins' do
|
338
|
+
@view.global_meta_tags(:site => 'someSite', :admins => 'some-Admins').should include('<meta content="some-admins" property="fb:admins" />')
|
339
|
+
end
|
340
|
+
|
341
|
+
it 'should join admins from Array' do
|
342
|
+
@view.global_meta_tags(:site => 'someSite', :admins => %w(user_id1 user_id2)).should include('<meta content="user_id1, user_id2" property="fb:admins" />')
|
343
|
+
end
|
344
|
+
|
345
|
+
it 'should join admins from nested Arrays' do
|
346
|
+
@view.global_meta_tags(:site => 'someSite', :admins => [%w(user_id1 user_id2), 'user_id3']).should include('<meta content="user_id1, user_id2, user_id3" property="fb:admins" />')
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
# app_id
|
351
|
+
context 'displaying app_id' do
|
352
|
+
it 'should display app_id when "app_id" used' do
|
353
|
+
@view.app_id('some-app_id')
|
354
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-app_id" property="fb:app_id" />')
|
355
|
+
end
|
356
|
+
|
357
|
+
it 'should display app_id when "single_meta_tags" used' do
|
358
|
+
@view.single_meta_tags(:app_id => 'some-app_id')
|
359
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-app_id" property="fb:app_id" />')
|
360
|
+
end
|
361
|
+
|
362
|
+
it 'should display default app_id' do
|
363
|
+
@view.global_meta_tags(:site => 'someSite', :app_id => 'some-app_id').should include('<meta content="some-app_id" property="fb:app_id" />')
|
364
|
+
end
|
365
|
+
|
366
|
+
it 'should use custom app_id if given' do
|
367
|
+
@view.app_id('some-app_id')
|
368
|
+
@view.global_meta_tags(:site => 'someSite', :app_id => 'some-app_id').should include('<meta content="some-app_id" property="fb:app_id" />')
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
# latitude
|
373
|
+
context 'displaying latitude' do
|
374
|
+
it 'should display latitude when "latitude" used' do
|
375
|
+
@view.latitude('some-latitude')
|
376
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-latitude" property="og:latitude" />')
|
377
|
+
end
|
378
|
+
|
379
|
+
it 'should display latitude when "single_meta_tags" used' do
|
380
|
+
@view.single_meta_tags(:latitude => 'some-latitude')
|
381
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-latitude" property="og:latitude" />')
|
382
|
+
end
|
383
|
+
|
384
|
+
it 'should display default latitude' do
|
385
|
+
@view.global_meta_tags(:site => 'someSite', :latitude => 'some-latitude').should include('<meta content="some-latitude" property="og:latitude" />')
|
386
|
+
end
|
387
|
+
|
388
|
+
it 'should use custom latitude if given' do
|
389
|
+
@view.latitude('some-latitude')
|
390
|
+
@view.global_meta_tags(:site => 'someSite', :latitude => 'some-latitude').should include('<meta content="some-latitude" property="og:latitude" />')
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
394
|
+
# longitude
|
395
|
+
context 'displaying longitude' do
|
396
|
+
it 'should display longitude when "longitude" used' do
|
397
|
+
@view.longitude('some-longitude')
|
398
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-longitude" property="og:longitude" />')
|
399
|
+
end
|
400
|
+
|
401
|
+
it 'should display longitude when "single_meta_tags" used' do
|
402
|
+
@view.single_meta_tags(:longitude => 'some-longitude')
|
403
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-longitude" property="og:longitude" />')
|
404
|
+
end
|
405
|
+
|
406
|
+
it 'should display default longitude' do
|
407
|
+
@view.global_meta_tags(:site => 'someSite', :longitude => 'some-longitude').should include('<meta content="some-longitude" property="og:longitude" />')
|
408
|
+
end
|
409
|
+
|
410
|
+
it 'should use custom longitude if given' do
|
411
|
+
@view.longitude('some-longitude')
|
412
|
+
@view.global_meta_tags(:site => 'someSite', :longitude => 'some-longitude').should include('<meta content="some-longitude" property="og:longitude" />')
|
413
|
+
end
|
414
|
+
end
|
415
|
+
|
416
|
+
# street address
|
417
|
+
context 'displaying street_address' do
|
418
|
+
it 'should display street_address when "street_address" used' do
|
419
|
+
@view.street_address('some-street_address')
|
420
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-street_address" property="og:street-address" />')
|
421
|
+
end
|
422
|
+
|
423
|
+
it 'should display street_address when "single_meta_tags" used' do
|
424
|
+
@view.single_meta_tags(:street_address => 'some-street_address')
|
425
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-street_address" property="og:street-address" />')
|
426
|
+
end
|
427
|
+
|
428
|
+
it 'should display default street_address' do
|
429
|
+
@view.global_meta_tags(:site => 'someSite', :street_address => 'some-street_address').should include('<meta content="some-street_address" property="og:street-address" />')
|
430
|
+
end
|
431
|
+
|
432
|
+
it 'should use custom street_address if given' do
|
433
|
+
@view.street_address('some-street_address')
|
434
|
+
@view.global_meta_tags(:site => 'someSite', :street_address => 'some-street_address').should include('<meta content="some-street_address" property="og:street-address" />')
|
435
|
+
end
|
436
|
+
end
|
437
|
+
|
438
|
+
# locality
|
439
|
+
context 'displaying locality' do
|
440
|
+
it 'should display locality when "locality" used' do
|
441
|
+
@view.locality('some-locality')
|
442
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-locality" property="og:locality" />')
|
443
|
+
end
|
444
|
+
|
445
|
+
it 'should display locality when "single_meta_tags" used' do
|
446
|
+
@view.single_meta_tags(:locality => 'some-locality')
|
447
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-locality" property="og:locality" />')
|
448
|
+
end
|
449
|
+
|
450
|
+
it 'should display default locality' do
|
451
|
+
@view.global_meta_tags(:site => 'someSite', :locality => 'some-locality').should include('<meta content="some-locality" property="og:locality" />')
|
452
|
+
end
|
453
|
+
|
454
|
+
it 'should use custom locality if given' do
|
455
|
+
@view.locality('some-locality')
|
456
|
+
@view.global_meta_tags(:site => 'someSite', :locality => 'some-locality').should include('<meta content="some-locality" property="og:locality" />')
|
457
|
+
end
|
458
|
+
end
|
459
|
+
|
460
|
+
# region
|
461
|
+
context 'displaying region' do
|
462
|
+
it 'should display region when "region" used' do
|
463
|
+
@view.region('some-region')
|
464
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-region" property="og:region" />')
|
465
|
+
end
|
466
|
+
|
467
|
+
it 'should display region when "single_meta_tags" used' do
|
468
|
+
@view.single_meta_tags(:region => 'some-region')
|
469
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-region" property="og:region" />')
|
470
|
+
end
|
471
|
+
|
472
|
+
it 'should display default region' do
|
473
|
+
@view.global_meta_tags(:site => 'someSite', :region => 'some-region').should include('<meta content="some-region" property="og:region" />')
|
474
|
+
end
|
475
|
+
|
476
|
+
it 'should use custom region if given' do
|
477
|
+
@view.region('some-region')
|
478
|
+
@view.global_meta_tags(:site => 'someSite', :region => 'some-region').should include('<meta content="some-region" property="og:region" />')
|
479
|
+
end
|
480
|
+
end
|
481
|
+
|
482
|
+
# # postal_code
|
483
|
+
context 'displaying postal_code' do
|
484
|
+
it 'should display postal_code when "postal_code" used' do
|
485
|
+
@view.postal_code('some-postal_code')
|
486
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-postal_code" property="og:postal-code" />')
|
487
|
+
end
|
488
|
+
|
489
|
+
it 'should display postal_code when "single_meta_tags" used' do
|
490
|
+
@view.single_meta_tags(:postal_code => 'some-postal_code')
|
491
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-postal_code" property="og:postal-code" />')
|
492
|
+
end
|
493
|
+
|
494
|
+
it 'should display default postal_code' do
|
495
|
+
@view.global_meta_tags(:site => 'someSite', :postal_code => 'some-postal_code').should include('<meta content="some-postal_code" property="og:postal-code" />')
|
496
|
+
end
|
497
|
+
|
498
|
+
it 'should use custom postal_code if given' do
|
499
|
+
@view.postal_code('some-postal_code')
|
500
|
+
@view.global_meta_tags(:site => 'someSite', :postal_code => 'some-postal_code').should include('<meta content="some-postal_code" property="og:postal-code" />')
|
501
|
+
end
|
502
|
+
end
|
503
|
+
|
504
|
+
# country_name
|
505
|
+
context 'displaying country_name' do
|
506
|
+
it 'should display country_name when "country_name" used' do
|
507
|
+
@view.country_name('some-country_name')
|
508
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-country_name" property="og:country-name" />')
|
509
|
+
end
|
510
|
+
|
511
|
+
it 'should display country_name when "single_meta_tags" used' do
|
512
|
+
@view.single_meta_tags(:country_name => 'some-country_name')
|
513
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-country_name" property="og:country-name" />')
|
514
|
+
end
|
515
|
+
|
516
|
+
it 'should display default country_name' do
|
517
|
+
@view.global_meta_tags(:site => 'someSite', :country_name => 'some-country_name').should include('<meta content="some-country_name" property="og:country-name" />')
|
518
|
+
end
|
519
|
+
|
520
|
+
it 'should use custom country_name if given' do
|
521
|
+
@view.country_name('some-country_name')
|
522
|
+
@view.global_meta_tags(:site => 'someSite', :country_name => 'some-country_name').should include('<meta content="some-country_name" property="og:country-name" />')
|
523
|
+
end
|
524
|
+
end
|
525
|
+
|
526
|
+
# email
|
527
|
+
context 'displaying email' do
|
528
|
+
it 'should display email when "email" used' do
|
529
|
+
@view.email('some-email')
|
530
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-email" property="og:email" />')
|
531
|
+
end
|
532
|
+
|
533
|
+
it 'should display email when "single_meta_tags" used' do
|
534
|
+
@view.single_meta_tags(:email => 'some-email')
|
535
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-email" property="og:email" />')
|
536
|
+
end
|
537
|
+
|
538
|
+
it 'should display default email' do
|
539
|
+
@view.global_meta_tags(:site => 'someSite', :email => 'some-email').should include('<meta content="some-email" property="og:email" />')
|
540
|
+
end
|
541
|
+
|
542
|
+
it 'should use custom email if given' do
|
543
|
+
@view.email('some-email')
|
544
|
+
@view.global_meta_tags(:site => 'someSite', :email => 'some-email').should include('<meta content="some-email" property="og:email" />')
|
545
|
+
end
|
546
|
+
end
|
547
|
+
|
548
|
+
# phone_number
|
549
|
+
context 'displaying phone_number' do
|
550
|
+
it 'should display phone_number when "phone_number" used' do
|
551
|
+
@view.phone_number('some-phone_number')
|
552
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-phone_number" property="og:phone_number" />')
|
553
|
+
end
|
554
|
+
|
555
|
+
it 'should display phone_number when "single_meta_tags" used' do
|
556
|
+
@view.single_meta_tags(:phone_number => 'some-phone_number')
|
557
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-phone_number" property="og:phone_number" />')
|
558
|
+
end
|
559
|
+
|
560
|
+
it 'should display default phone_number' do
|
561
|
+
@view.global_meta_tags(:site => 'someSite', :phone_number => 'some-phone_number').should include('<meta content="some-phone_number" property="og:phone_number" />')
|
562
|
+
end
|
563
|
+
|
564
|
+
it 'should use custom phone_number if given' do
|
565
|
+
@view.phone_number('some-phone_number')
|
566
|
+
@view.global_meta_tags(:site => 'someSite', :phone_number => 'some-phone_number').should include('<meta content="some-phone_number" property="og:phone_number" />')
|
567
|
+
end
|
568
|
+
end
|
569
|
+
|
570
|
+
# fax_number
|
571
|
+
context 'displaying fax_number' do
|
572
|
+
it 'should display fax_number when "fax_number" used' do
|
573
|
+
@view.fax_number('some-fax_number')
|
574
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-fax_number" property="og:fax_number" />')
|
575
|
+
end
|
576
|
+
|
577
|
+
it 'should display fax_number when "single_meta_tags" used' do
|
578
|
+
@view.single_meta_tags(:fax_number => 'some-fax_number')
|
579
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-fax_number" property="og:fax_number" />')
|
580
|
+
end
|
581
|
+
|
582
|
+
it 'should display default fax_number' do
|
583
|
+
@view.global_meta_tags(:site => 'someSite', :fax_number => 'some-fax_number').should include('<meta content="some-fax_number" property="og:fax_number" />')
|
584
|
+
end
|
585
|
+
|
586
|
+
it 'should use custom fax_number if given' do
|
587
|
+
@view.fax_number('some-fax_number')
|
588
|
+
@view.global_meta_tags(:site => 'someSite', :fax_number => 'some-fax_number').should include('<meta content="some-fax_number" property="og:fax_number" />')
|
589
|
+
end
|
590
|
+
end
|
591
|
+
|
592
|
+
# upc
|
593
|
+
context 'displaying upc' do
|
594
|
+
it 'should display upc when "upc" used' do
|
595
|
+
@view.upc('some-upc')
|
596
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-upc" property="og:upc" />')
|
597
|
+
end
|
598
|
+
|
599
|
+
it 'should display upc when "single_meta_tags" used' do
|
600
|
+
@view.single_meta_tags(:upc => 'some-upc')
|
601
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-upc" property="og:upc" />')
|
602
|
+
end
|
603
|
+
|
604
|
+
it 'should display default upc' do
|
605
|
+
@view.global_meta_tags(:site => 'someSite', :upc => 'some-upc').should include('<meta content="some-upc" property="og:upc" />')
|
606
|
+
end
|
607
|
+
|
608
|
+
it 'should use custom upc if given' do
|
609
|
+
@view.upc('some-upc')
|
610
|
+
@view.global_meta_tags(:site => 'someSite', :upc => 'some-upc').should include('<meta content="some-upc" property="og:upc" />')
|
611
|
+
end
|
612
|
+
end
|
613
|
+
|
614
|
+
# isbn
|
615
|
+
context 'displaying isbn' do
|
616
|
+
it 'should display isbn when "isbn" used' do
|
617
|
+
@view.isbn('some-isbn')
|
618
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-isbn" property="og:isbn" />')
|
619
|
+
end
|
620
|
+
|
621
|
+
it 'should display isbn when "single_meta_tags" used' do
|
622
|
+
@view.single_meta_tags(:isbn => 'some-isbn')
|
623
|
+
@view.global_meta_tags(:site => 'someSite').should include('<meta content="some-isbn" property="og:isbn" />')
|
624
|
+
end
|
625
|
+
|
626
|
+
it 'should display default isbn' do
|
627
|
+
@view.global_meta_tags(:site => 'someSite', :isbn => 'some-isbn').should include('<meta content="some-isbn" property="og:isbn" />')
|
628
|
+
end
|
629
|
+
|
630
|
+
it 'should use custom isbn if given' do
|
631
|
+
@view.isbn('some-isbn')
|
632
|
+
@view.global_meta_tags(:site => 'someSite', :isbn => 'some-isbn').should include('<meta content="some-isbn" property="og:isbn" />')
|
633
|
+
end
|
634
|
+
end
|
635
|
+
|
636
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: open-meta-tags
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 4
|
8
|
+
- 0
|
9
|
+
version: 0.4.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Intridea
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-08-23 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: thoughtbot-shoulda
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :development
|
31
|
+
version_requirements: *id001
|
32
|
+
description: something
|
33
|
+
email: jonathan@intridea.com
|
34
|
+
executables: []
|
35
|
+
|
36
|
+
extensions: []
|
37
|
+
|
38
|
+
extra_rdoc_files:
|
39
|
+
- LICENSE
|
40
|
+
- README.markdown
|
41
|
+
files:
|
42
|
+
- .document
|
43
|
+
- .gitignore
|
44
|
+
- LICENSE
|
45
|
+
- README.markdown
|
46
|
+
- Rakefile
|
47
|
+
- VERSION
|
48
|
+
- init.rb
|
49
|
+
- lib/open_meta_tags.rb
|
50
|
+
- lib/open_meta_tags/controller_helper.rb
|
51
|
+
- lib/open_meta_tags/view_helper.rb
|
52
|
+
- open-meta-tags.gemspec
|
53
|
+
- spec/open_meta_tags_spec.rb
|
54
|
+
- spec/spec_helper.rb
|
55
|
+
has_rdoc: true
|
56
|
+
homepage: http://github.com/jonathannelson/open-meta
|
57
|
+
licenses: []
|
58
|
+
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options:
|
61
|
+
- --charset=UTF-8
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
version: "0"
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.3.6
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: A
|
85
|
+
test_files:
|
86
|
+
- spec/open_meta_tags_spec.rb
|
87
|
+
- spec/spec_helper.rb
|