scaffold_plus 1.10.3 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +4 -4
  3. data/README.md +61 -51
  4. data/lib/generators/scaffold_plus/ancestry/ancestry_generator.rb +1 -1
  5. data/lib/generators/scaffold_plus/authority/authority_generator.rb +3 -0
  6. data/lib/generators/scaffold_plus/{enum/enum_generator.rb → enumerize/enumerize_generator.rb} +5 -5
  7. data/lib/generators/scaffold_plus/{enum → enumerize}/templates/enum_migration.rb +1 -1
  8. data/lib/generators/scaffold_plus/friendly_id/friendly_id_generator.rb +6 -0
  9. data/lib/generators/scaffold_plus/sorcery/sorcery_generator.rb +150 -0
  10. data/lib/generators/scaffold_plus/sorcery/templates/_form.html.erb +23 -0
  11. data/lib/generators/scaffold_plus/sorcery/templates/change.html.erb +15 -0
  12. data/lib/generators/scaffold_plus/sorcery/templates/edit.html.erb +5 -0
  13. data/lib/generators/scaffold_plus/sorcery/templates/index.html.erb +62 -0
  14. data/lib/generators/scaffold_plus/sorcery/templates/initializer.rb +114 -0
  15. data/lib/generators/scaffold_plus/sorcery/templates/log_in.html.erb +18 -0
  16. data/lib/generators/scaffold_plus/sorcery/templates/new.html.erb +5 -0
  17. data/lib/generators/scaffold_plus/sorcery/templates/password.html.erb +12 -0
  18. data/lib/generators/scaffold_plus/sorcery/templates/reset_password_email.html.erb +8 -0
  19. data/lib/generators/scaffold_plus/sorcery/templates/show.html.erb +87 -0
  20. data/lib/generators/scaffold_plus/sorcery/templates/sorcery.de.yml +62 -0
  21. data/lib/generators/scaffold_plus/sorcery/templates/sorcery.en.yml +62 -0
  22. data/lib/generators/scaffold_plus/sorcery/templates/user_mailer.rb +14 -0
  23. data/lib/generators/scaffold_plus/sorcery/templates/user_migration.rb +62 -0
  24. data/lib/generators/scaffold_plus/sorcery/templates/user_model.rb +18 -0
  25. data/lib/generators/scaffold_plus/sorcery/templates/users_controller.rb +156 -0
  26. data/lib/scaffold_plus/version.rb +1 -1
  27. data/scaffold_plus.gemspec +4 -4
  28. metadata +30 -14
  29. data/lib/generators/scaffold_plus/force_ssl/force_ssl_generator.rb +0 -46
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a06eafe527c42454877aac2670d62bc1ff41503c
4
- data.tar.gz: c5ba0379d8fb3a591d9a7c582d113bd154bd344f
3
+ metadata.gz: c7d2e202759f6157c5bca94e2616ea117b144a0a
4
+ data.tar.gz: c7594d18a5918aaa42d210770a61e251cac06205
5
5
  SHA512:
6
- metadata.gz: bab8484467855ead6d439a53b75b0239280373f055b195752b4148e97ad01c6850aeb6d8b931d0e06aeeccce115e2da7881773dca46324a9b6c27970f59d9bed
7
- data.tar.gz: 879f8b0701e895ccad7b968bcbb08ba03dde508d4626409c88226d5879f4663915a4d0e26a60d30b7fdf1f71388b550fcf980433e9a12d1e0600ee32fce76f8f
6
+ metadata.gz: d0590b2b7ae236631523e25e1dafc44a0472eb982929904891f532dc1976b98c9c345e18564e3acac04be72e8a5edaf142f233b3d3cfd089cc43e749ef0c9a87
7
+ data.tar.gz: f24bed53fcac42c60699a1ae75dc561039cdce7dbababb3c7e2d46842c374073f4fc3a510a4290e8f3ad44c5c40ebfb2bab2223c77b13bae64b2cd9d30b9f1eb
data/Makefile CHANGED
@@ -9,15 +9,15 @@ all: build
9
9
  rel: build
10
10
  vim lib/scaffold_plus/version.rb
11
11
  git commit -a
12
- sudo gem uninstall scaffold_plus --all
12
+ gem uninstall scaffold_plus --all
13
13
  rake release
14
14
 
15
15
 
16
16
  install: build
17
17
  git commit -a
18
- sudo gem uninstall scaffold_plus --all
19
- sudo rake install
20
- sudo rm -rf pkg
18
+ gem uninstall scaffold_plus --all
19
+ rake install
20
+ rm -rf pkg
21
21
 
22
22
  build:
23
23
  git add lib
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ScaffoldPlus
2
2
 
3
- A collection of little helpers for Rails scaffolding
3
+ A collection of helpers for Rails scaffolding
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,72 +18,41 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- ### Add migrations to change tables and columns
22
- rails generate scaffold_plus:migration table --remove column [...]
23
- rails generate scaffold_plus:migration table --rename old:new [...]
24
- rails generate scaffold_plus:migration table --change column:type [...]
25
- rails generate scaffold_plus:migration table --not_null column [...]
26
- rails generate scaffold_plus:migration table --set_default column:value [...]
27
-
28
- This helper creates migrations for some 'ALTER TABLE' statements.
29
-
30
- ### Add support for an enum field (requires Rails 4.1 and the enum_help Gem)
31
- rails generate scaffold_plus:enum
32
-
33
- This helper adds parent#has_many and child#belongs_to to the models
34
- and updates the mass assignment whitelist in the controller.
35
- It can also add a migration for the parent_id and a counter.
36
-
37
- ### Add regular one-to-many association (has_many / belongs_to)
38
- rails generate scaffold_plus:has_many
39
-
40
- This helper adds parent#has_many and child#belongs_to to the models
41
- and updates the mass assignment whitelist in the controller.
42
- It can also add a migration for the parent_id and a counter.
43
-
44
- ### Add regular one-to-one association (has_one / belongs_to)
45
- rails generate scaffold_plus:has_one
46
-
47
- This helper adds parent#has_one and child#belongs_to to the models
48
- and updates the mass assignment whitelist in the controller.
49
- It can also add a migration for the parent_id.
50
-
51
- ### Add a collection to a resource route
52
- rails generate scaffold_plus:collection
53
-
54
- This helper works on config/routes.rb and adds code for a collection
55
- to a newly created resource route.
56
-
57
21
  ### Add ancestry to create a tree structure (or hierarchy)
58
22
  rails generate scaffold_plus:ancestry
59
23
 
24
+ This helper depends on the [ancestry](https://github.com/stefankroes/ancestry) gem.
60
25
  This helper adds has_ancestry to the model and updates the mass assignment
61
26
  whitelist in the controller. It can also add a migration.
62
27
 
63
- ### Add many-to-many association with intermediate join table
64
- rails generate scaffold_plus:many_to_many
65
-
66
- This helper creates a join table and updates the two parent resources.
67
- It can handle additional attributes in the join table incl. whitelisting
68
- and accepts_nested_attributes_for in one of the parents.
28
+ ### Add authority
29
+ rails generate scaffold_plus:authority
69
30
 
70
- ### Add many-to-many association with has_and_belongs_to_many
71
- rails generate scaffold_plus:habtm
72
-
73
- This helper scaffolds a has_and_belongs_to_many relationship with migration
74
- and updates to the models.
31
+ TODO
75
32
 
76
33
  ### Set the autofocus flag on a column
77
34
  rails generate scaffold_plus:autofocus
78
35
 
79
36
  This helper adds "autofocus: true" to an input field in the form view.
80
37
 
38
+ ### Add a collection to a resource route
39
+ rails generate scaffold_plus:collection
40
+
41
+ This helper works on config/routes.rb and adds code for a collection
42
+ to a newly created resource route. Also, empty views are generated.
43
+
44
+ ### Add support for an enum field
45
+ rails generate scaffold_plus:enumerize
46
+
47
+ This helper depends on the [enumerize](https://github.com/brainspec/enumerize) gem.
48
+ A column of type string is added to the model and controller attribute whitelist.
49
+
81
50
  ### Add friendly_id to resource
82
51
  rails generate friendly_id
83
- rails generate scaffold_plus:friendly_id [attribute]
52
+ rails generate scaffold_plus:friendly_id resource [attribute = 'name']
84
53
 
85
- This helper depends on the [friendly_id](https://github.com/norman/friendly_id/)
86
- gem. It adds "extend FriendlyId" to the model and marks the attribute which is to
54
+ This helper depends on the [friendly_id](https://github.com/norman/friendly_id) gem.
55
+ It adds "extend FriendlyId" to the model and marks the attribute which is to
87
56
  be slugged (default: 'name'). Currently it is hardcoded to add a 'slug' attribute.
88
57
 
89
58
  ### Add geo location to resource
@@ -110,6 +79,47 @@ This helper requires the [geodesic_wgs84](https://github.com/volkerwiegand/geode
110
79
  gem. The purpose of this helper is to add a "to_ary" method to the model, which
111
80
  makes it easy to use the resource in calulations like average distance and the like.
112
81
 
82
+ ### Add many-to-many association with has_and_belongs_to_many
83
+ rails generate scaffold_plus:habtm
84
+
85
+ This helper scaffolds a has_and_belongs_to_many relationship with migration
86
+ and updates to the models.
87
+
88
+ ### Add regular one-to-many association (has_many / belongs_to)
89
+ rails generate scaffold_plus:has_many
90
+
91
+ This helper adds parent#has_many and child#belongs_to to the models
92
+ and updates the mass assignment whitelist in the controller.
93
+ It can also add a migration for the parent_id and a counter.
94
+
95
+ ### Add regular one-to-one association (has_one / belongs_to)
96
+ rails generate scaffold_plus:has_one
97
+
98
+ This helper adds parent#has_one and child#belongs_to to the models
99
+ and updates the mass assignment whitelist in the controller.
100
+ It can also add a migration for the parent_id.
101
+
102
+ ### Add many-to-many association with intermediate join table
103
+ rails generate scaffold_plus:many_to_many
104
+
105
+ This helper creates a join table and updates the two parent resources.
106
+ It can handle additional attributes in the join table incl. whitelisting
107
+ and accepts_nested_attributes_for in one of the parents.
108
+
109
+ ### Add migrations to change tables and columns
110
+ rails generate scaffold_plus:migration table --remove column [...]
111
+ rails generate scaffold_plus:migration table --rename old:new [...]
112
+ rails generate scaffold_plus:migration table --change column:type [...]
113
+ rails generate scaffold_plus:migration table --not_null column [...]
114
+ rails generate scaffold_plus:migration table --set_default column:value [...]
115
+
116
+ This helper creates migrations for some 'ALTER TABLE' statements.
117
+
118
+ ### Add sorcery
119
+ rails generate scaffold_plus:sorcery
120
+
121
+ TODO
122
+
113
123
  ## Testing
114
124
 
115
125
  Since I have no experience with test driven development (yet), this is
@@ -3,7 +3,7 @@ require 'rails/generators/active_record'
3
3
  module ScaffoldPlus
4
4
  module Generators
5
5
  class AncestryGenerator < ActiveRecord::Generators::Base
6
- desc "Add ancestry to create a tree structure (or hierarchy)"
6
+ desc "Add ancestry to create a tree structure (requires ancestry gem)"
7
7
  argument :name, type: :string,
8
8
  desc: "The object that has_ancestry"
9
9
  class_option :depth, type: :boolean, default: false,
@@ -50,6 +50,9 @@ module ScaffoldPlus
50
50
  inject_into_file file, after: /@#{name} = #{class_name}.find.*$/ do
51
51
  "\n authorize_action_for(@#{name})"
52
52
  end
53
+ inject_into_file file, after: /@#{name} = #{class_name}.friendly.find.*$/ do
54
+ "\n authorize_action_for(@#{name})"
55
+ end
53
56
  end
54
57
  end
55
58
  end
@@ -2,14 +2,14 @@ require 'rails/generators/active_record'
2
2
 
3
3
  module ScaffoldPlus
4
4
  module Generators
5
- class EnumGenerator < ActiveRecord::Generators::Base
6
- desc "Add an enum field to a resource (requires enum_help gem)"
5
+ class EnumerizeGenerator < ActiveRecord::Generators::Base
6
+ desc "Add an enum field to a resource (requires enumerize gem)"
7
7
  argument :name, type: :string,
8
8
  desc: "The object that will have the enum field"
9
9
  argument :column, type: :string,
10
10
  desc: "The column to be used as enum field"
11
11
  argument :values, type: :array, banner: "VALUE [...]",
12
- desc: "Values (counting from 0, first is default)"
12
+ desc: "Values (can be strings or symbols)"
13
13
  class_option :migration, type: :boolean, default: false,
14
14
  desc: 'Create a migration for added attributes'
15
15
  class_option :index, type: :boolean, default: true,
@@ -29,9 +29,9 @@ module ScaffoldPlus
29
29
 
30
30
  def update_model
31
31
  inject_into_class "app/models/#{name}.rb", class_name do
32
- list = values.map{|v| ":#{v}"}.join(', ')
33
32
  text = options.before? ? "\n" : ""
34
- text << " enum #{column}: [ #{list} ]\n"
33
+ text << " extend Enumerize\n"
34
+ text << " enumerize :#{column}, in: #{values}\n"
35
35
  text << "\n" if options.after?
36
36
  text
37
37
  end
@@ -1,6 +1,6 @@
1
1
  class <%= migration_name.camelize %> < ActiveRecord::Migration
2
2
  def change
3
- add_column :<%= table_name %>, :<%= column %>, :integer, default: 0
3
+ add_column :<%= table_name %>, :<%= column %>, :string
4
4
  <%- if options.index? -%>
5
5
  add_index :<%= table_name %>, :<%= column %>
6
6
  <%- end -%>
@@ -37,6 +37,12 @@ module ScaffoldPlus
37
37
  end
38
38
  end
39
39
 
40
+ def update_controller
41
+ return if options.finders?
42
+ file = "app/controllers/#{table_name}_controller.rb"
43
+ gsub_file file, /(#{class_name})\.find/, "\\1.friendly.find"
44
+ end
45
+
40
46
  protected
41
47
 
42
48
  def migration_name
@@ -0,0 +1,150 @@
1
+ require 'rails/generators/active_record'
2
+
3
+ module ScaffoldPlus
4
+ module Generators
5
+ class SorceryGenerator < ActiveRecord::Generators::Base
6
+ desc "Install authentication (with Sorcery) and setup users."
7
+ argument :name, type: :string, default: "user",
8
+ banner: "name of the user model"
9
+ class_option :user_activation, type: :boolean, default: false,
10
+ desc: 'User activation by email with optional success email'
11
+ class_option :reset_password, type: :boolean, default: false,
12
+ desc: 'Reset password with email verification'
13
+ class_option :remember_me, type: :boolean, default: false,
14
+ desc: 'Remember me with configurable expiration'
15
+ class_option :session_timeout, type: :boolean, default: false,
16
+ desc: 'Configurable session timeout'
17
+ class_option :brute_force_protection, type: :boolean, default: false,
18
+ desc: 'Brute force login hammering protection'
19
+ class_option :http_basic_auth, type: :boolean, default: false,
20
+ desc: 'A before filter for requesting authentication with HTTP Basic'
21
+ class_option :activity_logging, type: :boolean, default: false,
22
+ desc: 'Automatic logging of last login, logout and activity'
23
+ class_option :external, type: :boolean, default: false,
24
+ desc: 'OAuth1 and OAuth2 support (Twitter, Facebook, etc.)'
25
+ class_option :layout, type: :string, default: 'centered',
26
+ desc: 'Layout to be used for rendering login.html.erb'
27
+ class_option :authority, type: :boolean, default: false,
28
+ desc: 'Include Authority::UserAbilities in user model'
29
+ source_root File.expand_path("../templates", __FILE__)
30
+
31
+ def add_migrations
32
+ migration_template "user_migration.rb", "db/migrate/create_#{table_name}.rb"
33
+ end
34
+
35
+ def add_models
36
+ template "user_model.rb", "app/models/#{name}.rb"
37
+ end
38
+
39
+ def add_mailer
40
+ return unless options.reset_password?
41
+ template "user_mailer.rb", "app/mailers/#{mailer_name}.rb"
42
+ template "reset_password_email.html.erb", "app/views/#{mailer_name}/reset_password_email.html.erb"
43
+ end
44
+
45
+ def add_controllers
46
+ template "users_controller.rb", "app/controllers/#{table_name}_controller.rb"
47
+ end
48
+
49
+ def add_views
50
+ views = %w[edit _form index log_in new show]
51
+ views += %w[password change] if options.reset_password?
52
+ views.each do |view|
53
+ template "#{view}.html.erb", "app/views/#{table_name}/#{view}.html.erb"
54
+ end
55
+ end
56
+
57
+ def add_routes
58
+ lines = [
59
+ "resources :#{table_name} do",
60
+ " collection do",
61
+ " get 'log_in'",
62
+ " post 'access'",
63
+ " get 'log_out'"
64
+ ]
65
+ lines << [
66
+ " get 'password'",
67
+ " post 'reset'"
68
+ ] if options.reset_password?
69
+ lines << [
70
+ " end"
71
+ ]
72
+ lines << [
73
+ " member do",
74
+ " get 'change'",
75
+ " patch 'refresh'",
76
+ " put 'refresh'",
77
+ " end"
78
+ ] if options.reset_password?
79
+ lines << [
80
+ " end",
81
+ " get '/login' => '#{table_name}#log_in', as: :login, format: false",
82
+ " get '/logout' => '#{table_name}#log_out', as: :logout, format: false",
83
+ ""
84
+ ]
85
+ route lines.join("\n")
86
+ end
87
+
88
+ def add_initializer
89
+ template "initializer.rb", "config/initializers/sorcery.rb"
90
+ end
91
+
92
+ def add_locales
93
+ %w[en de].each do |locale|
94
+ template "sorcery.#{locale}.yml", "config/locales/sorcery.#{locale}.yml"
95
+ end
96
+ end
97
+
98
+ def update_application_controller
99
+ file = "app/controllers/application_controller.rb"
100
+ inject_into_class file, "ApplicationController", " before_action :require_login\n\n"
101
+ inject_into_file file, "\n\n private", after: /protect_from_forgery.*$/
102
+ lines = [
103
+ "",
104
+ " def not_authenticated",
105
+ " redirect_to login_path, alert: t('sorcery.required')",
106
+ " end",
107
+ "",
108
+ " def current_sysadm?",
109
+ " logged_in? and current_#{name}.sysadm",
110
+ " end",
111
+ " helper_method :current_sysadm?",
112
+ ""
113
+ ]
114
+ inject_into_file file, lines.join("\n"), before: /^end$/
115
+ end
116
+
117
+ protected
118
+
119
+ def submodules
120
+ modules = []
121
+ modules << ":user_activation" if options.user_activation?
122
+ modules << ":reset_password" if options.reset_password?
123
+ modules << ":remember_me" if options.remember_me?
124
+ modules << ":session_timeout" if options.session_timeout?
125
+ modules << ":brute_force_protection" if options.brute_force_protection?
126
+ modules << ":http_basic_auth" if options.http_basic_auth?
127
+ modules << ":activity_logging" if options.activity_logging?
128
+ modules << ":external" if options.external?
129
+ modules.join(', ')
130
+ end
131
+
132
+ def migration_name
133
+ "create_#{table_name}"
134
+ end
135
+
136
+ def mailer_name
137
+ "#{name}_mailer"
138
+ end
139
+
140
+ def controller_name
141
+ "#{table_name}_controller"
142
+ end
143
+
144
+ def whitelist
145
+ ":email, :name, :phone, :comment, :theme, " +
146
+ ":active, :sysadm, :password, :password_confirmation"
147
+ end
148
+ end
149
+ end
150
+ end
@@ -0,0 +1,23 @@
1
+ <%%= simple_form_for(@<%= name %>) do |f| %>
2
+ <%%= f.error_notification %>
3
+
4
+ <%%= f.input :email, autofocus: true %>
5
+ <%%= f.input :name %>
6
+ <%%= f.input :phone %>
7
+ <%%= f.input :comment %>
8
+ <%%= f.input :theme %>
9
+ <%%= f.input :active %>
10
+ <%%- if current_<%= name %>.sysadm and @<%= name %> != current_<%= name %> -%>
11
+ <%%= f.input :sysadm %>
12
+ <%%- end -%>
13
+ <%%= f.input :password %>
14
+ <%%= f.input :password_confirmation %>
15
+
16
+ <%%= f.button :submit, class: 'btn btn-primary' %>
17
+ <%%- if @<%= name %>.new_record? -%>
18
+ <%%= link_to t('actions.back.index'), <%= table_name %>_path, class: 'btn btn-default' %>
19
+ <%%- else -%>
20
+ <%%= link_to t('actions.back.show'), @<%= name %>, class: 'btn btn-default' %>
21
+ <%%= link_to t('actions.back.index'), <%= table_name %>_path, class: 'btn btn-default' %>
22
+ <%%- end -%>
23
+ <%% end %>
@@ -0,0 +1,15 @@
1
+ <%%- page_title t('sorcery.reset.choose') -%>
2
+ <h2><%%= t('sorcery.reset.choose') %></h2>
3
+ <%%- content_for(:help) { "<%= name %>_change" } -%>
4
+
5
+ <%%= simple_form_for(@<%= name %>, url: {action: "refresh"}) do |f| %>
6
+ <%%= f.error_notification %>
7
+
8
+ <%%= f.input :email, disabled: true, required: false %>
9
+ <%%= f.input :reset_password_token, as: :hidden %>
10
+ <%%= f.input :password, required: true, autofocus: true %>
11
+ <%%= f.input :password_confirmation, required: true %>
12
+
13
+ <%%= f.button :submit, t('sorcery.reset.change'), class: 'btn btn-primary' %>
14
+ <%%= link_to t('sorcery.reset.back'), log_in_<%= table_name %>_path, class: 'btn btn-default' %>
15
+ <%% end %>
@@ -0,0 +1,5 @@
1
+ <%%- page_title t('headers.edit', name: t('activerecord.models.<%= name %>.one')) -%>
2
+ <h2><%%= t('headers.edit', name: t('activerecord.models.<%= name %>.one')) %></h2>
3
+ <%%- content_for(:help) { "<%= name %>_edit" } -%>
4
+
5
+ <%%= render 'form' %>
@@ -0,0 +1,62 @@
1
+ <%%- page_title t('headers.index', name: t('activerecord.models.<%= name %>.other')) -%>
2
+ <h2><%%= t('headers.index', name: t('activerecord.models.<%= name %>.other')) %></h2>
3
+ <%%- content_for(:help) { "<%= name %>_index" } -%>
4
+
5
+ <table class="table table-striped table-hover">
6
+ <thead>
7
+ <tr>
8
+ <th>
9
+ <%%= t('activerecord.attributes.<%= name %>.name') %>
10
+ </th>
11
+ <th>
12
+ <%%= t('activerecord.attributes.<%= name %>.phone') %>
13
+ </th>
14
+ <th>
15
+ <%%= t('activerecord.attributes.<%= name %>.comment') %>
16
+ </th>
17
+ <th>
18
+ <%%= t('activerecord.attributes.<%= name %>.active') %>
19
+ </th>
20
+ <th class="index-actions">
21
+ <%%= t('actions.title') %>
22
+ </th>
23
+ </tr>
24
+ </thead>
25
+
26
+ <tbody>
27
+ <%% @<%= table_name %>.each do |<%= name %>| %>
28
+ <tr>
29
+ <td>
30
+ <%%= mail_to(<%= name %>.email, <%= name %>.name) %>
31
+ </td>
32
+ <td>
33
+ <%%= <%= name %>.phone %>
34
+ </td>
35
+ <td>
36
+ <%%= <%= name %>.comment %>
37
+ </td>
38
+ <td>
39
+ <%%= <%= name %>.active ? t('simple_form.yes') : t('simple_form.no') %>
40
+ <%%- if <%= name %>.sysadm -%>
41
+ (<%%= t('activerecord.attributes.<%= name %>.sysadm') %>)
42
+ <%%- end -%>
43
+ </td>
44
+ <td class="index-actions">
45
+ <%%= link_to t('actions.show'), <%= name %>, class: 'btn btn-default btn-xs' %>
46
+ <%%- if current_<%= name %>.sysadm or <%= name %> == current_<%= name %> -%>
47
+ <br>
48
+ <%%= link_to t('actions.edit'), [:edit, <%= name %>], class: 'btn btn-default btn-xs' %>
49
+ <%%- end -%>
50
+ <%%- if current_<%= name %>.sysadm and <%= name %> != current_<%= name %> -%>
51
+ <br>
52
+ <%%= link_to t('actions.destroy'), <%= name %>, method: :delete, data: { confirm: t('actions.confirm') }, class: 'btn btn-danger btn-xs' %>
53
+ <%%- end -%>
54
+ </td>
55
+ </tr>
56
+ <%% end %>
57
+ </tbody>
58
+ </table>
59
+
60
+ <br>
61
+
62
+ <%%= link_to t('actions.add', name: t('activerecord.models.<%= name %>.one')), new_<%= name %>_path, class: 'btn btn-primary' %>
@@ -0,0 +1,114 @@
1
+ #
2
+ # This initializer was derived from the original Sorcery initializer
3
+ #
4
+
5
+ Rails.application.config.sorcery.submodules = [<%= submodules %>]
6
+
7
+ Rails.application.config.sorcery.configure do |config|
8
+ # -- core --
9
+ # config.not_authenticated_action = :not_authenticated
10
+ # config.save_return_to_url = true
11
+ # config.cookie_domain = nil
12
+ <%- if options.session_timeout? -%>
13
+
14
+ # -- session_timeout --
15
+ # config.session_timeout = 3600
16
+ # config.session_timeout_from_last_action = false
17
+ <%- end -%>
18
+ <%- if options.http_basic_auth? -%>
19
+
20
+ # -- http_basic_auth --
21
+ # config.controller_to_realm_map = { "application" => "Application" }
22
+ <%- end -%>
23
+ <%- if options.activity_logging? -%>
24
+
25
+ # -- activity_logging --
26
+ # config.register_login_time = true
27
+ # config.register_logout_time = true
28
+ # config.register_last_activity_time = true
29
+ <%- end -%>
30
+ <%- if options.external? -%>
31
+
32
+ # -- external --
33
+ # config.external_providers = []
34
+ # config.ca_file = 'path/to/ca_file'
35
+ <%- end -%>
36
+
37
+ # --- user config ---
38
+ config.user_config do |user|
39
+ # -- core --
40
+ # user.username_attribute_names = [:email]
41
+ # user.password_attribute_name = :password
42
+ # user.downcase_username_before_authenticating = false
43
+ # user.email_attribute_name = :email
44
+ # user.crypted_password_attribute_name = :crypted_password
45
+ # user.salt_join_token = ""
46
+ # user.salt_attribute_name = :salt
47
+ # user.stretches = nil
48
+ # user.encryption_key = nil
49
+ # user.custom_encryption_provider = nil
50
+ # user.encryption_algorithm = :bcrypt
51
+ # user.subclasses_inherit_config = false
52
+ <%- if options.user_activation? -%>
53
+
54
+ # -- user_activation --
55
+ # user.activation_state_attribute_name = :activation_state
56
+ # user.activation_token_attribute_name = :activation_token
57
+ # user.activation_token_expires_at_attribute_name = :activation_token_expires_at
58
+ # user.activation_token_expiration_period = nil
59
+ # user.user_activation_mailer = nil
60
+ # user.activation_mailer_disabled = false
61
+ # user.activation_needed_email_method_name = :activation_needed_email
62
+ # user.activation_success_email_method_name = :activation_success_email
63
+ # user.prevent_non_active_users_to_login = true
64
+ <%- end -%>
65
+ <%- if options.reset_password? -%>
66
+
67
+ # -- reset_password --
68
+ # user.reset_password_token_attribute_name = :reset_password_token
69
+ # user.reset_password_token_expires_at_attribute_name = :reset_password_token_expires_at
70
+ # user.reset_password_email_sent_at_attribute_name = :reset_password_email_sent_at
71
+ user.reset_password_mailer = <%= class_name %>Mailer
72
+ # user.reset_password_email_method_name = :reset_password_email
73
+ # user.reset_password_mailer_disabled = false
74
+ # user.reset_password_expiration_period = nil
75
+ # user.reset_password_time_between_emails = 300
76
+ <%- end -%>
77
+ <%- if options.remember_me? -%>
78
+
79
+ # -- remember_me --
80
+ # user.remember_me_httponly = true
81
+ # user.remember_me_for = 604800
82
+ <%- end -%>
83
+ <%- if options.brute_force_protection? -%>
84
+
85
+ # -- brute_force_protection --
86
+ # user.failed_logins_count_attribute_name = :failed_logins_count
87
+ # user.lock_expires_at_attribute_name = :lock_expires_at
88
+ # user.consecutive_login_retries_amount_limit = 50
89
+ # user.login_lock_time_period = 3600
90
+ # user.unlock_token_attribute_name = :unlock_token
91
+ # user.unlock_token_email_method_name = :send_unlock_token_email
92
+ # user.unlock_token_mailer_disabled = false
93
+ # user.unlock_token_mailer = nil
94
+ <%- end -%>
95
+ <%- if options.activity_logging? -%>
96
+
97
+ # -- activity_logging --
98
+ # user.last_login_at_attribute_name = :last_login_at
99
+ # user.last_logout_at_attribute_name = :last_logout_at
100
+ # user.last_activity_at_attribute_name = :last_activity_at
101
+ # user.activity_timeout = 600
102
+ <%- end -%>
103
+ <%- if options.external? -%>
104
+
105
+ # -- external --
106
+ # user.authentications_class = nil
107
+ # user.authentications_user_id_attribute_name = :user_id
108
+ # user.provider_attribute_name = :provider
109
+ # user.provider_uid_attribute_name = :uid
110
+ <%- end -%>
111
+ end
112
+
113
+ config.user_class = "<%= class_name %>"
114
+ end
@@ -0,0 +1,18 @@
1
+ <%%- page_title t('sorcery.log_in') -%>
2
+ <h2><%%= t('sorcery.header', name: app_name) %></h2>
3
+ <%%- content_for(:help) { "<%= name %>_login" } -%>
4
+
5
+ <%%= simple_form_for(@<%= name %>, url: {action: "access"}) do |f| %>
6
+ <%%= f.error_notification %>
7
+
8
+ <%%= f.input :email, autofocus: true %>
9
+ <%%= f.input :password %>
10
+ <%- if options.remember_me? -%>
11
+ <%%= f.input :remember_me %>
12
+ <%- end -%>
13
+
14
+ <%%= f.button :submit, t('sorcery.submit'), class: 'btn btn-primary' %>
15
+ <%- if options.reset_password? -%>
16
+ <%%= link_to t('sorcery.reset.forgot'), password_<%= table_name %>_path, class: 'btn btn-default' %>
17
+ <%- end -%>
18
+ <%% end %>
@@ -0,0 +1,5 @@
1
+ <%%- page_title t('headers.new', name: t('activerecord.models.<%= name %>.one')) -%>
2
+ <h2><%%= t('headers.new', name: t('activerecord.models.<%= name %>.one')) %></h2>
3
+ <%%- content_for(:help) { "<%= name %>_new" } -%>
4
+
5
+ <%%= render 'form' %>
@@ -0,0 +1,12 @@
1
+ <%%- page_title t('sorcery.reset.header') -%>
2
+ <h2><%%= t('sorcery.reset.header') %></h2>
3
+ <%%- content_for(:help) { "<%= name %>_password" } -%>
4
+
5
+ <%%= simple_form_for(@<%= name %>, url: {action: "reset"}) do |f| %>
6
+ <%%= f.error_notification %>
7
+
8
+ <%%= f.input :email, autofocus: true %>
9
+
10
+ <%%= f.button :submit, t('sorcery.reset.send'), class: 'btn btn-primary' %>
11
+ <%%= link_to t('sorcery.reset.back'), log_in_<%= table_name %>_path, class: 'btn btn-default' %>
12
+ <%% end %>