seo_fuel 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -44,20 +44,14 @@ Add these lines to your assets manifest files
44
44
  //= require seo_fuel
45
45
 
46
46
  ### Implementation in views
47
- Replace the title, description and keywords tags for these methods:
47
+ Replace the title, description and keywords tags for this method:
48
48
 
49
- <%= show_title %>
50
- <%= show_description %>
51
- <%= show_keywords %>
49
+ <%= show_meta_tags %>
52
50
 
53
51
  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)
54
52
 
55
53
  <%= edit_seo_dialog %>
56
54
 
57
- or, if you wish to only let signed in users be able to see the form (using devse in this example):
58
-
59
- <%= edit_seo_dialog if admin_signed_in? %>
60
-
61
55
  ### Setting default values
62
56
  By default, all meta tags are blank. If a tag is blank, the one specified in `seo_fuel_settings.yml` will be used. Per template, you can specify a default value by adding a few lines of code to your view template. These values take precedence over the default values.
63
57
  The 'in browser' added SEO settings take precedence over all default values.
@@ -69,6 +63,14 @@ The 'in browser' added SEO settings take precedence over all default values.
69
63
  ### I18n
70
64
  This gem is fully I18n adjustable. Just edit the locale file, placed in the locales directory of your Rails app.
71
65
 
66
+
67
+ ## Authentication
68
+ Not all users are allowed to edit SEO settings, obviously. To only let specific users see the SEO form, you can simply use your own restrictions when rendering the form. If only admin users are supposed to see the form (when using Devise), use this:
69
+
70
+ <%= edit_seo_dialog if admin_signed_in? %>
71
+
72
+ Authentication for the Controller layer is added through the key in a hidden field in the form. This random key is set in the `seo_fuel_settings.yml` configuration file. Only when this key matches, the record will be saved. If this form is only visible for signed in admins, they are the only ones that can submit POST requests with the proper key.
73
+
72
74
  ## TODO
73
75
  This gem is in early development, there are still some things to do:
74
76
  - add options for open_graph
@@ -0,0 +1,8 @@
1
+ <title><%= title_to_show %></title>
2
+ <meta name="description" content="<%= description_to_show %>">
3
+ <% if keywords_to_show -%>
4
+ <meta name="keywords" content="<%= keywords_to_show %>">
5
+ <% end -%>
6
+ <% if canonical.present? -%>
7
+ <link rel="canonical" href="<%= canonical %>" />
8
+ <% end -%>
@@ -8,11 +8,23 @@
8
8
  <div class="spacer"></div>
9
9
  <%= f.label :description, "#{I18n.t('seo.form.description')}".html_safe %>
10
10
  <%= f.text_area :description, rows: 3, placeholder: @default_description %>
11
+
11
12
  <div class="spacer"></div>
13
+
14
+ <%= link_to I18n.t('seo.more_options'), "#", id: 'more-options-btn'%>
15
+
16
+ <div style="display: none;" id="more-options">
12
17
  <%= f.label :keywords, "#{I18n.t('seo.form.keywords')}".html_safe %>
13
18
  <%= f.text_area :keywords, rows: 3, placeholder: @default_keywords %>
14
19
  <div class="spacer"></div>
15
- <%= link_to I18n.t('seo.cancel'), "#", id: "cancel_seo_btn"%>
16
- <%= f.submit I18n.t('seo.save')%>
20
+ <%= f.label :canonical, "#{I18n.t('seo.form.canonical')}".html_safe %>
21
+ <%= f.text_field :canonical, placeholder: I18n.t('seo.form.canonical_placeholder') %>
22
+ </div>
23
+ <div class="spacer"></div>
24
+ <div id="seo_buttons">
25
+ <span id="cancel_seo_btn"><%= link_to I18n.t('seo.cancel'), "#" %> of</span>
26
+
27
+ <%= f.submit I18n.t('seo.save')%>
28
+ </div>
17
29
  <% end %>
18
30
  </div>
@@ -1,11 +1,14 @@
1
1
  en:
2
2
  seo:
3
- button_text: "Edit SEO options"
4
- cancel: "Cancel"
5
- save: "Save"
3
+ button_text: Edit SEO options
4
+ cancel: Cancel
5
+ save: Save
6
+ more_options: More options
6
7
  form:
7
- title: "Title tag"
8
+ title: "Title"
8
9
  title_tip: ""
9
- description: "Description tag"
10
+ description: "Description"
10
11
  description_tip: ""
11
- keywords: Keywords
12
+ keywords: Keywords
13
+ canonical: Canonical
14
+ canonical_placeholder: "URL of canoncial page, if applicable"
@@ -1,11 +1,14 @@
1
1
  nl:
2
2
  seo:
3
- button_text: "Bewerk SEO opties"
4
- cancel: "Annuleer"
5
- save: "Opslaan"
3
+ button_text: Bewerk SEO opties
4
+ cancel: Annuleer
5
+ save: Opslaan
6
+ more_options: Meer opties
6
7
  form:
7
8
  title: "Title tag"
8
9
  title_tip: "De tekst die als titel van de pagina wordt ingesteld. Is te zien boven in je browserscherm."
9
10
  description: "Description tag"
10
11
  description_tip: "Omschrijf waar deze pagina over gaat. Deze tekst wordt vaak getoond in Google."
11
- keywords: Keywords
12
+ keywords: Keywords
13
+ canonical: Canonical
14
+ canonical_placeholder: "URL van canoncial pagina, indien van toepassing"
@@ -0,0 +1,6 @@
1
+ SEO_FUEL_SETTINGS:
2
+ seperator: |
3
+ default_title: "Your Website Name"
4
+ default_description: Give a discription of your website
5
+ default_keywords: "enter, your, keywords, here"
6
+ key: "<%= (0...50).map{ ('a'..'z').to_a[rand(26)] }.join %>" # used for authentication in the controller
@@ -11,14 +11,14 @@ class SeoFuelGenerator < Rails::Generators::Base
11
11
  copy_javascript if needs_js_copied?
12
12
  copy_options_file
13
13
  copy_language_file
14
- # route("resources :seo_tags")
15
- # migration_template "migration.rb", "db/migrate/create_seo_fuel.rb"
14
+ route("resources :seo_tags")
15
+ migration_template "migration.rb", "db/migrate/create_seo_fuel.rb"
16
16
  end
17
17
 
18
18
  private
19
19
 
20
20
 
21
- def template(from, to)
21
+ def render_erb_template(from, to)
22
22
  erb = File.read(File.expand_path("../../../config/templates/#{from}", __FILE__))
23
23
  yml = ERB.new(erb).result(binding)
24
24
  File.open(to, 'w') {|f| f.write(yml) }
@@ -32,7 +32,7 @@ class SeoFuelGenerator < Rails::Generators::Base
32
32
  end
33
33
 
34
34
  def copy_options_file
35
- template "seo_fuel_settings.yml.erb", config_destination
35
+ render_erb_template "seo_fuel_settings.yml.erb", config_destination
36
36
  # copy_file File.join(config_path, 'seo_fuel_settings.yml'), config_destination
37
37
  end
38
38
 
@@ -8,6 +8,8 @@ class CreateSeoFuel < ActiveRecord::Migration
8
8
  t.text :open_graph
9
9
  t.string :path
10
10
  t.boolean :use_project_title
11
+ t.boolean :noindex
12
+ t.boolean :nofollow
11
13
  t.timestamps
12
14
  end
13
15
 
@@ -0,0 +1,8 @@
1
+ module SeoFuel
2
+ class Railtie < Rails::Railtie
3
+ initializer "Include your code in the controller" do
4
+ ActiveSupport.on_load(:action_controller) do
5
+ include SeoFuel
6
+ end
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module SeoFuel
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -73,6 +73,12 @@ module SeoFuel
73
73
  default_settings_from_config_file['SEO_FUEL_SETTINGS']['default_title']
74
74
  end
75
75
  end
76
+
77
+ # renders canonical
78
+ def canonical
79
+ current_page.canonical if current_page
80
+ end
81
+
76
82
 
77
83
  # render the dialog box and edit button by calling
78
84
  # `edit_seo_dialog` in the templates that should have this
@@ -100,8 +106,8 @@ module SeoFuel
100
106
  end
101
107
 
102
108
  # renders the keywords inside a `<meta>` tag.
103
- def show_keywords
104
- render :partial => "seo_tags/keywords"
109
+ def show_meta_tags
110
+ render :partial => "seo_tags/meta_tags"
105
111
  end
106
112
 
107
113
  end
Binary file
@@ -7,6 +7,10 @@ $(document).ready(function() {
7
7
  $('#cancel_seo_btn, #save_seo_tag').bind('click', function() {
8
8
  hideSeoForm();
9
9
  });
10
+
11
+ $('#more-options-btn').bind('click', function() {
12
+ $('#more-options').toggle();
13
+ });
10
14
 
11
15
  });
12
16
 
@@ -71,7 +71,9 @@
71
71
  float: left;
72
72
  width: 150px;
73
73
  text-align: right;
74
- margin-right: 15px;
74
+ margin-right: 12px;
75
+ font-size: 12px;
76
+ margin-top: 4px;
75
77
  }
76
78
 
77
79
  .seo_form input, .seo_form textarea {
@@ -84,15 +86,14 @@
84
86
  size: 18px;
85
87
  }
86
88
  .seo_form input[type=submit] {
87
- float: right;
88
89
  width: 150px;
89
- margin-right: 20px;
90
90
  background: #eee;
91
91
  -webkit-border-radius: 3px;
92
92
  -moz-border-radius: 3px;
93
93
  border-radius: 3px;
94
94
  text-shadow: 1px 1px 0px #dedede;
95
95
  filter: dropshadow(color=#dedede, offx=1, offy=1);
96
+ float: left;
96
97
  }
97
98
 
98
99
  .seo_form input[type=submit]:hover {
@@ -107,4 +108,23 @@
107
108
  float: left;
108
109
  text-decoration: none;
109
110
  color: #333;
111
+ font-size: 12px;
112
+ margin-right: 10px;
113
+ margin-top: 5px;
114
+ }
115
+ #cancel_seo_btn a {
116
+ text-decoration: none;
117
+ color: #333;
118
+ }
119
+
120
+ #more-options-btn{
121
+ font-size: 12px;
122
+ margin-left: 160px;
123
+ text-decoration: none;
124
+ color: #333;
125
+ }
126
+
127
+ #seo_buttons {
128
+ float: right;
129
+ font-size: 12px;
110
130
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seo_fuel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-11 00:00:00.000000000 Z
12
+ date: 2012-10-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -44,7 +44,7 @@ files:
44
44
  - app/controllers/seo_tags_controller.rb
45
45
  - app/models/seo_tag.rb
46
46
  - app/views/seo_tags/_description.html.erb
47
- - app/views/seo_tags/_keywords.html.erb
47
+ - app/views/seo_tags/_meta_tags.html.erb
48
48
  - app/views/seo_tags/_seo_options.html.erb
49
49
  - app/views/seo_tags/_title.html.erb
50
50
  - app/views/seo_tags/create.js.erb
@@ -52,13 +52,16 @@ files:
52
52
  - config/locales/en.seo_fuel.yml
53
53
  - config/locales/nl.seo_fuel.yml
54
54
  - config/routes.rb
55
+ - config/templates/seo_fuel_settings.yml.erb
56
+ - lib/generators/USAGE
55
57
  - lib/generators/seo_fuel_generator.rb
56
- - lib/generators/templates/USAGE
57
58
  - lib/generators/templates/migration.rb
58
59
  - lib/seo_fuel.rb
59
60
  - lib/seo_fuel/controller_helper.rb
61
+ - lib/seo_fuel/railtie.rb
60
62
  - lib/seo_fuel/version.rb
61
63
  - lib/seo_fuel/view_helper.rb
64
+ - lib/seo_fuel_example.png
62
65
  - seo_fuel.gemspec
63
66
  - vendor/assets/javascripts/seo_fuel.js
64
67
  - vendor/assets/stylesheets/seo_fuel.css
@@ -1 +0,0 @@
1
- <meta name="keywords" content="<%= keywords_to_show %>">
File without changes