hot-glue 0.5.7 → 0.5.9.1
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 -1
- data/.gitignore +2 -1
- data/Gemfile +1 -1
- data/LICENSE +12 -5
- data/README.md +323 -143
- data/app/helpers/hot_glue/controller_helper.rb +9 -6
- data/lib/generators/hot_glue/direct_upload_install_generator.rb +47 -0
- data/lib/generators/hot_glue/dropzone_install_generator.rb +39 -0
- data/lib/generators/hot_glue/layout/builder.rb +15 -7
- data/lib/generators/hot_glue/layout_strategy/base.rb +2 -0
- data/lib/generators/hot_glue/layout_strategy/bootstrap.rb +16 -3
- data/lib/generators/hot_glue/markup_templates/erb.rb +186 -127
- data/lib/generators/hot_glue/scaffold_generator.rb +269 -142
- data/lib/generators/hot_glue/templates/controller.rb.erb +19 -11
- data/lib/generators/hot_glue/templates/erb/_list.erb +19 -6
- data/lib/generators/hot_glue/templates/erb/_show.erb +6 -4
- data/lib/generators/hot_glue/templates/javascript/dropzone_controller.js +191 -0
- data/lib/generators/hot_glue/templates/system_spec.rb.erb +31 -13
- data/lib/hotglue/version.rb +1 -1
- data/script/clean_generated_code +1 -1
- metadata +7 -4
@@ -79,11 +79,14 @@ module HotGlue
|
|
79
79
|
hawk_schema.each do |hawk_key,hawk_definition|
|
80
80
|
hawk_root = hawk_definition[0]
|
81
81
|
# hawk_scope = hawk_definition[1]
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
82
|
+
|
83
|
+
unless modified_params[hawk_key.to_s].blank?
|
84
|
+
begin
|
85
|
+
eval("hawk_root").find(modified_params[hawk_key.to_s])
|
86
|
+
rescue ActiveRecord::RecordNotFound => e
|
87
|
+
@hawk_alarm << "You aren't allowed to set #{hawk_key.to_s} to #{modified_params[hawk_key.to_s]}. "
|
88
|
+
modified_params.tap { |hs| hs.delete(hawk_key.to_s) }
|
89
|
+
end
|
87
90
|
end
|
88
91
|
end
|
89
92
|
modified_params
|
@@ -95,4 +98,4 @@ module HotGlue
|
|
95
98
|
Time.now.strftime("%z").to_i/100
|
96
99
|
end
|
97
100
|
end
|
98
|
-
end
|
101
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module HotGlue
|
4
|
+
class DirectUploadInstallGenerator < Rails::Generators::Base
|
5
|
+
|
6
|
+
|
7
|
+
source_root File.expand_path('templates', __dir__)
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
def initialize(*args) #:nodoc:
|
12
|
+
super
|
13
|
+
if Gem::Specification.sort_by{ |g| [g.name.downcase, g.version] }.group_by{ |g| g.name }['importmap-rails'] # impomrtmaps
|
14
|
+
file_contents = File.read("app/javascript/application.js")
|
15
|
+
|
16
|
+
if !file_contents.include?("//= require activestorage")
|
17
|
+
file_contents << "//= require activestorage"
|
18
|
+
File.write("app/javascript/application.js", file_contents)
|
19
|
+
puts " HOTGLUE --> added to app/javascript/application.js: `//= require activestorage"
|
20
|
+
else
|
21
|
+
puts " HOTGLUE --> app/javascript/application.js already contains `//= require activestorage`"
|
22
|
+
end
|
23
|
+
|
24
|
+
elsif Gem::Specification.sort_by{ |g| [g.name.downcase, g.version] }.group_by{ |g| g.name }['jsbundling-rails']
|
25
|
+
|
26
|
+
|
27
|
+
file_contents = File.read("app/javascript/application.js")
|
28
|
+
|
29
|
+
if !file_contents.include?("ActiveStorage.start()")
|
30
|
+
file_contents << "import * as ActiveStorage from \"@rails/activestorage\"
|
31
|
+
ActiveStorage.start()"
|
32
|
+
File.write("app/javascript/application.js", file_contents)
|
33
|
+
puts " HOTGLUE --> added to app/javascript/application.js: `ActiveStorage.start()"
|
34
|
+
else
|
35
|
+
puts " HOTGLUE --> app/javascript/application.js already contains `ActiveStorage.start()`"
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
else
|
40
|
+
puts " HOTGLUE --> could not detect either importmap-rails or jsbundling-rails app"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module HotGlue
|
2
|
+
class DropzoneInstallGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path('templates', __dir__)
|
4
|
+
|
5
|
+
def initialize(*args) #:nodoc:
|
6
|
+
super
|
7
|
+
system("./bin/rails generate stimulus Dropzone")
|
8
|
+
copy_file "javascript/dropzone_controller.js", "app/javascript/controllers/dropzone_controller.js"
|
9
|
+
puts "HOT GLUE --> copying dropzone stimulus controller into app/javascript/controllers/dropzone_controller.js"
|
10
|
+
|
11
|
+
|
12
|
+
if File.exist?("app/assets/stylesheets/application.bootstrap.scss")
|
13
|
+
scss_file = "app/assets/stylesheets/application.bootstrap.scss"
|
14
|
+
elsif File.exist?("app/assets/stylesheets/application.scss")
|
15
|
+
scss_file = "app/assets/stylesheets/application.scss"
|
16
|
+
else
|
17
|
+
raise "Could not detect your stylesheet, aborting..."
|
18
|
+
end
|
19
|
+
|
20
|
+
file_contents = File.read(scss_file)
|
21
|
+
|
22
|
+
if !file_contents.include?("@import \"dropzone/dist/dropzone\"")
|
23
|
+
file_contents << "\n@import \"dropzone/dist/dropzone\";\n@import \"dropzone/dist/basic\";"
|
24
|
+
|
25
|
+
|
26
|
+
File.write(scss_file, file_contents)
|
27
|
+
|
28
|
+
puts " HOTGLUE --> added to #{scss_file}: @import dropzone ... "
|
29
|
+
else
|
30
|
+
puts " HOTGLUE --> #{scss_file} already contains @import dropzone"
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
|
@@ -6,13 +6,14 @@ module HotGlue
|
|
6
6
|
attr_reader :include_setting,
|
7
7
|
:downnest_object,
|
8
8
|
:buttons_width, :columns,
|
9
|
-
:smart_layout, :specified_grouping_mode
|
9
|
+
:smart_layout, :specified_grouping_mode, :stacked_downnesting
|
10
10
|
|
11
11
|
def initialize(include_setting: nil,
|
12
12
|
downnest_object: nil,
|
13
13
|
buttons_width: nil,
|
14
14
|
smart_layout: nil,
|
15
|
-
columns: nil
|
15
|
+
columns: nil,
|
16
|
+
stacked_downnesting: false)
|
16
17
|
@include_setting = include_setting
|
17
18
|
@downnest_object = downnest_object
|
18
19
|
@buttons_width = buttons_width
|
@@ -21,6 +22,7 @@ module HotGlue
|
|
21
22
|
|
22
23
|
@no_buttons = @buttons_width == 0
|
23
24
|
@specified_grouping_mode = include_setting.include?(":")
|
25
|
+
@stacked_downnesting = stacked_downnesting
|
24
26
|
end
|
25
27
|
|
26
28
|
def construct
|
@@ -44,25 +46,31 @@ module HotGlue
|
|
44
46
|
|
45
47
|
bootstrap_columns = (12 - @buttons_width )
|
46
48
|
|
47
|
-
|
49
|
+
if(!stacked_downnesting)
|
50
|
+
bootstrap_columns = bootstrap_columns - (downnest_object.collect{|k,v| v}.sum)
|
51
|
+
else
|
52
|
+
bootstrap_columns = bootstrap_columns - 4
|
53
|
+
end
|
48
54
|
|
49
55
|
available_columns = (bootstrap_columns / 2).floor # bascially turns the 12-column grid into a 6-column grid
|
50
56
|
|
51
57
|
if available_columns < 0
|
52
58
|
raise "Cannot build layout with #{how_many_downnest} downnested portals"
|
53
59
|
end
|
54
|
-
|
60
|
+
#
|
61
|
+
# if !stacked_downnesting
|
62
|
+
#
|
63
|
+
# else
|
64
|
+
#
|
65
|
+
# end
|
55
66
|
downnest_children_width = []
|
56
|
-
|
57
67
|
downnest_object.each do |child, size|
|
58
68
|
layout_object[:portals][child] = {size: size}
|
59
69
|
end
|
60
70
|
|
61
|
-
|
62
71
|
if smart_layout
|
63
72
|
# automatic control
|
64
73
|
#
|
65
|
-
layout_object[:columns][:button_columns] = 2
|
66
74
|
|
67
75
|
if columns.size > available_columns
|
68
76
|
if available_columns == 0
|
@@ -5,6 +5,7 @@ module LayoutStrategy
|
|
5
5
|
@builder = scaffold_builder
|
6
6
|
end
|
7
7
|
|
8
|
+
def button_applied_classes; end
|
8
9
|
def column_classes_for_button_column; ""; end
|
9
10
|
def button_classes; ""; end
|
10
11
|
def button_column_style; "" ; end
|
@@ -23,6 +24,7 @@ module LayoutStrategy
|
|
23
24
|
(col_width/(builder.columns.count)).to_i
|
24
25
|
end
|
25
26
|
def list_classes; ""; end
|
27
|
+
def magic_button_classes; ""; end
|
26
28
|
def row_classes; ""; end
|
27
29
|
def row_heading_classes; ""; end
|
28
30
|
def page_begin; '<div> '; end
|
@@ -1,10 +1,19 @@
|
|
1
1
|
class LayoutStrategy::Bootstrap < LayoutStrategy::Base
|
2
|
-
def button_classes
|
2
|
+
def button_classes # column classes
|
3
3
|
" " + "col-sm-#{builder.layout_object[:columns][:button_columns]}"
|
4
4
|
end
|
5
5
|
|
6
|
+
def button_applied_classes
|
7
|
+
"btn btn-sm"
|
8
|
+
end
|
9
|
+
|
10
|
+
def magic_button_classes
|
11
|
+
"btn-secondary"
|
12
|
+
end
|
13
|
+
|
14
|
+
|
6
15
|
def column_classes_for_button_column
|
7
|
-
"col-md-#{builder.layout_object[:
|
16
|
+
"col-md-#{builder.layout_object[:buttons][:size]}"
|
8
17
|
end
|
9
18
|
|
10
19
|
|
@@ -17,7 +26,7 @@ class LayoutStrategy::Bootstrap < LayoutStrategy::Base
|
|
17
26
|
end
|
18
27
|
|
19
28
|
def container_name
|
20
|
-
"container
|
29
|
+
"container"
|
21
30
|
end
|
22
31
|
|
23
32
|
def column_classes_for_line_fields
|
@@ -32,6 +41,10 @@ class LayoutStrategy::Bootstrap < LayoutStrategy::Base
|
|
32
41
|
"col-sm-#{ builder.layout_object[:portals][downnest][:size] }"
|
33
42
|
end
|
34
43
|
|
44
|
+
def downnest_portal_stacked_column_width
|
45
|
+
"col-sm-4"
|
46
|
+
end
|
47
|
+
|
35
48
|
def page_begin
|
36
49
|
'<div class="row"> <div class="col-md-12">'
|
37
50
|
end
|