hot-glue 0.2.9E → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +1 -2
- data/Gemfile.lock +3 -3
- data/LICENCE +11 -4
- data/README.md +0 -698
- data/app/helpers/hot_glue/controller_helper.rb +2 -1
- data/lib/generators/hot_glue/install_generator.rb +121 -33
- data/lib/generators/hot_glue/markup_templates/erb.rb +41 -28
- data/lib/generators/hot_glue/markup_templates/haml.rb +3 -1
- data/lib/generators/hot_glue/scaffold_generator.rb +159 -35
- data/lib/generators/hot_glue/templates/controller.rb.erb +34 -20
- data/lib/generators/hot_glue/templates/erb/_form.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/_line.erb +3 -2
- data/lib/generators/hot_glue/templates/erb/_list.erb +29 -14
- data/lib/generators/hot_glue/templates/erb/_new_button.erb +3 -1
- data/lib/generators/hot_glue/templates/erb/_show.erb +17 -9
- data/lib/generators/hot_glue/templates/erb/create.turbo_stream.erb +2 -2
- data/lib/generators/hot_glue/templates/erb/destroy.turbo_stream.erb +2 -2
- data/lib/generators/hot_glue/templates/erb/edit.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/index.erb +11 -8
- data/lib/generators/hot_glue/templates/erb/update.turbo_stream.erb +1 -1
- data/lib/generators/hot_glue/templates/haml/_list.haml +2 -2
- data/lib/generators/hot_glue/templates/haml/index.haml +1 -1
- data/lib/generators/hot_glue/templates/themes/hotglue_scaffold_dark_knight.scss +158 -0
- data/lib/generators/hot_glue/templates/themes/hotglue_scaffold_like_bootstrap.scss +154 -0
- data/lib/generators/hot_glue/templates/themes/hotglue_scaffold_like_los_gatos.scss +182 -0
- data/lib/generators/hot_glue/templates/themes/hotglue_scaffold_like_mountain_view.scss +179 -0
- data/lib/hotglue/version.rb +1 -1
- metadata +14 -20
@@ -61,7 +61,8 @@ module HotGlue
|
|
61
61
|
# elsif self.class.ancestors.include?(ApplicationController)
|
62
62
|
# self.try(:current_timezone)
|
63
63
|
else
|
64
|
-
|
64
|
+
puts "no method current_user is available; please implement/override the method current_timezone IN YOUR CONTROLLER"
|
65
|
+
exit
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|
@@ -5,12 +5,43 @@ module HotGlue
|
|
5
5
|
class InstallGenerator < Rails::Generators::Base
|
6
6
|
hook_for :form_builder, :as => :scaffold
|
7
7
|
class_option :markup, type: :string, default: "erb"
|
8
|
+
class_option :theme, type: :string, default: nil
|
9
|
+
class_option :layout, type: :string, default: "hotglue"
|
8
10
|
|
9
11
|
source_root File.expand_path('templates', __dir__)
|
10
12
|
|
11
|
-
|
12
13
|
def initialize(*args) #:nodoc:
|
13
14
|
super
|
15
|
+
@layout = options['layout'] || "hotglue"
|
16
|
+
@theme = options['theme']
|
17
|
+
|
18
|
+
if @layout == "hotglue" && options['theme'].nil?
|
19
|
+
puts "You have selected to install Hot Glue without a theme. You can either use the --layout=bootstrap to install NO HOT GLUE THEME, or to use a Hot Glue theme please choose: like_boostrap, like_menlo_park, like_cupertino, like_mountain_view, dark_knight"
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
|
23
|
+
if @layout == 'boostrap'
|
24
|
+
puts "IMPORTANT: You have selected to install Hot Glue with Bootstrap layout (legacy). Be sure to always use ``--layout=bootstrap` when building your scaffold. No Hot Glue theme will be installed at this time.` "
|
25
|
+
end
|
26
|
+
|
27
|
+
### INTERACTIVE LICENSING
|
28
|
+
#
|
29
|
+
|
30
|
+
|
31
|
+
print "(To purchase a license, please see https://heliosdev.shop/hot-glue-license) \n Please enter your license key: "
|
32
|
+
license_activation_key = STDIN.gets.strip
|
33
|
+
|
34
|
+
print "Please enter the EMAIL you used to purchase this license: "
|
35
|
+
license_email = STDIN.gets.strip
|
36
|
+
app_name = Rails.application.class.module_parent_name
|
37
|
+
license_should_be = Digest::SHA1.hexdigest("HOT-GLUE-LICENSE--#{app_name}--#{license_email}")
|
38
|
+
|
39
|
+
|
40
|
+
if (license_should_be != license_activation_key)
|
41
|
+
puts "Ooops... it seems that Hot Glue license is not valid. Please check 1) the email address you used for this license, 2) The app name you used to purchase this license, and 3) the activation key itself."
|
42
|
+
exit
|
43
|
+
end
|
44
|
+
|
14
45
|
@markup = options['markup']
|
15
46
|
if @markup == "haml"
|
16
47
|
copy_file "haml/_flash_notices.haml", "#{'spec/dummy/' if Rails.env.test?}app/views/layouts/_flash_notices.haml"
|
@@ -23,55 +54,112 @@ module HotGlue
|
|
23
54
|
copy_file "confirmable.js", "#{'spec/dummy/' if Rails.env.test?}app/javascript/controllers/confirmable.js"
|
24
55
|
end
|
25
56
|
|
26
|
-
|
27
|
-
|
28
|
-
if
|
29
|
-
app_js_contents.
|
30
|
-
|
57
|
+
|
58
|
+
begin
|
59
|
+
if Rails.version.split(".")[0].to_i == 6
|
60
|
+
app_js_contents = File.read("app/javascript/packs/application.js")
|
61
|
+
if app_js_contents.include?("import Turbolinks from \"turbolinks\"")
|
62
|
+
app_js_contents.gsub!("import Turbolinks from \"turbolinks\"", "import { Turbo } from \"@hotwired/turbo-rails\"")
|
63
|
+
puts " HOTGLUE --> fixed packs/application.js: swapping old Turbolinks syntas for new Turbo-Rails syntax [ import { Turbo } from \"@hotwired/turbo-rails\" ] "
|
64
|
+
end
|
65
|
+
|
66
|
+
if app_js_contents.include?("Turbolinks.start()")
|
67
|
+
app_js_contents.gsub!("Turbolinks.start()", "Turbo.start()")
|
68
|
+
puts " HOTGLUE --> fixed packs/application.js: swapping old Turbolinks syntas for new Turbo-Rails syntax[ Turbolinks.start() ] "
|
69
|
+
end
|
70
|
+
File.write("app/javascript/packs/application.js", app_js_contents)
|
71
|
+
end
|
72
|
+
rescue StandardError => e
|
73
|
+
puts "WARNING: error writing to app/javascript/packs/application.js --- #{e.message}"
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
begin
|
79
|
+
rails_helper_contents = File.read("spec/rails_helper.rb")
|
80
|
+
if !rails_helper_contents.include?("Capybara.default_driver =")
|
81
|
+
rails_helper_contents << "\nCapybara.default_driver = :selenium_chrome_headless "
|
82
|
+
puts " HOTGLUE --> added to spec/rails_helper.rb: `Capybara.default_driver = :selenium_chrome_headless` "
|
83
|
+
end
|
84
|
+
|
85
|
+
if !rails_helper_contents.include?("include FactoryBot::Syntax::Methods")
|
86
|
+
rails_helper_contents.gsub!("RSpec.configure do |config|", "RSpec.configure do |config| \n
|
87
|
+
config.include FactoryBot::Syntax::Methods
|
88
|
+
")
|
89
|
+
puts " HOTGLUE --> added to spec/rails_helper.rb: `config.include FactoryBot::Syntax::Methods` "
|
31
90
|
end
|
32
91
|
|
33
|
-
if
|
34
|
-
|
35
|
-
puts " HOTGLUE -->
|
92
|
+
if ! rails_helper_contents.include?("require 'support/capybara_login.rb'")
|
93
|
+
rails_helper_contents.gsub!("require 'rspec/rails'","require 'rspec/rails' \nrequire 'support/capybara_login.rb'")
|
94
|
+
puts " HOTGLUE --> added to spec/rails_helper.rb: `require 'support/capybara_login.rb'` "
|
36
95
|
end
|
37
|
-
File.write("
|
96
|
+
File.write("spec/rails_helper.rb", rails_helper_contents)
|
38
97
|
|
98
|
+
rescue StandardError => e
|
99
|
+
puts "WARNING: error writing to spec/rails_helper --- #{e.message}"
|
39
100
|
end
|
40
101
|
|
41
102
|
|
42
|
-
|
43
|
-
|
44
|
-
rails_helper_contents << "\nCapybara.default_driver = :selenium_chrome_headless "
|
45
|
-
puts " HOTGLUE --> added to spec/rails_helper.rb: `Capybara.default_driver = :selenium_chrome_headless` "
|
46
|
-
end
|
103
|
+
begin
|
104
|
+
application_layout_contents = File.read("app/views/layouts/application.html.erb")
|
47
105
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
")
|
52
|
-
|
106
|
+
if !application_layout_contents.include?("render partial: 'layouts/flash_notices'")
|
107
|
+
application_layout_contents.gsub!("<body>", "<body>\n
|
108
|
+
<%= render partial: 'layouts/flash_notices' %>
|
109
|
+
")
|
110
|
+
File.write("app/views/layouts/application.html.erb", application_layout_contents)
|
111
|
+
puts " HOTGLUE --> added to app/views/layouts/application.html.erb: `<%= render partial: 'layouts/flash_notices' %>` "
|
112
|
+
end
|
113
|
+
rescue StandardError => e
|
114
|
+
puts "WARNING: error writing to app/views/layouts/application.html.erb --- #{e.message}"
|
53
115
|
end
|
54
116
|
|
55
|
-
|
56
|
-
|
57
|
-
|
117
|
+
|
118
|
+
begin
|
119
|
+
if @layout == "hotglue"
|
120
|
+
theme_location = "themes/hotglue_scaffold_#{@theme}.scss"
|
121
|
+
theme_file = "hotglue_scaffold_#{@theme}.scss"
|
122
|
+
|
123
|
+
copy_file theme_location, "#{'spec/dummy/' if Rails.env.test?}app/assets/stylesheets/#{theme_file}"
|
124
|
+
|
125
|
+
application_scss = File.read("app/assets/stylesheets/application.scss")
|
126
|
+
|
127
|
+
if !application_scss.include?("@import '#{theme_file}';")
|
128
|
+
application_scss << ( "\n @import '#{theme_file}'; ")
|
129
|
+
File.write("app/assets/stylesheets/application.scss", application_scss)
|
130
|
+
puts " HOTGLUE --> added to app/assets/stylesheets/application.scss: @import '#{theme_file}' "
|
131
|
+
else
|
132
|
+
puts " HOTGLUE --> already found theme in app/assets/stylesheets/application.scss: @import '#{theme_file}' "
|
133
|
+
end
|
134
|
+
end
|
135
|
+
rescue StandardError => e
|
136
|
+
puts "WARNING: error writing to app/assets/stylesheets/application.scss --- #{e.message}"
|
58
137
|
end
|
59
|
-
File.write("spec/rails_helper.rb", rails_helper_contents)
|
60
138
|
|
61
139
|
|
62
|
-
application_layout_contents = File.read("app/views/layouts/application.html.erb")
|
63
140
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
141
|
+
begin
|
142
|
+
|
143
|
+
if !File.exists?("config/hot_glue.yml")
|
144
|
+
|
145
|
+
yaml = {layout: @layout,
|
146
|
+
markup: @markup,
|
147
|
+
license_activation_key: license_activation_key,
|
148
|
+
license_email: license_email}.to_yaml
|
149
|
+
File.write("#{'spec/dummy/' if Rails.env.test?}config/hot_glue.yml", yaml)
|
150
|
+
|
151
|
+
end
|
152
|
+
rescue StandardError => e
|
153
|
+
puts "WARNING: error writing to config/hot_glue.yml --- #{e.message}"
|
70
154
|
end
|
71
155
|
|
72
156
|
|
73
|
-
|
74
|
-
|
157
|
+
begin
|
158
|
+
if !File.exists?("spec/support/capybara_login.rb")
|
159
|
+
copy_file "capybara_login.rb", "#{'spec/dummy/' if Rails.env.test?}spec/support/capybara_login.rb"
|
160
|
+
end
|
161
|
+
rescue StandardError => e
|
162
|
+
puts "WARNING: error writing to spec/support/capybara_login.rb --- #{e.message}"
|
75
163
|
end
|
76
164
|
end
|
77
165
|
end
|
@@ -5,8 +5,8 @@ module HotGlue
|
|
5
5
|
attr_accessor :singular
|
6
6
|
|
7
7
|
def field_output(col, type = nil, width, col_identifier )
|
8
|
-
"<div class='
|
9
|
-
" <%= f.text_field :#{col.to_s}, value: @#{@singular}.#{col.to_s}, size: #{width}, class: 'form-control', type: '#{type}' %>\n "+
|
8
|
+
"<div class='#{col_identifier} form-group <%='alert-danger' if @#{singular}.errors.details.keys.include?(:#{col.to_s})%>' > \n" +
|
9
|
+
" <%= f.text_field :#{col.to_s}, value: @#{@singular}.#{col.to_s}, autocomplete: 'off', size: #{width}, class: 'form-control', type: '#{type}' %>\n "+
|
10
10
|
" <label class='form-text' >#{col.to_s.humanize}</label>\n" +
|
11
11
|
"</div>"
|
12
12
|
end
|
@@ -21,7 +21,7 @@ module HotGlue
|
|
21
21
|
magic_buttons.collect{ |button_name|
|
22
22
|
"<%= form_with model: #{singular}, url: #{path_helper_singular}(#{path_helper_args}) do |f| %>
|
23
23
|
<%= f.hidden_field :#{button_name}, value: \"#{button_name}\" %>
|
24
|
-
<%= f.submit '#{button_name.titleize}'.html_safe, data: {confirm: 'Are you sure you want to #{button_name} this #{singular}?'}, class: '#{singular}-button btn btn-primary ' %>
|
24
|
+
<%= f.submit '#{button_name.titleize}'.html_safe, disabled: (schedule.respond_to?(:#{button_name}able?) && ! schedule.#{button_name}able? ), data: {confirm: 'Are you sure you want to #{button_name} this #{singular}?'}, class: '#{singular}-button btn btn-primary ' %>
|
25
25
|
<% end %>"
|
26
26
|
}.join("\n")
|
27
27
|
end
|
@@ -33,7 +33,7 @@ module HotGlue
|
|
33
33
|
end
|
34
34
|
|
35
35
|
"<div class=\"#{col_identifier} form-group \#{'alert-danger' if #{singular}.errors.details.keys.include?(:#{col.to_s})}\">" +
|
36
|
-
"<%= f.text_area :#{col.to_s}, class: 'form-control', cols: 40, rows: '#{lines}' %>" +
|
36
|
+
"<%= f.text_area :#{col.to_s}, class: 'form-control', autocomplete: 'off', cols: 40, rows: '#{lines}' %>" +
|
37
37
|
"<label class='form-text'>#{col.to_s.humanize}</label>"+
|
38
38
|
"</div>"
|
39
39
|
|
@@ -41,8 +41,14 @@ module HotGlue
|
|
41
41
|
|
42
42
|
def list_column_headings(*args)
|
43
43
|
columns = args[0][:columns]
|
44
|
-
|
45
|
-
|
44
|
+
column_width = args[0][:column_width]
|
45
|
+
col_identifier = args[0][:col_identifier]
|
46
|
+
if @layout == "hotglue"
|
47
|
+
col_style = " style='flex-basis: #{column_width}%'"
|
48
|
+
else
|
49
|
+
col_style = ""
|
50
|
+
end
|
51
|
+
columns.map(&:to_s).map{|col_name| "<div class='#{col_identifier}'" + col_style +">#{col_name.humanize}</div>"}.join("\n")
|
46
52
|
end
|
47
53
|
|
48
54
|
|
@@ -50,13 +56,15 @@ module HotGlue
|
|
50
56
|
columns = args[0][:columns]
|
51
57
|
show_only = args[0][:show_only]
|
52
58
|
singular_class = args[0][:singular_class]
|
59
|
+
col_identifier = args[0][:col_identifier]
|
60
|
+
|
53
61
|
|
54
62
|
# TODO: CLEAN ME
|
55
63
|
@singular = args[0][:singular]
|
56
64
|
singular = @singular
|
57
65
|
|
58
66
|
|
59
|
-
|
67
|
+
|
60
68
|
col_spaces_prepend = " "
|
61
69
|
|
62
70
|
res = columns.map { |col|
|
@@ -111,10 +119,7 @@ module HotGlue
|
|
111
119
|
text_area_output(col, 65536, col_identifier)
|
112
120
|
end
|
113
121
|
when :float
|
114
|
-
|
115
|
-
field_output(col, nil, limit, col_identifier)
|
116
|
-
|
117
|
-
|
122
|
+
field_output(col, nil, 5, col_identifier)
|
118
123
|
when :datetime
|
119
124
|
|
120
125
|
|
@@ -166,11 +171,21 @@ module HotGlue
|
|
166
171
|
show_only = args[0][:show_only]
|
167
172
|
singular_class = args[0][:singular_class]
|
168
173
|
singular = args[0][:singular]
|
174
|
+
perc_width = args[0][:perc_width]
|
175
|
+
layout = args[0][:layout]
|
169
176
|
|
170
177
|
columns_count = columns.count + 1
|
171
|
-
perc_width = (
|
178
|
+
perc_width = (perc_width).floor
|
179
|
+
|
180
|
+
if layout == "bootstrap"
|
181
|
+
col_identifer = "col"
|
182
|
+
style_with_flex_basis = ""
|
183
|
+
else
|
184
|
+
style_with_flex_basis = " style='flex-basis: #{perc_width}%'"
|
185
|
+
col_identifer = "scaffold-cell"
|
186
|
+
end
|
187
|
+
|
172
188
|
|
173
|
-
col_identifer = "col"
|
174
189
|
columns.map { |col|
|
175
190
|
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
176
191
|
limit = eval("#{singular_class}.columns_hash['#{col}']").limit
|
@@ -188,35 +203,37 @@ module HotGlue
|
|
188
203
|
|
189
204
|
if assoc.nil?
|
190
205
|
exit_message = "*** Oops. on the #{singular_class} object, there doesn't seem to be an association called '#{assoc_name}'"
|
191
|
-
|
206
|
+
puts exit_message
|
207
|
+
exit
|
208
|
+
# raise(HotGlue::Error,exit_message)
|
192
209
|
end
|
193
210
|
|
194
211
|
display_column = HotGlue.derrive_reference_name(assoc.class_name)
|
195
212
|
|
196
|
-
"<div class='#{col_identifer}'>
|
213
|
+
"<div class='#{col_identifer}'#{style_with_flex_basis}>
|
197
214
|
<%= #{singular}.#{assoc.name.to_s}.try(:#{display_column}) || '<span class=\"content alert-danger\">MISSING</span>'.html_safe %>
|
198
215
|
</div>"
|
199
216
|
|
200
217
|
else
|
201
|
-
"<div class='#{col_identifer}'>
|
218
|
+
"<div class='#{col_identifer}'#{style_with_flex_basis}>
|
202
219
|
<%= #{singular}.#{col}%></div>"
|
203
220
|
end
|
204
221
|
when :float
|
205
222
|
width = (limit && limit < 40) ? limit : (40)
|
206
|
-
"<div class='#{col_identifer}'>
|
223
|
+
"<div class='#{col_identifer}'#{style_with_flex_basis}>
|
207
224
|
<%= #{singular}.#{col}%></div>"
|
208
225
|
when :string
|
209
226
|
width = (limit && limit < 40) ? limit : (40)
|
210
|
-
"<div class='#{col_identifer}'>
|
227
|
+
"<div class='#{col_identifer}'#{style_with_flex_basis} >
|
211
228
|
<%= #{singular}.#{col} %>
|
212
229
|
</div>"
|
213
230
|
when :text
|
214
|
-
"<div class='#{col_identifer}'>
|
231
|
+
"<div class='#{col_identifer}'#{style_with_flex_basis}>
|
215
232
|
<%= #{singular}.#{col} %>
|
216
233
|
</div>"
|
217
234
|
when :datetime
|
218
235
|
|
219
|
-
"<div class='#{col_identifer}'>
|
236
|
+
"<div class='#{col_identifer}' #{style_with_flex_basis} >
|
220
237
|
<% unless #{singular}.#{col}.nil? %>
|
221
238
|
<%= #{singular}.#{col}.in_time_zone(current_timezone).strftime('%m/%d/%Y @ %l:%M %p ') + timezonize(current_timezone) %>
|
222
239
|
<% else %>
|
@@ -224,7 +241,7 @@ module HotGlue
|
|
224
241
|
<% end %>
|
225
242
|
</div>"
|
226
243
|
when :date
|
227
|
-
"<div class='#{col_identifer}'>
|
244
|
+
"<div class='#{col_identifer}' #{style_with_flex_basis} >
|
228
245
|
<% unless #{singular}.#{col}.nil? %>
|
229
246
|
<%= #{singular}.#{col} %>
|
230
247
|
<% else %>
|
@@ -232,7 +249,7 @@ module HotGlue
|
|
232
249
|
<% end %>
|
233
250
|
</div>"
|
234
251
|
when :time
|
235
|
-
"<div class='#{col_identifer}'>
|
252
|
+
"<div class='#{col_identifer}' #{style_with_flex_basis} >
|
236
253
|
<% unless #{singular}.#{col}.nil? %>
|
237
254
|
<%= #{singular}.#{col}.in_time_zone(current_timezone).strftime('%l:%M %p ') + timezonize(current_timezone) %>
|
238
255
|
<% else %>
|
@@ -241,7 +258,7 @@ module HotGlue
|
|
241
258
|
</div>
|
242
259
|
"
|
243
260
|
when :boolean
|
244
|
-
"<div class='#{col_identifer}'>
|
261
|
+
"<div class='#{col_identifer}' #{style_with_flex_basis} >
|
245
262
|
<% if #{singular}.#{col}.nil? %>
|
246
263
|
<span class='alert-danger'>MISSING</span>
|
247
264
|
<% elsif #{singular}.#{col} %>
|
@@ -251,7 +268,7 @@ module HotGlue
|
|
251
268
|
<% end %>
|
252
269
|
</div>
|
253
270
|
" when :enum
|
254
|
-
|
271
|
+
"<div class='#{col_identifer}' #{style_with_flex_basis} >
|
255
272
|
<% if #{singular}.#{col}.nil? %>
|
256
273
|
<span class='alert-danger'>MISSING</span>
|
257
274
|
<% else %>
|
@@ -263,8 +280,4 @@ module HotGlue
|
|
263
280
|
}.join("\n")
|
264
281
|
end
|
265
282
|
end
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
283
|
end
|
@@ -159,7 +159,9 @@ module HotGlue
|
|
159
159
|
|
160
160
|
if assoc.nil?
|
161
161
|
exit_message = "*** Oops. on the #{singular_class} object, there doesn't seem to be an association called '#{assoc_name}'"
|
162
|
-
|
162
|
+
puts exit_message
|
163
|
+
exit
|
164
|
+
# raise(HotGlue::Error,exit_message)
|
163
165
|
end
|
164
166
|
|
165
167
|
display_column = HotGlue.derrive_reference_name(assoc.class_name)
|