seo_fuel 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in seo-fuel.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Henk Meijer
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,55 @@
1
+ # SEO Fuel: easily gas up search engines
2
+ SEO Fuel is a super easy way to manage SEO tags in your Rails App. It doesn't require any adjustments to existing models or controllers.
3
+
4
+ SEO Fuel works by adding a form with SEO settings (title, description, etc.) to every single page of your app. This form is hidden, but pops up when you hit the button. The SEO settings aren't linked to a page by foreign keys, but rather by path ('/articles/1-article-title')
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'seo_fuel'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install seo_fuel
19
+
20
+ ## Usage
21
+ After installation, run these commands:
22
+
23
+ $ rails generate seo_fuel
24
+ $ bundle exec rake db:migrate
25
+
26
+ this will generate a database migration to add a SeoTag table, it will also update your routes and add the .yml file for configuration.
27
+
28
+ Add these lines to your assets manifest files
29
+
30
+ # in appcliation.css
31
+ *= require seo_fuel
32
+
33
+ # in appcliation.js
34
+ //= require seo_fuel
35
+
36
+ ### Implementation in views
37
+ Replace the title, description and keywords tags for these methods:
38
+
39
+ <%= show_title %>
40
+ <%= show_description %>
41
+ <%= show_keywords %>
42
+
43
+ Display the edit button and the form on every page, by including these commands on the bottom of your application.html.erb (just above the closing body tag)
44
+
45
+ <%= edit_seo_button %>
46
+ <%= edit_seo_dialog %>
47
+
48
+
49
+ ## Contributing
50
+
51
+ 1. Fork it
52
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
53
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
54
+ 4. Push to the branch (`git push origin my-new-feature`)
55
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ class SeoTagsController < ApplicationController
2
+
3
+ def create
4
+ @tag = SeoTag.find_or_create_by_path(params[:path])
5
+ @tag.update_attributes(params[:seo_tag])
6
+ respond_to do |format|
7
+ format.js
8
+ format.html {redirect_to params[:path]}
9
+ end
10
+ end
11
+
12
+ def update
13
+ @tag = SeoTag.find_or_create_by_path(params[:path])
14
+ @tag.update_attributes(params[:seo_tag])
15
+ respond_to do |format|
16
+ format.js
17
+ format.html {redirect_to params[:path]}
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,12 @@
1
+ class SeoTag < ActiveRecord::Base
2
+ attr_accessible :title, :description, :keywords, :canonical, :open_graph, :path, :use_project_title
3
+ serialize :open_graph
4
+
5
+ def show_title
6
+ title
7
+ end
8
+
9
+ def exists?
10
+ !new_record?
11
+ end
12
+ end
@@ -0,0 +1 @@
1
+ <meta name="description" content="<%= current_page.description %>">
@@ -0,0 +1 @@
1
+ <meta name="keywords" content="<%= current_page.keywords %>">
@@ -0,0 +1,17 @@
1
+ <div id="edit_seo_dialog" class="seo_fuel" style="display: none;">
2
+ <%= form_for SeoTag.find_or_initialize_by_path(request.path), remote: true, html: {class: "seo_form"} do |f|%>
3
+ <%= f.hidden_field :path %>
4
+ <%= f.label :title, "#{I18n.t('seo.form.title')}".html_safe %>
5
+ <%= f.text_field :title %>
6
+ <div class="spacer"></div>
7
+ <%= f.label :description, "#{I18n.t('seo.form.description')}".html_safe %>
8
+ <%= f.text_area :description, rows: 3 %>
9
+ <div class="spacer"></div>
10
+ <%= f.label :keywords, "#{I18n.t('seo.form.keywords')}".html_safe %>
11
+ <%= f.text_area :keywords, rows: 3 %>
12
+ <div class="spacer"></div>
13
+ <%= link_to I18n.t('seo.cancel'), "#", id: "cancel_seo_btn"%>
14
+ <%= f.submit I18n.t('seo.save')%>
15
+ <% end %>
16
+
17
+ </div>
@@ -0,0 +1 @@
1
+ <title><%= current_page.title %></title>
@@ -0,0 +1 @@
1
+ hideSeoForm();
@@ -0,0 +1,2 @@
1
+ hideSeoForm();
2
+ $('title').text('<%= @tag.show_title %>');
@@ -0,0 +1,2 @@
1
+ en:
2
+
@@ -0,0 +1,11 @@
1
+ nl:
2
+ seo:
3
+ button_text: "Bewerk SEO opties"
4
+ cancel: "Annuleer"
5
+ save: "Opslaan"
6
+ form:
7
+ title: "Title tag"
8
+ title_tip: "De tekst die als titel van de pagina wordt ingesteld. Is te zien boven in je browserscherm."
9
+ description: "Description tag"
10
+ description_tip: "Omschrijf waar deze pagina over gaat. Deze tekst wordt vaak getoond in Google."
11
+ keywords: Keywords
data/config/routes.rb ADDED
File without changes
@@ -0,0 +1,4 @@
1
+ SEO_FUEL_SETTINGS:
2
+ seperator: |
3
+ default_title: "Your Website Name"
4
+ default_description: Give a discription of your website
@@ -0,0 +1,54 @@
1
+ require 'rails/generators/active_record/migration'
2
+
3
+ class SeoFuelGenerator < Rails::Generators::Base
4
+ include Rails::Generators::Migration
5
+ extend ActiveRecord::Generators::Migration
6
+
7
+ desc "Put the JavaScript and migration in place"
8
+ source_root File.join(File.dirname(__FILE__), "templates")
9
+
10
+ def install
11
+ copy_javascript if needs_js_copied?
12
+ copy_options_file
13
+ route("resources :seo_tags")
14
+ migration_template "migration.rb", "db/migrate/create_seo_fuel.rb"
15
+ end
16
+
17
+ private
18
+
19
+ def gsub_file(relative_destination, regexp, *args, &block)
20
+ path = destination_path(relative_destination)
21
+ content = File.read(path).gsub(regexp, *args, &block)
22
+ File.open(path, 'wb') { |file| file.write(content) }
23
+ end
24
+
25
+ def copy_options_file
26
+ copy_file File.join(config_path, 'seo_fuel_settings.yml'), config_destination
27
+ end
28
+
29
+ def copy_javascript
30
+ copy_file File.join(javascript_path, 'seo_fuel.js'), js_destination
31
+ end
32
+
33
+ def config_path
34
+ File.join(%w(.. .. .. config))
35
+ end
36
+
37
+ def javascripts_path
38
+ File.join(%w(.. .. .. vendor assets javascripts))
39
+ end
40
+
41
+ def needs_js_copied?
42
+ ::Rails.version < '3.1' || !::Rails.application.config.assets.enabled
43
+ end
44
+
45
+ def js_destination
46
+ 'public/javascripts/seo_fuel.js'
47
+ end
48
+
49
+ def config_destination
50
+ 'config/seo_fuel_settings.yml'
51
+ end
52
+
53
+
54
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Copies the migration file into the application.
3
+
4
+ Example:
5
+ rails generate seo_fuel
6
+
7
+ This will create:
8
+ db/migrate/create_seo_fuel.rb
@@ -0,0 +1,20 @@
1
+ class CreateSeoFuel < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :seo_tags do |t|
4
+ t.string :title
5
+ t.string :description
6
+ t.text :keywords
7
+ t.string :canonical
8
+ t.text :open_graph
9
+ t.string :path
10
+ t.boolean :use_project_title
11
+ t.timestamps
12
+ end
13
+
14
+ add_index :seo_tags, :path
15
+ end
16
+
17
+ def self.down
18
+ drop_table :seo_tags
19
+ end
20
+ end
data/lib/seo_fuel.rb ADDED
@@ -0,0 +1,16 @@
1
+ require 'action_controller'
2
+ require 'action_view'
3
+
4
+ module SeoFuel
5
+ module Rails
6
+ class Engine < ::Rails::Engine
7
+ end
8
+ end
9
+ end
10
+
11
+ require 'seo_fuel/version'
12
+ require 'seo_fuel/view_helper'
13
+ require 'seo_fuel/controller_helper'
14
+
15
+ ActionView::Base.send :include, SeoFuel::ViewHelper
16
+ ActionController::Base.send :include, SeoFuel::ControllerHelper
@@ -0,0 +1,48 @@
1
+ module SeoFuel
2
+ # Contains methods to use in controllers.
3
+ #
4
+ # You can define several instance variables to set meta tags:
5
+ # @page_title = 'Member Login'
6
+ # @page_description = 'Member login page.'
7
+ # @page_keywords = 'Site, Login, Members'
8
+ #
9
+ # Also you can use {InstanceMethods#set_meta_tags} method, that have the same parameters
10
+ # as {ViewHelper#set_meta_tags}.
11
+ #
12
+ module ControllerHelper
13
+ def self.included(base)
14
+ base.send :include, InstanceMethods
15
+ base.alias_method_chain :render, :meta_tags
16
+ end
17
+
18
+ module InstanceMethods
19
+ # Processes the <tt>@page_title</tt>, <tt>@page_keywords</tt>, and
20
+ # <tt>@page_description</tt> instance variables and calls +render+.
21
+ def render_with_meta_tags(*args, &block)
22
+ meta_tags = {}
23
+ meta_tags[:title] = @page_title if @page_title
24
+ meta_tags[:keywords] = @page_keywords if @page_keywords
25
+ meta_tags[:description] = @page_description if @page_description
26
+ set_meta_tags(meta_tags)
27
+
28
+ render_without_meta_tags(*args, &block)
29
+ end
30
+
31
+ # Set meta tags for the page.
32
+ #
33
+ # See <tt>MetaTags.set_meta_tags</tt> for details.
34
+ def set_meta_tags(meta_tags)
35
+ meta_tags ||= {}
36
+ meta_tags[:open_graph] = meta_tags.delete(:og) if meta_tags.key?(:og)
37
+ self.meta_tags.deep_merge!(meta_tags || {})
38
+ end
39
+ protected :set_meta_tags
40
+
41
+ # Get meta tags for the page.
42
+ def meta_tags
43
+ @meta_tags ||= {}
44
+ end
45
+ protected :meta_tags
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,3 @@
1
+ module SeoFuel
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,32 @@
1
+ module SeoFuel
2
+ # Contains methods to use in views and helpers.
3
+ #
4
+
5
+ module ViewHelper
6
+
7
+ def edit_seo_button(text=I18n.t('seo.button_text'), klass="")
8
+ link_to text, "#", class: "seo_fuel #{klass}", id: "edit_seo_btn"
9
+ end
10
+
11
+ def edit_seo_dialog
12
+ render :partial => "seo_tags/seo_options"
13
+ end
14
+
15
+ def current_page
16
+ SeoTag.find_by_path(request.path)
17
+ end
18
+
19
+ def show_title
20
+ render :partial => "seo_tags/title"
21
+ end
22
+
23
+ def show_description
24
+ render :partial => "seo_tags/description"
25
+ end
26
+
27
+ def show_keywords
28
+ render :partial => "seo_tags/keywords"
29
+ end
30
+
31
+ end
32
+ end
data/seo_fuel.gemspec ADDED
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/seo_fuel/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Henk Meijer"]
6
+ gem.email = ["meijerhenk@gmail.com"]
7
+ gem.description = ["Customize the SEO options for every single page of your rails app. Each url has its own SEO options."]
8
+ gem.summary = ["Add exstensive SEO options to every page on your website."]
9
+ gem.homepage = "https://github.com/henkm/seo_fuel"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+
15
+ gem.add_development_dependency "rake"
16
+
17
+ gem.name = "seo_fuel"
18
+ gem.require_paths = ["lib"]
19
+ gem.version = SeoFuel::VERSION
20
+ end
@@ -0,0 +1,16 @@
1
+ $(document).ready(function() {
2
+ $('#edit_seo_btn').bind('click', function() {
3
+ $('#edit_seo_btn').slideUp();
4
+ $('#edit_seo_dialog').slideDown();
5
+ });
6
+
7
+ $('#cancel_seo_btn, #save_seo_tag').bind('click', function() {
8
+ hideSeoForm();
9
+ });
10
+
11
+ });
12
+
13
+ function hideSeoForm(){
14
+ $('#edit_seo_dialog').slideUp();
15
+ $('#edit_seo_btn').slideDown();
16
+ }
@@ -0,0 +1,93 @@
1
+ .seo_fuel {
2
+ font-family: arial;
3
+ }
4
+
5
+ #edit_seo_btn {
6
+ text-align: center;
7
+ position: fixed;
8
+ top: -5px;
9
+ left: 50%;
10
+ margin-left: -75px;
11
+ width: 150px;
12
+ background: #fff;
13
+ border: 1px solid #dedede;
14
+ padding-bottom: 4px;
15
+ padding-top: 10px;
16
+ background-image: linear-gradient(bottom, rgb(166,166,166) 6%, rgb(217,217,217) 56%);
17
+ background-image: -o-linear-gradient(bottom, rgb(166,166,166) 6%, rgb(217,217,217) 56%);
18
+ background-image: -moz-linear-gradient(bottom, rgb(166,166,166) 6%, rgb(217,217,217) 56%);
19
+ background-image: -webkit-linear-gradient(bottom, rgb(166,166,166) 6%, rgb(217,217,217) 56%);
20
+ background-image: -ms-linear-gradient(bottom, rgb(166,166,166) 6%, rgb(217,217,217) 56%);
21
+
22
+ background-image: -webkit-gradient(
23
+ linear,
24
+ left bottom,
25
+ left top,
26
+ color-stop(0.06, rgb(166,166,166)),
27
+ color-stop(0.56, rgb(217,217,217))
28
+ );
29
+ -webkit-border-radius: 3px;
30
+ -moz-border-radius: 3px;
31
+ border-radius: 3px;
32
+ -webkit-box-shadow: 0px 0px 2px 2px #dedede;
33
+ box-shadow: 0px 0px 2px 2px #dedede;
34
+
35
+ border: 1px solid #aaa;
36
+
37
+ font-family: arial;
38
+ text-decoration: none;
39
+ color: #fff;
40
+
41
+ text-shadow: 1px 1px 0px #333;
42
+ filter: dropshadow(color=#333, offx=1, offy=1);
43
+ }
44
+
45
+ #edit_seo_dialog {
46
+
47
+ width: 800px;
48
+ background: #fff;
49
+ position: fixed;
50
+ top: -3px;
51
+ left: 50%;
52
+ padding: 5px;
53
+ padding-top: 15px;
54
+ margin-left: -400px;
55
+ border: 1px solid #dedede;
56
+ -webkit-border-radius: 3px;
57
+ -moz-border-radius: 3px;
58
+ border-radius: 3px;
59
+ -webkit-box-shadow: 0px 0px 2px 2px #dedede;
60
+ box-shadow: 0px 0px 2px 2px #dedede;
61
+
62
+
63
+ opacity:0.8;
64
+ filter:alpha(opacity=80); /* For IE8 and earlier */
65
+ }
66
+
67
+ .spacer{clear:both; height:1px;}
68
+
69
+ .seo_form label {
70
+ float: left;
71
+ width: 150px;
72
+ text-align: right;
73
+ margin-right: 15px;
74
+ }
75
+
76
+ .seo_form input, .seo_form textarea {
77
+ float: left;
78
+ clear: right;
79
+ width: 600px;
80
+ max-width: 600px;
81
+ border: 1px solid #dedede;
82
+ padding: 5px;
83
+ size: 18px;
84
+ }
85
+ .seo_form input[type=submit] {
86
+ float: right;
87
+ width: 150px;
88
+ }
89
+ #cancel_seo_btn {
90
+ float: left;
91
+ text-decoration: none;
92
+ color: #333;
93
+ }
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: seo_fuel
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Henk Meijer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: ! '["Customize the SEO options for every single page of your rails app.
31
+ Each url has its own SEO options."]'
32
+ email:
33
+ - meijerhenk@gmail.com
34
+ executables: []
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - .gitignore
39
+ - Gemfile
40
+ - LICENSE
41
+ - README.md
42
+ - Rakefile
43
+ - app/controllers/seo_tags_controller.rb
44
+ - app/models/seo_tag.rb
45
+ - app/views/seo_tags/_description.html.erb
46
+ - app/views/seo_tags/_keywords.html.erb
47
+ - app/views/seo_tags/_seo_options.html.erb
48
+ - app/views/seo_tags/_title.html.erb
49
+ - app/views/seo_tags/create.js.erb
50
+ - app/views/seo_tags/update.js.erb
51
+ - config/locales/en.yml
52
+ - config/locales/nl.yml
53
+ - config/routes.rb
54
+ - config/seo_fuel_settings.yml
55
+ - lib/generators/seo_fuel_generator.rb
56
+ - lib/generators/templates/USAGE
57
+ - lib/generators/templates/migration.rb
58
+ - lib/seo_fuel.rb
59
+ - lib/seo_fuel/controller_helper.rb
60
+ - lib/seo_fuel/version.rb
61
+ - lib/seo_fuel/view_helper.rb
62
+ - seo_fuel.gemspec
63
+ - vendor/assets/javascripts/seo_fuel.js
64
+ - vendor/assets/stylesheets/seo_fuel.css
65
+ homepage: https://github.com/henkm/seo_fuel
66
+ licenses: []
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 1.8.24
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: ! '["Add exstensive SEO options to every page on your website."]'
89
+ test_files: []
90
+ has_rdoc: