meta-tags 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 1.5.0 (May 7, 2013)
2
+
3
+ Features:
4
+
5
+ - Added "prev" and "next" links support
6
+ - Added refresh meta tag support
7
+
1
8
  ## 1.4.1 (March 14, 2013)
2
9
 
3
10
  Bugfixes:
data/README.md CHANGED
@@ -105,6 +105,41 @@ Further reading:
105
105
  * [About rel="canonical"](http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=139394)
106
106
  * [Canonicalization](http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=139066)
107
107
 
108
+ ### Pagination links
109
+
110
+ Previous and next links indicate indicate the relationship between individual
111
+ URLs. Using these attributes is a strong hint to Google that you want us to
112
+ treat these pages as a logical sequence.
113
+
114
+ set_meta_tags :prev => "http://yoursite.com/url?page=1"
115
+ # <link rel="prev" href="http://yoursite.com/url?page=1" />
116
+ set_meta_tags :next => "http://yoursite.com/url?page=3"
117
+ # <link rel="next" href="http://yoursite.com/url?page=3" />
118
+
119
+ Further reading:
120
+
121
+ * [Pagination](http://support.google.com/webmasters/bin/answer.py?hl=en&answer=1663744)
122
+ * [Pagination with rel="next" and rel="prev"](http://googlewebmastercentral.blogspot.ca/2011/09/pagination-with-relnext-and-relprev.html)
123
+
124
+ ### Refresh interval and redirect URL
125
+
126
+ Meta refresh is a method of instructing a web browser to automatically
127
+ refresh the current web page or frame after a given time interval. It is also
128
+ possible to instruct the browser to fetch a different URL when the page is
129
+ refreshed, by including the alternative URL in the content parameter. By
130
+ setting the refresh time interval to zero (or a very low value), this allows
131
+ meta refresh to be used as a method of URL redirection.
132
+
133
+ set_meta_tags :refresh => 5
134
+ # <meta content="5" http-equiv="refresh" />
135
+ set_meta_tags :refresh => '5;url=http://example.com'
136
+ # <meta content="5;url=http://example.com" http-equiv="refresh" />
137
+
138
+ Further reading:
139
+
140
+ * [Meta refresh](http://en.wikipedia.org/wiki/Meta_refresh)
141
+ * [What is the Meta Refresh Tag](http://webdesign.about.com/od/metataglibraries/a/aa080300a.htm)
142
+
108
143
  ### Hashes
109
144
 
110
145
  Any namespace can be built just passing any symbol name and a Hash. For example:
@@ -238,6 +273,9 @@ To set meta tags you can use following methods:
238
273
  <% title 'Member Login' %>
239
274
  <% description 'Member login page.' %>
240
275
  <% keywords 'Member login page.' %>
276
+ <% nofollow %>
277
+ <% noindex %>
278
+ <% refresh 3 %>
241
279
 
242
280
  Also there is `set_meta_tags` method exists:
243
281
 
@@ -270,8 +308,11 @@ Use these options to customize the title format:
270
308
  * `:noindex` — add noindex meta tag; when true, 'robots' will be used, otherwise the string will be used;
271
309
  * `:nofollow` — add nofollow meta tag; when true, 'robots' will be used, otherwise the string will be used;
272
310
  * `:canonical` — add canonical link tag;
273
- * `:og` — add Open Graph tags (Hash).
274
- * `:twitter` — add Twitter tags (Hash).
311
+ * `:prev` — add prev link tag;
312
+ * `:prev` — add next link tag;
313
+ * `:og` — add Open Graph tags (Hash);
314
+ * `:twitter` — add Twitter tags (Hash);
315
+ * `:refresh` — refresh interval and optionally url to redirect to.
275
316
 
276
317
  And here are a few examples to give you ideas.
277
318
 
@@ -331,24 +372,6 @@ And in your pjax templates:
331
372
  <!-- HTML goes here -->
332
373
  <% end %>
333
374
 
334
- ## Alternatives
335
-
336
- There are several plugins influenced me to create this one:
337
-
338
- * [Headliner](https://github.com/mokolabs/headliner)
339
- * [meta\_on_rals](https://github.com/ashchan/meta_on_rails)
340
-
341
- ## Credits
375
+ ## Author
342
376
 
343
- * [Dmytro Shteflyuk](https://github.com/kpumuk) (author)
344
- * [Morgan Roderick](https://github.com/mroderick) (contributor)
345
- * [Jesse Clark](https://github.com/jesseclark) (contributor)
346
- * Sergio Cambra (contributor)
347
- * Kristoffer Renholm (contributor)
348
- * [Jürg Lehni](https://github.com/lehni) (contributor)
349
- * [Tom Coleman](https://github.com/tmeasday) (contributor)
350
- * [Guille Lopez](https://github.com/guillelopez) (contributor)
351
- * [Holger Frohloff](https://github.com/jazzgumpy) (contributor)
352
- * [Jakub Wojtysiak](https://github.com/schiza) (contributor)
353
- * [Matthew Callis](https://github.com/MatthewCallis) (contributor)
354
- * [Andre Luiz Carvalho](https://github.com/alcarvalho) (contributor)
377
+ [Dmytro Shteflyuk](https://github.com/kpumuk), [http://kpumuk.info](http://kpumuk.info/)
@@ -1,3 +1,3 @@
1
1
  module MetaTags
2
- VERSION = '1.4.1'
2
+ VERSION = '1.5.0'
3
3
  end
@@ -105,7 +105,7 @@ module MetaTags
105
105
  #
106
106
  # @see #display_meta_tags
107
107
  #
108
- def noindex(noindex)
108
+ def noindex(noindex = true)
109
109
  set_meta_tags(:noindex => noindex)
110
110
  noindex
111
111
  end
@@ -121,11 +121,27 @@ module MetaTags
121
121
  #
122
122
  # @see #display_meta_tags
123
123
  #
124
- def nofollow(nofollow)
124
+ def nofollow(nofollow = true)
125
125
  set_meta_tags(:nofollow => nofollow)
126
126
  nofollow
127
127
  end
128
128
 
129
+ # Set the refresh meta tag
130
+ #
131
+ # @param [Integer, String] refresh a refresh value.
132
+ # @return [Integer, String] passed value.
133
+ #
134
+ # @example
135
+ # refresh 5
136
+ # refresh "5;url=http://www.example.com/"
137
+ #
138
+ # @see #display_meta_tags
139
+ #
140
+ def refresh(refresh)
141
+ set_meta_tags(:refresh => refresh)
142
+ refresh
143
+ end
144
+
129
145
  # Set default meta tag values and display meta tags. This method
130
146
  # should be used in layout file.
131
147
  #
@@ -142,6 +158,9 @@ module MetaTags
142
158
  # @option default [Boolean, String] :noindex (false) add noindex meta tag; when true, 'robots' will be used, otherwise the string will be used;
143
159
  # @option default [Boolean, String] :nofollow (false) add nofollow meta tag; when true, 'robots' will be used, otherwise the string will be used;
144
160
  # @option default [String] :canonical (nil) add canonical link tag.
161
+ # @option default [String] :prev (nil) add prev link tag;
162
+ # @option default [String] :next (nil) add next link tag.
163
+ # @option default [String, Integer] :refresh (nil) meta refresh tag;
145
164
  # @option default [Hash] :open_graph ({}) add Open Graph meta tags.
146
165
  # @return [String] HTML meta tags to render in HEAD section of the
147
166
  # HTML document.
@@ -182,6 +201,11 @@ module MetaTags
182
201
  meta_tags.delete(:noindex)
183
202
  meta_tags.delete(:nofollow)
184
203
 
204
+ # refresh
205
+ if refresh = meta_tags.delete(:refresh)
206
+ result << tag(:meta, 'http-equiv' => 'refresh', :content => refresh.to_s) unless refresh.blank?
207
+ end
208
+
185
209
  # hashes
186
210
  meta_tags.each do |property, data|
187
211
  if data.is_a?(Hash)
@@ -190,9 +214,11 @@ module MetaTags
190
214
  end
191
215
  end
192
216
 
193
- # canonical
194
- result << tag(:link, :rel => :canonical, :href => meta_tags[:canonical]) unless meta_tags[:canonical].blank?
195
- meta_tags.delete(:canonical)
217
+ # canonical, prev and next
218
+ [ :canonical, :prev, :next ].each do |tag_name|
219
+ next unless href = meta_tags.delete(tag_name)
220
+ result << tag(:link, :rel => tag_name, :href => href)
221
+ end
196
222
 
197
223
  # user defined
198
224
  meta_tags.each do |name, data|
@@ -248,6 +248,27 @@ describe MetaTags::ViewHelper do
248
248
  end
249
249
  end
250
250
 
251
+ context 'displaying refresh' do
252
+ it 'displays refresh when "refresh" is used' do
253
+ subject.refresh(5)
254
+ subject.display_meta_tags(:site => 'someSite').should include('<meta content="5" http-equiv="refresh" />')
255
+ end
256
+
257
+ it 'displays refresh when "set_meta_tags" used' do
258
+ subject.set_meta_tags(:refresh => 5)
259
+ subject.display_meta_tags(:site => 'someSite').should include('<meta content="5" http-equiv="refresh" />')
260
+ end
261
+
262
+ it 'should use custom refresh if given' do
263
+ subject.refresh("5;url=http://example.com/")
264
+ subject.display_meta_tags(:site => 'someSite').should include(%Q{<meta content="5;url=http://example.com/" http-equiv="refresh" />})
265
+ end
266
+
267
+ it 'should display nothing by default' do
268
+ subject.display_meta_tags(:site => 'someSite').should_not include('http-equiv="refresh"')
269
+ end
270
+ end
271
+
251
272
  context 'displaying noindex' do
252
273
  it 'should display noindex when "noindex" used' do
253
274
  subject.noindex(true)
@@ -339,6 +360,36 @@ describe MetaTags::ViewHelper do
339
360
  end
340
361
  end
341
362
 
363
+ context 'displaying prev url' do
364
+ it 'should not display prev url by default' do
365
+ subject.display_meta_tags(:site => 'someSite').should_not include('<link href="http://example.com/base/url" rel="prev" />')
366
+ end
367
+
368
+ it 'should display prev url when "set_meta_tags" used' do
369
+ subject.set_meta_tags(:prev => 'http://example.com/base/url')
370
+ subject.display_meta_tags(:site => 'someSite').should include('<link href="http://example.com/base/url" rel="prev" />')
371
+ end
372
+
373
+ it 'should display default prev url' do
374
+ subject.display_meta_tags(:site => 'someSite', :prev => 'http://example.com/base/url').should include('<link href="http://example.com/base/url" rel="prev" />')
375
+ end
376
+ end
377
+
378
+ context 'displaying next url' do
379
+ it 'should not display next url by default' do
380
+ subject.display_meta_tags(:site => 'someSite').should_not include('<link href="http://example.com/base/url" rel="next" />')
381
+ end
382
+
383
+ it 'should display next url when "set_meta_tags" used' do
384
+ subject.set_meta_tags(:next => 'http://example.com/base/url')
385
+ subject.display_meta_tags(:site => 'someSite').should include('<link href="http://example.com/base/url" rel="next" />')
386
+ end
387
+
388
+ it 'should display default next url' do
389
+ subject.display_meta_tags(:site => 'someSite', :next => 'http://example.com/base/url').should include('<link href="http://example.com/base/url" rel="next" />')
390
+ end
391
+ end
392
+
342
393
  context 'displaying Open Graph meta tags' do
343
394
  it 'should display meta tags specified with :open_graph' do
344
395
  subject.set_meta_tags(:open_graph => {
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
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 4
9
- - 1
10
- version: 1.4.1
8
+ - 5
9
+ - 0
10
+ version: 1.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dmytro Shteflyuk
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-03-14 00:00:00 -04:00
18
+ date: 2013-05-07 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency