html_meta_tags 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3c22711e9645bc635fb03223c58171ea5e3ac0f8
4
+ data.tar.gz: d2467942f05ee00e8b5cfadf5ed2fa6765f79de5
5
+ SHA512:
6
+ metadata.gz: 22da8b542d298cb2dbae0dca8d6ba7c66c6a6ae1419eb3c50f80e2b02f6b0b8a2b82b80eb8e1e34b765f2806ee87db5307f305de6a2be751192f7676e11c6b21
7
+ data.tar.gz: 0311597dc5fc10ebab5350820e167a297b6b894495281c47dd3cb1e541c4dd489b0f4076e61b49df89d61ba1cd68b80dd9fa0eb7e48358ef8c80a4917bff78e5
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in seo_landing_pages.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Joaquin Rivera Padron
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,132 @@
1
+ # SEO Landing Pages
2
+
3
+ Create and manage your SEO landing pages easily.
4
+
5
+ SEO gives great importance to 3 html elements in the html head: title, meta
6
+ description and meta keywords (to a lesser extent).
7
+
8
+ This gem lets you easily:
9
+
10
+ - create landing pages identified by their path
11
+ - edit their title, description and keywords
12
+ - render them easily in your views with provided helpers
13
+ - have your SEO guru love you :-)
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ gem 'seo_landing_pages'
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install seo_landing_pages
28
+
29
+ ## Usage
30
+
31
+ ### The landing pages data
32
+
33
+ Use the generator provided to create the landing pages table
34
+
35
+ $ rails g seo_landing_pages migration
36
+
37
+ run the migration and you should be ready to create landing pages, an example
38
+ in the rails console would be:
39
+
40
+ > SeoLandingPages::Model.create! slug: '/', title: 'SEO landing pages FTW'
41
+
42
+ *Note* the `slug` must be given and be unique.
43
+
44
+ It's your work now to determine which pages you want to create, e.g. for your
45
+ blog, listings page, etc.
46
+
47
+ ### Configure the controller
48
+
49
+ Configure your `ApplicationController` by running:
50
+
51
+ $ rails g seo_landing_pages controller
52
+
53
+ That will include the module `SeoLandingPages::Controllers::Helpers` in your controller,
54
+ the module provides a method `seo_current_landing_page` which finds a Landing Page
55
+ matching the request path (`/` in the example), and also will make view helpers
56
+ available for your views.
57
+
58
+ For advanced options of how to match Landing Pages check the module mentioned.
59
+
60
+ ### Landing pages in the views
61
+
62
+ To show the SEO data in your views there are handy view helpers available, add
63
+ to your views layout in the head section:
64
+
65
+ ```ruby
66
+ = seo_landing_page_title_tag
67
+ = seo_landing_page_description_tag
68
+ = seo_landing_page_keywords_tag
69
+ ```
70
+
71
+ these add the proper HTML tags, visit your home page and the title
72
+ `SEO Landing Pages FTW` should be showing in your HTML.
73
+
74
+ There are also helpers to access the landing pages attributes without the HTML
75
+ tag for you to concatenate them or so.
76
+
77
+ ```ruby
78
+ = seo_landing_page_title
79
+ = seo_landing_page_description
80
+ = seo_landing_page_keywords
81
+ ```
82
+
83
+ ### Internationalization support
84
+
85
+ For internationalization, instead of writing plain text in the title, description
86
+ and keywords write i18n keys, e.g. a landing page for your home page:
87
+
88
+ > SeoLandingPages::Model.create! slug: '/', title: 'title_home_page',
89
+ description: 'description_home_page',
90
+ keywords: 'keywords_home_page'
91
+
92
+ Create the translations in your locale files. Then use the view helpers like this:
93
+
94
+ ```ruby
95
+ = seo_landing_page_title_tag i18n: true
96
+ = seo_landing_page_description_tag i18n: true
97
+ = seo_landing_page_keywords_tag i18n: true
98
+ ```
99
+
100
+ Now your pages have the HTML elements localized.
101
+
102
+ ### Admin section
103
+
104
+ There's an Active Admin view provided, to get it run:
105
+
106
+ $ rails g seo_landing_pages active_admin
107
+
108
+ $ rails g seo_landing_pages i18n
109
+
110
+ and let your SEO guru float in love waves editing all the Landing Pages and seeing
111
+ traffic increasing for your website.
112
+
113
+ ## TODO
114
+
115
+ - write another CRUD admin section for those not using Active Admin, or accept
116
+ a Pull Request having it ;-)
117
+ - fix the TODOs in the code
118
+ - write tests
119
+
120
+ ## Contributing
121
+
122
+ 1. Fork it ( https://github.com/joahking/seo_landing_pages/fork )
123
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
124
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
125
+ 4. Push to the branch (`git push origin my-new-feature`)
126
+ 5. Create a new Pull Request
127
+
128
+ ## Credits
129
+
130
+ This gem was developed in the [Hack Week at XING Barcelona](https://twitter.com/hashtag/hackweekxing),
131
+ Big thanks to XING for providing the time to see ideas being realized.
132
+
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,14 @@
1
+ Description:
2
+ Generates migration and boilerplate code for the landing pages
3
+
4
+ Example:
5
+ rails generate seo_landing_pages migration
6
+
7
+ This will create:
8
+ the migration to create the landing pages table
9
+
10
+ rails generate seo_landing_pages active_admin
11
+
12
+ This will create:
13
+ the boilerplate code to administer your landing pages with Active Admin
14
+
@@ -0,0 +1,42 @@
1
+ require 'rails/generators/active_record'
2
+
3
+ class SeoLandingPagesGenerator < ActiveRecord::Generators::Base
4
+ source_root File.expand_path('../templates', __FILE__)
5
+
6
+ #TODO all the methods run now, turn them into options, as Thor intended :-)
7
+
8
+ # Public: copies the migration.
9
+ def migration
10
+ migration_template 'migration.rb', 'db/migrate/create_seo_landing_pages.rb'
11
+ end
12
+
13
+ # Public: configures the application controller to include the Helpers module.
14
+ def controller
15
+ inject_into_class 'app/controllers/application_controller.rb', ApplicationController do
16
+ " include SeoLandingPages::Controllers::Helpers\n\n"
17
+ end
18
+ end
19
+
20
+ # Public: copies the active admin boilerplate code.
21
+ def active_admin
22
+ copy_file 'active_admin.rb', 'app/admin/seo_landing_pages.rb'
23
+ end
24
+
25
+ # Public: copies the i18n files.
26
+ def i18n
27
+ %w(en es).each do |locale|
28
+ copy_file "i18n.#{ locale }.yml", "config/locales/seo_landing_pages.#{ locale }.yml"
29
+ end
30
+ end
31
+
32
+ # Public: adds an admin route to the router.
33
+ def route
34
+ #TODO
35
+ end
36
+
37
+ # Public: copies the CRUD admin code.
38
+ def admin
39
+ #TODO
40
+ end
41
+ end
42
+
@@ -0,0 +1,41 @@
1
+ ActiveAdmin.register SeoLandingPages::Model do
2
+
3
+ permit_params :slug, :title, :description, :keywords
4
+
5
+ index do
6
+ column :slug do |landing_page|
7
+ link_to landing_page.slug, landing_page.slug, target: :blank
8
+ end
9
+ column :title
10
+ column :description
11
+ column :keywords
12
+ default_actions
13
+ end
14
+
15
+ filter :slug
16
+
17
+ form do |f|
18
+ f.inputs "SEO Landing Page" do
19
+ f.input :slug
20
+ f.input :title
21
+ f.input :description, as: :text
22
+ f.input :keywords, as: :text
23
+ end
24
+ f.actions
25
+ end
26
+
27
+ show do |landing_page|
28
+ attributes_table do
29
+ row :slug do
30
+ link_to landing_page.slug, landing_page.slug, target: :blank
31
+ end
32
+ row :title
33
+ row :description
34
+ row :keywords
35
+ row :created_at
36
+ row :updated_at
37
+ end
38
+ end
39
+
40
+ end
41
+
@@ -0,0 +1,7 @@
1
+ en:
2
+ activerecord:
3
+ models:
4
+ seo_landing_pages/model:
5
+ one: 'SEO Landing Page'
6
+ other: 'SEO Landing Pages'
7
+
@@ -0,0 +1,10 @@
1
+ es:
2
+ activerecord:
3
+ models:
4
+ seo_landing_pages/model:
5
+ one: 'Página SEO'
6
+ other: 'Páginas SEO'
7
+ attributes:
8
+ seo_landing_pages/model:
9
+ slug: 'URL'
10
+
@@ -0,0 +1,14 @@
1
+ class CreateSeoLandingPages < ActiveRecord::Migration
2
+ def change
3
+ create_table :seo_landing_pages do |t|
4
+ t.string :slug
5
+ t.string :title
6
+ t.string :description
7
+ t.string :keywords
8
+
9
+ t.timestamps null: false
10
+ end
11
+ add_index :seo_landing_pages, :slug
12
+ end
13
+ end
14
+
@@ -0,0 +1,12 @@
1
+ require 'seo_landing_pages/version'
2
+
3
+ module SeoLandingPages
4
+ autoload :Model, 'seo_landing_pages/model'
5
+
6
+ module Controllers
7
+ autoload :Helpers, 'seo_landing_pages/controllers/helpers'
8
+ end
9
+
10
+ autoload :Helper, 'seo_landing_pages/helper'
11
+ end
12
+
@@ -0,0 +1,41 @@
1
+ # Public: helper methods for ApplicationController.
2
+ #
3
+ # Include this module in your controllers to gain access to the landing page
4
+ # in your views.
5
+ #
6
+ module SeoLandingPages
7
+ module Controllers
8
+ module Helpers
9
+ extend ActiveSupport::Concern
10
+
11
+ included do
12
+ helper SeoLandingPages::Helper
13
+ helper_method :seo_current_landing_page
14
+ end
15
+
16
+ # Public: returns the current landing page.
17
+ # The landing page is matched by the request path, check the method
18
+ # seo_request_path for details on how to change the matching.
19
+ def seo_current_landing_page
20
+ @seo_current_landing_page ||= SeoLandingPages::Model.where(slug: seo_request_path).first
21
+ end
22
+
23
+ protected
24
+
25
+ # Internal: the request path is used to match landing pages.
26
+ #
27
+ # Override this method in your controllers to change the way the landing
28
+ # pages are matched.
29
+ #
30
+ # Example: the request path is '/blog?search=XYZ', to handle all blog pages
31
+ # as the same landing page (e.g. '/blog') change this method in your
32
+ # blogs_controller to remove everything after the '?'
33
+ #
34
+ def seo_request_path
35
+ request.path
36
+ end
37
+
38
+ end
39
+ end
40
+ end
41
+
@@ -0,0 +1,78 @@
1
+ # Public: helpers for your views.
2
+ module SeoLandingPages
3
+ module Helper
4
+
5
+ # Public: html title tag with the landing page title.
6
+ # - i18n: false = render plain text title. This is the default.
7
+ # true = title is an i18n key, so translate it.
8
+ # If the landing page title is empty it returns nothing.
9
+ def seo_landing_page_title_tag(i18n: false)
10
+ title = seo_landing_page_title i18n: i18n
11
+ if title.present?
12
+ "<title>#{ title }</title>".html_safe
13
+ end
14
+ end
15
+
16
+ # Public: landing page title.
17
+ # - i18n: false = render plain text title. This is the default.
18
+ # true = title is an i18n key, so translate it.
19
+ def seo_landing_page_title(i18n: false)
20
+ if seo_current_landing_page
21
+ title = seo_current_landing_page.title
22
+ if title.present?
23
+ i18n ? t(title) : title
24
+ end
25
+ end
26
+ end
27
+
28
+ # Public: html description meta tag with the landing page description.
29
+ # - i18n: false = render plain text description. This is the default.
30
+ # true = description is an i18n key, so translate it.
31
+ # If the landing page description is empty it returns nothing.
32
+ def seo_landing_page_description_tag(i18n: false)
33
+ description = seo_landing_page_description i18n: i18n
34
+ if description.present?
35
+ "<meta name='description' content='#{ description }'/>".html_safe
36
+ end
37
+ end
38
+
39
+ # Public: landing page description.
40
+ # - i18n: false = render plain text description. This is the default.
41
+ # true = description is an i18n key, so translate it.
42
+ # If the landing page description is empty it returns nothing.
43
+ def seo_landing_page_description(i18n: false)
44
+ if seo_current_landing_page
45
+ description = seo_current_landing_page.description
46
+ if description.present?
47
+ i18n ? t(description) : description
48
+ end
49
+ end
50
+ end
51
+
52
+ # Public: html keywords meta tag with the landing page keywords.
53
+ # - i18n: false = render plain text keywords. This is the default.
54
+ # true = keywords is an i18n key, so translate it.
55
+ # If the landing page keywords is empty it returns nothing.
56
+ def seo_landing_page_keywords_tag(i18n: false)
57
+ keywords = seo_landing_page_keywords i18n: i18n
58
+ if keywords.present?
59
+ "<meta name='keywords' content='#{ keywords }'/>".html_safe
60
+ end
61
+ end
62
+
63
+ # Public: landing page keywords.
64
+ # - i18n: false = render plain text keywords. This is the default.
65
+ # true = keywords is an i18n key, so translate it.
66
+ # If the landing page keywords is empty it returns nothing.
67
+ def seo_landing_page_keywords(i18n: false)
68
+ if seo_current_landing_page
69
+ keywords = seo_current_landing_page.keywords
70
+ if keywords.present?
71
+ i18n ? t(keywords) : keywords
72
+ end
73
+ end
74
+ end
75
+
76
+ end
77
+ end
78
+
@@ -0,0 +1,10 @@
1
+ module SeoLandingPages
2
+ class Model < ActiveRecord::Base
3
+ # TODO make table_name configurable and use it
4
+ self.table_name = 'seo_landing_pages'
5
+
6
+ # TODO test this
7
+ validates :slug, presence: true, uniqueness: true
8
+ end
9
+ end
10
+
@@ -0,0 +1,4 @@
1
+ module SeoLandingPages
2
+ VERSION = '0.2.2'
3
+ end
4
+
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'seo_landing_pages/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'html_meta_tags'
8
+ spec.version = SeoLandingPages::VERSION
9
+ spec.authors = ['Joaquin Rivera Padron']
10
+ spec.email = ['joahking@gmail.com']
11
+ spec.summary = %q{Manage HTML meta tags in rails admin area to improve SEO.}
12
+ spec.description = %q{Manage HTML meta tags in rails admin area to improve SEO, manage their i18n title, description and keywords in Rails easily.}
13
+ spec.homepage = 'https://github.com/joahking/html-meta-tags'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+ spec.required_ruby_version = '~> 2'
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.6'
23
+ spec.add_development_dependency 'rake', '~> 10'
24
+
25
+ spec.add_dependency 'railties', '>= 3.2.6', '< 5'
26
+ end
27
+
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: html_meta_tags
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
5
+ platform: ruby
6
+ authors:
7
+ - Joaquin Rivera Padron
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-01-11 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.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
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'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: railties
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 3.2.6
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '5'
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 3.2.6
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '5'
61
+ description: Manage HTML meta tags in rails admin area to improve SEO, manage their
62
+ i18n title, description and keywords in Rails easily.
63
+ email:
64
+ - joahking@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - ".gitignore"
70
+ - Gemfile
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - lib/generators/USAGE
75
+ - lib/generators/seo_landing_pages_generator.rb
76
+ - lib/generators/templates/active_admin.rb
77
+ - lib/generators/templates/i18n.en.yml
78
+ - lib/generators/templates/i18n.es.yml
79
+ - lib/generators/templates/migration.rb
80
+ - lib/seo_landing_pages.rb
81
+ - lib/seo_landing_pages/controllers/helpers.rb
82
+ - lib/seo_landing_pages/helper.rb
83
+ - lib/seo_landing_pages/model.rb
84
+ - lib/seo_landing_pages/version.rb
85
+ - seo_landing_pages.gemspec
86
+ homepage: https://github.com/joahking/html-meta-tags
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - "~>"
97
+ - !ruby/object:Gem::Version
98
+ version: '2'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.2.2
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Manage HTML meta tags in rails admin area to improve SEO.
110
+ test_files: []