meta-tags 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  rdoc
2
2
  doc
3
- pkg
3
+ pkg
4
+ .yardoc
data/README.rdoc CHANGED
@@ -58,8 +58,8 @@ Recommended keywords tag length: up to <b>255 characters</b>, <b>20 words</b>.
58
58
  By using the noindex meta tag, you can signal to search engines to not
59
59
  include specific pages in their indexes.
60
60
 
61
- <meta name="robots" content="noindex">
62
- <meta name="googlebot" content="noindex">
61
+ <meta name="robots" content="noindex" />
62
+ <meta name="googlebot" content="noindex" />
63
63
 
64
64
  This is useful for pages like login, password reset, privacy policy, etc.
65
65
 
@@ -74,13 +74,25 @@ page. It's entirely likely that a robot might find the same links on some
74
74
  other page without a nofollow (perhaps on some other site), and so
75
75
  still arrives at your undesired page.
76
76
 
77
- <meta name="robots" content="nofollow">
78
- <meta name="googlebot" content="nofollow">
77
+ <meta name="robots" content="nofollow" />
78
+ <meta name="googlebot" content="nofollow" />
79
79
 
80
80
  Further reading:
81
81
  * About rel="nofollow" http://www.google.com/support/webmasters/bin/answer.py?answer=96569
82
82
  * Meta tags http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=79812
83
83
 
84
+ == Canonical URL
85
+
86
+ Canonical link element tells a search engine what is the canonical or main URL
87
+ for a content which have multiple URLs. The search engine will always return
88
+ that URL, and link popularity and authority will be applied to that URL.
89
+
90
+ <link rel="canonical" href="http://yoursite.com/canonical/url" />
91
+
92
+ Further reading:
93
+ * About rel="canonical" http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=139394
94
+ * Canonicalization http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=139066
95
+
84
96
  == MetaTags Usage
85
97
 
86
98
  First, add this code to your main layout:
@@ -157,7 +169,8 @@ Use these options to customize the title format:
157
169
  * <tt>:lowercase</tt> -- when true, the page name will be lowercase;
158
170
  * <tt>:reverse</tt> -- when true, the page and site names will be reversed;
159
171
  * <tt>:noindex</tt> -- add noindex meta tag; when true, 'robots' will be used, otherwise the string will be used;
160
- * <tt>:nofollow</tt> -- add nofollow meta tag; when true, 'robots' will be used, otherwise the string will be used.
172
+ * <tt>:nofollow</tt> -- add nofollow meta tag; when true, 'robots' will be used, otherwise the string will be used;
173
+ * <tt>:canonical</tt> -- add canonical link tag.
161
174
 
162
175
  And here are a few examples to give you ideas.
163
176
 
@@ -193,3 +206,4 @@ There are several plugins influenced me to create this one:
193
206
 
194
207
  * Dmytro Shteflyuk (author) <kpumuk@kpumuk.info> http://kpumuk.info
195
208
  * Morgan Roderick (contributor) <morgan@roderick.dk> http://roderick.dk
209
+ * Sergio Cambra (contributor) <sergio@entrecables.com>
data/Rakefile CHANGED
@@ -1,6 +1,4 @@
1
1
  require 'rake'
2
- require 'spec/rake/spectask'
3
- require 'rake/rdoctask'
4
2
 
5
3
  begin
6
4
  require 'jeweler'
@@ -17,22 +15,33 @@ rescue LoadError
17
15
  puts 'Jeweler not available. Install it with: sudo gem install jeweler'
18
16
  end
19
17
 
20
- desc 'Default: run unit tests.'
21
- task :default => :spec
18
+ begin
19
+ require 'spec/rake/spectask'
20
+
21
+ desc 'Default: run specs'
22
+ task :default => :spec
22
23
 
23
- desc 'Test the meta-tags plugin.'
24
- Spec::Rake::SpecTask.new(:spec) do |t|
25
- t.libs << 'lib'
26
- t.pattern = 'spec/**/*_spec.rb'
27
- t.verbose = true
28
- t.spec_opts = ['-cfs']
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'
29
33
  end
30
34
 
31
- desc 'Generate documentation for the meta-tags plugin.'
32
- Rake::RDocTask.new(:rdoc) do |rdoc|
33
- rdoc.rdoc_dir = 'rdoc'
34
- rdoc.title = 'MetaTags'
35
- rdoc.options << '--line-numbers' << '--inline-source'
36
- rdoc.rdoc_files.include('README.rdoc')
37
- rdoc.rdoc_files.include('lib/**/*.rb')
35
+ begin
36
+ require 'yard'
37
+ YARD::Rake::YardocTask.new(:yard) do |t|
38
+ t.options = ['--title', 'MetaTags Documentation']
39
+ if ENV['PRIVATE']
40
+ t.options.concat ['--protected', '--private']
41
+ else
42
+ t.options << '--no-private'
43
+ end
44
+ end
45
+ rescue LoadError
46
+ puts 'Yard not available. Install it with: sudo gem install yard'
38
47
  end
data/VERSION.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  ---
2
+ :patch: 1
3
+ :build:
2
4
  :major: 1
3
5
  :minor: 1
4
- :patch: 0
@@ -107,7 +107,8 @@ module MetaTags
107
107
  # * <tt>:lowercase</tt> -- when true, the page name will be lowercase;
108
108
  # * <tt>:reverse</tt> -- when true, the page and site names will be reversed;
109
109
  # * <tt>:noindex</tt> -- add noindex meta tag; when true, 'robots' will be used, otherwise the string will be used;
110
- # * <tt>:nofollow</tt> -- add nofollow meta tag; when true, 'robots' will be used, otherwise the string will be used.
110
+ # * <tt>:nofollow</tt> -- add nofollow meta tag; when true, 'robots' will be used, otherwise the string will be used;
111
+ # * <tt>:canonical</tt> -- add canonical link tag.
111
112
  def display_meta_tags(default = {})
112
113
  meta_tags = (default || {}).merge(@meta_tags || {})
113
114
 
@@ -173,6 +174,9 @@ module MetaTags
173
174
  result << "\n" + tag(:meta, :name => nofollow_name, :content => 'nofollow') if meta_tags[:nofollow]
174
175
  end
175
176
 
177
+ # canonical
178
+ result << "\n" + tag(:link, :rel => :canonical, :href => meta_tags[:canonical]) unless meta_tags[:canonical].blank?
179
+
176
180
  return result
177
181
  end
178
182
 
data/meta-tags.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{meta-tags}
8
- s.version = "1.1.0"
8
+ s.version = "1.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dmytro Shteflyuk"]
12
- s.date = %q{2009-11-05}
12
+ s.date = %q{2009-11-21}
13
13
  s.description = %q{Search Engine Optimization (SEO) plugin for Ruby on Rails applications.}
14
14
  s.email = %q{kpumuk@kpumuk.info}
15
15
  s.extra_rdoc_files = [
@@ -275,4 +275,19 @@ describe MetaTags::ViewHelper do
275
275
  content.should include('<meta content="nofollow" name="some-nofollow" />')
276
276
  end
277
277
  end
278
+
279
+ context 'displaying canonical url' do
280
+ it 'should not display canonical url by default' do
281
+ @view.display_meta_tags(:site => 'someSite').should_not include('<link href="http://example.com/base/url" rel="canonical" />')
282
+ end
283
+
284
+ it 'should display canonical url when "set_meta_tags" used' do
285
+ @view.set_meta_tags(:canonical => 'http://example.com/base/url')
286
+ @view.display_meta_tags(:site => 'someSite').should include('<link href="http://example.com/base/url" rel="canonical" />')
287
+ end
288
+
289
+ it 'should display default canonical url' do
290
+ @view.display_meta_tags(:site => 'someSite', :canonical => 'http://example.com/base/url').should include('<link href="http://example.com/base/url" rel="canonical" />')
291
+ end
292
+ end
278
293
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meta-tags
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmytro Shteflyuk
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-05 00:00:00 +02:00
12
+ date: 2009-11-21 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15