draft_generators 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/VERSION +1 -1
- data/draft_generators.gemspec +21 -20
- data/lib/draft_generators.rb +1 -0
- data/lib/generators/draft/account/account_generator.rb +189 -0
- data/lib/generators/draft/account/templates/controllers/authentication_controller.rb +96 -0
- data/lib/generators/draft/account/templates/views/authentication/edit_profile.html.erb +38 -0
- data/lib/generators/draft/account/templates/views/authentication/edit_profile_with_errors.html.erb +44 -0
- data/lib/generators/draft/account/templates/views/authentication/sign_in.html.erb +23 -0
- data/lib/generators/draft/account/templates/views/authentication/sign_up.html.erb +43 -0
- data/lib/generators/draft/layout/layout_generator.rb +3 -3
- data/lib/generators/draft/layout/templates/_cdn_assets.html.erb +13 -0
- data/lib/generators/draft/layout/templates/_navbar.html.erb +1 -1
- data/lib/generators/draft/layout/templates/layout.html.erb +13 -12
- data/lib/generators/draft/resource/resource_generator.rb +19 -17
- data/lib/generators/draft/resource/templates/controllers/controller.rb +45 -44
- data/lib/generators/draft/resource/templates/controllers/read_only_controller.rb +2 -2
- data/lib/generators/draft/resource/templates/views/association_new_form.html.erb +6 -6
- data/lib/generators/draft/resource/templates/views/edit_form.html.erb +7 -7
- data/lib/generators/draft/resource/templates/views/edit_form_with_errors.html.erb +8 -8
- data/lib/generators/draft/resource/templates/views/index.html.erb +69 -23
- data/lib/generators/draft/resource/templates/views/new_form.html.erb +7 -7
- data/lib/generators/draft/resource/templates/views/new_form_with_errors.html.erb +8 -8
- data/lib/generators/draft/resource/templates/views/show.html.erb +65 -25
- metadata +24 -5
- data/lib/generators/draft/layout/templates/_bootstrapcdn_assets.html.erb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d209a8d2e3679c9017931e313f683ea37cbfd82b3c15b7c342babc1ff200a297
|
4
|
+
data.tar.gz: 3d4309214d3292e7a4a763ae8796f5c415f472faa00564efec1d01c530ffcfb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e07f6a687883dc6d265d74b91fece5b402346a7c9f2f57a2749b02c221a9153ac7db2f407598fba7bc4b227a0eae0d0b8d8d98c0f0bf1b025465daf679ecac8
|
7
|
+
data.tar.gz: 17c6d5992dba3a40c16241b46119548722031bbfbbe406c506165f44c0e181a7515a043a609370070a8879019f509bde5c1392e1939bb82060749b8bee8c152f
|
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/draft_generators.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: draft_generators 0.0.
|
5
|
+
# stub: draft_generators 0.0.4 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "draft_generators".freeze
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.4"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Raghu Betina".freeze]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2023-05-30"
|
15
15
|
s.description = "This is a set of generators that help beginners learn to program. Primarily, they generate code that is more explicit and verbose and less idiomatic and \u201Cmagical\u201D than the built-in scaffold generator, which is helpful for beginners while they are learning how exactly things are wired together.".freeze
|
16
16
|
s.email = "raghu@firstdraft.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -31,6 +31,12 @@ Gem::Specification.new do |s|
|
|
31
31
|
"draft_generators.gemspec",
|
32
32
|
"lib/devise_customization_service.rb",
|
33
33
|
"lib/draft_generators.rb",
|
34
|
+
"lib/generators/draft/account/account_generator.rb",
|
35
|
+
"lib/generators/draft/account/templates/controllers/authentication_controller.rb",
|
36
|
+
"lib/generators/draft/account/templates/views/authentication/edit_profile.html.erb",
|
37
|
+
"lib/generators/draft/account/templates/views/authentication/edit_profile_with_errors.html.erb",
|
38
|
+
"lib/generators/draft/account/templates/views/authentication/sign_in.html.erb",
|
39
|
+
"lib/generators/draft/account/templates/views/authentication/sign_up.html.erb",
|
34
40
|
"lib/generators/draft/devise/devise_generator.rb",
|
35
41
|
"lib/generators/draft/devise/views/templates/confirmations/new.html.erb",
|
36
42
|
"lib/generators/draft/devise/views/templates/mailer/confirmation_instructions.html.erb",
|
@@ -50,7 +56,7 @@ Gem::Specification.new do |s|
|
|
50
56
|
"lib/generators/draft/devise/views/views_generator.rb",
|
51
57
|
"lib/generators/draft/layout/USAGE",
|
52
58
|
"lib/generators/draft/layout/layout_generator.rb",
|
53
|
-
"lib/generators/draft/layout/templates/
|
59
|
+
"lib/generators/draft/layout/templates/_cdn_assets.html.erb",
|
54
60
|
"lib/generators/draft/layout/templates/_flashes.html.erb",
|
55
61
|
"lib/generators/draft/layout/templates/_navbar.html.erb",
|
56
62
|
"lib/generators/draft/layout/templates/layout.html.erb",
|
@@ -87,28 +93,23 @@ Gem::Specification.new do |s|
|
|
87
93
|
]
|
88
94
|
s.homepage = "http://github.com/raghubetina/draft_generators".freeze
|
89
95
|
s.licenses = ["MIT".freeze]
|
90
|
-
s.rubygems_version = "
|
96
|
+
s.rubygems_version = "3.1.6".freeze
|
91
97
|
s.summary = "Generators that help beginners learn to program.".freeze
|
92
98
|
|
93
99
|
if s.respond_to? :specification_version then
|
94
100
|
s.specification_version = 4
|
101
|
+
end
|
95
102
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
s.add_dependency(%q<devise>.freeze, [">= 0"])
|
105
|
-
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
106
|
-
s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
107
|
-
s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
108
|
-
s.add_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
|
109
|
-
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
110
|
-
end
|
103
|
+
if s.respond_to? :add_runtime_dependency then
|
104
|
+
s.add_runtime_dependency(%q<indefinite_article>.freeze, [">= 0"])
|
105
|
+
s.add_runtime_dependency(%q<devise>.freeze, [">= 0"])
|
106
|
+
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
107
|
+
s.add_development_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
108
|
+
s.add_development_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
109
|
+
s.add_development_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
|
110
|
+
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
111
111
|
else
|
112
|
+
s.add_dependency(%q<indefinite_article>.freeze, [">= 0"])
|
112
113
|
s.add_dependency(%q<devise>.freeze, [">= 0"])
|
113
114
|
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
114
115
|
s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
data/lib/draft_generators.rb
CHANGED
@@ -0,0 +1,189 @@
|
|
1
|
+
require "rails/generators/named_base"
|
2
|
+
|
3
|
+
module Draft
|
4
|
+
class AccountGenerator < Rails::Generators::NamedBase
|
5
|
+
source_root File.expand_path("../templates", __FILE__)
|
6
|
+
|
7
|
+
argument :attributes, type: :array, default: [],
|
8
|
+
banner: "field:type field:type"
|
9
|
+
|
10
|
+
include Rails::Generators::ResourceHelpers
|
11
|
+
|
12
|
+
def generate_required_attributes
|
13
|
+
unless attributes_has_password_digest?
|
14
|
+
password_digest = Rails::Generators::GeneratedAttribute.parse(["password_digest", :string, nil].compact.join(":"))
|
15
|
+
attributes.unshift(password_digest)
|
16
|
+
end
|
17
|
+
unless attributes_has_email?
|
18
|
+
email = Rails::Generators::GeneratedAttribute.parse(["email", :string, nil].compact.join(":"))
|
19
|
+
attributes.unshift(email)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def generate_model
|
24
|
+
invoke "draft:model", paramaterize_attributes
|
25
|
+
edit_model
|
26
|
+
end
|
27
|
+
|
28
|
+
def generate_routes
|
29
|
+
authentication_routes
|
30
|
+
end
|
31
|
+
|
32
|
+
def generate_before_actions
|
33
|
+
authentication_helpers
|
34
|
+
end
|
35
|
+
|
36
|
+
def generate_controller
|
37
|
+
template "controllers/authentication_controller.rb", "app/controllers/#{singular_table_name.underscore}_authentication_controller.rb"
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_root_folder
|
41
|
+
empty_directory File.join("app/views", "#{singular_table_name.underscore}_authentication")
|
42
|
+
end
|
43
|
+
|
44
|
+
def generate_view_files
|
45
|
+
available_views.each do |view|
|
46
|
+
filename = view_authentication_filename_with_extensions(view)
|
47
|
+
template filename, File.join("app/views/#{singular_table_name.underscore}_authentication", File.basename(filename))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def authentication_routes
|
54
|
+
log :route, "Authentication routes"
|
55
|
+
|
56
|
+
route <<-RUBY.gsub(/^ /, "")
|
57
|
+
|
58
|
+
# Routes for the #{singular_table_name.humanize} account:
|
59
|
+
|
60
|
+
# SIGN UP FORM
|
61
|
+
get("/#{singular_table_name.underscore}_sign_up", { :controller => "#{singular_table_name.underscore}_authentication", :action => "sign_up_form" })
|
62
|
+
# CREATE RECORD
|
63
|
+
post("/insert_#{singular_table_name.underscore}", { :controller => "#{singular_table_name.underscore}_authentication", :action => "create" })
|
64
|
+
|
65
|
+
# EDIT PROFILE FORM
|
66
|
+
get("/edit_#{singular_table_name.underscore}_profile", { :controller => "#{singular_table_name.underscore}_authentication", :action => "edit_profile_form" })
|
67
|
+
# UPDATE RECORD
|
68
|
+
post("/modify_#{singular_table_name.underscore}", { :controller => "#{singular_table_name.underscore}_authentication", :action => "update" })
|
69
|
+
|
70
|
+
# DELETE RECORD
|
71
|
+
get("/cancel_#{singular_table_name.underscore}_account", { :controller => "#{singular_table_name.underscore}_authentication", :action => "destroy" })
|
72
|
+
|
73
|
+
# ------------------------------
|
74
|
+
|
75
|
+
# SIGN IN FORM
|
76
|
+
get("/#{singular_table_name.underscore}_sign_in", { :controller => "#{singular_table_name.underscore}_authentication", :action => "sign_in_form" })
|
77
|
+
# AUTHENTICATE AND STORE COOKIE
|
78
|
+
post("/#{singular_table_name.underscore}_verify_credentials", { :controller => "#{singular_table_name.underscore}_authentication", :action => "create_cookie" })
|
79
|
+
|
80
|
+
# SIGN OUT
|
81
|
+
get("/#{singular_table_name.underscore}_sign_out", { :controller => "#{singular_table_name.underscore}_authentication", :action => "destroy_cookies" })
|
82
|
+
|
83
|
+
#------------------------------
|
84
|
+
RUBY
|
85
|
+
end
|
86
|
+
|
87
|
+
def authentication_helpers
|
88
|
+
log :controller, "Authentication before_actions"
|
89
|
+
|
90
|
+
application_controller <<-RUBY.gsub(/^ /, "")
|
91
|
+
|
92
|
+
before_action(:load_current_#{singular_table_name.underscore})
|
93
|
+
|
94
|
+
# Uncomment line 5 in this file and line 3 in #{class_name.singularize}AuthenticationController if you want to force #{plural_table_name} to sign in before any other actions.
|
95
|
+
# before_action(:force_#{singular_table_name.underscore}_sign_in)
|
96
|
+
|
97
|
+
def load_current_#{singular_table_name.underscore}
|
98
|
+
the_id = session.fetch(:#{singular_table_name.underscore}_id, nil)
|
99
|
+
|
100
|
+
@current_#{singular_table_name.underscore} = #{class_name.singularize}.where({ :id => the_id }).first
|
101
|
+
end
|
102
|
+
|
103
|
+
def force_#{singular_table_name.underscore}_sign_in
|
104
|
+
if @current_#{singular_table_name.underscore} == nil
|
105
|
+
redirect_to("/#{singular_table_name.underscore}_sign_in", { :notice => "You have to sign in first." })
|
106
|
+
end
|
107
|
+
end
|
108
|
+
RUBY
|
109
|
+
end
|
110
|
+
|
111
|
+
def edit_model
|
112
|
+
sentinel = /.*ApplicationRecord\n/
|
113
|
+
content = " validates :email, :uniqueness => { :case_sensitive => false }\n"\
|
114
|
+
" validates :email, :presence => true\n"\
|
115
|
+
" has_secure_password\n"
|
116
|
+
if model_exists?
|
117
|
+
inside "app/models" do
|
118
|
+
insert_into_file "#{singular_table_name.underscore}.rb", content, after: sentinel
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def route(routing_code)
|
124
|
+
sentinel = /\.routes\.draw do(?:\s*\|map\|)?\s*$/
|
125
|
+
|
126
|
+
inside "config" do
|
127
|
+
insert_into_file "routes.rb", routing_code, after: sentinel
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def application_controller(app_code)
|
132
|
+
sentinel = /::Base$/
|
133
|
+
|
134
|
+
inside "app/controllers" do
|
135
|
+
insert_into_file "application_controller.rb", app_code, after: sentinel
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def available_views
|
140
|
+
%w(sign_up sign_in edit_profile edit_profile_with_errors)
|
141
|
+
end
|
142
|
+
|
143
|
+
def view_filename_with_extensions(name)
|
144
|
+
filename = [name, :html, :erb].compact.join(".")
|
145
|
+
folders = ["views"]
|
146
|
+
filename = File.join(folders, filename) if folders.any?
|
147
|
+
filename
|
148
|
+
end
|
149
|
+
|
150
|
+
def view_authentication_filename_with_extensions(name)
|
151
|
+
filename = [name, :html, :erb].compact.join(".")
|
152
|
+
folders = ["views", "authentication"]
|
153
|
+
filename = File.join(folders, filename) if folders.any?
|
154
|
+
filename
|
155
|
+
end
|
156
|
+
|
157
|
+
def controller_filename_with_extensions(name)
|
158
|
+
filename = [name,:rb].compact.join(".")
|
159
|
+
folders = ["controllers"]
|
160
|
+
filename = File.join(folders, filename) if folders.any?
|
161
|
+
filename
|
162
|
+
end
|
163
|
+
|
164
|
+
def model_exists?
|
165
|
+
File.exist?(File.join(destination_root, model_path))
|
166
|
+
end
|
167
|
+
|
168
|
+
def model_path
|
169
|
+
@model_path ||= File.join("app", "models", "#{file_path}.rb")
|
170
|
+
end
|
171
|
+
|
172
|
+
def attributes_has_email?
|
173
|
+
attributes.any? { |attribute| attribute.column_name.include?("email") }
|
174
|
+
end
|
175
|
+
|
176
|
+
def attributes_has_password_digest?
|
177
|
+
attributes.any?{ |attribute| attribute.column_name.include?("password_digest") }
|
178
|
+
end
|
179
|
+
|
180
|
+
def paramaterize_attributes
|
181
|
+
array = [singular_table_name.underscore]
|
182
|
+
attributes.each do |attribute|
|
183
|
+
array.push(attribute.column_name + ":" + attribute.type.to_s)
|
184
|
+
end
|
185
|
+
array
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
class <%= class_name.singularize %>AuthenticationController < ApplicationController
|
2
|
+
# Uncomment line 3 in this file and line 5 in ApplicationController if you want to force <%= plural_table_name %> to sign in before any other actions.
|
3
|
+
# skip_before_action(:force_<%= singular_table_name.underscore %>_sign_in, { :only => [:sign_up_form, :create, :sign_in_form, :create_cookie] })
|
4
|
+
|
5
|
+
def sign_in_form
|
6
|
+
render({ :template => "<%= singular_table_name.underscore %>_authentication/sign_in" })
|
7
|
+
end
|
8
|
+
|
9
|
+
def create_cookie
|
10
|
+
<%= singular_table_name.underscore %> = <%= class_name.singularize %>.where({ :email => params.fetch("query_email") }).first
|
11
|
+
|
12
|
+
the_supplied_password = params.fetch("query_password")
|
13
|
+
|
14
|
+
if <%= singular_table_name.underscore %> != nil
|
15
|
+
are_they_legit = <%= singular_table_name.underscore %>.authenticate(the_supplied_password)
|
16
|
+
|
17
|
+
if are_they_legit == false
|
18
|
+
redirect_to("/<%= singular_table_name.underscore %>_sign_in", { :alert => "Incorrect password." })
|
19
|
+
else
|
20
|
+
session.store(:<%= singular_table_name.underscore %>_id, <%= singular_table_name.underscore %>.id)
|
21
|
+
|
22
|
+
redirect_to("/", { :notice => "Signed in successfully." })
|
23
|
+
end
|
24
|
+
else
|
25
|
+
redirect_to("/<%= singular_table_name.underscore %>_sign_in", { :alert => "No <%= singular_table_name.underscore %> with that email address." })
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def destroy_cookies
|
30
|
+
reset_session
|
31
|
+
|
32
|
+
redirect_to("/", { :notice => "Signed out successfully." })
|
33
|
+
end
|
34
|
+
|
35
|
+
def sign_up_form
|
36
|
+
render({ :template => "<%= singular_table_name.underscore %>_authentication/sign_up" })
|
37
|
+
end
|
38
|
+
|
39
|
+
def create
|
40
|
+
@<%= singular_table_name.underscore %> = <%= class_name.singularize %>.new
|
41
|
+
<% attributes.each do |attribute| -%>
|
42
|
+
<% if attribute.field_type == :check_box -%>
|
43
|
+
@<%= singular_table_name.underscore %>.<%= attribute.column_name %> = params.fetch("query_<%= attribute.column_name %>", false)
|
44
|
+
<% elsif attribute.column_name != "password_digest" -%>
|
45
|
+
@<%= singular_table_name.underscore %>.<%= attribute.column_name %> = params.fetch("query_<%= attribute.column_name %>")
|
46
|
+
<% else -%>
|
47
|
+
@<%= singular_table_name.underscore %>.password = params.fetch("query_password")
|
48
|
+
@<%= singular_table_name.underscore %>.password_confirmation = params.fetch("query_password_confirmation")
|
49
|
+
<% end -%>
|
50
|
+
<% end -%>
|
51
|
+
|
52
|
+
save_status = @<%= singular_table_name.underscore %>.save
|
53
|
+
|
54
|
+
if save_status == true
|
55
|
+
session.store(:<%= singular_table_name.underscore %>_id, @<%= singular_table_name.underscore %>.id)
|
56
|
+
|
57
|
+
redirect_to("/", { :notice => "<%= singular_table_name.humanize %> account created successfully."})
|
58
|
+
else
|
59
|
+
redirect_to("/<%= singular_table_name.underscore %>_sign_up", { :alert => @<%= singular_table_name%>.errors.full_messages.to_sentence })
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def edit_profile_form
|
64
|
+
render({ :template => "<%= singular_table_name.underscore %>_authentication/edit_profile" })
|
65
|
+
end
|
66
|
+
|
67
|
+
def update
|
68
|
+
@<%= singular_table_name.underscore %> = @current_<%= singular_table_name.underscore %>
|
69
|
+
<% attributes.each do |attribute| -%>
|
70
|
+
<% if attribute.field_type == :check_box -%>
|
71
|
+
@<%= singular_table_name.underscore %>.<%= attribute.column_name %> = params.fetch("query_<%= attribute.column_name %>", false)
|
72
|
+
<% elsif attribute.column_name != "password_digest" -%>
|
73
|
+
@<%= singular_table_name.underscore %>.<%= attribute.column_name %> = params.fetch("query_<%= attribute.column_name %>")
|
74
|
+
<% else -%>
|
75
|
+
@<%= singular_table_name.underscore %>.password = params.fetch("query_password")
|
76
|
+
@<%= singular_table_name.underscore %>.password_confirmation = params.fetch("query_password_confirmation")
|
77
|
+
<% end -%>
|
78
|
+
<% end -%>
|
79
|
+
|
80
|
+
if @<%= singular_table_name.underscore %>.valid?
|
81
|
+
@<%= singular_table_name.underscore %>.save
|
82
|
+
|
83
|
+
redirect_to("/", { :notice => "<%= singular_table_name.humanize %> account updated successfully."})
|
84
|
+
else
|
85
|
+
render({ :template => "<%= singular_table_name.underscore %>_authentication/edit_profile_with_errors" , :alert => @<%= singular_table_name%>.errors.full_messages.to_sentence })
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def destroy
|
90
|
+
@current_<%= singular_table_name.underscore %>.destroy
|
91
|
+
reset_session
|
92
|
+
|
93
|
+
redirect_to("/", { :notice => "<%= class_name.singularize %> account cancelled" })
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<div >
|
2
|
+
<h5>
|
3
|
+
Edit <%= class_name.titleize %> Account
|
4
|
+
</h5>
|
5
|
+
|
6
|
+
<div>
|
7
|
+
<form action="/modify_<%= singular_table_name.underscore %>" method="post">
|
8
|
+
<% attributes.each do |attribute| -%>
|
9
|
+
<% if attribute.column_name != "password_digest" -%>
|
10
|
+
<div>
|
11
|
+
<label for="<%= attribute.column_name %>_box"><%= attribute.column_name.humanize %></label>
|
12
|
+
<% if attribute.field_type == :text_area -%>
|
13
|
+
<textarea id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>" rows="3"><%%= @current_<%= singular_table_name %>.<%= attribute.column_name %> %></textarea>
|
14
|
+
<% elsif attribute.field_type == :check_box -%>
|
15
|
+
<input id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>" type="checkbox" value="1" <%%= "checked" if @current_<%= singular_table_name %>.<%= attribute.column_name %> %>>
|
16
|
+
<% else -%>
|
17
|
+
<input id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>" value="<%%= @current_<%= singular_table_name.underscore %>.<%= attribute.column_name %> %>">
|
18
|
+
<% end -%>
|
19
|
+
</div>
|
20
|
+
<% end -%>
|
21
|
+
<% end -%>
|
22
|
+
|
23
|
+
<div>
|
24
|
+
<label for="password_box">Password</label>
|
25
|
+
<input id="password_box" name="query_password" placeholder="Choose a password..." type="password">
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div>
|
29
|
+
<label for="password_confirmation_box">Password Confirmation</label>
|
30
|
+
<input id="password_confirmation_box" name="query_password_confirmation" placeholder="Confirm your password..." type="password">
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<button>
|
34
|
+
Update account
|
35
|
+
</button>
|
36
|
+
</form>
|
37
|
+
</div>
|
38
|
+
</div>
|
data/lib/generators/draft/account/templates/views/authentication/edit_profile_with_errors.html.erb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
<div >
|
2
|
+
<h5>
|
3
|
+
Edit <%= class_name.titleize %> Account
|
4
|
+
</h5>
|
5
|
+
|
6
|
+
<%% if @<%= singular_table_name %>.errors.any? %>
|
7
|
+
<%% @<%= singular_table_name %>.errors.full_messages.each do |message| %>
|
8
|
+
<div class="alert">
|
9
|
+
<%%= message %>
|
10
|
+
</div>
|
11
|
+
<%% end %>
|
12
|
+
<%% end %>
|
13
|
+
<div>
|
14
|
+
<form action="/modify_<%= singular_table_name.underscore %>" method="post">
|
15
|
+
<% attributes.each do |attribute| -%>
|
16
|
+
<% if attribute.column_name != "password_digest" %>
|
17
|
+
<div>
|
18
|
+
<label for="<%= attribute.column_name %>_box"><%= attribute.column_name.humanize %></label>
|
19
|
+
<% if attribute.field_type == :text_area %>
|
20
|
+
<textarea id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>" rows="3"><%%= @current_<%= singular_table_name %>.<%= attribute.column_name %> %></textarea>
|
21
|
+
<% elsif attribute.field_type == :check_box %>
|
22
|
+
<input id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>" type="checkbox" value="1" <%%= "checked" if @current_<%= singular_table_name %>.<%= attribute.column_name %> %>>
|
23
|
+
<% else %>
|
24
|
+
<input id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>" value="<%%= @current_<%= singular_table_name.underscore %>.<%= attribute.column_name %> %>">
|
25
|
+
<% end %>
|
26
|
+
</div>
|
27
|
+
<% end -%>
|
28
|
+
<% end %>
|
29
|
+
<div>
|
30
|
+
<label for="password_box">Password</label>
|
31
|
+
<input id="password_box" name="query_password" placeholder="Choose a new password..." type="password">
|
32
|
+
</div>
|
33
|
+
|
34
|
+
<div>
|
35
|
+
<label for="password_confirmation_box">Password Confirmation</label>
|
36
|
+
<input id="password_confirmation_box" name="query_password_confirmation" placeholder="Confirm your new password..." type="password">
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<button>
|
40
|
+
Update account
|
41
|
+
</button>
|
42
|
+
</form>
|
43
|
+
</div>
|
44
|
+
</div>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<h1>Sign in</h1>
|
2
|
+
|
3
|
+
<form action="/<%= singular_table_name.underscore %>_verify_credentials" method="post">
|
4
|
+
<div>
|
5
|
+
<label for="email_box">Email</label>
|
6
|
+
<input id="email_box" name="query_email" placeholder="Enter your email..." type="text">
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<div>
|
10
|
+
<label for="password_box">Password</label>
|
11
|
+
<input id="password_box" name="query_password" placeholder="Enter your password..." type="password">
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<button>
|
15
|
+
Sign in
|
16
|
+
</button>
|
17
|
+
</form>
|
18
|
+
|
19
|
+
<hr>
|
20
|
+
|
21
|
+
<p>
|
22
|
+
Or, <a href="/<%= singular_table_name.underscore %>_sign_up">Sign up</a> instead.
|
23
|
+
</p>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<h1>Sign up</h1>
|
2
|
+
|
3
|
+
<form action="/insert_<%= singular_table_name.underscore %>" method="post">
|
4
|
+
|
5
|
+
<div>
|
6
|
+
<label for="email_box">Email</label>
|
7
|
+
<input id="email_box" name="query_email" placeholder="Choose a email..." type="text">
|
8
|
+
</div>
|
9
|
+
<% attributes.each do |attribute| -%>
|
10
|
+
<% if attribute.column_name != "password_digest" && attribute.column_name != "email" -%>
|
11
|
+
<div>
|
12
|
+
<label for="<%= attribute.column_name %>_box"><%= attribute.column_name.humanize %></label>
|
13
|
+
<%- if attribute.field_type == :check_box -%>
|
14
|
+
<input id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>" type="checkbox">
|
15
|
+
<%- elsif attribute.field_type == :text_area -%>
|
16
|
+
<textarea id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>" rows="3"></textarea>
|
17
|
+
<%- else -%>
|
18
|
+
<input type="text" id="<%= attribute.column_name %>_box" name="query_<%= attribute.column_name %>">
|
19
|
+
<%- end -%>
|
20
|
+
</div>
|
21
|
+
<%- end -%>
|
22
|
+
<% end -%>
|
23
|
+
|
24
|
+
<div>
|
25
|
+
<label for="password_box">Password</label>
|
26
|
+
<input id="password_box" name="query_password" placeholder="Choose a password..." type="password">
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<div>
|
30
|
+
<label for="password_confirmation_box">Password Confirmation</label>
|
31
|
+
<input id="password_confirmation_box" name="query_password_confirmation" placeholder="Confirm your password..." type="password">
|
32
|
+
</div>
|
33
|
+
|
34
|
+
<button>
|
35
|
+
Sign up
|
36
|
+
</button>
|
37
|
+
</form>
|
38
|
+
|
39
|
+
<hr>
|
40
|
+
|
41
|
+
<p>
|
42
|
+
Or, <a href="/<%= singular_table_name.underscore %>_sign_in">Sign in</a> instead.
|
43
|
+
</p>
|
@@ -29,7 +29,7 @@ module Draft
|
|
29
29
|
template "_flashes.html.erb", "app/views/shared/_flashes.html.erb"
|
30
30
|
|
31
31
|
unless skip_cdn?
|
32
|
-
template "
|
32
|
+
template "_cdn_assets.html.erb", "app/views/shared/_cdn_assets.html.erb"
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -50,7 +50,7 @@ module Draft
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def app_resources
|
53
|
-
route_names.reject { |name| /^
|
53
|
+
route_names.reject { |name| /^rails_*/.match(name) || /batch_action*/.match(name) || /admin_*/.match(name) || name.pluralize != name }
|
54
54
|
end
|
55
55
|
|
56
56
|
def devise_routes
|
@@ -60,7 +60,7 @@ module Draft
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def route_names
|
63
|
-
@route_names ||= Rails.application.routes.routes.map(&:name).uniq.compact
|
63
|
+
@route_names ||= Rails.application.routes.routes.reject { |route| route.verb != "GET" }.map(&:name).uniq.compact
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<!-- Connect Bootstrap CSS -->
|
2
|
+
<% if bootswatch? -%>
|
3
|
+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/<%= theme_name %>/bootstrap.min.css">
|
4
|
+
<% else -%>
|
5
|
+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
6
|
+
<% end -%>
|
7
|
+
|
8
|
+
<!-- Connect Font Awesome CSS -->
|
9
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css">
|
10
|
+
|
11
|
+
<!-- Connect Bootstrap JavaScript and its dependencies -->
|
12
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
13
|
+
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js"></script>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<nav class="navbar navbar-expand-lg navbar-light bg-light mb-4">
|
2
2
|
<div class="container">
|
3
3
|
<a class="navbar-brand" href="/">
|
4
|
-
<%= Rails.application.class.
|
4
|
+
<%= Rails.application.class.module_parent_name.underscore %>
|
5
5
|
</a>
|
6
6
|
|
7
7
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsible-nav-links" aria-controls="collapsible-nav-links" aria-expanded="false" aria-label="Toggle navigation">
|
@@ -2,26 +2,27 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>
|
5
|
-
<%= Rails.application.class.
|
5
|
+
<%= Rails.application.class.module_parent_name.underscore %>
|
6
6
|
</title>
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
<!-- Expand the number of characters we can use in the document beyond basic ASCII 🎉 -->
|
9
|
+
<meta charset="utf-8">
|
10
|
+
|
11
|
+
<!-- Make it responsive to small screens. Include only if you're using responsive CSS. -->
|
12
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
10
13
|
|
11
|
-
<% end -%>
|
12
14
|
<%%= csrf_meta_tags %>
|
13
|
-
|
14
|
-
<%%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
15
|
-
<%%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
16
|
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-4/5.0.0-alpha14/css/tempusdominus-bootstrap-4.min.css" />
|
17
|
-
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-4/5.0.0-alpha14/js/tempusdominus-bootstrap-4.min.js"></script>
|
18
|
-
<script src="//maps.google.com/maps/api/js?v=3.24&key=AIzaSyCOTPWiuvyyo6sKoIBzKA4-1ol-vTOIOlM"></script>
|
19
|
-
<script src="//cdn.rawgit.com/mahnunchik/markerclustererplus/master/dist/markerclusterer.min.js"></script>
|
15
|
+
<%%= csp_meta_tag %>
|
20
16
|
|
17
|
+
<!-- Helper methods that create <link>s and <script>s for all of the stylesheets and javascript files in the non-`/public/` assets folders. -->
|
18
|
+
<%%= stylesheet_link_tag 'application', media: 'all' %>
|
19
|
+
<%%# javascript_pack_tag 'application' %>
|
20
|
+
|
21
|
+
<!-- Rendering a partial that has all the <link>s and <script>s for assets we are pulling from content-delivery networks. -->
|
22
|
+
<%%= render "shared/cdn_assets" %>
|
21
23
|
|
22
24
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
23
25
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
24
|
-
<meta charset="utf-8">
|
25
26
|
<style>
|
26
27
|
body { padding-bottom: 70px }
|
27
28
|
</style>
|