hot-glue 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ea47eaaf1c1a9a92b6382e2dc41a5e9f119600cfd0f58bc8b8091c33e3ac48a
4
- data.tar.gz: c9ebd867495aff539bbb53c7d1ecb09c5fd83cb00121a129eadfc96533647efc
3
+ metadata.gz: 0a29f1b4b001de5e14dbfc1ce046aae144d53f81eb5efecb05c88a69cad06b09
4
+ data.tar.gz: e4efb4c1d9d87cda11f835750475b6cfc86ea9daa4c25ce5cc08eebca1968d97
5
5
  SHA512:
6
- metadata.gz: 2022393514c059339cc9e4c163962501a48609f317ab7d3f4be3a00e467637d6dbb14757dadf9312569dedc6372a43f427e28b6c3b2638067bdc25ca4d23fe3d
7
- data.tar.gz: 7a19916224effd9ad2726baf944b110083978ee8328588301f89c4c2ae4791bfad8fcbf5f37b9dc5844153cfe39432933a47e1f890b121b78372e5cdedbc5afc
6
+ metadata.gz: 1b2b2f354390c5d2d0cef4fbd87dfee63de72b69112efc4e1c24c23037ca96f899d077b8876f81a6b8347787d3b997b1b5a7d08608c3039640003398c4974071
7
+ data.tar.gz: f933f8f06deff1d2f80632ed4b2e4d9ed5ff4d70246c8c99562a15b13ece0a75b3aa9fa86e27935de4555744ee6039183d960debd89eb9bc82f6f2937ab99730
data/README.md CHANGED
@@ -44,8 +44,20 @@ Instantly get a simple CRUD interface
44
44
 
45
45
  ![hot-glue-4](https://user-images.githubusercontent.com/59002/116405517-c2b2e300-a7fd-11eb-8423-d43e3afc9fa6.gif)
46
46
 
47
+ ## TO INSTALL (RAILS 7)
47
48
 
48
- ## TO INSTALL
49
+ - Install Turbo `rails turbo:install` (?)
50
+
51
+ - Add `gem 'hot-glue'` to your Gemfile & `bundle install`
52
+ `rails generate hot_glue:install --markup=erb`
53
+
54
+ - Add to your `application.html.erb`
55
+ ```
56
+ <%= render partial: 'layouts/flash_notices' %>
57
+ ```
58
+
59
+
60
+ ## TO INSTALL (RAILS 6)
49
61
 
50
62
  - Add `gem 'turbo-rails'` to your Gemfile & `bundle install`
51
63
 
@@ -55,14 +67,27 @@ Instantly get a simple CRUD interface
55
67
 
56
68
  - Add `gem 'hot-glue'` to your Gemfile & `bundle install`
57
69
 
58
- - Run the hot-glue installation with `rails generate hot_glue:install`
70
+ - in `javascript/packs/application.js` remove this line:
71
+ `import Turbolinks from "turbolinks"`
72
+
73
+ - in the same file (`javascript/packs/application.js`) add this line:
74
+ `import { Turbo } from "@hotwired/turbo-rails"`
75
+
76
+ - Run the hot-glue install generator
77
+
78
+ FOR ERB:
79
+ `rails generate hot_glue:install --markup=erb`
80
+
81
+ FOR HAML:
82
+ `rails generate hot_glue:install --markup=haml`
59
83
 
60
84
  - Add to your `application.html.erb`
61
85
  ```
62
86
  <%= render partial: 'layouts/flash_notices' %>
63
87
  ```
64
88
 
65
- - Rspec setup
89
+
90
+ ## Rspec setup
66
91
  - add `gem 'rspec-rails'` to your gemfile inside :development and :test
67
92
  - add `gem 'factory_bot_rails'` to your gemfile inside :development and :test
68
93
  - run `rails generate rspec:install`
@@ -88,12 +113,27 @@ Instantly get a simple CRUD interface
88
113
  end
89
114
  ```
90
115
 
91
- - Install Bootstrap
92
- - Bootstrap with Sprockets (Rails 5 or 7 default — Rails 6 custom)
116
+ ## Install Bootstrap using Sprockets (IMPORTANT: YOU DO NOT NEED JQUERY*)
117
+ - Bootstrap with Sprockets for Rails 5 or 7 default — Rails 6 custom
93
118
  - use twbs/bootstrap-rubygem gem
94
119
  - see README for bootstrap-rubygem to install
95
-
96
- Bootstrap with Webpack RAILS 6 ONLY:
120
+ - Bootstrap with Webpack for FOR RAILS 7 :
121
+
122
+ - add to Gemfile
123
+ - gem 'bootstrap', '~> 5.1.0'
124
+
125
+
126
+ - completely delete the file `app/assets/application.css`
127
+ - create new file where it was `app/assets/application.scss` with this contents (do not keep the contents of the old application.css file):
128
+
129
+ ```
130
+ // Custom bootstrap variables must be set or imported *before* bootstrap.
131
+ @import "bootstrap";
132
+ ```
133
+
134
+ * You do not need jQuery for HotGlue to work *
135
+
136
+ ### Bootstrap with Webpack RAILS 6 ONLY:
97
137
  - change `stylesheet_link_tag` to `stylesheet_pack_tag` in your application layout
98
138
  - run `yarn add bootstrap`
99
139
  - create a new file at `app/javascript/require_bootstrap.scss` with this content
@@ -106,16 +146,13 @@ Bootstrap with Webpack RAILS 6 ONLY:
106
146
  import 'require_bootstrap'
107
147
  ```
108
148
 
109
- Bootstrap with Webpack for FOR RAILS 7 :
110
- -- See this BLOG POST
111
- https://jasonfleetwoodboldt.com/stepping-up-rails/rails-7-with-webpacker-and-bootstrap/
112
149
 
113
150
 
114
151
 
115
- - Install Devise or implement your own authentication
152
+ ## Install Devise or implement your own authentication
116
153
  (or only use --gd mode, see below)
117
154
 
118
- - font-awesome
155
+ ## install font-awesome. I recommend https://github.com/tomkra/font_awesome5_rails or https://github.com/FortAwesome/font-awesome-sass
119
156
 
120
157
 
121
158
  ### First Argument
@@ -307,21 +344,30 @@ IMPORTANT: By default, all fields that begin with an underscore (`_`) are automa
307
344
 
308
345
  I would recommend this for fields you want globally non-editable by users in your app. For example, a counter cache or other field set only by a backend mechanism.
309
346
 
310
- ### `--god` or `--gd`
347
+ ### `stimulus_syntax` (default is false for Rails <=6; true for Rails 7)
311
348
 
312
- Use this flag to create controllers with no root authentication. You can still use an auth_identifier, which can be useful for a meta-leval authentication to the controller.
349
+ Your delete buttons will look like so:
350
+ ```
351
+ <%= button_to "Delete <i class='fa fa-1x fa-remove'></i>".html_safe,
352
+ thing_path(branch), method: :delete,
353
+ data: {
354
+ 'controller: 'confirmable',
355
+ 'confirm-message': 'Are you sure you want to delete Thing?',
356
+ 'action': 'confirmation#confirm'
357
+ },
358
+ disable_with: "Loading...", class: "delete-branch-button btn btn-primary " %>
313
359
 
314
- For example, FOR ADMIN CONTROLLERS ONLY, supply a auth_identifier and use `--god` flag.
315
360
 
316
- In Gd mode, the objects are loaded directly from the base class (these controllers have full access)
317
361
  ```
318
- def load_thing
319
- @thing = Thing.find(params[:id])
320
- end
362
+
363
+ Your install script will output an additional stimulus controller:
364
+
365
+ ```
321
366
 
322
367
  ```
323
368
 
324
369
 
370
+
325
371
  ### `--markup` (default: 'erb')
326
372
 
327
373
  ERB is default. For HAML, `--markup=haml`.
@@ -330,6 +376,21 @@ ERB is default. For HAML, `--markup=haml`.
330
376
  ## FLAGS (Options with no values)
331
377
  These options (flags) also uses `--` syntax but do not take any values. Everything is assumed (default) to be false unless specified.
332
378
 
379
+ ### `--god` or `--gd`
380
+
381
+ Use this flag to create controllers with no root authentication. You can still use an auth_identifier, which can be useful for a meta-leval authentication to the controller.
382
+
383
+ For example, FOR ADMIN CONTROLLERS ONLY, supply a auth_identifier and use `--god` flag.
384
+
385
+ In Gd mode, the objects are loaded directly from the base class (these controllers have full access)
386
+ ```
387
+ def load_thing
388
+ @thing = Thing.find(params[:id])
389
+ end
390
+
391
+ ```
392
+
393
+
333
394
  ### `--specs-only`
334
395
 
335
396
  Produces ONLY the controller spec file, nothing else.
@@ -362,6 +423,10 @@ If you do not want inline editing of your list items but instead to fall back to
362
423
 
363
424
 
364
425
  # VERSION HISTORY
426
+ #### 2021-09-30 - v0.2.3 - fixes ERB output for show-only fields; fixes flash_notices for erb or haml; adds @stimulus_syntax flag for delete confirmations with stimulus
427
+
428
+ #### 2021-09-27 - v0.2.2 - Fixes some issues with related fields; unlocks Rails 7 in Gemspec file
429
+
365
430
  #### 2021-09-20 - v0.2.1 - Fixes nesting behavior when using gd option
366
431
 
367
432
  #### 2021-09-06 - v0.2.0 - ERB or HAML; use the option --markup=erb or --markup=haml (default is now erb)
@@ -4,13 +4,20 @@ require 'ffaker'
4
4
  module HotGlue
5
5
  class InstallGenerator < Rails::Generators::Base
6
6
  hook_for :form_builder, :as => :scaffold
7
+ class_option :markup, type: :string, default: "erb"
7
8
 
8
9
  source_root File.expand_path('templates', __dir__)
9
10
 
10
11
 
11
12
  def initialize(*args) #:nodoc:
12
13
  super
13
- copy_file "_flash_notices.haml", "#{'spec/dummy/' if Rails.env.test?}app/views/layouts/_flash_notices.haml"
14
+ @markup = options['markup']
15
+ if @markup == "haml"
16
+ copy_file "haml/_flash_notices.haml", "#{'spec/dummy/' if Rails.env.test?}app/views/layouts/_flash_notices.haml"
17
+ elsif @markup == "erb"
18
+ copy_file "erb/_flash_notices.erb", "#{'spec/dummy/' if Rails.env.test?}app/views/layouts/_flash_notices.erb"
19
+
20
+ end
14
21
  end
15
22
  end
16
23
  end
@@ -36,10 +36,11 @@ module HotGlue
36
36
 
37
37
  if show_only.include?(col)
38
38
 
39
- "#{col_identifier}{class: \"form-group <%= 'alert-danger' if #{singular}.errors.details.keys.include?(:#{col.to_s}) %> \"}
40
- = @#{singular}.#{col.to_s}
41
- %label.form-text
42
- #{col.to_s.humanize}\n"
39
+ "<div class=\"#{col_identifier} form-group <%= 'alert-danger' if #{singular}.errors.details.keys.include?(:#{col}) %>\">" +
40
+ "<%= @#{singular}.#{col.to_s} %>" +
41
+ "<label class='form-text'>#{col.to_s.humanize}</label>" +
42
+ "</div>"
43
+
43
44
  else
44
45
 
45
46
 
@@ -168,9 +169,8 @@ module HotGlue
168
169
  end
169
170
  when :float
170
171
  width = (limit && limit < 40) ? limit : (40)
171
- "#{col_identifer}
172
- = #{singular}.#{col}"
173
-
172
+ "<div class='#{col_identifer}'>
173
+ <%= #{singular}.#{col}%></div>"
174
174
  when :string
175
175
  width = (limit && limit < 40) ? limit : (40)
176
176
  "<div class='#{col_identifer}'>
@@ -55,6 +55,7 @@ module HotGlue
55
55
  class_option :big_edit, type: :boolean, default: false
56
56
  class_option :show_only, type: :string, default: ""
57
57
  class_option :markup, type: :string, default: "erb"
58
+ class_option :stimulus_syntax, type: :boolean, default: nil
58
59
 
59
60
 
60
61
 
@@ -80,6 +81,14 @@ module HotGlue
80
81
  raise(HotGlue::Error, "*** Oops: You seem to have specified both the --specs-only flag and --no-specs flags. this doesn't make any sense, so I am aborting. sorry.")
81
82
  end
82
83
 
84
+ if @stimulus_syntax.nil?
85
+ if Rails.version.split(".")[0].to_i >= 7
86
+ @stimulus_syntax = true
87
+ else
88
+ @stimulus_syntax = false
89
+ end
90
+ end
91
+
83
92
  if options['markup'] == "erb"
84
93
  @template_builder = HotGlue::ErbTemplate.new
85
94
  elsif options['markup'] == "slim"
@@ -645,9 +654,19 @@ module HotGlue
645
654
  end
646
655
  end
647
656
 
648
- def paginate
649
- @template_builder.paginate(plural: plural)
657
+ def paginate
658
+ @template_builder.paginate(plural: plural)
659
+ end
660
+
661
+ def delete_confirmation_syntax
662
+ if !@stimulus_syntax
663
+ "{confirm: 'Are you sure?'}"
664
+ else
665
+ "{controller: 'confirmable', 'confirm-message': \"Are you sure you want to delete \#{ @#{@singular}.#{ display_class } } \", 'action': 'confirmation#confirm'}"
650
666
  end
667
+ end
668
+
669
+
651
670
  private # thor does something fancy like sending the class all of its own methods during some strange run sequence
652
671
  # does not like public methods
653
672
 
@@ -655,7 +674,6 @@ module HotGlue
655
674
  [name, file_format].compact.join(".")
656
675
  end
657
676
  end
658
-
659
677
  end
660
678
 
661
679
 
@@ -68,7 +68,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
68
68
  load_all_<%= plural %>
69
69
  respond_to do |format|
70
70
  format.turbo_stream
71
- format.html { redirect_to <%= plural %>_path }
71
+ format.html { redirect_to <%= path_helper_plural %> }
72
72
  end
73
73
  else
74
74
  flash[:alert] = "Oops, your <%= singular_name %> could not be created."
@@ -113,7 +113,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
113
113
  load_all_<%= plural %>
114
114
  respond_to do |format|
115
115
  format.turbo_stream
116
- format.html { redirect_to <%= plural %>_path }
116
+ format.html { redirect_to <%= path_helper_plural %> }
117
117
  end
118
118
  end<% end %>
119
119
 
@@ -1,7 +1,7 @@
1
1
  <%= all_line_fields %>
2
2
  <div class="col">
3
3
  <% if destroy_action %>
4
- <\%= link_to "Delete <i class='fa fa-1x fa-remove'></i>".html_safe, <%= path_helper_singular %>(<%= path_helper_args %>), method: :delete, data: {confirm: 'Are you sure?'}, disable_with: "Loading...", class: "delete-<%= singular %>-button btn btn-primary " %>
4
+ <\%= button_to "Delete <i class='fa fa-1x fa-remove'></i>".html_safe, <%= path_helper_singular %>(<%= path_helper_args %>), method: :delete, data: <%= delete_confirmation_syntax %>, disable_with: "Loading...", class: "delete-<%= singular %>-button btn btn-primary " %>
5
5
  <% end %>
6
6
  &nbsp;
7
7
  <\%= link_to "Edit <i class='fa fa-1x fa-list-alt'></i>".html_safe, edit_<%= path_helper_singular %>(<%= path_helper_args %>), <% if @big_edit %>'data-turbo' => 'false', <% end %>disable_with: "Loading...", class: "edit-<%= singular %>-button btn btn-primary " %>
@@ -1,3 +1,3 @@
1
1
  module HotGlue
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hot-glue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Fleetwood-Boldt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-27 00:00:00.000000000 Z
11
+ date: 2021-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails