seo_fuel 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -0
- data/README.md +10 -3
- data/app/controllers/seo_tags_controller.rb +6 -2
- data/app/views/seo_tags/_seo_options.html.erb +1 -1
- data/lib/generators/seo_fuel_generator.rb +12 -0
- data/lib/seo_fuel/version.rb +1 -1
- data/lib/seo_fuel/view_helper.rb +16 -1
- metadata +5 -4
- /data/config/locales/{en.yml → en.seo_fuel.yml} +0 -0
- /data/config/locales/{nl.yml → nl.seo_fuel.yml} +0 -0
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# SEO Fuel: easily gas up search engines
|
2
|
-
|
2
|
+
|
3
|
+
_This gem is still in early development. Described features work, but some features are still lacking. I'll be updating the documentation as I go along. Feel free to fork this project and improve on it._
|
4
|
+
|
5
|
+
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
6
|
|
4
7
|
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
8
|
|
@@ -42,17 +45,21 @@ Replace the title, description and keywords tags for these methods:
|
|
42
45
|
|
43
46
|
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
47
|
|
45
|
-
<%= edit_seo_button %>
|
46
48
|
<%= edit_seo_dialog %>
|
47
49
|
|
48
50
|
### Setting default values
|
49
|
-
By default, all titles are blank. If a title is blank, the one specified in `seo_fuel_settings.yml` should be used (NOT YET IMPLEMENTED). Per template, you can specify a default value by adding a line of code to your view template
|
51
|
+
By default, all titles are blank. If a title is blank, the one specified in `seo_fuel_settings.yml` should be used (NOT YET IMPLEMENTED). Per template, you can specify a default value by adding a line of code to your view template. This value takes precedence over the default title.
|
52
|
+
The 'in browser' added SEO settings take precedence over all default values.
|
50
53
|
|
51
54
|
<% default_title("Site Name | #{@article.title}") %>
|
52
55
|
|
53
56
|
|
57
|
+
### I18n
|
58
|
+
This gem is fully I18n adjustable. Just edit the locale file, placed in the config directory of your Rails app.
|
59
|
+
|
54
60
|
## TODO
|
55
61
|
This gem is in early development, there are still some things to do:
|
62
|
+
- add authentication layer
|
56
63
|
- add options for open_graph
|
57
64
|
- add documentation
|
58
65
|
- include testing
|
@@ -1,7 +1,9 @@
|
|
1
1
|
class SeoTagsController < ApplicationController
|
2
2
|
|
3
|
+
# POST
|
4
|
+
# creates the seo tags for given path (params[:seo_tag][:path])
|
3
5
|
def create
|
4
|
-
@tag = SeoTag.find_or_create_by_path(params[:path])
|
6
|
+
@tag = SeoTag.find_or_create_by_path(params[:seo_tag][:path])
|
5
7
|
@tag.update_attributes(params[:seo_tag])
|
6
8
|
respond_to do |format|
|
7
9
|
format.js
|
@@ -9,6 +11,8 @@ class SeoTagsController < ApplicationController
|
|
9
11
|
end
|
10
12
|
end
|
11
13
|
|
14
|
+
# PUT
|
15
|
+
# updates the seo tags for given path (params[:seo_tag][:path])
|
12
16
|
def update
|
13
17
|
@tag = SeoTag.find_or_create_by_path(params[:seo_tag][:path])
|
14
18
|
@tag.update_attributes(params[:seo_tag])
|
@@ -17,5 +21,5 @@ class SeoTagsController < ApplicationController
|
|
17
21
|
format.html {redirect_to params[:path]}
|
18
22
|
end
|
19
23
|
end
|
20
|
-
|
24
|
+
|
21
25
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
<%= link_to I18n.t('seo.button_text'), "#", class: "seo_fuel", id: "edit_seo_btn" unless SeoFuel::VERSION > "0.0.5" %>
|
1
2
|
<div id="edit_seo_dialog" class="seo_fuel" style="display: none;">
|
2
3
|
<%= form_for SeoTag.find_or_initialize_by_path(request.path), remote: true, html: {class: "seo_form"} do |f|%>
|
3
4
|
<%= f.hidden_field :path %>
|
@@ -13,5 +14,4 @@
|
|
13
14
|
<%= link_to I18n.t('seo.cancel'), "#", id: "cancel_seo_btn"%>
|
14
15
|
<%= f.submit I18n.t('seo.save')%>
|
15
16
|
<% end %>
|
16
|
-
|
17
17
|
</div>
|
@@ -10,6 +10,7 @@ class SeoFuelGenerator < Rails::Generators::Base
|
|
10
10
|
def install
|
11
11
|
copy_javascript if needs_js_copied?
|
12
12
|
copy_options_file
|
13
|
+
copy_language_file
|
13
14
|
route("resources :seo_tags")
|
14
15
|
migration_template "migration.rb", "db/migrate/create_seo_fuel.rb"
|
15
16
|
end
|
@@ -25,6 +26,10 @@ class SeoFuelGenerator < Rails::Generators::Base
|
|
25
26
|
def copy_options_file
|
26
27
|
copy_file File.join(config_path, 'seo_fuel_settings.yml'), config_destination
|
27
28
|
end
|
29
|
+
|
30
|
+
def copy_language_file
|
31
|
+
copy_file File.join(locales_path, 'en.seo_fuel.yml'), language_file_destination
|
32
|
+
end
|
28
33
|
|
29
34
|
def copy_javascript
|
30
35
|
copy_file File.join(javascript_path, 'seo_fuel.js'), js_destination
|
@@ -33,6 +38,10 @@ class SeoFuelGenerator < Rails::Generators::Base
|
|
33
38
|
def config_path
|
34
39
|
File.join(%w(.. .. .. config))
|
35
40
|
end
|
41
|
+
|
42
|
+
def locales_path
|
43
|
+
File.join(%w(.. .. .. config locales))
|
44
|
+
end
|
36
45
|
|
37
46
|
def javascripts_path
|
38
47
|
File.join(%w(.. .. .. vendor assets javascripts))
|
@@ -50,5 +59,8 @@ class SeoFuelGenerator < Rails::Generators::Base
|
|
50
59
|
'config/seo_fuel_settings.yml'
|
51
60
|
end
|
52
61
|
|
62
|
+
def language_file_destination
|
63
|
+
'config/locales/en.seo_fuel.yml'
|
64
|
+
end
|
53
65
|
|
54
66
|
end
|
data/lib/seo_fuel/version.rb
CHANGED
data/lib/seo_fuel/view_helper.rb
CHANGED
@@ -1,17 +1,22 @@
|
|
1
1
|
module SeoFuel
|
2
2
|
# Contains methods to use in views and helpers.
|
3
|
-
#
|
4
3
|
|
5
4
|
module ViewHelper
|
6
5
|
|
6
|
+
# used in version < 0.0.4
|
7
7
|
def edit_seo_button(text=I18n.t('seo.button_text'), klass="")
|
8
8
|
link_to text, "#", class: "seo_fuel #{klass}", id: "edit_seo_btn"
|
9
9
|
end
|
10
10
|
|
11
|
+
# set your default title in any view template, by
|
12
|
+
# simply calling `default_title(your_title_here)`
|
13
|
+
# this title takes precedence over the default title set
|
14
|
+
# in your config file, but not over the one set 'in browser'
|
11
15
|
def default_title(title)
|
12
16
|
@default_title = title.force_encoding('utf-8')
|
13
17
|
end
|
14
18
|
|
19
|
+
# determines wich title to show
|
15
20
|
def title_to_show
|
16
21
|
if current_page && current_page.title.present?
|
17
22
|
current_page.title
|
@@ -22,22 +27,32 @@ module SeoFuel
|
|
22
27
|
end
|
23
28
|
end
|
24
29
|
|
30
|
+
# render the dialog box and edit button by calling
|
31
|
+
# `edit_seo_dialog` in the templates that should have this
|
32
|
+
# form. Usually this should be on every page, so this helper
|
33
|
+
# methods is mostly used on the bottom of the application.html,
|
34
|
+
# just above the closing `<body>` tag.
|
25
35
|
def edit_seo_dialog
|
26
36
|
render :partial => "seo_tags/seo_options"
|
27
37
|
end
|
28
38
|
|
39
|
+
# returns the current SeoTag object
|
40
|
+
# this instance contains all the SEO options
|
29
41
|
def current_page
|
30
42
|
SeoTag.find_by_path(request.path)
|
31
43
|
end
|
32
44
|
|
45
|
+
# renders the `title_to_show` inside a `<title>` tag.
|
33
46
|
def show_title
|
34
47
|
render :partial => "seo_tags/title"
|
35
48
|
end
|
36
49
|
|
50
|
+
# renders the description inside a `<meta>` tag.
|
37
51
|
def show_description
|
38
52
|
render :partial => "seo_tags/description"
|
39
53
|
end
|
40
54
|
|
55
|
+
# renders the keywords inside a `<meta>` tag.
|
41
56
|
def show_keywords
|
42
57
|
render :partial => "seo_tags/keywords"
|
43
58
|
end
|
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.0.
|
4
|
+
version: 0.0.6
|
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-
|
12
|
+
date: 2012-10-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -36,6 +36,7 @@ extensions: []
|
|
36
36
|
extra_rdoc_files: []
|
37
37
|
files:
|
38
38
|
- .gitignore
|
39
|
+
- CHANGELOG.md
|
39
40
|
- Gemfile
|
40
41
|
- LICENSE
|
41
42
|
- README.md
|
@@ -48,8 +49,8 @@ files:
|
|
48
49
|
- app/views/seo_tags/_title.html.erb
|
49
50
|
- app/views/seo_tags/create.js.erb
|
50
51
|
- app/views/seo_tags/update.js.erb
|
51
|
-
- config/locales/en.yml
|
52
|
-
- config/locales/nl.yml
|
52
|
+
- config/locales/en.seo_fuel.yml
|
53
|
+
- config/locales/nl.seo_fuel.yml
|
53
54
|
- config/routes.rb
|
54
55
|
- config/seo_fuel_settings.yml
|
55
56
|
- lib/generators/seo_fuel_generator.rb
|
File without changes
|
File without changes
|