seo_rails_helpers 0.1.0

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: e00c828025913363293db9eab7e239621ae2d2c7
4
+ data.tar.gz: b4b0cd7735af4cfb4c27e5a4e46b7e055e508cf5
5
+ SHA512:
6
+ metadata.gz: 8db37a200d19a826aa5536be6c6a0eec843c88b3e21ad12660420b8f665c68106072dd64d01a0b803d841d00065523149dd07bcbee0bfccc64ba8eb8eba9c5b1
7
+ data.tar.gz: 54fb4cfe7473baaec172ea9a46d48e8d54ed757cff727e4b1796973b94338be9f2152f9ac7422e49e7d898904678b10fcd7f192cbf488073ae3e12c88483119d
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /log/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.1.0 (2015-07-16)
2
+
3
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in seo_rails_helpers.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Dmitriy Tarasov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # SEO Rails Helpers
2
+
3
+ Collection of view helpers to improve search engine optimization of Ruby on Rails application.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your Rails application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'seo_rails_helpers'
11
+ ```
12
+
13
+ And then execute `bundle` command to install.
14
+
15
+ ## Usage
16
+
17
+ ### 1. seo_page_title
18
+
19
+ This helper will produce SEO friendly page title. It assumes you are using either `content_for` or `provide` helper in your page view to store page title.
20
+
21
+ Include `seo_page_title` in the `<head>` section of your layout
22
+
23
+ ERB example:
24
+ ```erb
25
+ <head>
26
+ <%= seo_page_title %>
27
+ <%# other elements %>
28
+ </head>
29
+ ```
30
+
31
+ Haml example:
32
+ ```haml
33
+ %head
34
+ seo_page_title
35
+ -# other elements
36
+ ```
37
+
38
+ This will create HTML title element:
39
+ ```html
40
+ <title>Page Title | Base Title</title>
41
+ ```
42
+
43
+ Exact format of title element will vary based on user-specific options.
44
+
45
+ #### seo_page_title options
46
+
47
+ | Name | Description | Default
48
+ | ----------- | ------------------------|-----------
49
+ | ```:page_title```| Identifier for stored page title. Specify symbol representing identifier in your ```provide``` or ```content_for``` method. | ```:title```
50
+ | ```:separator``` | Character that separates `:page_title` and `:base_title` | \|
51
+ | ```:base_title```| Base title, like your brand or app name. In case `:page_title` is missing or empty the title will consist of `:base_title` only. | Your Rails application name
52
+
53
+ #### example seo_page_title usage
54
+
55
+ ```ruby
56
+ provide(:page_title, 'Example Page')
57
+ ```
58
+
59
+ ```ruby
60
+ seo_page_title(page_title: :page_title,
61
+ separator: '>',
62
+ base_title: 'Example Site')
63
+ ```
64
+
65
+ Will produce following title element:
66
+ ```html
67
+ <title>Example Page &gt; Example Site</title>
68
+ ```
69
+
70
+ ## Contributing
71
+
72
+ Fork the project and submit a pull request.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'seo_rails_helpers'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,23 @@
1
+ module SeoRailsHelpers
2
+ module SeoPageTitleHelper
3
+ # Produces html title element
4
+ def seo_page_title(options = {})
5
+ page_title = content_for(options[:page_title] || :title)
6
+ separator = options[:separator] || '|'
7
+ base_title = options[:base_title] || default_base_title
8
+
9
+ if page_title.present?
10
+ content_tag(:title, page_title + ' ' + separator + ' ' + base_title)
11
+ else
12
+ content_tag(:title, base_title)
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ # Returns Rails application name as default base title
19
+ def default_base_title
20
+ Rails.application.class.to_s.split('::').first
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ module SeoRailsHelpers
2
+ class Railtie < Rails::Railtie
3
+ initializer 'seo_page_title.helper' do
4
+ ActiveSupport.on_load :action_view do
5
+ include SeoRailsHelpers::SeoPageTitleHelper
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module SeoRailsHelpers
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,6 @@
1
+ require 'seo_rails_helpers/version'
2
+ require 'seo_rails_helpers/helpers/seo_page_title_helper'
3
+ require 'seo_rails_helpers/railtie' if defined? Rails
4
+
5
+ module SeoRailsHelpers
6
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'seo_rails_helpers/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'seo_rails_helpers'
8
+ spec.version = SeoRailsHelpers::VERSION
9
+ spec.authors = ['Dmitriy Tarasov']
10
+ spec.email = ['info@rubysamurai.com']
11
+
12
+ spec.summary = 'Rails view helpers for search engine optimization (SEO)'
13
+ spec.description = 'Rails view helpers for search engine optimization (SEO)'
14
+ spec.homepage = 'https://github.com/rubysamurai/seo_rails_helpers'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.9'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'rspec-rails', '~> 3.3'
25
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: seo_rails_helpers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dmitriy Tarasov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-07-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.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: '3.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.3'
55
+ description: Rails view helpers for search engine optimization (SEO)
56
+ email:
57
+ - info@rubysamurai.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - CHANGELOG.md
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - lib/seo_rails_helpers.rb
73
+ - lib/seo_rails_helpers/helpers/seo_page_title_helper.rb
74
+ - lib/seo_rails_helpers/railtie.rb
75
+ - lib/seo_rails_helpers/version.rb
76
+ - seo_rails_helpers.gemspec
77
+ homepage: https://github.com/rubysamurai/seo_rails_helpers
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.4.7
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Rails view helpers for search engine optimization (SEO)
101
+ test_files: []