meta-tags 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -3
- data/Gemfile +4 -0
- data/Gemfile.lock +53 -0
- data/README.rdoc +27 -19
- data/Rakefile +2 -33
- data/lib/meta_tags/controller_helper.rb +0 -1
- data/lib/meta_tags/version.rb +3 -0
- data/lib/meta_tags/view_helper.rb +30 -19
- data/lib/meta_tags.rb +4 -2
- data/meta-tags.gemspec +19 -45
- data/spec/meta_tags_spec.rb +41 -15
- data/spec/spec_helper.rb +2 -5
- metadata +53 -10
- data/VERSION.yml +0 -5
- data/init.rb +0 -1
data/.gitignore
CHANGED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
meta-tags (1.2.4)
|
5
|
+
actionpack
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
abstract (1.0.0)
|
11
|
+
actionpack (3.0.7)
|
12
|
+
activemodel (= 3.0.7)
|
13
|
+
activesupport (= 3.0.7)
|
14
|
+
builder (~> 2.1.2)
|
15
|
+
erubis (~> 2.6.6)
|
16
|
+
i18n (~> 0.5.0)
|
17
|
+
rack (~> 1.2.1)
|
18
|
+
rack-mount (~> 0.6.14)
|
19
|
+
rack-test (~> 0.5.7)
|
20
|
+
tzinfo (~> 0.3.23)
|
21
|
+
activemodel (3.0.7)
|
22
|
+
activesupport (= 3.0.7)
|
23
|
+
builder (~> 2.1.2)
|
24
|
+
i18n (~> 0.5.0)
|
25
|
+
activesupport (3.0.7)
|
26
|
+
builder (2.1.2)
|
27
|
+
diff-lcs (1.1.2)
|
28
|
+
erubis (2.6.6)
|
29
|
+
abstract (>= 1.0.0)
|
30
|
+
i18n (0.5.0)
|
31
|
+
rack (1.2.2)
|
32
|
+
rack-mount (0.6.14)
|
33
|
+
rack (>= 1.0.0)
|
34
|
+
rack-test (0.5.7)
|
35
|
+
rack (>= 1.0)
|
36
|
+
rspec (2.5.0)
|
37
|
+
rspec-core (~> 2.5.0)
|
38
|
+
rspec-expectations (~> 2.5.0)
|
39
|
+
rspec-mocks (~> 2.5.0)
|
40
|
+
rspec-core (2.5.1)
|
41
|
+
rspec-expectations (2.5.0)
|
42
|
+
diff-lcs (~> 1.1.2)
|
43
|
+
rspec-mocks (2.5.0)
|
44
|
+
tzinfo (0.3.26)
|
45
|
+
yard (0.6.8)
|
46
|
+
|
47
|
+
PLATFORMS
|
48
|
+
ruby
|
49
|
+
|
50
|
+
DEPENDENCIES
|
51
|
+
meta-tags!
|
52
|
+
rspec
|
53
|
+
yard
|
data/README.rdoc
CHANGED
@@ -4,27 +4,16 @@ Search Engine Optimization (SEO) plugin for Ruby on Rails applications.
|
|
4
4
|
|
5
5
|
== Rails 3
|
6
6
|
|
7
|
-
MetaTags master branch
|
7
|
+
MetaTags master branch now fully supports Rails 3 and is backward
|
8
8
|
compatible.
|
9
9
|
|
10
10
|
== Installation
|
11
11
|
|
12
|
-
|
12
|
+
Add the "meta-tags" gem to your +Gemfile+.
|
13
13
|
|
14
|
-
|
15
|
-
* install as a Rails plugin
|
14
|
+
gem 'meta-tags', :require => 'meta_tags'
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
config.gem 'meta-tags', :lib => 'meta_tags'
|
20
|
-
|
21
|
-
And then run the command:
|
22
|
-
|
23
|
-
sudo rake gems:install
|
24
|
-
|
25
|
-
To install meta-tags as a Rails plugin use this:
|
26
|
-
|
27
|
-
script/plugin install git://github.com/kpumuk/meta-tags.git
|
16
|
+
And run +bundle install+ command.
|
28
17
|
|
29
18
|
== Titles
|
30
19
|
|
@@ -98,6 +87,22 @@ Further reading:
|
|
98
87
|
* About rel="canonical" http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=139394
|
99
88
|
* Canonicalization http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=139066
|
100
89
|
|
90
|
+
== Open Graph
|
91
|
+
|
92
|
+
To turn your web pages into graph objects, you'll need to add Open Graph protocol
|
93
|
+
<meta> tags to your webpages. The tags allow you to specify structured information
|
94
|
+
about your web pages. The more information you provide, the more opportunities your
|
95
|
+
web pages can be surfaced within Facebook today and in the future. Here's an example
|
96
|
+
for a movie page:
|
97
|
+
|
98
|
+
<meta property="og:title" content="The Rock"/>
|
99
|
+
<meta property="og:type" content="movie"/>
|
100
|
+
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/"/>
|
101
|
+
<meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/>
|
102
|
+
|
103
|
+
Further reading:
|
104
|
+
* Open Graph protocol http://developers.facebook.com/docs/opengraph/
|
105
|
+
|
101
106
|
== MetaTags Usage
|
102
107
|
|
103
108
|
First, add this code to your main layout:
|
@@ -125,9 +130,9 @@ You can find allowed options for +display_meta_tags+ method below.
|
|
125
130
|
|
126
131
|
You can define following instance variables:
|
127
132
|
|
128
|
-
@page_title
|
133
|
+
@page_title = 'Member Login'
|
129
134
|
@page_description = 'Member login page.'
|
130
|
-
@page_keywords
|
135
|
+
@page_keywords = 'Site, Login, Members'
|
131
136
|
|
132
137
|
Also you could use +set_meta_tags+ method to define all meta tags simultaneously:
|
133
138
|
|
@@ -175,14 +180,16 @@ Use these options to customize the title format:
|
|
175
180
|
* <tt>:reverse</tt> -- when true, the page and site names will be reversed;
|
176
181
|
* <tt>:noindex</tt> -- add noindex meta tag; when true, 'robots' will be used, otherwise the string will be used;
|
177
182
|
* <tt>:nofollow</tt> -- add nofollow meta tag; when true, 'robots' will be used, otherwise the string will be used;
|
178
|
-
* <tt>:canonical</tt> -- add canonical link tag
|
183
|
+
* <tt>:canonical</tt> -- add canonical link tag;
|
184
|
+
* <tt>:open_graph</tt> -- add Open Graph tags (Hash).
|
179
185
|
|
180
186
|
And here are a few examples to give you ideas.
|
181
187
|
|
182
|
-
<%= display_meta_tags :separator => "—" %>
|
188
|
+
<%= display_meta_tags :separator => "—".html_safe %>
|
183
189
|
<%= display_meta_tags :prefix => false, :separator => ":" %>
|
184
190
|
<%= display_meta_tags :lowercase => true %>
|
185
191
|
<%= display_meta_tags :reverse => true, :prefix => false %>
|
192
|
+
<%= display_meta_tags :open_graph => { :title => 'The Rock', :type => 'movie' } %>
|
186
193
|
|
187
194
|
=== Allowed values
|
188
195
|
|
@@ -213,3 +220,4 @@ There are several plugins influenced me to create this one:
|
|
213
220
|
* Morgan Roderick (contributor) <morgan@roderick.dk> http://roderick.dk
|
214
221
|
* Sergio Cambra (contributor) <sergio@entrecables.com>
|
215
222
|
* Kristoffer Renholm (contributor) <kristoffer@renholm.se>
|
223
|
+
* Jesse Clark (contributor) <jesse@jesseclark.com> http://jesseclark.com/blog
|
data/Rakefile
CHANGED
@@ -1,36 +1,5 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'jeweler'
|
5
|
-
Jeweler::Tasks.new do |gemspec|
|
6
|
-
gemspec.name = 'meta-tags'
|
7
|
-
gemspec.summary = 'Collection of SEO helpers for Ruby on Rails'
|
8
|
-
gemspec.description = 'Search Engine Optimization (SEO) plugin for Ruby on Rails applications.'
|
9
|
-
gemspec.email = 'kpumuk@kpumuk.info'
|
10
|
-
gemspec.homepage = 'http://github.com/kpumuk/meta-tags'
|
11
|
-
gemspec.authors = ['Dmytro Shteflyuk']
|
12
|
-
end
|
13
|
-
Jeweler::GemcutterTasks.new
|
14
|
-
rescue LoadError
|
15
|
-
puts 'Jeweler not available. Install it with: sudo gem install jeweler'
|
16
|
-
end
|
17
|
-
|
18
|
-
begin
|
19
|
-
require 'spec/rake/spectask'
|
20
|
-
|
21
|
-
desc 'Default: run specs'
|
22
|
-
task :default => :spec
|
23
|
-
|
24
|
-
desc 'Test the sphinx plugin'
|
25
|
-
Spec::Rake::SpecTask.new do |t|
|
26
|
-
t.libs << 'lib'
|
27
|
-
t.pattern = 'spec/*_spec.rb'
|
28
|
-
t.verbose = true
|
29
|
-
t.spec_opts = ['-cfs']
|
30
|
-
end
|
31
|
-
rescue LoadError
|
32
|
-
puts 'RSpec not available. Install it with: sudo gem install rspec'
|
33
|
-
end
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
34
3
|
|
35
4
|
begin
|
36
5
|
require 'yard'
|
@@ -135,6 +135,7 @@ module MetaTags
|
|
135
135
|
# @option default [Boolean, String] :noindex (false) add noindex meta tag; when true, 'robots' will be used, otherwise the string will be used;
|
136
136
|
# @option default [Boolean, String] :nofollow (false) add nofollow meta tag; when true, 'robots' will be used, otherwise the string will be used;
|
137
137
|
# @option default [String] :canonical (nil) add canonical link tag.
|
138
|
+
# @option default [Hash] :open_graph ({}) add Open Graph meta tags.
|
138
139
|
# @return [String] HTML meta tags to render in HEAD section of the
|
139
140
|
# HTML document.
|
140
141
|
#
|
@@ -150,19 +151,20 @@ module MetaTags
|
|
150
151
|
prefix = meta_tags[:prefix] === false ? '' : (meta_tags[:prefix] || ' ')
|
151
152
|
|
152
153
|
# Separator
|
153
|
-
separator = meta_tags[:separator]
|
154
|
+
separator = meta_tags[:separator] === false ? '' : (meta_tags[:separator] || '|')
|
154
155
|
|
155
156
|
# Suffix (trailing space)
|
156
157
|
suffix = meta_tags[:suffix] === false ? '' : (meta_tags[:suffix] || ' ')
|
157
158
|
|
159
|
+
# Special case: if separator is hidden, do not display suffix/prefix
|
160
|
+
if meta_tags[:separator] == false
|
161
|
+
prefix = suffix = ''
|
162
|
+
end
|
163
|
+
|
158
164
|
# Title
|
159
165
|
title = meta_tags[:title]
|
160
166
|
if meta_tags[:lowercase] === true and !title.blank?
|
161
|
-
title =
|
162
|
-
title.map { |t| t.downcase }
|
163
|
-
else
|
164
|
-
title.downcase
|
165
|
-
end
|
167
|
+
title = Array(title).map { |t| t.downcase }
|
166
168
|
end
|
167
169
|
|
168
170
|
result = []
|
@@ -171,11 +173,13 @@ module MetaTags
|
|
171
173
|
if title.blank?
|
172
174
|
result << content_tag(:title, meta_tags[:site])
|
173
175
|
else
|
174
|
-
title = normalize_title(title)
|
175
|
-
title = [meta_tags[:site]] + title
|
176
|
+
title = normalize_title(title).unshift(h(meta_tags[:site]))
|
176
177
|
title.reverse! if meta_tags[:reverse] === true
|
177
|
-
sep = prefix + separator + suffix
|
178
|
-
|
178
|
+
sep = h(prefix) + h(separator) + h(suffix)
|
179
|
+
title = title.join(sep)
|
180
|
+
# We escaped every chunk of the title, so the whole title should be HTML safe
|
181
|
+
title = title.html_safe if title.respond_to?(:html_safe)
|
182
|
+
result << content_tag(:title, title)
|
179
183
|
end
|
180
184
|
|
181
185
|
# description
|
@@ -187,17 +191,23 @@ module MetaTags
|
|
187
191
|
result << tag(:meta, :name => :keywords, :content => keywords) unless keywords.blank?
|
188
192
|
|
189
193
|
# noindex & nofollow
|
190
|
-
noindex_name
|
191
|
-
nofollow_name = meta_tags[:nofollow]
|
194
|
+
noindex_name = String === meta_tags[:noindex] ? meta_tags[:noindex] : 'robots'
|
195
|
+
nofollow_name = String === meta_tags[:nofollow] ? meta_tags[:nofollow] : 'robots'
|
192
196
|
|
193
197
|
if noindex_name == nofollow_name
|
194
|
-
content = [
|
198
|
+
content = [meta_tags[:noindex] && 'noindex', meta_tags[:nofollow] && 'nofollow'].compact.join(', ')
|
195
199
|
result << tag(:meta, :name => noindex_name, :content => content) unless content.blank?
|
196
200
|
else
|
197
|
-
result << tag(:meta, :name => noindex_name,
|
201
|
+
result << tag(:meta, :name => noindex_name, :content => 'noindex') if meta_tags[:noindex]
|
198
202
|
result << tag(:meta, :name => nofollow_name, :content => 'nofollow') if meta_tags[:nofollow]
|
199
203
|
end
|
200
204
|
|
205
|
+
# Open Graph
|
206
|
+
open_graph = meta_tags[:open_graph] || meta_tags[:og] || {}
|
207
|
+
open_graph.each do |property, content|
|
208
|
+
result << tag(:meta, :property => "og:#{property}", :content => content)
|
209
|
+
end
|
210
|
+
|
201
211
|
# canonical
|
202
212
|
result << tag(:link, :rel => :canonical, :href => meta_tags[:canonical]) unless meta_tags[:canonical].blank?
|
203
213
|
|
@@ -205,13 +215,14 @@ module MetaTags
|
|
205
215
|
result.respond_to?(:html_safe) ? result.html_safe : result
|
206
216
|
end
|
207
217
|
|
218
|
+
if respond_to? :safe_helper
|
219
|
+
safe_helper :display_meta_tags
|
220
|
+
end
|
221
|
+
|
208
222
|
private
|
209
223
|
|
210
224
|
def normalize_title(title)
|
211
|
-
|
212
|
-
title = [title]
|
213
|
-
end
|
214
|
-
title.map { |t| h(strip_tags(t)) }
|
225
|
+
Array(title).map { |t| h(strip_tags(t)) }
|
215
226
|
end
|
216
227
|
|
217
228
|
def normalize_description(description)
|
@@ -221,7 +232,7 @@ module MetaTags
|
|
221
232
|
|
222
233
|
def normalize_keywords(keywords)
|
223
234
|
return '' unless keywords
|
224
|
-
keywords = keywords.flatten.join(', ') if keywords
|
235
|
+
keywords = keywords.flatten.join(', ') if Array === keywords
|
225
236
|
strip_tags(keywords).mb_chars.downcase
|
226
237
|
end
|
227
238
|
end
|
data/lib/meta_tags.rb
CHANGED
@@ -2,9 +2,11 @@ require 'action_controller'
|
|
2
2
|
require 'action_view'
|
3
3
|
|
4
4
|
module MetaTags
|
5
|
-
autoload :ViewHelper, 'meta_tags/view_helper'
|
6
|
-
autoload :ControllerHelper, 'meta_tags/controller_helper'
|
7
5
|
end
|
8
6
|
|
7
|
+
require 'meta_tags/version'
|
8
|
+
require 'meta_tags/view_helper'
|
9
|
+
require 'meta_tags/controller_helper'
|
10
|
+
|
9
11
|
ActionView::Base.send :include, MetaTags::ViewHelper
|
10
12
|
ActionController::Base.send :include, MetaTags::ControllerHelper
|
data/meta-tags.gemspec
CHANGED
@@ -1,52 +1,26 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'meta_tags/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
9
|
-
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
6
|
+
s.name = 'meta-tags'
|
7
|
+
s.version = MetaTags::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ['Dmytro Shteflyuk']
|
10
|
+
s.email = ['kpumuk@kpumuk.info']
|
11
|
+
s.homepage = 'http://github.com/kpumuk/meta-tags'
|
12
|
+
s.summary = %q{Collection of SEO helpers for Ruby on Rails.}
|
13
13
|
s.description = %q{Search Engine Optimization (SEO) plugin for Ruby on Rails applications.}
|
14
|
-
s.email = %q{kpumuk@kpumuk.info}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"README.rdoc"
|
17
|
-
]
|
18
|
-
s.files = [
|
19
|
-
".gitignore",
|
20
|
-
"MIT-LICENSE",
|
21
|
-
"README.rdoc",
|
22
|
-
"Rakefile",
|
23
|
-
"VERSION.yml",
|
24
|
-
"init.rb",
|
25
|
-
"lib/meta_tags.rb",
|
26
|
-
"lib/meta_tags/controller_helper.rb",
|
27
|
-
"lib/meta_tags/view_helper.rb",
|
28
|
-
"meta-tags.gemspec",
|
29
|
-
"spec/meta_tags_spec.rb",
|
30
|
-
"spec/spec_helper.rb"
|
31
|
-
]
|
32
|
-
s.homepage = %q{http://github.com/kpumuk/meta-tags}
|
33
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
34
|
-
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = %q{1.3.7}
|
36
|
-
s.summary = %q{Collection of SEO helpers for Ruby on Rails}
|
37
|
-
s.test_files = [
|
38
|
-
"spec/meta_tags_spec.rb",
|
39
|
-
"spec/spec_helper.rb"
|
40
|
-
]
|
41
14
|
|
42
|
-
|
43
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
44
|
-
s.specification_version = 3
|
15
|
+
s.add_dependency 'actionpack'
|
45
16
|
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
else
|
50
|
-
end
|
51
|
-
end
|
17
|
+
s.add_development_dependency 'rspec'
|
18
|
+
s.add_development_dependency 'yard'
|
52
19
|
|
20
|
+
s.files = `git ls-files`.split("\n")
|
21
|
+
s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
|
22
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
|
+
s.extra_rdoc_files = ['README.rdoc']
|
24
|
+
s.rdoc_options = ['--charset=UTF-8']
|
25
|
+
s.require_paths = ['lib']
|
26
|
+
end
|
data/spec/meta_tags_spec.rb
CHANGED
@@ -4,20 +4,20 @@ describe MetaTags::ViewHelper do
|
|
4
4
|
before :each do
|
5
5
|
@view = ActionView::Base.new
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
context 'module' do
|
9
9
|
it 'should be mixed into ActionView::Base' do
|
10
10
|
ActionView::Base.included_modules.should include(MetaTags::ViewHelper)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
it 'should respond to "title" helper' do
|
14
14
|
@view.should respond_to(:title)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it 'should respond to "description" helper' do
|
18
18
|
@view.should respond_to(:description)
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
it 'should respond to "keywords" helper' do
|
22
22
|
@view.should respond_to(:keywords)
|
23
23
|
end
|
@@ -38,7 +38,7 @@ describe MetaTags::ViewHelper do
|
|
38
38
|
@view.should respond_to(:display_meta_tags)
|
39
39
|
end
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
context 'returning values' do
|
43
43
|
it 'should return title' do
|
44
44
|
@view.title('some-title').should == 'some-title'
|
@@ -47,7 +47,7 @@ describe MetaTags::ViewHelper do
|
|
47
47
|
it 'should return headline if specified' do
|
48
48
|
@view.title('some-title', 'some-headline').should == 'some-headline'
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
it 'should return description' do
|
52
52
|
@view.description('some-description').should == 'some-description'
|
53
53
|
end
|
@@ -64,12 +64,12 @@ describe MetaTags::ViewHelper do
|
|
64
64
|
@view.noindex('some-nofollow').should == 'some-nofollow'
|
65
65
|
end
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
context 'title' do
|
69
69
|
it 'should use website name if title is empty' do
|
70
70
|
@view.display_meta_tags(:site => 'someSite').should == '<title>someSite</title>'
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
it 'should display title when "title" used' do
|
74
74
|
@view.title('someTitle')
|
75
75
|
@view.display_meta_tags(:site => 'someSite').should == '<title>someSite | someTitle</title>'
|
@@ -106,7 +106,9 @@ describe MetaTags::ViewHelper do
|
|
106
106
|
@view.title('someTitle')
|
107
107
|
@view.display_meta_tags(:site => 'someSite', :separator => '-').should == '<title>someSite - someTitle</title>'
|
108
108
|
@view.display_meta_tags(:site => 'someSite', :separator => ':').should == '<title>someSite : someTitle</title>'
|
109
|
-
@view.display_meta_tags(:site => 'someSite', :separator => '—').should == '<title>someSite — someTitle</title>'
|
109
|
+
@view.display_meta_tags(:site => 'someSite', :separator => '—').should == '<title>someSite &mdash; someTitle</title>'
|
110
|
+
@view.display_meta_tags(:site => 'someSite', :separator => '—'.html_safe).should == '<title>someSite — someTitle</title>'
|
111
|
+
@view.display_meta_tags(:site => 'someSite: ', :separator => false).should == '<title>someSite: someTitle</title>'
|
110
112
|
end
|
111
113
|
|
112
114
|
it 'should use custom prefix and suffix if available' do
|
@@ -130,7 +132,7 @@ describe MetaTags::ViewHelper do
|
|
130
132
|
:lowercase => true,
|
131
133
|
:reverse => true).should == '<title>sometitle -:+ someSite</title>'
|
132
134
|
end
|
133
|
-
|
135
|
+
|
134
136
|
it 'shold allow Arrays in title' do
|
135
137
|
@view.display_meta_tags(:site => 'someSite', :title => ['someTitle', 'anotherTitle']).should == '<title>someSite | someTitle | anotherTitle</title>'
|
136
138
|
end
|
@@ -148,7 +150,7 @@ describe MetaTags::ViewHelper do
|
|
148
150
|
:reverse => true).should == '<title>anotherTitle -:+ someTitle -:+ someSite</title>'
|
149
151
|
end
|
150
152
|
end
|
151
|
-
|
153
|
+
|
152
154
|
context 'displaying description' do
|
153
155
|
it 'should display description when "description" used' do
|
154
156
|
@view.description('someDescription')
|
@@ -176,8 +178,12 @@ describe MetaTags::ViewHelper do
|
|
176
178
|
it 'should strip HTML' do
|
177
179
|
@view.display_meta_tags(:site => 'someSite', :description => "<p>some <b>description</b></p>").should include('<meta content="some description" name="description" />')
|
178
180
|
end
|
181
|
+
|
182
|
+
it 'should truncate correctly' do
|
183
|
+
@view.display_meta_tags(:site => 'someSite', :description => "Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.").should include('<meta content="Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dol..." name="description" />')
|
184
|
+
end
|
179
185
|
end
|
180
|
-
|
186
|
+
|
181
187
|
context 'displaying keywords' do
|
182
188
|
it 'should display keywords when "keywords" used' do
|
183
189
|
@view.keywords('some-keywords')
|
@@ -210,7 +216,7 @@ describe MetaTags::ViewHelper do
|
|
210
216
|
@view.display_meta_tags(:site => 'someSite', :keywords => [%w(keyword1 keyword2), 'keyword3']).should include('<meta content="keyword1, keyword2, keyword3" name="keywords" />')
|
211
217
|
end
|
212
218
|
end
|
213
|
-
|
219
|
+
|
214
220
|
context 'displaying noindex' do
|
215
221
|
it 'should display noindex when "noindex" used' do
|
216
222
|
@view.noindex(true)
|
@@ -252,7 +258,7 @@ describe MetaTags::ViewHelper do
|
|
252
258
|
@view.display_meta_tags(:site => 'someSite').should_not include('<meta content="nofollow"')
|
253
259
|
end
|
254
260
|
end
|
255
|
-
|
261
|
+
|
256
262
|
context 'displaying both nofollow and noindex' do
|
257
263
|
it 'should be displayed when set using helpers' do
|
258
264
|
@view.noindex(true)
|
@@ -294,4 +300,24 @@ describe MetaTags::ViewHelper do
|
|
294
300
|
@view.display_meta_tags(:site => 'someSite', :canonical => 'http://example.com/base/url').should include('<link href="http://example.com/base/url" rel="canonical" />')
|
295
301
|
end
|
296
302
|
end
|
297
|
-
|
303
|
+
|
304
|
+
context 'displaying Open Graph meta tags' do
|
305
|
+
it 'should display meta tags specified with :open_graph' do
|
306
|
+
@view.set_meta_tags(:open_graph => {
|
307
|
+
:title => 'Facebook Share Title',
|
308
|
+
:description => 'Facebook Share Description'
|
309
|
+
})
|
310
|
+
@view.display_meta_tags(:site => 'someSite').should include('<meta content="Facebook Share Title" property="og:title" />')
|
311
|
+
@view.display_meta_tags(:site => 'someSite').should include('<meta content="Facebook Share Description" property="og:description" />')
|
312
|
+
end
|
313
|
+
|
314
|
+
it 'should display meta tags specified with :og' do
|
315
|
+
@view.set_meta_tags(:og => {
|
316
|
+
:title => 'Facebook Share Title',
|
317
|
+
:description => 'Facebook Share Description'
|
318
|
+
})
|
319
|
+
@view.display_meta_tags(:site => 'someSite').should include('<meta content="Facebook Share Title" property="og:title" />')
|
320
|
+
@view.display_meta_tags(:site => 'someSite').should include('<meta content="Facebook Share Description" property="og:description" />')
|
321
|
+
end
|
322
|
+
end
|
323
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meta-tags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 4
|
10
|
+
version: 1.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dmytro Shteflyuk
|
@@ -15,12 +15,54 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-04-26 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: actionpack
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: yard
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :development
|
62
|
+
version_requirements: *id003
|
22
63
|
description: Search Engine Optimization (SEO) plugin for Ruby on Rails applications.
|
23
|
-
email:
|
64
|
+
email:
|
65
|
+
- kpumuk@kpumuk.info
|
24
66
|
executables: []
|
25
67
|
|
26
68
|
extensions: []
|
@@ -29,13 +71,14 @@ extra_rdoc_files:
|
|
29
71
|
- README.rdoc
|
30
72
|
files:
|
31
73
|
- .gitignore
|
74
|
+
- Gemfile
|
75
|
+
- Gemfile.lock
|
32
76
|
- MIT-LICENSE
|
33
77
|
- README.rdoc
|
34
78
|
- Rakefile
|
35
|
-
- VERSION.yml
|
36
|
-
- init.rb
|
37
79
|
- lib/meta_tags.rb
|
38
80
|
- lib/meta_tags/controller_helper.rb
|
81
|
+
- lib/meta_tags/version.rb
|
39
82
|
- lib/meta_tags/view_helper.rb
|
40
83
|
- meta-tags.gemspec
|
41
84
|
- spec/meta_tags_spec.rb
|
@@ -73,7 +116,7 @@ rubyforge_project:
|
|
73
116
|
rubygems_version: 1.3.7
|
74
117
|
signing_key:
|
75
118
|
specification_version: 3
|
76
|
-
summary: Collection of SEO helpers for Ruby on Rails
|
119
|
+
summary: Collection of SEO helpers for Ruby on Rails.
|
77
120
|
test_files:
|
78
121
|
- spec/meta_tags_spec.rb
|
79
122
|
- spec/spec_helper.rb
|
data/VERSION.yml
DELETED
data/init.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'meta_tags'
|