meta-rails 0.1.1 → 1.0.0
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.
- checksums.yaml +5 -5
- data/.travis.yml +11 -4
- data/CHANGELOG.md +8 -1
- data/Gemfile +3 -1
- data/LICENSE.txt +1 -1
- data/README.md +97 -3
- data/gemfiles/4.2.gemfile +1 -0
- data/gemfiles/5.0.gemfile +1 -0
- data/gemfiles/5.1.gemfile +1 -0
- data/gemfiles/5.2.gemfile +1 -0
- data/lib/meta-rails.rb +2 -0
- data/lib/meta/rails/helpers/meta_description_helper.rb +10 -0
- data/lib/meta/rails/helpers/robots_helper.rb +10 -0
- data/lib/meta/rails/helpers/title_helper.rb +12 -15
- data/lib/meta/rails/railtie.rb +12 -0
- data/lib/meta/rails/version.rb +1 -1
- data/meta-rails.gemspec +5 -5
- metadata +14 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6e91103f602c3e7f2dc9d205675dc9afadd8ccddbc3d50f884c218c9e471d14b
|
4
|
+
data.tar.gz: 9095044ab4e566c005212226efeb9f6b077f923bf2d4dfe64c72b5845f909c5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5726eac72cbe99e0e38c6f7e71a787fad93097cf5b45642bf4b7f78c5515ffc9a7509bd52dbb09583fe9e7f31efc536dd6ef8aa3af9608ebb76a74f923c8966b
|
7
|
+
data.tar.gz: 606d588e315cfad395f278536e44708ffb38a582d25f8ba4b239af41f84f0620c352c2e66988a7fa219fe55d4f0f7f6a7233eaa886d6985cd183fd605cf2f8dc
|
data/.travis.yml
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
+
sudo: false
|
1
2
|
language: ruby
|
2
3
|
rvm:
|
3
|
-
-
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
- 2.
|
4
|
+
- 2.2.10
|
5
|
+
- 2.3.7
|
6
|
+
- 2.4.4
|
7
|
+
- 2.5.1
|
8
|
+
env:
|
9
|
+
- RAILS_VERSION=4.2
|
10
|
+
- RAILS_VERSION=5.0
|
11
|
+
- RAILS_VERSION=5.1
|
12
|
+
- RAILS_VERSION=5.2
|
13
|
+
before_install: gem install bundler
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,14 @@
|
|
1
|
+
## 1.0.0 (2018-05-11)
|
2
|
+
|
3
|
+
- New: `meta_description` helper
|
4
|
+
- New: `robots` helper
|
5
|
+
- Changed: `:page_title` renamed to `:identifer` for `title` helper
|
6
|
+
- Rails versioning: support rails 5.0, 5.1, 5.2; drop support for rails 3.2, 4.0, 4.1
|
7
|
+
|
1
8
|
## 0.1.1 (2015-11-16)
|
2
9
|
|
3
10
|
- Bug Fix: Brand display when page title is omitted
|
4
11
|
|
5
12
|
## 0.1.0 (2015-11-16)
|
6
13
|
|
7
|
-
- Initial release
|
14
|
+
- Initial release
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Meta Rails
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/meta-rails)
|
4
|
+
[](https://travis-ci.org/rubysamurai/meta-rails)
|
5
|
+
|
3
6
|
Collection of view helpers to improve search engine optimization of Ruby on Rails application by including appropriate meta tags.
|
4
7
|
|
5
8
|
## Installation
|
@@ -12,10 +15,101 @@ gem 'meta-rails'
|
|
12
15
|
|
13
16
|
Save `Gemfile` and execute `bundle` command to install the gem.
|
14
17
|
|
15
|
-
##
|
18
|
+
## Title
|
19
|
+
|
20
|
+
Based on [Moz](https://moz.com/learn/seo/title-tag) and [Google Help](https://support.google.com/webmasters/answer/35624#3) guidelines a proper title consist of *page title*, *brand name*, and *separator* between them.
|
21
|
+
|
22
|
+
#### How to use `title` helper
|
23
|
+
|
24
|
+
```erb
|
25
|
+
# Include 'title' helper in the head section of your site
|
26
|
+
# e.g., ~/app/views/layouts/application.html.erb
|
27
|
+
<head>
|
28
|
+
<%= title %>
|
29
|
+
</head>
|
30
|
+
|
31
|
+
# Utilize 'provide' or 'content for' to store page's title
|
32
|
+
# e.g., ~/app/views/users/new.html.erb
|
33
|
+
<% provide(:title, 'Sign up') %>
|
34
|
+
```
|
35
|
+
|
36
|
+
This code will create HTML `<title>` element:
|
37
|
+
|
38
|
+
```html
|
39
|
+
<title>Sign up | AwesomeRailsApp</title>
|
40
|
+
```
|
41
|
+
|
42
|
+
Format of HTML `<title>` element can be modified by passing options hash to the `title` helper:
|
43
|
+
|
44
|
+
Option | Description | Default
|
45
|
+
-------------|-----------------------------------------------|-----------
|
46
|
+
`:identifier`| Identifier for stored page's title | `:title`
|
47
|
+
`:brand` | Brand name | Rails.application.class.parent_name
|
48
|
+
`:separator` | Character between title and brand | `\|`
|
49
|
+
`:reverse` | Switch position of title and brand | `false`
|
50
|
+
|
51
|
+
## Meta description
|
52
|
+
|
53
|
+
Meta description tag provides a short summary of the page.
|
54
|
+
|
55
|
+
#### How to use `meta_description` helper
|
56
|
+
|
57
|
+
```erb
|
58
|
+
# Include 'meta_description' helper in the head section of your site
|
59
|
+
# e.g., ~/app/views/layouts/application.html.erb
|
60
|
+
<head>
|
61
|
+
<%= meta_description %>
|
62
|
+
</head>
|
63
|
+
|
64
|
+
# Utilize 'provide' or 'content for' to store page's meta description
|
65
|
+
# e.g., ~/app/views/users/new.html.erb
|
66
|
+
<% provide(:meta_description, 'Register to manage your account') %>
|
67
|
+
```
|
68
|
+
|
69
|
+
This code will create HTML `<meta>` tag:
|
70
|
+
|
71
|
+
```html
|
72
|
+
<meta name="description" content="Register to manage your account" />
|
73
|
+
```
|
74
|
+
|
75
|
+
Options hash can be passed to `meta_description` helper:
|
76
|
+
|
77
|
+
Option | Description | Default
|
78
|
+
-------------|-----------------------------------------------|-----------
|
79
|
+
`:identifier`| Identifier for stored page's meta description | `:meta_description`
|
80
|
+
|
81
|
+
## Robots
|
82
|
+
|
83
|
+
Robots meta tag can control the behavior of search engine crawling and indexing.
|
84
|
+
|
85
|
+
#### How to use `robots` helper
|
86
|
+
|
87
|
+
```erb
|
88
|
+
# Include 'robots' helper in the head section of your site
|
89
|
+
# e.g., ~/app/views/layouts/application.html.erb
|
90
|
+
<head>
|
91
|
+
<%= robots %>
|
92
|
+
</head>
|
93
|
+
|
94
|
+
# Utilize 'provide' or 'content for' to store page's robots directives
|
95
|
+
# e.g., ~/app/views/users/new.html.erb
|
96
|
+
<% provide(:robots, 'noindex,nofollow') %>
|
97
|
+
```
|
98
|
+
|
99
|
+
This code will create HTML `<meta>` tag:
|
100
|
+
|
101
|
+
```html
|
102
|
+
<meta name="robots" content="noindex,nofollow" />
|
103
|
+
```
|
104
|
+
|
105
|
+
Options hash can be passed to `robots` helper:
|
106
|
+
|
107
|
+
Option | Description | Default
|
108
|
+
-------------|------------------------------------------------|-----------
|
109
|
+
`:identifier`| Identifier for stored page's robots directives | `:robots`
|
16
110
|
|
17
|
-
|
111
|
+
Please refer to [valid indexing & serving directives](https://developers.google.com/search/reference/robots_meta_tag?csw=1#valid-indexing--serving-directives) page for list of valid robots directives.
|
18
112
|
|
19
113
|
## License
|
20
114
|
|
21
|
-
`meta-rails` © Dmitriy Tarasov
|
115
|
+
`meta-rails` © Dmitriy Tarasov. Released under the [MIT](LICENSE.txt) license.
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'rails', '~> 4.2.0'
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'rails', '~> 5.0.0'
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'rails', '~> 5.1.0'
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'rails', '~> 5.2.0'
|
data/lib/meta-rails.rb
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
module MetaRailsHelpers
|
2
|
+
module MetaDescriptionHelper
|
3
|
+
# Produces html meta element for description
|
4
|
+
def meta_description(identifier: :meta_description)
|
5
|
+
meta_description = content_for(identifier)
|
6
|
+
return if meta_description.blank?
|
7
|
+
tag(:meta, name: 'description', content: meta_description)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -1,27 +1,24 @@
|
|
1
1
|
module MetaRailsHelpers
|
2
2
|
module TitleHelper
|
3
3
|
# Produces html title element
|
4
|
-
def title(
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
if
|
11
|
-
|
12
|
-
content_tag(:title, brand + ' ' + separator + ' ' + page_title)
|
13
|
-
else
|
14
|
-
content_tag(:title, page_title + ' ' + separator + ' ' + brand)
|
15
|
-
end
|
4
|
+
def title(identifier: :title,
|
5
|
+
separator: '|',
|
6
|
+
brand: default_brand,
|
7
|
+
reverse: false)
|
8
|
+
title = content_for(identifier)
|
9
|
+
separator = '' unless title.present? && brand.present?
|
10
|
+
if reverse == true
|
11
|
+
content_tag :title, [brand, separator, title].reject(&:blank?).join(' ')
|
16
12
|
else
|
17
|
-
content_tag
|
13
|
+
content_tag :title, [title, separator, brand].reject(&:blank?).join(' ')
|
18
14
|
end
|
19
15
|
end
|
20
16
|
|
21
17
|
private
|
22
|
-
|
18
|
+
|
19
|
+
# Returns Rails application class name as default brand
|
23
20
|
def default_brand
|
24
|
-
Rails.application.class.
|
21
|
+
Rails.application.class.parent_name
|
25
22
|
end
|
26
23
|
end
|
27
24
|
end
|
data/lib/meta/rails/railtie.rb
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
module MetaRailsHelpers
|
2
2
|
class Railtie < Rails::Railtie
|
3
|
+
initializer 'meta_description.helper' do
|
4
|
+
ActiveSupport.on_load :action_view do
|
5
|
+
include MetaRailsHelpers::MetaDescriptionHelper
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
initializer 'robots.helper' do
|
10
|
+
ActiveSupport.on_load :action_view do
|
11
|
+
include MetaRailsHelpers::RobotsHelper
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
3
15
|
initializer 'title.helper' do
|
4
16
|
ActiveSupport.on_load :action_view do
|
5
17
|
include MetaRailsHelpers::TitleHelper
|
data/lib/meta/rails/version.rb
CHANGED
data/meta-rails.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'meta/rails/version'
|
@@ -14,13 +13,14 @@ Gem::Specification.new do |spec|
|
|
14
13
|
spec.homepage = 'https://github.com/rubysamurai/meta-rails'
|
15
14
|
spec.license = 'MIT'
|
16
15
|
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
18
19
|
spec.bindir = 'exe'
|
19
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
21
|
spec.require_paths = ['lib']
|
21
22
|
|
22
|
-
spec.required_ruby_version = '>= 1.
|
23
|
+
spec.required_ruby_version = '>= 2.1.0'
|
23
24
|
|
24
|
-
spec.add_development_dependency 'rails', '
|
25
|
-
spec.add_development_dependency 'rspec-rails', '~> 3.3'
|
25
|
+
spec.add_development_dependency 'rspec-rails', '>= 3.5'
|
26
26
|
end
|
metadata
CHANGED
@@ -1,43 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meta-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitriy Tarasov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-05-11 00:00:00.000000000 Z
|
12
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.2'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '4.2'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rspec-rails
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
|
-
- - "
|
17
|
+
- - ">="
|
32
18
|
- !ruby/object:Gem::Version
|
33
|
-
version: '3.
|
19
|
+
version: '3.5'
|
34
20
|
type: :development
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
|
-
- - "
|
24
|
+
- - ">="
|
39
25
|
- !ruby/object:Gem::Version
|
40
|
-
version: '3.
|
26
|
+
version: '3.5'
|
41
27
|
description: Meta tags helpers to improve search engine optimization (SEO) of Rails
|
42
28
|
application
|
43
29
|
email:
|
@@ -56,7 +42,13 @@ files:
|
|
56
42
|
- Rakefile
|
57
43
|
- bin/console
|
58
44
|
- bin/setup
|
45
|
+
- gemfiles/4.2.gemfile
|
46
|
+
- gemfiles/5.0.gemfile
|
47
|
+
- gemfiles/5.1.gemfile
|
48
|
+
- gemfiles/5.2.gemfile
|
59
49
|
- lib/meta-rails.rb
|
50
|
+
- lib/meta/rails/helpers/meta_description_helper.rb
|
51
|
+
- lib/meta/rails/helpers/robots_helper.rb
|
60
52
|
- lib/meta/rails/helpers/title_helper.rb
|
61
53
|
- lib/meta/rails/railtie.rb
|
62
54
|
- lib/meta/rails/version.rb
|
@@ -73,7 +65,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
65
|
requirements:
|
74
66
|
- - ">="
|
75
67
|
- !ruby/object:Gem::Version
|
76
|
-
version: 1.
|
68
|
+
version: 2.1.0
|
77
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
70
|
requirements:
|
79
71
|
- - ">="
|
@@ -81,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
73
|
version: '0'
|
82
74
|
requirements: []
|
83
75
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.
|
76
|
+
rubygems_version: 2.7.6
|
85
77
|
signing_key:
|
86
78
|
specification_version: 4
|
87
79
|
summary: Meta tags helpers for search engine optimization (SEO)
|