seo_landing_pages 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: 77d15341615a1eaef42e7ea13588d6837ff9da30
4
+ data.tar.gz: 0f38fd88a97ad81d5df5b3f4b32525686a97c1b3
5
+ SHA512:
6
+ metadata.gz: ae1473d234033c963fa61655ce458902e0e57ecad76b31492e2f643e148e9bbffcaac25148991ef99f1cd62e8b39e97add4b50a0885c3b0b9b394f81f200141e
7
+ data.tar.gz: 20ab9063e8686716e5d67378617abcc9a6e6996ba8ef428e1b877ee6b1f3eef4db8c883d6fc450e3ffc16069a770b966c5501cdeffe747cbd8d8f4bc8e2099d3
data/.gitignore ADDED
@@ -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
data/LICENSE.txt ADDED
@@ -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.
data/README.md ADDED
@@ -0,0 +1,111 @@
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
+ ### Admin section
84
+
85
+ There's an Active Admin view provided, to get it run:
86
+
87
+ $ rails g seo_landing_pages active_admin
88
+
89
+ $ rails g seo_landing_pages i18n
90
+
91
+ and let your SEO guru float in love waves editing all the Landing Pages and seeing
92
+ traffic increasing for your website.
93
+
94
+ ## TODO
95
+
96
+ - write another CRUD admin section for those not using Active Admin
97
+ - write tests
98
+
99
+ ## Credits
100
+
101
+ This gem was developed in the [Hack Week at XING Barcelona](http://www.xing.com), Big
102
+ thanks to XING for providing the time to see ideas being realized.
103
+
104
+ ## Contributing
105
+
106
+ 1. Fork it ( https://github.com/joahking/seo_landing_pages/fork )
107
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
108
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
109
+ 4. Push to the branch (`git push origin my-new-feature`)
110
+ 5. Create a new Pull Request
111
+
data/Rakefile ADDED
@@ -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
10
+ end
11
+ add_index :seo_landing_pages, :slug
12
+ end
13
+ end
14
+
@@ -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,52 @@
1
+ # Public: helpers for your views.
2
+ module SeoLandingPages
3
+ module Helper
4
+
5
+ # Public: html title tag with the landing page title.
6
+ # If the landing page title is empty it returns nothing.
7
+ def seo_landing_page_title_tag
8
+ if seo_landing_page_title
9
+ "<title>#{ seo_landing_page_title }</title>".html_safe
10
+ end
11
+ end
12
+
13
+ # Public: landing page title.
14
+ def seo_landing_page_title
15
+ if seo_current_landing_page
16
+ seo_current_landing_page.title
17
+ end
18
+ end
19
+
20
+ # Public: html description meta tag with the landing page description.
21
+ # If the landing page description is empty it returns nothing.
22
+ def seo_landing_page_description_tag
23
+ if seo_landing_page_description
24
+ "<meta name='description' content='#{ seo_landing_page_description }'/>".html_safe
25
+ end
26
+ end
27
+
28
+ # Public: landing page description.
29
+ def seo_landing_page_description
30
+ if seo_current_landing_page
31
+ seo_current_landing_page.description
32
+ end
33
+ end
34
+
35
+ # Public: html keywords meta tag with the landing page keywords.
36
+ # If the landing page keywords is empty it returns nothing.
37
+ def seo_landing_page_keywords_tag
38
+ if seo_landing_page_keywords
39
+ "<meta name='keywords' content='#{ seo_landing_page_keywords }'/>".html_safe
40
+ end
41
+ end
42
+
43
+ # Public: landing page keywords.
44
+ def seo_landing_page_keywords
45
+ if seo_current_landing_page
46
+ seo_current_landing_page.keywords
47
+ end
48
+ end
49
+
50
+ end
51
+ end
52
+
@@ -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.1.0'
3
+ end
4
+
@@ -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,26 @@
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 = 'seo_landing_pages'
8
+ spec.version = SeoLandingPages::VERSION
9
+ spec.authors = ['Joaquin Rivera Padron']
10
+ spec.email = ['joahking@gmail.com']
11
+ spec.summary = %q{Manage SEO key elements of landing pages in Rails easily.}
12
+ spec.description = %q{Create landing pages matching your pages, and manage their title, description and keywords in Rails easily.}
13
+ spec.homepage = 'https://github.com/joahking/seo-landing-pages'
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
+
21
+ spec.add_development_dependency 'bundler', '~> 1.6'
22
+ spec.add_development_dependency 'rake', '~> 10'
23
+
24
+ spec.add_dependency 'railties', '>= 3.2.6', '< 5'
25
+ end
26
+
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: seo_landing_pages
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Joaquin Rivera Padron
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-02 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: Create landing pages matching your pages, and manage their title, description
62
+ 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/seo-landing-pages
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: '0'
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 SEO key elements of landing pages in Rails easily.
110
+ test_files: []