meta-tags 1.2.4 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +9 -0
- data/CHANGELOG.md +49 -0
- data/MIT-LICENSE +4 -2
- data/README.md +248 -0
- data/Rakefile +13 -11
- data/lib/meta_tags/controller_helper.rb +9 -2
- data/lib/meta_tags/version.rb +1 -1
- data/lib/meta_tags/view_helper.rb +53 -38
- data/meta-tags.gemspec +4 -2
- data/spec/controller_helper_spec.rb +42 -0
- data/spec/meta_tags_spec.rb +118 -100
- data/spec/spec_helper.rb +23 -0
- metadata +45 -16
- data/Gemfile.lock +0 -53
- data/README.rdoc +0 -223
data/spec/spec_helper.rb
CHANGED
@@ -1,2 +1,25 @@
|
|
1
1
|
require 'bundler/setup'
|
2
2
|
require 'meta_tags'
|
3
|
+
|
4
|
+
shared_examples_for '.set_meta_tags' do
|
5
|
+
it 'should update meta tags' do
|
6
|
+
subject.set_meta_tags(:title => 'hello')
|
7
|
+
subject.meta_tags[:title].should == 'hello'
|
8
|
+
|
9
|
+
subject.set_meta_tags(:title => 'world')
|
10
|
+
subject.meta_tags[:title].should == 'world'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should use deep merge when updating meta tags' do
|
14
|
+
subject.set_meta_tags(:open_graph => { :title => 'hello' })
|
15
|
+
subject.meta_tags[:open_graph].should == { :title => 'hello' }
|
16
|
+
|
17
|
+
subject.set_meta_tags(:open_graph => { :description => 'world' })
|
18
|
+
subject.meta_tags[:open_graph].should == { :title => 'hello', :description => 'world' }
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should normalize :og to :open_graph' do
|
22
|
+
subject.set_meta_tags(:og => { :title => 'hello' })
|
23
|
+
subject.meta_tags[:open_graph].should == { :title => 'hello' }
|
24
|
+
end
|
25
|
+
end
|
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:
|
5
|
-
prerelease:
|
4
|
+
hash: 21
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 5
|
10
|
+
version: 1.2.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dmytro Shteflyuk
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
18
|
+
date: 2012-03-03 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: actionpack
|
@@ -33,7 +32,7 @@ dependencies:
|
|
33
32
|
type: :runtime
|
34
33
|
version_requirements: *id001
|
35
34
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
35
|
+
name: rake
|
37
36
|
prerelease: false
|
38
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
38
|
none: false
|
@@ -47,7 +46,7 @@ dependencies:
|
|
47
46
|
type: :development
|
48
47
|
version_requirements: *id002
|
49
48
|
- !ruby/object:Gem::Dependency
|
50
|
-
name:
|
49
|
+
name: rspec
|
51
50
|
prerelease: false
|
52
51
|
requirement: &id003 !ruby/object:Gem::Requirement
|
53
52
|
none: false
|
@@ -60,6 +59,34 @@ dependencies:
|
|
60
59
|
version: "0"
|
61
60
|
type: :development
|
62
61
|
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: yard
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
type: :development
|
75
|
+
version_requirements: *id004
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: bluecloth
|
78
|
+
prerelease: false
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
hash: 3
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
version: "0"
|
88
|
+
type: :development
|
89
|
+
version_requirements: *id005
|
63
90
|
description: Search Engine Optimization (SEO) plugin for Ruby on Rails applications.
|
64
91
|
email:
|
65
92
|
- kpumuk@kpumuk.info
|
@@ -68,22 +95,24 @@ executables: []
|
|
68
95
|
extensions: []
|
69
96
|
|
70
97
|
extra_rdoc_files:
|
71
|
-
- README.
|
98
|
+
- README.md
|
99
|
+
- CHANGELOG.md
|
72
100
|
files:
|
73
101
|
- .gitignore
|
102
|
+
- .travis.yml
|
103
|
+
- CHANGELOG.md
|
74
104
|
- Gemfile
|
75
|
-
- Gemfile.lock
|
76
105
|
- MIT-LICENSE
|
77
|
-
- README.
|
106
|
+
- README.md
|
78
107
|
- Rakefile
|
79
108
|
- lib/meta_tags.rb
|
80
109
|
- lib/meta_tags/controller_helper.rb
|
81
110
|
- lib/meta_tags/version.rb
|
82
111
|
- lib/meta_tags/view_helper.rb
|
83
112
|
- meta-tags.gemspec
|
113
|
+
- spec/controller_helper_spec.rb
|
84
114
|
- spec/meta_tags_spec.rb
|
85
115
|
- spec/spec_helper.rb
|
86
|
-
has_rdoc: true
|
87
116
|
homepage: http://github.com/kpumuk/meta-tags
|
88
117
|
licenses: []
|
89
118
|
|
@@ -113,10 +142,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
142
|
requirements: []
|
114
143
|
|
115
144
|
rubyforge_project:
|
116
|
-
rubygems_version: 1.
|
145
|
+
rubygems_version: 1.7.2
|
117
146
|
signing_key:
|
118
147
|
specification_version: 3
|
119
148
|
summary: Collection of SEO helpers for Ruby on Rails.
|
120
|
-
test_files:
|
121
|
-
|
122
|
-
|
149
|
+
test_files: []
|
150
|
+
|
151
|
+
has_rdoc:
|
data/Gemfile.lock
DELETED
@@ -1,53 +0,0 @@
|
|
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
DELETED
@@ -1,223 +0,0 @@
|
|
1
|
-
= MetaTags
|
2
|
-
|
3
|
-
Search Engine Optimization (SEO) plugin for Ruby on Rails applications.
|
4
|
-
|
5
|
-
== Rails 3
|
6
|
-
|
7
|
-
MetaTags master branch now fully supports Rails 3 and is backward
|
8
|
-
compatible.
|
9
|
-
|
10
|
-
== Installation
|
11
|
-
|
12
|
-
Add the "meta-tags" gem to your +Gemfile+.
|
13
|
-
|
14
|
-
gem 'meta-tags', :require => 'meta_tags'
|
15
|
-
|
16
|
-
And run +bundle install+ command.
|
17
|
-
|
18
|
-
== Titles
|
19
|
-
|
20
|
-
Page titles are very important for Search engines. The titles in the
|
21
|
-
browser are displayed in the title bar. The search engines would look at
|
22
|
-
the this title bar to determine what the page is all about.
|
23
|
-
|
24
|
-
<title>Some Page Title</title>
|
25
|
-
<title>Page Title | Site Title</title>
|
26
|
-
|
27
|
-
Recommended title tag length: up to <b>70 characters</b>, <b>10 words</b>.
|
28
|
-
|
29
|
-
== Description
|
30
|
-
|
31
|
-
Description tags are called meta tags as they are not displayed by the
|
32
|
-
browsers as that of titles. But these descriptions may be displayed by
|
33
|
-
some search engines. They are used to describe the contents of a page in
|
34
|
-
2 or 3 sentences.
|
35
|
-
|
36
|
-
<meta name="description" content="All text about keywords, other keywords" />
|
37
|
-
|
38
|
-
Recommended description tag length: up to <b>160 characters</b>.
|
39
|
-
|
40
|
-
== Keywords
|
41
|
-
|
42
|
-
Meta keywords tag are used to place your keywords that you think a
|
43
|
-
surfer would search in Search engines. Repeating keywords unnecessarily
|
44
|
-
would be considered spam and you may get permanently banned from SERP's
|
45
|
-
|
46
|
-
<meta name="keywords" content="keyword1, keyword2, keyword3" />
|
47
|
-
|
48
|
-
Recommended keywords tag length: up to <b>255 characters</b>, <b>20 words</b>.
|
49
|
-
|
50
|
-
== Noindex
|
51
|
-
|
52
|
-
By using the noindex meta tag, you can signal to search engines to not
|
53
|
-
include specific pages in their indexes.
|
54
|
-
|
55
|
-
<meta name="robots" content="noindex" />
|
56
|
-
<meta name="googlebot" content="noindex" />
|
57
|
-
|
58
|
-
This is useful for pages like login, password reset, privacy policy, etc.
|
59
|
-
|
60
|
-
Further reading:
|
61
|
-
* Blocking Google http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=93708
|
62
|
-
* Using meta tags to block access to your site http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=93710
|
63
|
-
|
64
|
-
== Nofollow
|
65
|
-
|
66
|
-
Nofollow meta tag tells a search engine not to follow the links on a specific
|
67
|
-
page. It's entirely likely that a robot might find the same links on some
|
68
|
-
other page without a nofollow (perhaps on some other site), and so
|
69
|
-
still arrives at your undesired page.
|
70
|
-
|
71
|
-
<meta name="robots" content="nofollow" />
|
72
|
-
<meta name="googlebot" content="nofollow" />
|
73
|
-
|
74
|
-
Further reading:
|
75
|
-
* About rel="nofollow" http://www.google.com/support/webmasters/bin/answer.py?answer=96569
|
76
|
-
* Meta tags http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=79812
|
77
|
-
|
78
|
-
== Canonical URL
|
79
|
-
|
80
|
-
Canonical link element tells a search engine what is the canonical or main URL
|
81
|
-
for a content which have multiple URLs. The search engine will always return
|
82
|
-
that URL, and link popularity and authority will be applied to that URL.
|
83
|
-
|
84
|
-
<link rel="canonical" href="http://yoursite.com/canonical/url" />
|
85
|
-
|
86
|
-
Further reading:
|
87
|
-
* About rel="canonical" http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=139394
|
88
|
-
* Canonicalization http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=139066
|
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
|
-
|
106
|
-
== MetaTags Usage
|
107
|
-
|
108
|
-
First, add this code to your main layout:
|
109
|
-
|
110
|
-
<head>
|
111
|
-
<%= display_meta_tags :site => 'My website' %>
|
112
|
-
</head>
|
113
|
-
|
114
|
-
Then, to set the page title, add this to each of your views (see below for other options):
|
115
|
-
|
116
|
-
<h1><%= title 'My page title' %></h1>
|
117
|
-
|
118
|
-
When views are rendered, the page title will be included in the right spots:
|
119
|
-
|
120
|
-
<head>
|
121
|
-
<title>My website | My page title</title>
|
122
|
-
</head>
|
123
|
-
<body>
|
124
|
-
<h1>My page title</h1>
|
125
|
-
</body>
|
126
|
-
|
127
|
-
You can find allowed options for +display_meta_tags+ method below.
|
128
|
-
|
129
|
-
=== Using MetaTags in controller
|
130
|
-
|
131
|
-
You can define following instance variables:
|
132
|
-
|
133
|
-
@page_title = 'Member Login'
|
134
|
-
@page_description = 'Member login page.'
|
135
|
-
@page_keywords = 'Site, Login, Members'
|
136
|
-
|
137
|
-
Also you could use +set_meta_tags+ method to define all meta tags simultaneously:
|
138
|
-
|
139
|
-
set_meta_tags :title => 'Member Login',
|
140
|
-
:description => 'Member login page.',
|
141
|
-
:keywords => 'Site, Login, Members'
|
142
|
-
|
143
|
-
You can find allowed options for +set_meta_tags+ method below.
|
144
|
-
|
145
|
-
=== Using MetaTags in view
|
146
|
-
|
147
|
-
To set meta tags you can use following methods:
|
148
|
-
|
149
|
-
<% title 'Member Login' %>
|
150
|
-
<% description 'Member login page.' %>
|
151
|
-
<% keywords 'Member login page.' %>
|
152
|
-
|
153
|
-
Also there is +set_meta_tags+ method exists:
|
154
|
-
|
155
|
-
<% set_meta_tags :title => 'Member Login',
|
156
|
-
:description => 'Member login page.',
|
157
|
-
:keywords => 'Site, Login, Members' %>
|
158
|
-
|
159
|
-
The +title+ method returns title itself, so you can use it to show the title
|
160
|
-
somewhere on the page:
|
161
|
-
|
162
|
-
<h1><%= title 'Member Login' %></h1>
|
163
|
-
|
164
|
-
If you want to set the title and display another text, use this:
|
165
|
-
|
166
|
-
<h1><%= title 'Member Login', 'Here you can login to the site:' %></h1>
|
167
|
-
|
168
|
-
=== Allowed options for +display_meta_tags+ and +set_meta_tags+ methods
|
169
|
-
|
170
|
-
Use these options to customize the title format:
|
171
|
-
|
172
|
-
* <tt>:site</tt> -- site title;
|
173
|
-
* <tt>:title</tt> -- page title;
|
174
|
-
* <tt>:description</tt> -- page description;
|
175
|
-
* <tt>:keywords</tt> -- page keywords;
|
176
|
-
* <tt>:prefix</tt> -- text between site name and separator;
|
177
|
-
* <tt>:separator</tt> -- text used to separate website name from page title;
|
178
|
-
* <tt>:suffix</tt> -- text between separator and page title;
|
179
|
-
* <tt>:lowercase</tt> -- when true, the page name will be lowercase;
|
180
|
-
* <tt>:reverse</tt> -- when true, the page and site names will be reversed;
|
181
|
-
* <tt>:noindex</tt> -- add noindex meta tag; when true, 'robots' will be used, otherwise the string will be used;
|
182
|
-
* <tt>:nofollow</tt> -- add nofollow meta tag; when true, 'robots' will be used, otherwise the string will be used;
|
183
|
-
* <tt>:canonical</tt> -- add canonical link tag;
|
184
|
-
* <tt>:open_graph</tt> -- add Open Graph tags (Hash).
|
185
|
-
|
186
|
-
And here are a few examples to give you ideas.
|
187
|
-
|
188
|
-
<%= display_meta_tags :separator => "—".html_safe %>
|
189
|
-
<%= display_meta_tags :prefix => false, :separator => ":" %>
|
190
|
-
<%= display_meta_tags :lowercase => true %>
|
191
|
-
<%= display_meta_tags :reverse => true, :prefix => false %>
|
192
|
-
<%= display_meta_tags :open_graph => { :title => 'The Rock', :type => 'movie' } %>
|
193
|
-
|
194
|
-
=== Allowed values
|
195
|
-
|
196
|
-
You can specify <tt>:title</tt> as a string or array:
|
197
|
-
|
198
|
-
set_meta_tags :title => ['part1', 'part2'], :site => 'site'
|
199
|
-
# site | part1 | part2
|
200
|
-
set_meta_tags :title => ['part1', 'part2'], :reverse => true, :site => 'site'
|
201
|
-
# part2 | part1 | site
|
202
|
-
|
203
|
-
Keywords can be passed as string of comma-separated values, or as an array:
|
204
|
-
|
205
|
-
set_meta_tags :keywords => ['tag1', 'tag2']
|
206
|
-
# tag1, tag2
|
207
|
-
|
208
|
-
Description is a string (HTML will be stripped from output string).
|
209
|
-
|
210
|
-
== Alternatives
|
211
|
-
|
212
|
-
There are several plugins influenced me to create this one:
|
213
|
-
|
214
|
-
* Headliner: http://github.com/mokolabs/headliner
|
215
|
-
* meta_on_rals: http://github.com/ashchan/meta_on_rails
|
216
|
-
|
217
|
-
== Credits
|
218
|
-
|
219
|
-
* Dmytro Shteflyuk (author) <kpumuk@kpumuk.info> http://kpumuk.info
|
220
|
-
* Morgan Roderick (contributor) <morgan@roderick.dk> http://roderick.dk
|
221
|
-
* Sergio Cambra (contributor) <sergio@entrecables.com>
|
222
|
-
* Kristoffer Renholm (contributor) <kristoffer@renholm.se>
|
223
|
-
* Jesse Clark (contributor) <jesse@jesseclark.com> http://jesseclark.com/blog
|