canonicalifier 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3fb3d8ab9da1c2b004a63b1de73ba560d0384944
4
+ data.tar.gz: e284c342bd56237721189e847abb3a7d18c69100
5
+ SHA512:
6
+ metadata.gz: 1a5861a96476d134a1451eb69d6a09cafff0b67de74695e34e294f651e51f2cbc88336b276cd8b47fb30c6eb4b551b3def85f908563c9ca82d88ec7a16f15759
7
+ data.tar.gz: 0aaac270393fd62a7a01ab410692afd9b4920c625b68e68074ff1c0569f198ddd892939e336f6ab5ab20b6a24eaad144821a0423d946c024c9c37edce177560e
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2009 Michael Bleigh and Intridea, Inc.
2
+ Copyright (c) 2013 Ronny Haryanto
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # Canonicalifier
2
+
3
+ Canonicalifier is a Rails plugin that provides a simple way to utilize
4
+ [Canonical URL Standards][1] adopted by all of the major search engines to
5
+ improve recognition of duplicated URLs. This allows you to represent
6
+ information in several different places without harming your search engine
7
+ rank.
8
+
9
+ This gem is basically a repackaged version of the [canonical-url][2] gem to
10
+ make it work with Rails 4. The original gem appears to be no longer actively
11
+ maintained. The name of the gem has also been changed, mainly to make it
12
+ easier to refer to different versions in discussions and to make installation
13
+ easier.
14
+
15
+ ## Installation
16
+
17
+ Add the following line to your `Gemfile`:
18
+
19
+ ```
20
+ gem 'canonicalifier'
21
+ ```
22
+
23
+
24
+ ## Usage
25
+
26
+ The plugin is very simple to use and consists of a controller method and a
27
+ helper. To set a canonical URL you will first need to add it into your site's
28
+ layout, like so:
29
+
30
+ ```erb
31
+ <html>
32
+ <head>
33
+ ...
34
+ <%= canonical_link_tag %>
35
+ ...
36
+ </head>
37
+ ...
38
+ </html>
39
+ ```
40
+
41
+ This will automatically insert a canonical URL tag into every page of your
42
+ site, defaulting to the request's current URL (it will not output anything
43
+ when you have not specified a canonical URL through the controller or
44
+ explicitly through the link tag). Then you can set canonical URLs in the
45
+ controller as follows:
46
+
47
+ ```ruby
48
+ class BlogController < ApplicationController
49
+ def show
50
+ @post = find_post # assume this is a standard blog post type record
51
+ canonical_url blog_post_path(post.year, post.month, post.day, post.slug)
52
+ end
53
+ end
54
+ ```
55
+
56
+ Now no matter what the routing is that takes you to the post, the canonical
57
+ URL will remain the same.
58
+
59
+ ## License
60
+
61
+ Parts of this gem that was taken from [canonical-url][2] are copyright © 2009
62
+ [Michael Bleigh](http://www.mbleigh.com/) and
63
+ [Intridea, Inc.](http://www.intridea.com/).
64
+
65
+ Everything else, copyright © 2013 [Ronny Haryanto](https://github.com/ronny).
66
+
67
+ See LICENSE for details.
68
+
69
+
70
+ ## See Also
71
+
72
+ - [Specify Your Canonical][3] from Google Webmaster Central blog.
73
+
74
+ [1]: http://www.seomoz.org/blog/canonical-url-tag-the-most-important-advancement-in-seo-practices-since-sitemaps
75
+ [2]: https://github.com/mbleigh/canonical-url
76
+ [3]: http://googlewebmastercentral.blogspot.com.au/2009/02/specify-your-canonical.html
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Canonicalifier'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('lib/**/*.rb')
14
+ end
15
+
16
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,3 @@
1
+ require 'canonicalifier/railtie' if defined?(Rails)
2
+ require 'canonicalifier/controller_extensions'
3
+ require 'canonicalifier/helpers'
@@ -0,0 +1,12 @@
1
+ module Canonicalifier
2
+ module ControllerExtensions
3
+ def canonical_url(url_for_options = {})
4
+ case url_for_options
5
+ when Hash
6
+ @canonical_url = url_for(url_for_options)
7
+ else
8
+ @canonical_url = url_for_options
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ module Canonicalifier
2
+ module Helpers
3
+ def canonical_link_tag(url = nil)
4
+ return '' unless url || @canonical_url
5
+ tag('link', rel: 'canonical', href: url || @canonical_url || request.url)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ module Canonicalifier
2
+ class Railtie < Rails::Railtie
3
+ initializer "canonicalifier.action_controller" do
4
+ ActionController::Base.send :include, Canonicalifier::ControllerExtensions
5
+ end
6
+
7
+ initializer "canonicalifier.action_view" do
8
+ ActionView::Base.send :include, Canonicalifier::Helpers
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Canonicalifier
2
+ VERSION = "0.0.2"
3
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: canonicalifier
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Ronny Haryanto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.0rc1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 4.0.0rc1
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Rails plugin to handle canonical urls
70
+ email:
71
+ - ronny@haryan.to
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - lib/canonicalifier/controller_extensions.rb
77
+ - lib/canonicalifier/helpers.rb
78
+ - lib/canonicalifier/railtie.rb
79
+ - lib/canonicalifier/version.rb
80
+ - lib/canonicalifier.rb
81
+ - LICENSE
82
+ - Rakefile
83
+ - README.md
84
+ homepage: https://github.com/ronny/canonicalifier
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.0.3
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Rails plugin to handle canonical urls
108
+ test_files: []