seo_fuel 0.0.9 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.md CHANGED
@@ -1,8 +1,11 @@
1
- ## version 0.0.5
2
- - copy locale files to config folder upon installation
3
- - the button is now included in the same view helper as the dialog. Only use `<%= edit_seo_dialog %>` now
4
-
1
+ ## version 0.0.9
2
+ - improved UI
3
+ - read defaults from YAML file
5
4
 
6
5
  ## version 0.0.8
7
6
  - updated README
8
- - added option to create default description and default keywords
7
+ - added option to create default description and default keywords
8
+
9
+ ## version 0.0.5
10
+ - copy locale files to config folder upon installation
11
+ - the button is now included in the same view helper as the dialog. Only use `<%= edit_seo_dialog %>` now
data/README.md CHANGED
@@ -71,7 +71,6 @@ This gem is fully I18n adjustable. Just edit the locale file, placed in the loca
71
71
 
72
72
  ## TODO
73
73
  This gem is in early development, there are still some things to do:
74
- - add authentication layer
75
74
  - add options for open_graph
76
75
  - add documentation
77
76
  - include testing
@@ -3,23 +3,34 @@ class SeoTagsController < ApplicationController
3
3
  # POST
4
4
  # creates the seo tags for given path (params[:seo_tag][:path])
5
5
  def create
6
- @tag = SeoTag.find_or_create_by_path(params[:seo_tag][:path])
7
- @tag.update_attributes(params[:seo_tag])
8
- respond_to do |format|
9
- format.js
10
- format.html {redirect_to params[:path]}
6
+ if params[:key] && params[:key] == authentication_key
7
+ @tag = SeoTag.find_or_create_by_path(params[:seo_tag][:path])
8
+ @tag.update_attributes(params[:seo_tag])
9
+ respond_to do |format|
10
+ format.js
11
+ format.html {redirect_to params[:path]}
12
+ end
11
13
  end
12
14
  end
13
15
 
14
16
  # PUT
15
17
  # updates the seo tags for given path (params[:seo_tag][:path])
16
18
  def update
17
- @tag = SeoTag.find_or_create_by_path(params[:seo_tag][:path])
18
- @tag.update_attributes(params[:seo_tag])
19
- respond_to do |format|
20
- format.js
21
- format.html {redirect_to params[:path]}
19
+ if params[:key] && params[:key] == authentication_key
20
+ @tag = SeoTag.find_or_create_by_path(params[:seo_tag][:path])
21
+ @tag.update_attributes(params[:seo_tag])
22
+ respond_to do |format|
23
+ format.js
24
+ format.html {redirect_to params[:path]}
25
+ end
22
26
  end
23
27
  end
28
+
29
+ private
30
+
31
+ # Reads the authentication key from the seo_fuel_settings.yml file
32
+ def authentication_key
33
+ YAML::load(File.open("config/seo_fuel_settings.yml"))['SEO_FUEL_SETTINGS']['key']
34
+ end
24
35
 
25
36
  end
@@ -2,6 +2,7 @@
2
2
  <div id="edit_seo_dialog" class="seo_fuel" style="display: none;">
3
3
  <%= form_for SeoTag.find_or_initialize_by_path(request.path), remote: true, html: {class: "seo_form"} do |f|%>
4
4
  <%= f.hidden_field :path %>
5
+ <%= hidden_field_tag :key, seo_fuel_authentication_key %>
5
6
  <%= f.label :title, "#{I18n.t('seo.form.title')}".html_safe %>
6
7
  <%= f.text_field :title, placeholder: @default_title %>
7
8
  <div class="spacer"></div>
@@ -6,17 +6,25 @@ class SeoFuelGenerator < Rails::Generators::Base
6
6
 
7
7
  desc "Put the JavaScript and migration in place"
8
8
  source_root File.join(File.dirname(__FILE__), "templates")
9
-
9
+
10
10
  def install
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
+
21
+ def template(from, to)
22
+ erb = File.read(File.expand_path("../../../config/templates/#{from}", __FILE__))
23
+ yml = ERB.new(erb).result(binding)
24
+ File.open(to, 'w') {|f| f.write(yml) }
25
+ puts "created option file: config/seo_fuel_settigns.yml"
26
+ end
27
+
20
28
  def gsub_file(relative_destination, regexp, *args, &block)
21
29
  path = destination_path(relative_destination)
22
30
  content = File.read(path).gsub(regexp, *args, &block)
@@ -24,7 +32,8 @@ class SeoFuelGenerator < Rails::Generators::Base
24
32
  end
25
33
 
26
34
  def copy_options_file
27
- copy_file File.join(config_path, 'seo_fuel_settings.yml'), config_destination
35
+ template "seo_fuel_settings.yml.erb", config_destination
36
+ # copy_file File.join(config_path, 'seo_fuel_settings.yml'), config_destination
28
37
  end
29
38
 
30
39
  def copy_language_file
@@ -5,13 +5,7 @@ module SeoFuel
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
8
- helper_method :testing
9
8
  end
10
-
11
- def testing
12
- logger.info "TESTING: OK"
13
- raise "ERROR!!!!!!!!!!!!!"
14
- end
15
-
9
+
16
10
  end
17
11
  end
@@ -1,3 +1,3 @@
1
1
  module SeoFuel
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -7,6 +7,10 @@ module SeoFuel
7
7
  def default_settings_from_config_file
8
8
  YAML::load(File.open("config/seo_fuel_settings.yml"))
9
9
  end
10
+
11
+ def seo_fuel_authentication_key
12
+ default_settings_from_config_file['SEO_FUEL_SETTINGS']['key']
13
+ end
10
14
 
11
15
  # used in version < 0.0.4
12
16
  def edit_seo_button(text=I18n.t('seo.button_text'), klass="")
data/lib/seo_fuel.rb CHANGED
@@ -2,10 +2,13 @@ require 'action_controller'
2
2
  require 'action_view'
3
3
 
4
4
  module SeoFuel
5
+
5
6
  module Rails
6
7
  class Engine < ::Rails::Engine
7
8
  end
8
9
  end
10
+
11
+
9
12
  end
10
13
 
11
14
  require 'seo_fuel/version'
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.9
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -52,7 +52,6 @@ files:
52
52
  - config/locales/en.seo_fuel.yml
53
53
  - config/locales/nl.seo_fuel.yml
54
54
  - config/routes.rb
55
- - config/seo_fuel_settings.yml
56
55
  - lib/generators/seo_fuel_generator.rb
57
56
  - lib/generators/templates/USAGE
58
57
  - lib/generators/templates/migration.rb
@@ -1,5 +0,0 @@
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"