beautiful_scaffold 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +13 -0
  3. data/Gemfile +4 -3
  4. data/README.rdoc +22 -4
  5. data/lib/beautiful_scaffold/version.rb +1 -1
  6. data/lib/generators/USAGE +3 -1
  7. data/lib/generators/beautiful_cancancan_generator.rb +51 -0
  8. data/lib/generators/beautiful_jointable_generator.rb +1 -1
  9. data/lib/generators/beautiful_locale_generator.rb +15 -13
  10. data/lib/generators/beautiful_scaffold_common_methods.rb +5 -1
  11. data/lib/generators/beautiful_scaffold_generator.rb +1 -1
  12. data/lib/generators/beautiful_sorcery_generator.rb +137 -0
  13. data/lib/generators/beautiful_storage_generator.rb +61 -0
  14. data/lib/generators/templates/app/controllers/user_sessions_controller.rb +20 -0
  15. data/lib/generators/templates/app/locales/beautiful_scaffold.en.yml +8 -0
  16. data/lib/generators/templates/app/locales/beautiful_scaffold.fr.yml +9 -1
  17. data/lib/generators/templates/app/locales/beautiful_scaffold.ja.yml +9 -2
  18. data/lib/generators/templates/app/mailers/user_mailer.rb +13 -0
  19. data/lib/generators/templates/app/models/ability.rb +39 -0
  20. data/lib/generators/templates/app/models/concerns/caption_concern.rb +1 -1
  21. data/lib/generators/templates/app/models/user.rb +11 -0
  22. data/lib/generators/templates/app/views/layout.html.erb +9 -2
  23. data/lib/generators/templates/app/views/login_logout/user_mailer/activation_needed_email.en.html.erb +16 -0
  24. data/lib/generators/templates/app/views/login_logout/user_mailer/activation_needed_email.en.text.erb +9 -0
  25. data/lib/generators/templates/app/views/login_logout/user_mailer/activation_needed_email.fr.html.erb +16 -0
  26. data/lib/generators/templates/app/views/login_logout/user_mailer/activation_needed_email.fr.text.erb +8 -0
  27. data/lib/generators/templates/app/views/login_logout/user_mailer/activation_success_email.en.html.erb +19 -0
  28. data/lib/generators/templates/app/views/login_logout/user_mailer/activation_success_email.en.text.erb +8 -0
  29. data/lib/generators/templates/app/views/login_logout/user_mailer/activation_success_email.fr.html.erb +19 -0
  30. data/lib/generators/templates/app/views/login_logout/user_mailer/activation_success_email.fr.text.erb +8 -0
  31. data/lib/generators/templates/app/views/login_logout/user_sessions/_form.html.erb +15 -0
  32. data/lib/generators/templates/app/views/login_logout/user_sessions/new.html.erb +3 -0
  33. data/lib/generators/templates/app/views/partials/_login_logout_register.html.erb +7 -0
  34. metadata +21 -8
  35. data/lib/generators/beautiful_devisecancan_generator.rb +0 -128
  36. data/lib/generators/templates/app/views/partials/_register_form.html.erb +0 -44
  37. data/lib/generators/templates/app/views/partials/_sign_in_form.html.erb +0 -18
  38. data/lib/generators/templates/app/views/partials/_sign_in_sign_out.html.erb +0 -19
  39. data/lib/generators/templates/lib/custom_failure.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1fe3aee750d2046a19d5f956820fb36e03a49ecac78cef8046d75e573e44e5e
4
- data.tar.gz: aa521359c646d5171eeb3981f67ba5c7138ef9f422f2f88856e04280acc4b434
3
+ metadata.gz: f2c5cc9830b52e9bdc57663e3e93779e3457502e4f3656f0c541b8213775edca
4
+ data.tar.gz: 03260e7d438e1aa4c9161a5fdf1b221fd21c2acc4625857ac00eadf4686ac04c
5
5
  SHA512:
6
- metadata.gz: a3816f89d26548eccf73546dd698a3606f739bd1637e70fc53b19eaa27e7455ce61ea65a18fdc504ec8a8bea5f24dfd2d3bf6d030480c84f077e427d1481a447
7
- data.tar.gz: 1256a2a3b5534405148fb3a0f9f2c3a404703e4ea2ff521887e8bb5f61c6937da8793a69fcfa8e4a584c131cd6af44c9d14c8bc8886b0daf97bfb54be4f98ebe
6
+ metadata.gz: d95e8b02e11a731844977432a230d83b200da69018184d3583a3ade48f448face2799f8e76bcb01ee13b40b7166813f0921fe57442db6fa7f18ec23eb6b62f79
7
+ data.tar.gz: 7ab3d32603cf3c89f6c34a7d5798610b60ccbf701a3c8583eee89bdabadb0a090c96436e8e17c11f2c9d41d7ba4262820414b1096e54124df2b02cccaf9b777e
data/CHANGELOG CHANGED
@@ -4,6 +4,19 @@
4
4
 
5
5
  * bugfix
6
6
 
7
+ == 2.0.1
8
+
9
+ * enhancement
10
+ * Replace Devise by Sorcery
11
+ * Tests Sorcery and Cancancan generators
12
+ * New generator for ActiveStorage
13
+
14
+ * bugfix
15
+ * Locale : fix all locale in the same file.
16
+ * Visual fix ('-' in menu)
17
+ * Will_paginate right locales
18
+ * Avoid adding gems multiple times
19
+
7
20
  == 2.0.0
8
21
 
9
22
  * enhancement
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem "rails", "~> 6.0"
5
+ gem "rails", "~> 6.1"
6
6
 
7
7
  group :test do
8
8
  gem 'sqlite3'
@@ -15,10 +15,11 @@ group :test do
15
15
  'prawn-table' => nil, #'0.2.2',
16
16
  'sanitize' => nil,
17
17
  'bootstrap' => '~> 4.3.1',
18
- 'font-awesome-rails' => '4.7.0.5',
18
+ 'font-awesome-rails' => '4.7.0.7',
19
19
  'momentjs-rails' => '>= 2.9.0',
20
20
  'bootstrap4-datetime-picker-rails' => nil,
21
- 'jquery-rails' => '4.3.1'
21
+ 'jquery-rails' => '4.3.1',
22
+ 'sorcery' => '0.15.0'
22
23
  }
23
24
 
24
25
  gems.each{ |gem_to_add, version|
data/README.rdoc CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  Beautiful Scaffold is a gem which propose generators for a complete scaffold with paginate, sort and filter.
4
4
  Fully customizable.
5
+
6
+ Note : Avoid to change Beautiful-Scaffold version in your project (incompatibility between generated code).
7
+ Note 2 : Be careful to have a clean git repository for your project because Beautiful-Scaffold change many files.
8
+ It will be easier to revert changes.
9
+
5
10
  Info : https://github.com/rivsc/Beautiful-Scaffold
6
11
  Demo : http://beautiful-scaffold.rivsc.ovh/
7
12
 
@@ -70,10 +75,23 @@ Run `rake db:migrate` before `rails g beautiful_locale` (to get lastest attribut
70
75
 
71
76
  rails g beautiful_jointable model1 model2
72
77
 
73
- TODO replace Devise by Sorcery & Cancan by Cancancan
74
- === Install et Configure Devise (authentification) and Cancan (authorization)
78
+ === Install et preconfigure Sorcery (authentification) (this generator doesn't work on engine)
79
+
80
+ # If it is not done yet
81
+ rails g beautiful_scaffold user email:string
82
+ rails g beautiful_sorcery
83
+
84
+ === Install et preconfigure Cancancan (authorization) (this generator doesn't work on engine)
85
+
86
+ # If it is not done yet
87
+ rails g beautiful_scaffold user email:string
88
+ # If it is not done yet
89
+ rails g beautiful_sorcery
90
+ rails g beautiful_cancancan
91
+
92
+ === Storage (ActiveStorage)
75
93
 
76
- rails g beautiful_devisecancan model
94
+ rails g beautiful_storage model attachment_field
77
95
 
78
96
  === In views
79
97
 
@@ -103,7 +121,7 @@ Example : when you click on the #bs-help tag presentation tour display on screen
103
121
 
104
122
  If you want to add 'slide' :
105
123
 
106
- For add instruction to element, add this to your markup :
124
+ For add instruction to DOM element, add this to your markup :
107
125
 
108
126
  id="myunique-id-in-the-page" data-present-title="Title for the slide" data-present-description="Short description" data-present-order="1"
109
127
 
@@ -1,3 +1,3 @@
1
1
  module BeautifulScaffold
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.1'
3
3
  end
data/lib/generators/USAGE CHANGED
@@ -12,5 +12,7 @@ Example:
12
12
 
13
13
  rails generate beautiful_jointable product tag
14
14
 
15
- rails generate beautiful_devisecancan user
15
+ rails generate beautiful_sorcery
16
+ rails generate beautiful_cancancan
17
+
16
18
 
@@ -0,0 +1,51 @@
1
+ # encoding : utf-8
2
+ class BeautifulCancancanGenerator < Rails::Generators::Base
3
+ require_relative 'beautiful_scaffold_common_methods'
4
+ include BeautifulScaffoldCommonMethods
5
+
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ #argument :model, :type => :string, :desc => "Name of model (ex: user)"
9
+
10
+ def install_cancancan
11
+ model = "user"
12
+
13
+ gem("cancancan", "3.2.1")
14
+
15
+ Bundler.with_unbundled_env do
16
+ run "bundle install"
17
+ end
18
+
19
+ # Because generators doesn't work !
20
+ copy_file("app/models/ability.rb")
21
+
22
+ # Why that doesn't work... boring...
23
+ #puts rails_command("generate cancan:ability", capture: true)
24
+ # Why that doesn't work too... boring...
25
+ #generate("cancan:ability")
26
+
27
+ # current_user method need for CanCan
28
+ current_user_method = ""
29
+ if model != "user" then
30
+ current_user_method = "
31
+ def current_user
32
+ current_#{model}
33
+ end"
34
+ end
35
+
36
+ # Exception for AccessDenied
37
+ inject_into_file("app/controllers/application_controller.rb", "
38
+ rescue_from CanCan::AccessDenied do |exception|
39
+ respond_to do |format|
40
+ format.json { head :forbidden, content_type: 'text/html' }
41
+ format.html { redirect_to root_url, :alert => exception.message }
42
+ format.js { head :forbidden, content_type: 'text/html' }
43
+ end
44
+ end
45
+ #{current_user_method}
46
+ ", :after => "class ApplicationController < ActionController::Base\n")
47
+
48
+ # Access controlled by CanCanCan (in beautiful_scaffold)
49
+ inject_into_file("app/controllers/application_controller.rb", "#", :before => "before_action :authenticate_#{model}!, :except => [:dashboard]")
50
+ end
51
+ end
@@ -5,7 +5,7 @@ class BeautifulJointableGenerator < Rails::Generators::Base
5
5
 
6
6
  source_root File.expand_path('../templates', __FILE__)
7
7
 
8
- argument :join_models, :type => :array, :default => [], :banner => "model model"
8
+ argument :join_models, :type => :array, :default => [], :banner => "Two model names singular downcase (ex: product family)"
9
9
 
10
10
  class_option :mountable_engine, default: nil
11
11
 
@@ -5,7 +5,7 @@ class BeautifulLocaleGenerator < Rails::Generators::Base
5
5
 
6
6
  source_root File.expand_path('../templates', __FILE__)
7
7
 
8
- argument :name, :type => :string, :desc => "type of locale : fr OR en OR de OR ja all..."
8
+ argument :name, :type => :string, :desc => "type of locale : fr, en, de, all"
9
9
 
10
10
  class_option :mountable_engine, :default => nil
11
11
 
@@ -18,13 +18,15 @@ class BeautifulLocaleGenerator < Rails::Generators::Base
18
18
 
19
19
  def install_locale
20
20
  list_locales.each{ |temp_locale|
21
- filename = "beautiful_scaffold.#{temp_locale}.yml"
22
- gem_localepath = "app/locales/#{filename}"
23
- app_localepath = "config/locales/#{filename}"
24
- begin
25
- copy_file gem_localepath, app_localepath
26
- rescue
27
- say_status("Error", "This beautiful_locale #{localestr} doesn't exist !", :red)
21
+
22
+ ["beautiful_scaffold.#{temp_locale}.yml"].each do |filename|
23
+ gem_localepath = "app/locales/#{filename}"
24
+ app_localepath = "config/locales/#{filename}"
25
+ begin
26
+ copy_file gem_localepath, app_localepath
27
+ rescue
28
+ say_status("Error", "This beautiful_locale #{temp_locale} doesn't exist !", :red)
29
+ end
28
30
  end
29
31
 
30
32
  rails_locale_file = "#{temp_locale}.yml"
@@ -36,7 +38,7 @@ class BeautifulLocaleGenerator < Rails::Generators::Base
36
38
  end
37
39
 
38
40
  willpaginate_locale_file = "will_paginate.#{temp_locale}.yml"
39
- download_path = "https://raw.github.com/mislav/will_paginate/master/lib/will_paginate/locale/en.yml"
41
+ download_path = "https://raw.githubusercontent.com/tigrish/will-paginate-i18n/master/config/locales/#{temp_locale}.yml"
40
42
  begin
41
43
  get download_path, "config/locales/#{willpaginate_locale_file}"
42
44
  say_status("Warning", "You must modify Will_paginate locale at : Rails.root/config/locale/#{willpaginate_locale_file}", :red)
@@ -51,8 +53,8 @@ class BeautifulLocaleGenerator < Rails::Generators::Base
51
53
  def regenerate_app_locale
52
54
  require 'net/http'
53
55
 
54
- app_name = (Rails.root || engine_opt)
55
- engine_or_apps = (Rails.application.class.parent_name || engine_opt).downcase
56
+ app_path = (Rails.root || engine_opt)
57
+ app_name = Rails.application.class.name.split('::').first.downcase
56
58
  prefix = engine_opt.blank? ? '' : "#{engine_opt.camelize}::"
57
59
 
58
60
  already_processed = {}
@@ -63,7 +65,7 @@ class BeautifulLocaleGenerator < Rails::Generators::Base
63
65
 
64
66
  already_processed[locale] ||= {}
65
67
 
66
- filepath = File.join(app_name, 'config', 'locales', "#{engine_or_apps}.#{locale}.yml")
68
+ filepath = File.join(app_path, 'config', 'locales', "#{app_name}.#{locale}.yml")
67
69
  begin
68
70
  if File.exist?(filepath)
69
71
  hi18n = YAML.load_file(filepath)
@@ -154,7 +156,7 @@ class BeautifulLocaleGenerator < Rails::Generators::Base
154
156
  File.unlink(filepath) if File.exist?(filepath)
155
157
 
156
158
  file = File.open(filepath, "w")
157
- file.write(hi18n.to_yaml)
159
+ file.write(hi18n[locale].to_yaml)
158
160
  file.close
159
161
  end
160
162
  end
@@ -208,8 +208,12 @@ module BeautifulScaffoldCommonMethods
208
208
  puts "============> Engine : You must add gems to your main app \n #{gems.to_a.map{ |a| "gem '#{a[0]}'#{(a[1].nil? ? '' : ", '#{a[1]}'")} " }.join("\n")}"
209
209
  end
210
210
 
211
+ gemfile_content = File.read('Gemfile')
211
212
  gems.each{ |gem_to_add, version|
212
- gem(gem_to_add, version)
213
+ # Bug add at every times, need to check if already present
214
+ if !gemfile_content.include?(gem_to_add)
215
+ gem(gem_to_add, version)
216
+ end
213
217
  }
214
218
  end
215
219
 
@@ -13,7 +13,7 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
13
13
 
14
14
  source_root File.expand_path('../templates', __FILE__)
15
15
 
16
- argument :model_opt, type: :string, desc: "Name of model (singular)"
16
+ argument :model_opt, type: :string, desc: "Name of model singular downcase (ex: family)"
17
17
  argument :myattributes, type: :array, default: [], banner: "field:type field:type"
18
18
 
19
19
  class_option :namespace, default: nil
@@ -0,0 +1,137 @@
1
+ # encoding : utf-8
2
+ class BeautifulSorceryGenerator < Rails::Generators::Base
3
+ require_relative 'beautiful_scaffold_common_methods'
4
+ include BeautifulScaffoldCommonMethods
5
+
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ #argument :model, :type => :string, :desc => "Name of model (ex: User)"
9
+
10
+ def install_sorcery
11
+ model = "User"
12
+ view_path = "app/views/"
13
+
14
+ if !File.read('Gemfile').include?("sorcery")
15
+ gem("sorcery", "0.16.0")
16
+ end
17
+
18
+ Bundler.with_unbundled_env do
19
+ run "bundle install"
20
+ end
21
+
22
+ raise "Model must be specified" if model.blank?
23
+
24
+ # Install sorcery
25
+ generate("sorcery:install", "remember_me reset_password user_activation brute_force_protection external --model #{model}")
26
+
27
+ # If exist users migration just add columns
28
+ create_user_migration = Dir.glob("db/migrate/*create_users.rb").first
29
+ if create_user_migration
30
+ already_email = File.read(create_user_migration).include?(":email")
31
+ sorcery_core_file = Dir.glob("db/migrate/*sorcery_core.rb").first
32
+ File.open(sorcery_core_file, "w+") do |f|
33
+ f.write("class SorceryCore < ActiveRecord::Migration[6.1]
34
+ def change
35
+ #{(already_email ? '' : 'add_column :users, :email, :string')}
36
+ add_column :users, :crypted_password, :string
37
+ add_column :users, :salt, :string
38
+
39
+ #{(already_email ? '' : 'add_index :users, :email, unique: true')}
40
+ end
41
+ end")
42
+ end
43
+ end
44
+
45
+ # Generate mailer
46
+ copy_file("app/mailers/user_mailer.rb")
47
+
48
+ # Install controllers
49
+ copy_file("app/controllers/user_sessions_controller.rb")
50
+
51
+ # ===== Controller
52
+ inject_into_file("app/controllers/users_controller.rb",
53
+ "\n
54
+ skip_before_action :require_login, only: [:new, :create, :activate]
55
+ \n", after: "< BeautifulController")
56
+
57
+ inject_into_file("app/controllers/users_controller.rb",
58
+ "def activate
59
+ if @user = User.load_from_activation_token(params[:id])
60
+ @user.activate!
61
+ redirect_to(login_path, :notice => 'User was successfully activated.')
62
+ else
63
+ not_authenticated
64
+ end
65
+ end\n\n ", before: "private")
66
+
67
+ # ====== Model
68
+ # Add password & password_confirmation in model
69
+ inject_into_file("app/models/user.rb",
70
+ "\n
71
+ validates :password, length: { minimum: 3 }, if: -> { new_record? || changes[:crypted_password] }
72
+ validates :password, confirmation: true, if: -> { new_record? || changes[:crypted_password] }
73
+ validates :password_confirmation, presence: true, if: -> { new_record? || changes[:crypted_password] }
74
+
75
+ before_update :setup_activation, if: -> { email_changed? }
76
+ after_update :send_activation_needed_email!, if: -> { previous_changes['email'].present? }\n",
77
+ after: "ApplicationRecord")
78
+
79
+ inject_into_file("app/models/user.rb", ":password,:password_confirmation,", :after => "def self.permitted_attributes\n return ")
80
+
81
+ # ====== Views
82
+ inject_into_file("app/views/users/_form.html.erb",
83
+ ' <div class="form-group">
84
+ <%= f.label :password, t(\'app.models.user.bs_attributes.password\', :default => \'password\').capitalize, :class => "control-label" %><br />
85
+ <%= f.password_field :password, :class => "form-control" %>
86
+ </div>
87
+ <div class="form-group">
88
+ <%= f.label :password_confirmation, t(\'app.models.user.bs_attributes.password_confirmation\', :default => \'password_confirmation\').capitalize, :class => "control-label" %><br />
89
+ <%= f.password_field :password_confirmation, :class => "form-control" %>
90
+ </div>', before: '<!-- Beautiful_scaffold - AddField - Do not remove -->')
91
+
92
+ # Install all views for login/logout
93
+ directory "app/views/login_logout", "app/views"
94
+
95
+ # Domain in action_mailer
96
+ for current_env in ['production', 'development', 'test']
97
+ inject_into_file("config/environments/#{current_env}.rb", " config.action_mailer.default_url_options = { :host => 'localhost:3000' }", :after => "Rails.application.configure do\n" )
98
+ end
99
+
100
+ # In model
101
+ #remove_file("app/models/user.rb") # remove generated by sorcery
102
+ #copy_file("app/models/user.rb") # copy BS version ;)
103
+
104
+ # Limited access
105
+ inject_into_file("app/controllers/beautiful_controller.rb",
106
+ "\n before_action :require_login, except: [:dashboard]\n",
107
+ :after => 'layout "beautiful_layout"' + "\n")
108
+
109
+ inject_into_file("config/initializers/sorcery.rb",
110
+ "\nuser.user_activation_mailer = UserMailer\n",
111
+ :after => "# user.user_activation_mailer =\n")
112
+
113
+ # Routes (session)
114
+ inject_into_file("config/routes.rb",
115
+ '
116
+ resources :user_sessions, only: [:create]
117
+ get "login" => "user_sessions#new", :as => :login
118
+ post "logout" => "user_sessions#destroy", :as => :logout' + "\n\n\n",
119
+ :after => "Rails.application.routes.draw do\n")
120
+
121
+ # Activate
122
+ inject_into_file("config/routes.rb", " do
123
+ member do
124
+ get :activate
125
+ end
126
+ end", after: 'resources :users, concerns: :bs_routes')
127
+
128
+ copy_file("#{view_path}partials/_login_logout_register.html.erb", "#{view_path}layouts/_login_logout_register.html.erb")
129
+
130
+ # Sign in sign out
131
+ inject_into_file("#{view_path}layouts/beautiful_layout.html.erb",
132
+ "\n<%= render :partial => 'layouts/login_logout_register' %>\n",
133
+ :after => "<!-- Beautiful_scaffold - Signin - Do not remove -->")
134
+
135
+ say "Beautiful-Scaffold enable 'user_activation' sorcery module for you, so when you sign up, find in logs the activation link. You can't sign in yourself until you activate the account"
136
+ end
137
+ end
@@ -0,0 +1,61 @@
1
+ # encoding : utf-8
2
+ class BeautifulStorageGenerator < Rails::Generators::Base
3
+ require_relative 'beautiful_scaffold_common_methods'
4
+ include BeautifulScaffoldCommonMethods
5
+
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ # TODO voir pour engine
9
+
10
+ argument :model, :type => :string, :desc => "Name of model (ex: user)"
11
+ argument :storage_name, :type => :string, :desc => "Storage's name (ex: picture_file)"
12
+
13
+ class_option :mountable_engine, default: nil
14
+
15
+ def install_storage
16
+
17
+ #if !File.read('Gemfile').include?("image_processing")
18
+ gem("image_processing", '~> 1.2')
19
+ #end
20
+
21
+ Bundler.with_unbundled_env do
22
+ run "bundle install"
23
+ end
24
+
25
+ # Install activestorage
26
+ run "bin/rails active_storage:install"
27
+ #run "rake db:migrate"
28
+
29
+ raise "Model must be specified" if model.blank?
30
+ raise "Attachment must be specified" if storage_name.blank?
31
+
32
+ # ===== Model
33
+ inject_into_file("app/models/#{engine_name}#{model}.rb",
34
+ "\n
35
+ has_one_attached :#{storage_name}
36
+ \n", after: "< ApplicationRecord")
37
+ inject_into_file("app/models/#{engine_name}#{model}.rb", ":#{storage_name},", :after => "def self.permitted_attributes\n return ")
38
+
39
+ # ====== Views
40
+ inject_into_file("app/views/#{engine_name}#{model_pluralize}/_form.html.erb",
41
+ " <div class='form-group'>
42
+ <%= f.label :#{storage_name}, t('app.models.#{model}.bs_attributes.#{storage_name}', :default => '#{storage_name}').capitalize, :class => 'control-label' %><br />
43
+ <%= f.file_field :#{storage_name}, direct_upload: true, :class => 'form-control' %>
44
+ </div>\n", before: '<!-- Beautiful_scaffold - AddField - Do not remove -->')
45
+
46
+ inject_into_file("app/views/#{engine_name}#{model_pluralize}/_form.html.erb",
47
+ ", multipart: true", after: "form_for(@#{model}")
48
+
49
+ inject_into_file("app/views/#{engine_name}#{model_pluralize}/show.html.erb",
50
+ "<p><b><%= t('app.models.#{model}.bs_attributes.#{storage_name}', :default => '#{storage_name}') %>:</b><br><%= image_tag @#{model}.#{storage_name}.variant(resize_to_limit: [100, 100]) %></p>",
51
+ before: "<!-- Beautiful_scaffold - AddField - Field - Do not remove -->")
52
+
53
+ # Controller
54
+ #inject_into_file("app/controllers/#{engine_name}#{model_pluralize}_controller.rb",
55
+ # "\n before_action :require_login, except: [:dashboard]\n",
56
+ # :after => 'layout "beautiful_layout"' + "\n")
57
+
58
+ say "You must run 'rake db:migrate' to create activestorage migrations !"
59
+
60
+ end
61
+ end
@@ -0,0 +1,20 @@
1
+ class UserSessionsController < BeautifulController
2
+
3
+ skip_before_action :require_login, only: [:new, :create]
4
+
5
+ def create
6
+ @user = login(params[:email], params[:password])
7
+
8
+ if @user
9
+ redirect_back_or_to(:users, notice: 'Login successful')
10
+ else
11
+ flash.now[:alert] = 'Login failed'
12
+ render action: 'new'
13
+ end
14
+ end
15
+
16
+ def destroy
17
+ logout
18
+ redirect_to(:users, notice: 'Logged out!')
19
+ end
20
+ end
@@ -47,3 +47,11 @@ en:
47
47
  register: "Register"
48
48
  search_and_filter: "Search and filter"
49
49
  more_options: "More options..."
50
+ edit_profile: "edit profile"
51
+ logout: "Logout"
52
+ register: "Register"
53
+ login: "Login"
54
+ logged_out: "Logged out"
55
+ login_failed: "Login failed"
56
+ login_successful: "Login successful"
57
+ crypted_password: "Crypted password"
@@ -46,4 +46,12 @@ fr:
46
46
  send_me_reset_password_instructions: "Me ré-envoyer les instructions de réinitialisation du mot de passe"
47
47
  register: "Inscription"
48
48
  search_and_filter: "Option de filtre"
49
- more_options: "Plus d'options..."
49
+ more_options: "Plus d'options..."
50
+ edit_profile: "Editer mon profil"
51
+ logout: "Déconnexion"
52
+ register: "S'incrire"
53
+ login: "S'identifier"
54
+ logged_out: "déconnecté"
55
+ login_failed: "Erreur d'identification"
56
+ login_successful: "Identification réussie"
57
+ crypted_password: "Crypted password"
@@ -15,7 +15,7 @@ ja:
15
15
  cancel: "キャンセル"
16
16
  export: "エクスポート"
17
17
  search: "検索"
18
- sort: "Sort"
18
+ sort: "トライ"
19
19
  download: "ダウンロード"
20
20
  "yes": "はい"
21
21
  "no": "いいえ"
@@ -47,4 +47,11 @@ ja:
47
47
  register: "登録"
48
48
  search_and_filter: "検索条件"
49
49
  more_options: "追加オプション..."
50
-
50
+ edit_profile: "プロファイル編集"
51
+ logout: "ログアウト"
52
+ register: "登録"
53
+ login: "ログイン"
54
+ logged_out: "ログアウトしました"
55
+ login_failed: "ログインに失敗しました"
56
+ login_successful: "ログイン成功"
57
+ crypted_password: "暗号化されたパスワード"
@@ -0,0 +1,13 @@
1
+ class UserMailer < ApplicationMailer
2
+ def activation_needed_email(user)
3
+ @user = user
4
+ @url = activate_user_url(@user.activation_token)
5
+ mail(to: user.email, subject: 'Welcome to My Awesome Site')
6
+ end
7
+
8
+ def activation_success_email(user)
9
+ @user = user
10
+ @url = login_url
11
+ mail(to: user.email, subject: 'Your account is now activated')
12
+ end
13
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Ability
4
+ include CanCan::Ability
5
+
6
+ def initialize(user)
7
+ if !user.nil?
8
+ if user.id == 1
9
+ can :manage, :all
10
+ end
11
+ end
12
+ # Define abilities for the passed in user here. For example:
13
+ #
14
+ # user ||= User.new # guest user (not logged in)
15
+ # if user.admin?
16
+ # can :manage, :all
17
+ # else
18
+ # can :read, :all
19
+ # end
20
+ #
21
+ # The first argument to `can` is the action you are giving the user
22
+ # permission to do.
23
+ # If you pass :manage it will apply to every action. Other common actions
24
+ # here are :read, :create, :update and :destroy.
25
+ #
26
+ # The second argument is the resource the user can perform the action on.
27
+ # If you pass :all it will apply to every resource. Otherwise pass a Ruby
28
+ # class of the resource.
29
+ #
30
+ # The third argument is an optional hash of conditions to further filter the
31
+ # objects.
32
+ # For example, here the user can only update published articles.
33
+ #
34
+ # can :update, Article, :published => true
35
+ #
36
+ # See the wiki for details:
37
+ # https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities
38
+ end
39
+ end
@@ -3,6 +3,6 @@ module CaptionConcern
3
3
 
4
4
  # You can OVERRIDE this method used in model form and search form (in belongs_to relation)
5
5
  def caption
6
- (self["name"] || self["label"] || self["description"] || "##{id}")
6
+ (self["name"] || self["label"] || self["description"] || self["email"] || "##{id}")
7
7
  end
8
8
  end
@@ -0,0 +1,11 @@
1
+ class User < ApplicationRecord
2
+ authenticates_with_sorcery!
3
+
4
+ validates :password, length: { minimum: 3 }, if: -> { new_record? || changes[:crypted_password] }
5
+ validates :password, confirmation: true, if: -> { new_record? || changes[:crypted_password] }
6
+ validates :password_confirmation, presence: true, if: -> { new_record? || changes[:crypted_password] }
7
+
8
+ before_update :setup_activation, if: -> { email_changed? }
9
+ after_update :send_activation_needed_email!, if: -> { previous_changes["email"].present? }
10
+
11
+ end
@@ -30,11 +30,11 @@
30
30
  </div>
31
31
  <div class="navbar-collapse collapse">
32
32
  <nav class="nav navbar-nav">
33
- <a href="/" class="nav-link">Home</a>-
33
+ <a href="/" class="nav-link">Home</a>
34
34
  <%%= render :partial => "layouts/beautiful_menu" %>
35
+ <!-- Beautiful_scaffold - Signin - Do not remove -->
35
36
  </nav>
36
37
  <i class="fa fa-question-circle text-white float-right" id="bs-help"></i>
37
- <!-- Beautiful_scaffold - Signin - Do not remove -->
38
38
  </div>
39
39
  </div>
40
40
  <div class="container-fluid">
@@ -47,6 +47,13 @@
47
47
  <%%= flash[:notice] %>
48
48
  </div>
49
49
  <%% end %>
50
+ <%% if !flash[:alert].blank? %>
51
+ <div class="alert alert-warning">
52
+ <a class="close" data-dismiss="alert" href="#">×</a>
53
+ <h4 class="alert-heading">Warning : </h4>
54
+ <%%= flash[:alert] %>
55
+ </div>
56
+ <%% end %>
50
57
  <%% if !flash[:error].blank? %>
51
58
  <div class="alert alert-danger">
52
59
  <a class="close" data-dismiss="alert" href="#">×</a>
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
5
+ </head>
6
+ <body>
7
+ <h1> Welcome <%= @user.email %> </h1>
8
+ <p>
9
+ You have successfully signed up to www.example.com, and your username is: <%= @user.email %>.
10
+ </p>
11
+ <p>
12
+ To login to the site, just follow this link: <%= @url %> .
13
+ </p>
14
+ <p>Thanks for joining and have a great day!</p>
15
+ </body>
16
+ </html>
@@ -0,0 +1,9 @@
1
+ Welcome to example.com, <%= @user.email %>
2
+ ===============================================
3
+
4
+ You have successfully signed up to example.com,
5
+ your username is: <%= @user.email %>.
6
+
7
+ To login to the site, just follow this link: <%= @url %> .
8
+
9
+ Thanks for joining and have a great day!
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
5
+ </head>
6
+ <body>
7
+ <h1>Bienvenue <%= @user.email %> </h1>
8
+ <p>
9
+ Vous vous êtes inscrit à www.example.com, votre identifiant est : <%= @user.email %>.
10
+ </p>
11
+ <p>
12
+ Pour activer votre compte, veuillez cliquer sur ce lien : <%= @url %> .
13
+ </p>
14
+ <p>Merci d'avoir créé votre compte, bonne journée !</p>
15
+ </body>
16
+ </html>
@@ -0,0 +1,8 @@
1
+ Bienvenue, <%= @user.email %>
2
+ ===============================================
3
+
4
+ Vous vous êtes inscrit à www.example.com, votre identifiant est : <%= @user.email %>.
5
+
6
+ Pour activer votre compte, veuillez cliquer sur ce lien : <%= @url %> .
7
+
8
+ Merci d'avoir créé votre compte, bonne journée !
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
5
+ </head>
6
+ <body>
7
+ <h1>Congratulations, <%= @user.email %>!</h1>
8
+ <p>
9
+ You have successfully activated your example.com account,
10
+ your username is: <%= @user.email %>.
11
+ </p>
12
+ <p>
13
+ To login to the site, just follow this link: <%= @url %>.
14
+ </p>
15
+ <p>
16
+ Thanks for joining and have a great day!
17
+ </p>
18
+ </body>
19
+ </html>
@@ -0,0 +1,8 @@
1
+ Congratulations, <%= @user.email %>!
2
+
3
+ You have successfully activated your example.com account,
4
+ your username is: <%= @user.email %>.
5
+
6
+ To login to the site, just follow this link: <%= @url %>.
7
+
8
+ Thanks for joining and have a great day!
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
5
+ </head>
6
+ <body>
7
+ <h1>Félicitations <%= @user.email %>!</h1>
8
+ <p>
9
+ Vous avez activé votre compte sur www.example.com avec succès,
10
+ Votre identifiant est : <%= @user.email %>.
11
+ </p>
12
+ <p>
13
+ Pour ce connecter sur le site, veuillez suivre ce lien : <%= @url %>.
14
+ </p>
15
+ <p>
16
+ Merci de vous être inscrit, bonne journée !
17
+ </p>
18
+ </body>
19
+ </html>
@@ -0,0 +1,8 @@
1
+ Félicitations <%= @user.email %>!
2
+
3
+ Vous avez activé votre compte sur www.example.com avec succès,
4
+ Votre identifiant est : <%= @user.email %>.
5
+
6
+ Pour ce connecter sur le site, veuillez suivre ce lien : <%= @url %>.
7
+
8
+ Merci de vous être inscrit, bonne journée !
@@ -0,0 +1,15 @@
1
+ <%= form_with url: user_sessions_path, method: :post do |f| %>
2
+ <div class="form-group">
3
+ <%= f.label :email, :class => "control-label" %><br />
4
+ <%= f.text_field :email, :class => "form-control" %>
5
+ </div>
6
+ <div class="form-group">
7
+ <%= f.label :password, :class => "control-label" %><br />
8
+ <%= f.password_field :password, :class => "form-control" %>
9
+ </div>
10
+ <div>
11
+ <%= link_to t(:back, :default => 'Back'), users_path, :class => "btn btn-light" %>
12
+ <%= f.submit :class => "btn btn-primary", :data => { :disable_with => t(:saving, :default => "Saving...") } %>
13
+ </div>
14
+ <% end %>
15
+
@@ -0,0 +1,3 @@
1
+ <h2><%= t(:login, :default => 'Login') %></h2>
2
+
3
+ <%= render 'form' %>
@@ -0,0 +1,7 @@
1
+ <% if current_user %>
2
+ <%= link_to "Edit Profile", edit_user_path(current_user.id), class: "nav-link" %>
3
+ <%= link_to "Logout", :logout, method: :post, class: "nav-link" %>
4
+ <% else %>
5
+ <%= link_to "Register", new_user_path, class: "nav-link" %>
6
+ <%= link_to "Login", :login, class: "nav-link" %>
7
+ <% end %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beautiful_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Claudel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-23 00:00:00.000000000 Z
11
+ date: 2021-02-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Beautiful Scaffold generate a complete scaffold (sort, export, paginate
14
14
  and filter data) http://beautiful-scaffold.rivsc.ovh
@@ -27,12 +27,14 @@ files:
27
27
  - beautiful_scaffold.gemspec
28
28
  - lib/beautiful_scaffold/version.rb
29
29
  - lib/generators/USAGE
30
- - lib/generators/beautiful_devisecancan_generator.rb
30
+ - lib/generators/beautiful_cancancan_generator.rb
31
31
  - lib/generators/beautiful_jointable_generator.rb
32
32
  - lib/generators/beautiful_locale_generator.rb
33
33
  - lib/generators/beautiful_migration_generator.rb
34
34
  - lib/generators/beautiful_scaffold_common_methods.rb
35
35
  - lib/generators/beautiful_scaffold_generator.rb
36
+ - lib/generators/beautiful_sorcery_generator.rb
37
+ - lib/generators/beautiful_storage_generator.rb
36
38
  - lib/generators/templates/app/assets/images/alpha.png
37
39
  - lib/generators/templates/app/assets/images/hue.png
38
40
  - lib/generators/templates/app/assets/images/saturation.png
@@ -65,6 +67,7 @@ files:
65
67
  - lib/generators/templates/app/controllers/base.rb
66
68
  - lib/generators/templates/app/controllers/master_base.rb
67
69
  - lib/generators/templates/app/controllers/registrations_controller.rb
70
+ - lib/generators/templates/app/controllers/user_sessions_controller.rb
68
71
  - lib/generators/templates/app/helpers/beautiful_helper.rb
69
72
  - lib/generators/templates/app/helpers/model_helper.rb
70
73
  - lib/generators/templates/app/initializers/link_renderer.rb
@@ -72,10 +75,13 @@ files:
72
75
  - lib/generators/templates/app/locales/beautiful_scaffold.en.yml
73
76
  - lib/generators/templates/app/locales/beautiful_scaffold.fr.yml
74
77
  - lib/generators/templates/app/locales/beautiful_scaffold.ja.yml
78
+ - lib/generators/templates/app/mailers/user_mailer.rb
79
+ - lib/generators/templates/app/models/ability.rb
75
80
  - lib/generators/templates/app/models/concerns/caption_concern.rb
76
81
  - lib/generators/templates/app/models/concerns/default_sorting_concern.rb
77
82
  - lib/generators/templates/app/models/concerns/fulltext_concern.rb
78
83
  - lib/generators/templates/app/models/pdf_report.rb
84
+ - lib/generators/templates/app/models/user.rb
79
85
  - lib/generators/templates/app/views/_beautiful_menu.html.erb
80
86
  - lib/generators/templates/app/views/_form.html.erb
81
87
  - lib/generators/templates/app/views/_form_habtm_tag.html.erb
@@ -85,6 +91,16 @@ files:
85
91
  - lib/generators/templates/app/views/edit.html.erb
86
92
  - lib/generators/templates/app/views/index.html.erb
87
93
  - lib/generators/templates/app/views/layout.html.erb
94
+ - lib/generators/templates/app/views/login_logout/user_mailer/activation_needed_email.en.html.erb
95
+ - lib/generators/templates/app/views/login_logout/user_mailer/activation_needed_email.en.text.erb
96
+ - lib/generators/templates/app/views/login_logout/user_mailer/activation_needed_email.fr.html.erb
97
+ - lib/generators/templates/app/views/login_logout/user_mailer/activation_needed_email.fr.text.erb
98
+ - lib/generators/templates/app/views/login_logout/user_mailer/activation_success_email.en.html.erb
99
+ - lib/generators/templates/app/views/login_logout/user_mailer/activation_success_email.en.text.erb
100
+ - lib/generators/templates/app/views/login_logout/user_mailer/activation_success_email.fr.html.erb
101
+ - lib/generators/templates/app/views/login_logout/user_mailer/activation_success_email.fr.text.erb
102
+ - lib/generators/templates/app/views/login_logout/user_sessions/_form.html.erb
103
+ - lib/generators/templates/app/views/login_logout/user_sessions/new.html.erb
88
104
  - lib/generators/templates/app/views/new.html.erb
89
105
  - lib/generators/templates/app/views/partials/_forget_password.html.erb
90
106
  - lib/generators/templates/app/views/partials/_form_field.html.erb
@@ -93,13 +109,10 @@ files:
93
109
  - lib/generators/templates/app/views/partials/_index_header.html.erb
94
110
  - lib/generators/templates/app/views/partials/_index_search.html.erb
95
111
  - lib/generators/templates/app/views/partials/_index_search_default_fields.html.erb
96
- - lib/generators/templates/app/views/partials/_register_form.html.erb
112
+ - lib/generators/templates/app/views/partials/_login_logout_register.html.erb
97
113
  - lib/generators/templates/app/views/partials/_show_field.html.erb
98
- - lib/generators/templates/app/views/partials/_sign_in_form.html.erb
99
- - lib/generators/templates/app/views/partials/_sign_in_sign_out.html.erb
100
114
  - lib/generators/templates/app/views/show.html.erb
101
115
  - lib/generators/templates/app/views/treeview.html.erb
102
- - lib/generators/templates/lib/custom_failure.rb
103
116
  homepage: https://blog.rivsc.ovh
104
117
  licenses:
105
118
  - MIT
@@ -121,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
134
  - !ruby/object:Gem::Version
122
135
  version: '0'
123
136
  requirements: []
124
- rubygems_version: 3.1.2
137
+ rubygems_version: 3.1.4
125
138
  signing_key:
126
139
  specification_version: 4
127
140
  summary: Beautiful Scaffold generate fully customizable scaffold
@@ -1,128 +0,0 @@
1
- # encoding : utf-8
2
- class BeautifulDevisecancanGenerator < Rails::Generators::Base
3
- require_relative 'beautiful_scaffold_common_methods'
4
- include BeautifulScaffoldCommonMethods
5
-
6
- source_root File.expand_path('../templates', __FILE__)
7
-
8
- argument :model, :type => :string, :desc => "Name of model (downcase singular)"
9
-
10
- def install_devise
11
- view_path = "app/views/"
12
-
13
- gem("devise", "2.1.0")
14
-
15
- inside Rails.root do
16
- run "bundle install"
17
- end
18
-
19
- generate("devise:install")
20
-
21
- for current_env in ['production', 'development', 'test']
22
- inject_into_file("config/environments/#{current_env}.rb", " config.action_mailer.default_url_options = { :host => 'localhost:3000' }", :after => "::Application.configure do\n" )
23
- end
24
-
25
- # Install devise in the model
26
- generate("devise", model)
27
-
28
- # Add :token_authenticatable and :lockable
29
- # In model
30
- inject_into_file( "app/models/#{model}.rb",
31
- ":token_authenticatable, :lockable,",
32
- :after => "devise ")
33
- # In migration
34
- filename = Dir.glob("db/migrate/*_add_devise_to_#{model.pluralize}.rb")[0]
35
- gsub_file filename, /#\s*(t\.integer\s+:failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts)/, '\1'
36
- gsub_file filename, /#\s*(t\.string\s+:unlock_token # Only if unlock strategy is :email or :both)/, '\1'
37
- gsub_file filename, /#\s*(t\.datetime\s+:locked_at)/, '\1'
38
- gsub_file filename, /#\s*(t\.string\s+:authentication_token)/, '\1'
39
-
40
-
41
- # Limited access (Must be commented if use cancan)
42
- inject_into_file("app/controllers/beautiful_controller.rb","before_action :authenticate_#{model}!, :except => [:dashboard]", :after => 'layout "beautiful_layout"' + "\n")
43
-
44
- # Custom redirect
45
- inject_into_file("app/controllers/application_controller.rb","
46
- def after_sign_out_path_for(resource_or_scope)
47
- root_path
48
- end
49
- def after_sign_in_path_for(resource)
50
- root_path
51
- end
52
- def after_sign_up_path_for(resource)
53
- root_path
54
- end
55
- ", :after => "protect_from_forgery\n")
56
- copy_file("lib/custom_failure.rb")
57
- copy_file("app/controllers/registrations_controller.rb")
58
- inject_into_file("config/initializers/devise.rb","
59
- config.warden do |manager|
60
- manager.failure_app = CustomFailure
61
- end
62
- ", :after => "Devise.setup do |config|\n")
63
- inject_into_file("config/application.rb",' #{config.root}/lib', :after => '#{config.root}/app/modules')
64
-
65
- # Use my register controller
66
- inject_into_file("config/routes.rb",
67
- ', :controllers => {:registrations => "registrations"}',
68
- :after => "devise_for :#{model.pluralize}")
69
-
70
-
71
- # Install partials dans layout (forget password, sign_in)
72
- template("#{view_path}partials/_forget_password.html.erb", "#{view_path}layouts/_forget_password.html.erb")
73
- template("#{view_path}partials/_sign_in_sign_out.html.erb", "#{view_path}layouts/_sign_in_sign_out.html.erb")
74
- template("#{view_path}partials/_sign_in_form.html.erb", "#{view_path}layouts/_sign_in_form.html.erb")
75
- template("#{view_path}partials/_register_form.html.erb", "#{view_path}layouts/_register_form.html.erb")
76
-
77
- # Sign in sign out
78
- inject_into_file("#{view_path}layouts/beautiful_layout.html.erb",
79
- "<%= render :partial => 'layouts/sign_in_sign_out' %>",
80
- :after => "<!-- Beautiful_scaffold - Signin - Do not remove -->\n")
81
-
82
- # Modal (forget password)
83
- inject_into_file("#{view_path}layouts/beautiful_layout.html.erb",
84
- " <%= render :partial => 'layouts/forget_password' %>",
85
- :after => "<!-- Beautiful_scaffold - Modal - Do not remove -->\n")
86
- inject_into_file("#{view_path}layouts/beautiful_layout.html.erb",
87
- " <%= render :partial => 'layouts/register_form' %>",
88
- :after => "<!-- Beautiful_scaffold - Modal - Do not remove -->\n")
89
-
90
- end
91
-
92
- def install_cancan
93
- gem("cancan")
94
-
95
- inside Rails.root do
96
- run "bundle install"
97
- end
98
-
99
- generate("cancan:ability")
100
-
101
- inject_into_file("app/models/ability.rb", "
102
- if not user.nil? then
103
- if user.id == 1 then
104
- can :manage, :all
105
- end
106
- end\n", :after => "def initialize(user)\n")
107
-
108
- # current_user method need for CanCan
109
- current_user_method = ""
110
- if model != "user" then
111
- current_user_method = "
112
- def current_user
113
- current_#{model}
114
- end"
115
- end
116
-
117
- # Exception for AccessDenied
118
- inject_into_file("app/controllers/application_controller.rb", "
119
- rescue_from CanCan::AccessDenied do |exception|
120
- redirect_to root_url, :alert => exception.message
121
- end
122
- #{current_user_method}
123
- ", :after => "class ApplicationController < ActionController::Base\n")
124
-
125
- # Access controlled by CanCan (in beautiful_scaffold)
126
- inject_into_file("app/controllers/application_controller.rb", "#", :before => "before_action :authenticate_#{model}!, :except => [:dashboard]")
127
- end
128
- end
@@ -1,44 +0,0 @@
1
-
2
- <div class="modal fade" id="modal-register-form">
3
- <div class="modal-dialog">
4
- <div class="modal-content">
5
- <div class="modal-header">
6
- <h5 class="modal-title"><%%= t(:register, :default => "Register") %></h5>
7
- <button type="button" class="close" data-dismiss="modal">×</button>
8
- </div>
9
- <div class="modal-body">
10
- <%% resource ||= <%= model.camelize %>.new %>
11
- <%%= form_for(resource, :as => '<%= model %>', :url => registration_path('<%= model %>'), :html => { :class => "form-horizontal" }) do |f| %>
12
- <%% begin %>
13
- <%%= devise_error_messages! %>
14
- <%% rescue %>
15
- <%% end %>
16
- <div class="form-group">
17
- <%%= f.label :email, t(:email, :default => "Email"), :class => "control-label" %>
18
- <div>
19
- <%%= f.email_field :email %>
20
- </div>
21
- </div>
22
- <div class="form-group">
23
- <%%= f.label :password, t(:password, :default => "Password"), :class => "control-label" %>
24
- <div>
25
- <%%= f.password_field :password %>
26
- </div>
27
- </div>
28
- <div class="form-group">
29
- <%%= f.label :password_confirmation, t(:password_confirmation, :default => "Password confirmation"), :class => "control-label" %>
30
- <div>
31
- <%%= f.password_field :password_confirmation %>
32
- </div>
33
- </div>
34
-
35
- <div class="form-group">
36
- <div>
37
- <%%= f.submit t(:sign_up, :default => "Sign up"), :class => 'btn btn-light' %>
38
- </div>
39
- </div>
40
- <%% end %>
41
- </div>
42
- </div>
43
- </div>
44
- </div>
@@ -1,18 +0,0 @@
1
- <div style="padding:10px;">
2
- <%%= form_for("<%= model %>", :url => <%= model %>_session_path, :html => { :class => "form-horizontal" }) do |f| %>
3
- <div class="form-group">
4
- <%%= f.text_field :email, :placeholder => t(:email, :default => "Email") %>
5
- </div>
6
- <div class="form-group">
7
- <%%= f.password_field :password, :placeholder => t(:password, :default => "Password") %>
8
- </div>
9
- <div class="form-group">
10
- <label for="<%= model %>_remember_me">
11
- <%%= f.check_box :remember_me %> <%%= t(:remember_me, :default => "Remember me") %>
12
- </label>
13
- </div>
14
- <%%= f.submit t(:sign_in, :default => "Sign in"), :class => "btn btn-light" %>
15
- <%% end %>
16
- <a data-toggle="modal" href="#modal-forget-password"><%%= t(:forgot_your_password, :default => "Forgot your password?") %></a>
17
- <a data-toggle="modal" href="#modal-register-form"><%%= t(:register, :default => "Register") %></a>
18
- </div>
@@ -1,19 +0,0 @@
1
- <%% if <%= model %>_signed_in? %>
2
- <a class="dropdown-toggle" data-toggle="dropdown" href="#">
3
- <i class="icon-user"></i> <%%= current_<%= model %>.caption %>
4
- <span class="caret"></span>
5
- </a>
6
- <ul class="dropdown-menu">
7
- <li><a href="#"><%%= t(:profile, :default => "Profile") %></a></li>
8
- <li class="dropdown-divider"></li>
9
- <li><%%= link_to t(:sign_out, :default => "Sign Out"), destroy_<%= model %>_session_path, :method => :delete %></li>
10
- </ul>
11
- <%% else %>
12
- <a class="dropdown-toggle" data-toggle="dropdown" href="#">
13
- <i class="icon-user"></i> <%%= t(:login, :default => "Login") %>
14
- <span class="caret"></span>
15
- </a>
16
- <ul class="dropdown-menu">
17
- <li><%%= render :partial => "layouts/sign_in_form" %></li>
18
- </ul>
19
- <%% end %>
@@ -1,15 +0,0 @@
1
- class CustomFailure < Devise::FailureApp
2
- def redirect_url
3
- #return super unless [:worker, :employer, :user].include?(scope) #make it specific to a scope
4
- root_path
5
- end
6
-
7
- # You need to override respond to eliminate recall
8
- def respond
9
- if http_auth?
10
- http_auth
11
- else
12
- redirect
13
- end
14
- end
15
- end