meta-rails 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 20e68d96f8ec3b1288c4bee9dd0d209605800365
4
- data.tar.gz: c3c6bc140f1ff796f2c0ec1cea9c4f2cb5bb9936
2
+ SHA256:
3
+ metadata.gz: 6e91103f602c3e7f2dc9d205675dc9afadd8ccddbc3d50f884c218c9e471d14b
4
+ data.tar.gz: 9095044ab4e566c005212226efeb9f6b077f923bf2d4dfe64c72b5845f909c5a
5
5
  SHA512:
6
- metadata.gz: 1f47fb18be8f19d7170a10115c73bfdcb4031eba82c09536464af544a02c9468be61e03377a87ceb4966f83fab753a3d484fc86bc6a2dbf096788f1a01d543f8
7
- data.tar.gz: 8412877ef5e49d750d0008e356ef1147b92f40266e66b4160fd807739e4cfe078c7b12f1b1143936c5745995fb2c4aea8568418692d311cec58040409e459300
6
+ metadata.gz: 5726eac72cbe99e0e38c6f7e71a787fad93097cf5b45642bf4b7f78c5515ffc9a7509bd52dbb09583fe9e7f31efc536dd6ef8aa3af9608ebb76a74f923c8966b
7
+ data.tar.gz: 606d588e315cfad395f278536e44708ffb38a582d25f8ba4b239af41f84f0620c352c2e66988a7fa219fe55d4f0f7f6a7233eaa886d6985cd183fd605cf2f8dc
@@ -1,6 +1,13 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1.7
6
- - 2.2.3
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
@@ -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
@@ -1,4 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in meta-rails.gemspec
4
3
  gemspec
4
+
5
+ rails_version = ENV['RAILS_VERSION'] || '5.2'
6
+ eval_gemfile File.expand_path("../gemfiles/#{rails_version}.gemfile", __FILE__)
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 Dmitriy Tarasov
3
+ Copyright (c) 2018 Dmitriy Tarasov
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Meta Rails
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/meta-rails.svg)](https://badge.fury.io/rb/meta-rails)
4
+ [![Build Status](https://travis-ci.org/rubysamurai/meta-rails.svg)](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
- ## Contributing
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
- Anyone is welcome to contribute to Meta Rails. Please [raise an issue](https://github.com/rubysamurai/meta-rails/issues), fork the project, make changes to your forked repository and submit a pull request.
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, 2015. Released under the [MIT](https://github.com/rubysamurai/meta-rails/blob/master/LICENSE.txt) license.
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'
@@ -1,4 +1,6 @@
1
1
  require 'meta/rails/version'
2
+ require 'meta/rails/helpers/meta_description_helper'
3
+ require 'meta/rails/helpers/robots_helper'
2
4
  require 'meta/rails/helpers/title_helper'
3
5
  require 'meta/rails/railtie' if defined? Rails
4
6
 
@@ -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
@@ -0,0 +1,10 @@
1
+ module MetaRailsHelpers
2
+ module RobotsHelper
3
+ # Produces html meta element for robots
4
+ def robots(identifier: :robots)
5
+ robots = content_for(identifier)
6
+ return if robots.blank?
7
+ tag(:meta, name: 'robots', content: robots)
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(options = {})
5
- page_title = content_for(options[:page_title] || :title)
6
- separator = options[:separator] || '|'
7
- brand = options[:brand] || default_brand
8
- reverse = options[:reverse] || false
9
-
10
- if page_title.present?
11
- if reverse
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(:title, brand)
13
+ content_tag :title, [title, separator, brand].reject(&:blank?).join(' ')
18
14
  end
19
15
  end
20
16
 
21
17
  private
22
- # Returns Rails application name as default brand
18
+
19
+ # Returns Rails application class name as default brand
23
20
  def default_brand
24
- Rails.application.class.to_s.split('::').first
21
+ Rails.application.class.parent_name
25
22
  end
26
23
  end
27
24
  end
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Meta
2
2
  module Rails
3
- VERSION = '0.1.1'
3
+ VERSION = '1.0.0'.freeze
4
4
  end
5
5
  end
@@ -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 { |f| f.match(%r{^(test|spec|features)/}) }
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.9.3'
23
+ spec.required_ruby_version = '>= 2.1.0'
23
24
 
24
- spec.add_development_dependency 'rails', '~> 4.2'
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.1.1
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: 2015-11-16 00:00:00.000000000 Z
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.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.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.9.3
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.4.7
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)