hot-glue 0.2.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -2
  3. data/Gemfile.lock +4 -24
  4. data/LICENCE +11 -4
  5. data/README.md +0 -524
  6. data/app/helpers/hot_glue/controller_helper.rb +8 -5
  7. data/app/views/layouts/_flash_notices.erb +12 -0
  8. data/lib/generators/hot_glue/install_generator.rb +110 -1
  9. data/lib/generators/hot_glue/markup_templates/erb.rb +68 -29
  10. data/lib/generators/hot_glue/markup_templates/haml.rb +5 -3
  11. data/lib/generators/hot_glue/scaffold_generator.rb +223 -58
  12. data/lib/generators/hot_glue/templates/capybara_login.rb +8 -0
  13. data/lib/generators/hot_glue/templates/controller.rb.erb +41 -32
  14. data/lib/generators/hot_glue/templates/erb/_form.erb +1 -1
  15. data/lib/generators/hot_glue/templates/erb/_line.erb +3 -2
  16. data/lib/generators/hot_glue/templates/erb/_list.erb +24 -8
  17. data/lib/generators/hot_glue/templates/erb/_show.erb +24 -4
  18. data/lib/generators/hot_glue/templates/erb/create.turbo_stream.erb +4 -4
  19. data/lib/generators/hot_glue/templates/erb/destroy.turbo_stream.erb +2 -2
  20. data/lib/generators/hot_glue/templates/erb/edit.erb +3 -13
  21. data/lib/generators/hot_glue/templates/erb/index.erb +11 -9
  22. data/lib/generators/hot_glue/templates/erb/update.turbo_stream.erb +5 -2
  23. data/lib/generators/hot_glue/templates/haml/_line.haml +1 -1
  24. data/lib/generators/hot_glue/templates/haml/_list.haml +6 -2
  25. data/lib/generators/hot_glue/templates/haml/create.turbo_stream.haml +3 -3
  26. data/lib/generators/hot_glue/templates/haml/destroy.turbo_stream.haml +1 -1
  27. data/lib/generators/hot_glue/templates/haml/edit.haml +0 -2
  28. data/lib/generators/hot_glue/templates/haml/index.haml +2 -3
  29. data/lib/generators/hot_glue/templates/system_spec.rb.erb +146 -47
  30. data/lib/generators/hot_glue/templates/themes/hotglue_scaffold_dark_knight.scss +158 -0
  31. data/lib/generators/hot_glue/templates/themes/hotglue_scaffold_like_bootstrap.scss +154 -0
  32. data/lib/generators/hot_glue/templates/themes/hotglue_scaffold_like_los_gatos.scss +182 -0
  33. data/lib/generators/hot_glue/templates/themes/hotglue_scaffold_like_mountain_view.scss +179 -0
  34. data/lib/hot-glue.rb +1 -2
  35. data/lib/hotglue/version.rb +1 -1
  36. metadata +15 -33
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51ed0488e72bcd508f979de89c9f9d11ee1284c702c22066e72311d9cee03894
4
- data.tar.gz: f30e2325ec4a08af8df44fa54e955b103aed04b650e2b165bcded589d2f8faa6
3
+ metadata.gz: 2fe831af428ff123db3490a3a376cadb40c1acd01f10f8926213dced0b78abaa
4
+ data.tar.gz: 5091fd12e7ca86865891e6f4fbaa5ad36b78951f2dd99d1819eb5eab8e32a2a7
5
5
  SHA512:
6
- metadata.gz: 8eb5cf4982698c4b51ac9caa4c223885ea9f8c2eac423c45e11ff2c7ccbb6c8aaad0e5f43d00cdf4ef3376a04bdc5ea3477813302a1fec8cc3d82e22463a5b51
7
- data.tar.gz: 94af84f2f7e66846e593e8ab7ac5c441fbd4b8814c1fc390823a97350fe00854f6c91868094820ca3461e28b10a671cc892430b5d86621a88ef8700376b81a87
6
+ metadata.gz: 35ecea29e077ad022c227ad994f0dd98fea31e849eef0158e578aa6be8d1b3cd212d124285193169f3fd23f7643a24ee327f5b2edb47837069f6db44de122d5a
7
+ data.tar.gz: 7fa9b3bc28743cf2c0989a47705335b9270d42c208c6b8317a9efac6d7a7de4c6d1a873c9550c7d056e9a2f85003f2c521ce7c0d5a30b6f3535e1057299e2119
data/.github/FUNDING.yml CHANGED
@@ -1,2 +1 @@
1
- github: [jasonfb]
2
- custom: ["https://www.instagram.com/jfbcodes/"]
1
+ custom: ["https://heliosdev.shop/hot-glue-license?utm_source=github.com&utm_campaign=github_hot_glue_repo_funding_link","https://jfbcodes.com/hot-glue-tutorial", "https://shop.heliosdev.shop/?utm_source=github.com&utm_campaign=github_hot_glue_repo_funding_link"]
data/Gemfile.lock CHANGED
@@ -1,13 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hot-glue (0.2.3)
4
+ hot-glue (0.2.9E)
5
5
  ffaker (~> 2.16)
6
- haml-rails (~> 2.0)
7
6
  kaminari (~> 1.2)
8
7
  rails (> 5.1, <= 7.0.0)
9
8
  sass-rails
10
- turbo-rails (~> 0.5)
9
+ turbo-rails (> 0.5)
11
10
 
12
11
  GEM
13
12
  remote: https://rubygems.org/
@@ -90,25 +89,10 @@ GEM
90
89
  warden (~> 1.2.3)
91
90
  diff-lcs (1.4.4)
92
91
  erubi (1.10.0)
93
- erubis (2.7.0)
94
- ffaker (2.19.0)
92
+ ffaker (2.20.0)
95
93
  ffi (1.15.4)
96
94
  globalid (0.4.2)
97
95
  activesupport (>= 4.2.0)
98
- haml (5.2.2)
99
- temple (>= 0.8.0)
100
- tilt
101
- haml-rails (2.0.1)
102
- actionpack (>= 5.1)
103
- activesupport (>= 5.1)
104
- haml (>= 4.0.6, < 6.0)
105
- html2haml (>= 1.0.1)
106
- railties (>= 5.1)
107
- html2haml (2.2.0)
108
- erubis (~> 2.7.0)
109
- haml (>= 4.0, < 6)
110
- nokogiri (>= 1.6.0)
111
- ruby_parser (~> 3.5)
112
96
  i18n (1.8.10)
113
97
  concurrent-ruby (~> 1.0)
114
98
  kaminari (1.2.1)
@@ -197,8 +181,6 @@ GEM
197
181
  rspec-mocks (~> 3.10)
198
182
  rspec-support (~> 3.10)
199
183
  rspec-support (3.10.2)
200
- ruby_parser (3.17.0)
201
- sexp_processor (~> 4.15, >= 4.15.1)
202
184
  sass-rails (6.0.0)
203
185
  sassc-rails (~> 2.1, >= 2.1.1)
204
186
  sassc (2.4.0)
@@ -209,7 +191,6 @@ GEM
209
191
  sprockets (> 3.0)
210
192
  sprockets-rails
211
193
  tilt
212
- sexp_processor (4.15.3)
213
194
  sprockets (4.0.2)
214
195
  concurrent-ruby (~> 1.0)
215
196
  rack (> 1, < 3)
@@ -218,10 +199,9 @@ GEM
218
199
  activesupport (>= 4.0)
219
200
  sprockets (>= 3.0.0)
220
201
  sqlite3 (1.4.2)
221
- temple (0.8.2)
222
202
  thor (1.1.0)
223
203
  tilt (2.0.10)
224
- turbo-rails (0.8.1)
204
+ turbo-rails (7.1.1)
225
205
  rails (>= 6.0.0)
226
206
  tzinfo (2.0.4)
227
207
  concurrent-ruby (~> 1.0)
data/LICENCE CHANGED
@@ -1,13 +1,20 @@
1
+
2
+ FOR HOBBYISTS/STUDENTS/TEACHERS/INDIVIDUALS/NON-PROFITS:
3
+
1
4
  Permission is hereby granted to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
2
5
 
3
6
  Any users of this software agree to work to
4
- 1) dismantle systemic racism;
7
+ 1) dismantle systemic racism
5
8
  2) seek justice for black, brown, transgender people, women, and
6
- 3) work towards LGBTQIAA+ representation and inclusion.
9
+ 3) work towards LGBTQIAA+ representation and inclusion
7
10
 
8
- Organizations using this software agree to center the narratives of black, brown, transgender, and non-advantaged people in the world.
11
+ FOR ALL OTHERS:
9
12
 
10
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
+ TO PURCHASE A LICENSE PLEASE VISIT
14
+ https://heliosdev.shop/hot-glue-license
11
15
 
16
+ Organizations using this software agree to center the narratives of black, brown, transgender, and non-advantaged people in the world.
17
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
18
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
19
 
20
+
data/README.md CHANGED
@@ -1,524 +0,0 @@
1
-
2
- [![Build Status](https://app.travis-ci.com/jasonfb/hot-glue.svg?branch=main)](https://travis-ci.com/jasonfb/hot-glue)
3
-
4
-
5
- Hot Glue is a Rails scaffold builder for the Turbo era. It is an evolution of the admin-interface style scaffolding systems of the 2010s ([activeadmin](https://github.com/activeadmin/activeadmin), [rails_admin](https://github.com/sferik/rails_admin), and [active_scaffold](https://github.com/activescaffold/active_scaffold)).
6
-
7
-
8
- Using Turbo-Rails and Hotwire (default in Rails 7) you get a lightning-fast out-of-the-box CRUD building experience.
9
-
10
- Every page displays only a list view: new and edit operations happen as 'edit-in-place', so the user never leaves the page.
11
-
12
- Because all page navigation is Turbo's responsibilty, everything plugs & plays nicely into a Turbo-backed Rails app.
13
-
14
- Alternatively, you can use this tool to create a Turbo-backed *section* of your Rails app-- like an admin interface -- while still treating the rest of the Rails app as an API or building out other features by hand.
15
-
16
- It will read your relationships and field types to generate your code for you, leaving you with a 'sourdough starter' to work from. If you modify the generated code, you're on your own if you want to preserve your changes and also re-generate scaffold after adding fields.
17
-
18
- By default, it generates code that gives users full control over objects they 'own' and by default it spits out functionality giving access to all fields.
19
-
20
- Hot Glue generates functionality that's quick and dirty. It let's you be crafty. As with a real hot glue gun, use with caution.
21
-
22
- * Build plug-and-play scaffolding for any CRUD on any object
23
- * mixes HAML and turbo_stream responses
24
- * Everything edits-in-place (unless you use --big-edit, then it won't)
25
- * Automatically reads your ActiveRecord models and relationships (make them before building your scaffolding!)
26
- * Create-read-update-delete (CRUD) with pagination (one day: sorting & searching)
27
- * Excellent tool for prototyping and hackathons, but a knowledge of Rails is needed.
28
- * Nest your routes model-by-model for built-in poor man's access control. (Customers have_many :invoices; Invoices have_many :line_items; etc)
29
- * Plays nicely with Devise, but you can implement your own current_user object instead.
30
- * Kaminari for pagination.
31
- * Create specs automatically along with the controllers.
32
- * Throw the scaffolding away when your app is ready to graduate to its next phase (or don't if you like it).
33
-
34
- ## QUICK START
35
-
36
- It's really easy to get started by following along with this blog post that creates three simple tables (User, Event, and Format).
37
-
38
- Feel free to build your own tables when you get to the sections for building the 'Event' scaffold:
39
-
40
- https://jasonfleetwoodboldt.com/hot-glue
41
-
42
- ## HOW EASY?
43
-
44
- ```
45
- rails generate hot_glue:scaffold Thing
46
- ```
47
-
48
- Generate a quick scaffold to manage a table called `pronouns`
49
- ![hot-glue-3](https://user-images.githubusercontent.com/59002/116405509-bdee2f00-a7fd-11eb-9723-4c6e22f81bd3.gif)
50
-
51
-
52
-
53
- Instantly get a simple CRUD interface
54
-
55
- ![hot-glue-4](https://user-images.githubusercontent.com/59002/116405517-c2b2e300-a7fd-11eb-8423-d43e3afc9fa6.gif)
56
-
57
- ## TO INSTALL (RAILS 7)
58
-
59
- - Install Turbo `rails turbo:install` (?)
60
-
61
- - Add `gem 'hot-glue'` to your Gemfile
62
- - `bundle install`
63
- - `rails generate hot_glue:install --markup=erb` for ERB
64
- - or `rails generate hot_glue:install --markup=haml` for HAML
65
-
66
- - Add to your `application.html.erb`
67
- ```
68
- <%= render partial: 'layouts/flash_notices' %>
69
- ```
70
- - Or for Haml add to your `application.haml`
71
- ```
72
- = render partial: 'layouts/flash_notices'
73
- ```
74
-
75
- ## TO INSTALL (RAILS 6)
76
-
77
- - Add `gem 'turbo-rails'` to your Gemfile & `bundle install`
78
-
79
- - Then install it with `rails turbo:install`
80
-
81
- - The Turbo install has switched your action cable settings from 'async' to Redis, so be sure to start a redis server
82
-
83
- - Add `gem 'hot-glue'` to your Gemfile & `bundle install`
84
-
85
- - in `javascript/packs/application.js` remove this line:
86
- `import Turbolinks from "turbolinks"`
87
-
88
- - in the same file (`javascript/packs/application.js`) add this line:
89
- `import { Turbo } from "@hotwired/turbo-rails"`
90
-
91
- - Run the hot-glue install generator
92
-
93
- FOR ERB:
94
- `rails generate hot_glue:install --markup=erb`
95
-
96
- FOR HAML:
97
- `rails generate hot_glue:install --markup=haml`
98
-
99
- - Add to your `application.html.erb`
100
- ```
101
- <%= render partial: 'layouts/flash_notices' %>
102
- ```
103
-
104
-
105
- ## Rspec setup
106
- - add `gem 'rspec-rails'` to your gemfile inside :development and :test
107
- - add `gem 'factory_bot_rails'` to your gemfile inside :development and :test
108
- - run `rails generate rspec:install`
109
- - configure Rspec to work with Factory Bot inside of `rails_helper.rb`
110
- ```
111
- RSpec.configure do |config|
112
- // ... more rspec configuration (not shown)
113
- config.include FactoryBot::Syntax::Methods
114
- end
115
- ```
116
- more info:
117
- https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#rspec
118
-
119
- - for a quick Capybara login, create a support helper in `spec/support/` and log-in as your user
120
- ```
121
- def login_as(account)
122
- visit '/accounts/sign_in'
123
- within("#new_account") do
124
- fill_in 'Email', with: account.email
125
- fill_in 'Password', with: 'password'
126
- end
127
- click_button 'Log in'
128
- end
129
- ```
130
-
131
- ## Install Bootstrap using Sprockets (IMPORTANT: YOU DO NOT NEED JQUERY*)
132
- Bootstrap with Sprockets for Rails 5 or 7 default — Rails 6 custom
133
- - use twbs/bootstrap-rubygem gem
134
- - see README for bootstrap-rubygem to install
135
- Bootstrap with Webpack for FOR RAILS 7 :
136
-
137
- - add to Gemfile
138
- - gem 'bootstrap', '~> 5.1.0'
139
-
140
-
141
- - completely delete the file `app/assets/application.css`
142
- - create new file where it was `app/assets/application.scss` with this contents (do not keep the contents of the old application.css file):
143
-
144
- ```
145
- // Custom bootstrap variables must be set or imported *before* bootstrap.
146
- @import "bootstrap";
147
- ```
148
-
149
- * You do not need jQuery for HotGlue to work *
150
-
151
- ### Bootstrap with Webpack RAILS 6 ONLY:
152
- - change `stylesheet_link_tag` to `stylesheet_pack_tag` in your application layout
153
- - run `yarn add bootstrap`
154
- - create a new file at `app/javascript/require_bootstrap.scss` with this content
155
- ```
156
- @import "~bootstrap/scss/bootstrap.scss";
157
- ```
158
-
159
- - add to `app/javascript/packs/application.js`
160
- ```
161
- import 'require_bootstrap'
162
- ```
163
-
164
-
165
-
166
-
167
- ## Install Devise or implement your own authentication
168
- (or only use --gd mode, see below)
169
-
170
- ## install font-awesome. I recommend https://github.com/tomkra/font_awesome5_rails or https://github.com/FortAwesome/font-awesome-sass
171
-
172
-
173
- ### First Argument
174
- (no double slash)
175
-
176
- TitleCase class name of the thing you want to build a scaffoling for.
177
-
178
-
179
- ## Options With Arguments
180
-
181
- All options two dashes (--) and these take an `=` and a value
182
-
183
- ### `--namespace=`
184
-
185
- pass `--namespace=` as an option to denote a namespace to apply to the Rails path helpers
186
-
187
-
188
- `rails generate hot_glue:scaffold Thing --namespace=dashboard`
189
-
190
- This produces several views at `app/views/dashboard/things/` and a controller at`app/controllers/dashboard/things_controller.rb`
191
-
192
- The controller looks like so:
193
-
194
- ```
195
- class Dashboard::ThingsController < ApplicationController
196
- before_action :authenticate_user!
197
- before_action :load_thing, only: [:show, :edit, :update, :destroy]
198
- def load_thing
199
- @thing = current_user.things.find(params[:id])
200
- end
201
- ...
202
- end
203
-
204
- ```
205
-
206
-
207
- ### `--nest=`
208
-
209
- pass `--nest=` to denote a nested resources
210
-
211
-
212
- `rails generate hot_glue:scaffold Line --nest=invoice`
213
-
214
- In this example, it is presumed that the current user has_many :invoices, and that invoices have many :lines
215
-
216
-
217
- For multi-level nesting use slashes to separate your levels of nesting. Remember, you should match what you have in your routes.rb file.
218
-
219
- ```
220
- resources :invoices do
221
- resources :lines do
222
- resources :charge
223
- end
224
- end
225
-
226
- ```
227
- In this example, it is presumed that the current user has_many :invoices, and that invoices have many :lines, and that lines have many :charges
228
-
229
-
230
- To generate scaffold:
231
- `rails generate hot_glue:scaffold Charge --nest=invoice/line`
232
-
233
- The order of the nest should match the nested resources you have in your own app. In particular, you auth root will be used as the starting point when loading the objects from the URL:
234
-
235
- In the example above, @invoice will be loaded from
236
-
237
- `@invoice = current_user.invoices.find(params[:invoice_id])`
238
-
239
- Then, @line will be loaded
240
-
241
- `@line = @invoice.lines.find(params[:line_id])`
242
-
243
- Then, finally the @charge will be loaded
244
-
245
- `@charge = @line.charges.find(params[:id])`
246
-
247
- It's called "poor man's access control" because if a user attempts to hack the URL by passing ids for objects they don't own--- which Rails makes relatively easy with its default URL pattern-- they will hit ActiveRecord not found errors (the objects they don't own won't be found in the associated relationship).
248
-
249
- It works, but it isn't granular. As well, it isn't appropriate for a large app with any level of intricacy to access control (that is, having roles).
250
-
251
- Your customers can delete their own objects by default (may be a good idea or a bad idea for you). If you don't want that, you should strip out the delete actions off the controllers.
252
-
253
-
254
- ### `--auth=`
255
-
256
- By default, it will be assumed you have a `current_user` for your user authentication. This will be treated as the "authentication root" for the "poor man's auth" explained above.
257
-
258
- The poor man's auth presumes that object graphs have only one natural way to traverse them (that is, one primary way to traverse them), and that all relationships infer that a set of things or their descendants are granted access to me for reading, writing, updating, and deleting.
259
-
260
- Of course this is a sloppy way to do access control, and can easily leave open endpoints your real users shouldn't have access to.
261
-
262
- When you display anything built with the scaffolding, we assume the `current_user` will have `has_many` association that matches the pluralized name of the scaffold. In the case of nesting, we will automatically find the nested objects first, then continue down the nest chain to find the target object. In this way, we know that all object are 'anchored' to the logged-in user.
263
-
264
- If you use Devise, you probably already have a `current_user` method available in your controllers. If you don't use Devise, you can implement it in your ApplicationController.
265
-
266
- If you use a different object other than "User" for authentication, override using the `auth` option.
267
-
268
- `rails generate hot_glue:scaffold Thing --auth=current_account`
269
-
270
- You will note that in this example it is presumed that the Account object will have an association for `things`
271
-
272
- It is also presumed that when viewing their own dashboard of things, the user will want to see ALL of their associated things.
273
-
274
- If you supply nesting (see below), your nest chain will automatically begin with your auth root object (see nesting)
275
-
276
-
277
-
278
-
279
- ### `--auth_identifier=`
280
-
281
- Your controller will call a method authenticate_ (AUTH IDENTIFIER) bang, like:
282
-
283
- `authenticate_user!`
284
-
285
- Before all of the controller actions. If you leave this blank, it will default to using the variable name supplied by auth with "current_" stripped away.
286
- (This is setup for devise.)
287
-
288
- Be sure to implement the following method in your ApplicationController or some other method. Here's a quick example using Devise. You will note in the code below, user_signed_in? is implemented when you add Devise methods to your User table.
289
-
290
- As well, the `after_sign_in_path_for(user)` here is a hook for Devise also that provides you with after login redirect to the page where the user first intended to go.
291
-
292
- ```
293
- def authenticate_user!
294
- if ! user_signed_in?
295
- session['user_return_to'] = request.path
296
- redirect_to new_user_registration_path
297
- end
298
- end
299
-
300
- def after_sign_in_path_for(user)
301
- session['user_return_to'] || account_url(user)
302
- end
303
- ```
304
-
305
-
306
- The default (do not pass `auth_identifier=`) will match the `auth` (So if you use 'account' as the auth, `authenticate_account!` will get invoked from your generated controller; the default is always 'user', so you can leave both auth and auth_identifier off if you want 'user')
307
-
308
-
309
- `rails generate hot_glue:scaffold Thing --auth=current_account --auth_identifier=login`
310
- In this example, the controller produced with:
311
- ```
312
- before_action :authenticate_login!
313
- ```
314
- However, the object graph anchors would continue to start from current_account. That is,
315
- ```
316
- @thing = current_account.things.find(params[:id])
317
- ```
318
-
319
- Use empty string to **turn this method off**:
320
- `rails generate hot_glue:scaffold Thing --auth=current_account --auth_identifier=''`
321
-
322
- In this case a controller would be generated that would have NO before_action to authenticate the account, but it would still treat the current_account as the auth root for the purpose of loading the objects.
323
-
324
- Please note that this example would product non-functional code, so you would need to manually fix your controllers to make sure `current_account` is available to the controller.
325
-
326
-
327
- ### `--plural=`
328
-
329
- You don't need this if the pluralized version is just + "s" of the singular version. Only use for non-standard plurlizations, and be sure to pass it as TitleCase (as if you pluralized the model name which is non-standard for Rails)
330
-
331
-
332
- ### `--exclude=`
333
- (separate field names by COMMA)
334
-
335
- By default, all fields are included unless they are on the exclude list. (The default for the exclude list is `id`, `created_at`, and `updated_at` so you don't need to exclude those-- they are added.)
336
-
337
- If you specify an exclude list, those and the default excluded list will be excluded.
338
-
339
-
340
- `rails generate hot_glue:scaffold Account --exclude=password`
341
-
342
- (The default excluded list is: :id, :created_at, :updated_at, :encrypted_password, :reset_password_token, :reset_password_sent_at, :remember_created_at, :confirmation_token, :confirmed_at, :confirmation_sent_at, :unconfirmed_email. If you want to edit any fields with the same name, you must use the include flag instead.)
343
-
344
-
345
- ### `--include=`
346
- (separate field names by COMMA)
347
-
348
- You may not specify both include and exclude. If you specify an include list, it will be treated as a whitelist: no fields will be included unless specified on the include list.
349
-
350
- `rails generate hot_glue:scaffold Account --include=first_name,last_name,company_name,created_at,kyc_verified_at`
351
-
352
-
353
- ### `--show-only=`
354
- (separate field names by COMMA)
355
-
356
- Any fields only the 'show-only' list will appear as non-editable on the generate form. (visible only)
357
-
358
- IMPORTANT: By default, all fields that begin with an underscore (`_`) are automatically show-only.
359
-
360
- 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.
361
-
362
- ### `--stimulus_syntax=true` or `--stimulus_syntax=false`
363
- (for Rails <=6, default is false. For Rails 7, default is true.)
364
-
365
- Stimulus is only used for the delete button's confirmation dialog.
366
-
367
- If you don't have stimulus syntax enabled, your delete buttons have this. This will confirm the delete with a simple alert if you have UJS enabled.
368
-
369
- ```
370
- {confirm: 'Are you sure?'}
371
- ```
372
-
373
- If you do have Stimulus syntax enabled, your delete buttons will look like so:
374
- ```
375
- <%= button_to "Delete <i class='fa fa-1x fa-remove'></i>".html_safe,
376
- thing_path(branch), method: :delete,
377
- data: {
378
- 'controller: 'confirmable',
379
- 'confirm-message': 'Are you sure you want to delete Thing?',
380
- 'action': 'confirmation#confirm'
381
- },
382
- disable_with: "Loading...", class: "delete-branch-button btn btn-primary " %>
383
- ```
384
-
385
- Your install script will output an additional stimulus controller:
386
-
387
- ```
388
-
389
- ```
390
-
391
-
392
-
393
- ### `--markup` (default: 'erb')
394
-
395
- ERB is default. For HAML, `--markup=haml`.
396
-
397
-
398
- ## FLAGS (Options with no values)
399
- These options (flags) also uses `--` syntax but do not take any values. Everything is assumed (default) to be false unless specified.
400
-
401
- ### `--god` or `--gd`
402
-
403
- 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.
404
-
405
- For example, FOR ADMIN CONTROLLERS ONLY, supply a auth_identifier and use `--god` flag.
406
-
407
- In Gd mode, the objects are loaded directly from the base class (these controllers have full access)
408
- ```
409
- def load_thing
410
- @thing = Thing.find(params[:id])
411
- end
412
-
413
- ```
414
-
415
-
416
- ### `--specs-only`
417
-
418
- Produces ONLY the controller spec file, nothing else.
419
-
420
-
421
- ### `--no-specs`
422
-
423
- Produces all the files except the spec file.
424
-
425
-
426
- ### `--no-paginate`
427
-
428
- Omits pagination. (All list views have pagination by default.)
429
-
430
-
431
- ### `--no-create`
432
-
433
- Omits create action.
434
-
435
- ### `--no-delete`
436
-
437
- Omits delete action.
438
-
439
- ### `--big-edit`
440
-
441
- If you do not want inline editing of your list items but instead to fall back to full page style behavior for your edit views, use `--big-edit`. Turbo still handles the page interactions, but the user is taken to a full-screen edit page instead of an edit-in-place interaction.
442
-
443
-
444
- ## Automatic Base Controller
445
-
446
- HotGlue will copy a file named base_controller.rb to the same folder where it tries to create any controller, unless such a file exists there already.
447
-
448
- Obviously, the created controller will always have this base controller as its subclass. In this way, you are encouraged to implement functionality common to the *namespace* (shared between the controllers in the namespace), using this technique.
449
-
450
- ## Field Types Supported
451
-
452
- - Integers that don't end with `_id`, they will be displayed as text fields.
453
- - Integers that do end with `_id` will be treated automatically as associations. You should have a Rails association defined. (Hot Glue will warn you if it can't find one.)
454
- - String*
455
- - Text*
456
- - Float*
457
- - Datetime
458
- - Date (TOOD: implement this)
459
- - Time (TOOD: implement this)
460
- - Boolean
461
- - Enum - will be magically displayed as a value list populated from the enum list defined on your model. see https://jasonfleetwoodboldt.com/courses/stepping-up-rails/enumerated-types-in-rails-and-postgres/
462
-
463
- * shows in a size-aware container, i.e. in a bigger box if the field allows for more content
464
-
465
-
466
-
467
- # VERSION HISTORY
468
-
469
- #### 2021-10-07 - v0.2.4 - removes erroneous icons display in delete buttos (these don't work inside of button_to);
470
- - adds support for ENUM types direclty on your field types
471
- - you must use activerecord-pgenum
472
- - see my blog post at https://jasonfleetwoodboldt.com/courses/stepping-up-rails/enumerated-types-in-rails-and-postgres/
473
-
474
- #### 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
475
-
476
- #### 2021-09-27 - v0.2.2 - Fixes some issues with related fields; unlocks Rails 7 in Gemspec file
477
-
478
- #### 2021-09-20 - v0.2.1 - Fixes nesting behavior when using gd option
479
-
480
- #### 2021-09-06 - v0.2.0 - ERB or HAML; use the option --markup=erb or --markup=haml (default is now erb)
481
-
482
- #### 2021-06-28 - v0.1.2 - fixes problem with namespaces on path helpers
483
-
484
- #### 2021-05-09 (yanked) - v0.1.1 - add cancellation buttons
485
-
486
- #### 2021-04-28 - v0.1.0 - Very pleased to introduce full behavior specs, found in specs/system/, generated by default on all build code; also many fixes involving nesting and authentication"
487
-
488
- #### 2021-03-24 - v0.0.9 - fixes in the automatic field label detection; cleans up junk in spec output
489
-
490
- #### 2021-03-21 - v0.0.8 - show only flag; more specific spec coverage in generator spec
491
-
492
- #### 2021-03-20 - v0.0.7 - adds lots of spec coverage; cleans up generated cruft code on each run; adds no-delete, no-create; a working --big-edit with basic data-turbo false to disable inline editing
493
-
494
- #### 2021-03-06 - v0.0.6 - internal specs test the error catches and cover basic code generation (dummy testing only)
495
-
496
- #### 2021-03-01 - v0.0.5 - Validation magic; refactors the options to the correct Rails::Generators syntax
497
-
498
- #### (yanked) - v0.0.4
499
-
500
- #### 2021-02-27 - v0.0.3 - several fixes for namespaces; adds pagination; adds exclude list to fields
501
-
502
- #### 2021-02-25 - v0.0.2 - bootstrapy
503
-
504
- #### 2021-02-24 - v0.0.1 - first proof of concept release -- basic CRUD works
505
-
506
- #### 2021-02-23 - v0.0.0 - Port of my prior work from github.com/jasonfb/common_core_js
507
-
508
-
509
-
510
- # HOW THIS GEM IS TESTED
511
-
512
- SETUP:
513
- • Run bundle install
514
- • if you can't get through see https://stackoverflow.com/questions/68050807/gem-install-mimemagic-v-0-3-10-fails-to-install-on-big-sur/68170982#68170982
515
-
516
-
517
- The dummy sandbox is found at `spec/dummy`
518
-
519
- The dummy sandbox lives as mostly checked- into the repository, **except** the folders where the generated code goes (`spec/dummy/app/views/`, `spec/dummy/app/controllers/`, `spec/dummy/specs/` are excluded from Git)
520
-
521
- When you run the **internal specs**, which you can do **at the root of this repo** using the command `rspec`, a set of specs will run to assert the generators are erroring when they are supposed to and producing code when they are supposed to.
522
-
523
- The DUMMY testing DOES NOT test the actual functionality of the output code (it just tests the functionality of the generation process).
524
-
@@ -54,12 +54,15 @@ module HotGlue
54
54
  else
55
55
  server_timezone
56
56
  end
57
- elsif defined?(controller) == "method"
58
- # controller.try(:current_timezone)
59
- elsif self.class.ancestors.include?(ApplicationController)
60
- self.try(:current_timezone)
57
+ elsif true
58
+ server_timezone
59
+ # elsif defined?(controller) == "method"
60
+ # # controller.try(:current_timezone)
61
+ # elsif self.class.ancestors.include?(ApplicationController)
62
+ # self.try(:current_timezone)
61
63
  else
62
- raise "no method current_user is available; please implement/override the method current_timezone IN YOUR CONTROLLER"
64
+ puts "no method current_user is available; please implement/override the method current_timezone IN YOUR CONTROLLER"
65
+ exit
63
66
  end
64
67
  end
65
68
 
@@ -0,0 +1,12 @@
1
+ <%= turbo_frame_tag "flash_notices" do %>
2
+ <% unless notice.nil? %>
3
+ <div class="alert alert-notice alert-dismissible">
4
+ <%= notice %>
5
+ </div>
6
+ <% end %>
7
+ <% unless alert.nil? %>
8
+ <div class="alert alert-danger alert-dismissible">
9
+ <%= alert %>
10
+ </div>
11
+ <% end %>
12
+ <% end %>