hot-glue 0.5.3 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +0 -1
- data/.gitignore +12 -5
- data/README.md +162 -42
- data/lib/generators/hot_glue/install_generator.rb +13 -13
- data/lib/generators/hot_glue/layout/builder.rb +11 -8
- data/lib/generators/hot_glue/layout_strategy/base.rb +31 -0
- data/lib/generators/hot_glue/layout_strategy/bootstrap.rb +41 -0
- data/lib/generators/hot_glue/layout_strategy/hot_glue.rb +82 -0
- data/lib/generators/hot_glue/layout_strategy/tailwind.rb +28 -0
- data/lib/generators/hot_glue/markup_templates/base.rb +3 -3
- data/lib/generators/hot_glue/markup_templates/erb.rb +90 -80
- data/lib/generators/hot_glue/scaffold_generator.rb +103 -110
- data/lib/generators/hot_glue/templates/controller.rb.erb +14 -40
- data/lib/generators/hot_glue/templates/erb/_form.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/_line.erb +3 -3
- data/lib/generators/hot_glue/templates/erb/_list.erb +6 -11
- data/lib/generators/hot_glue/templates/erb/_new_button.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/_new_form.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/_show.erb +3 -3
- 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/edit.turbo_stream.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/index.erb +3 -6
- data/lib/generators/hot_glue/templates/erb/update.turbo_stream.erb +1 -1
- data/lib/generators/hot_glue/templates/system_spec.rb.erb +3 -1
- data/lib/hot-glue.rb +0 -4
- data/lib/hotglue/engine.rb +1 -1
- data/lib/hotglue/version.rb +1 -1
- metadata +6 -3
- data/lib/generators/hot_glue/helpers.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eedf5dcbc79766ed47352778020a633eb34324ecefb715b5e9b5476f119f80e6
|
4
|
+
data.tar.gz: 95e59bd0f9dc73b62c7b1d4a653a9384fed801ec9b8d672f44cc9e4636b56dc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99c381f75071b812279eb0cda17d4e0086fafba3385e37283e838610fb2e8574d3659c7e130ef4ac2531309a564d3c4b7a1a1064475c4d370ba7de942d67dcfd
|
7
|
+
data.tar.gz: 5fd29976555c4dc94814afeec9759c8156db92d6df9c178ece27d7b9bbd9570db5e764f75c3b2c61a7c26391950718c181fa0b03224858e41f836654fc9a6a01
|
data/.github/workflows/test.yml
CHANGED
data/.gitignore
CHANGED
@@ -16,11 +16,18 @@ Gemfile.lock
|
|
16
16
|
|
17
17
|
db/*.sqlite3
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
dummy/app/views/
|
20
|
+
dummy/app/controllers/
|
21
|
+
dummy/specs/
|
22
|
+
|
23
|
+
dummy/node_modules/
|
24
|
+
dummy/log/
|
25
|
+
dummy/Gemfile.lock
|
26
|
+
dummy/config/hot_glue.yml
|
22
27
|
|
23
|
-
spec/dummy/node_modules/
|
24
|
-
spec/dummy/log/
|
25
28
|
|
26
29
|
coverage/
|
30
|
+
|
31
|
+
|
32
|
+
spec/dummy/
|
33
|
+
dummy/spec/system/
|
data/README.md
CHANGED
@@ -5,9 +5,7 @@ Hot Glue is a Rails scaffold builder for the Turbo era. It is an evolution of th
|
|
5
5
|
|
6
6
|
Using Turbo-Rails and Hotwire (default in Rails 7) you get a lightning-fast out-of-the-box CRUD-building experience.
|
7
7
|
|
8
|
-
Every page displays only a list view: new and edit operations happen as 'edit-in-place,' so the user never leaves the page.
|
9
|
-
|
10
|
-
Because all page navigation is Turbo's responsibility, everything plugs & plays nicely into a Turbo-backed Rails app.
|
8
|
+
Every page displays only a list view: new and edit operations happen as 'edit-in-place,' so the user never leaves the page. Because all page navigation is Turbo's responsibility, everything plugs & plays nicely into a Turbo-backed Rails app.
|
11
9
|
|
12
10
|
Alternatively, you can use this tool to create a Turbo-backed *section* of your Rails app -- such as an admin interface -- while still treating the rest of the Rails app as an API or building out other features by hand.
|
13
11
|
|
@@ -27,6 +25,16 @@ Hot Glue generates functionality that is quick and dirty. It lets you be crafty.
|
|
27
25
|
* Nest your routes model-by-model for built-in poor man's authentication.
|
28
26
|
* Throw the scaffolding away when your app is ready to graduate to its next phase.
|
29
27
|
|
28
|
+
How is it different than Rails scaffolding?
|
29
|
+
|
30
|
+
Although inspired by the Rails scaffold generators (built-in to Rails), Hot Glue does something similiar but has made opinionated decisions that deviate from the normal Rails scaffold:
|
31
|
+
|
32
|
+
1. The Hot Glue scaffolds are complete packages and pre-optimized for 'edit-in-place.' (the Rails scaffolds still generates views that make you flip between pages to do create/update operations)
|
33
|
+
2. Hot Glue does not create your models along with your scaffolding. Instead, create them first using `rails generate model X`
|
34
|
+
3. Hot Glue *reads* the fields on your database *and* the relationships defined on your models. Unlike the Rails scaffolding you must add relationships and migration your DB before building your scaffolding.
|
35
|
+
4. Hot Glue has many more features for building layouts quickly, like choosing which fields to include or exclude and how to lay them out on the page, for stitching together related objects (nesting and child portals), and more.
|
36
|
+
|
37
|
+
Other than the opinionated differences and additional features, Hot Glue produces code that is fundamentally very similiar and works consistent with the Rails 7 ways of working.
|
30
38
|
|
31
39
|
# Get Hot Glue
|
32
40
|
|
@@ -36,16 +44,6 @@ Hot Glue generates functionality that is quick and dirty. It lets you be crafty.
|
|
36
44
|
[![Hot Glue Course](https://user-images.githubusercontent.com/59002/189544503-6edbcd40-1728-4b13-ac9a-c7772ccb8284.jpg)](https://jfbcodes.com/courses/hot-glue-in-depth-tutorial/?utm_source=github.com&utm_campaign=github_hot_glue_readme_page)
|
37
45
|
|
38
46
|
---
|
39
|
-
|
40
|
-
|
41
|
-
## GETTING STARTED VIDEO
|
42
|
-
|
43
|
-
|
44
|
-
~~Check it out on Youtube at https://www.youtube.com/watch?v=bKjKHMTvzZc~~
|
45
|
-
|
46
|
-
While you're over there could you give my Youtube channel a 'Subscribe'? (look for the RED SUBSCRIBE BUTTON)
|
47
|
-
|
48
|
-
|
49
47
|
---
|
50
48
|
## HOW EASY?
|
51
49
|
|
@@ -71,29 +69,101 @@ To run Turbo (which Hot Glue requires), you must either (1) be running an Import
|
|
71
69
|
|
72
70
|
For reference, see https://jasonfleetwoodboldt.com/courses/stepping-up-rails/rails-7-do-i-need-importmap-rails/
|
73
71
|
|
72
|
+
Once you create the new Rails app, you can skip to the 'Super-Quick Setup' below.
|
73
|
+
|
74
74
|
(1) To use ImportMap Rails, start with
|
75
75
|
`rails new`
|
76
76
|
|
77
|
-
|
77
|
+
(For full instructions to install Bootstrap with Importmap, check out [these instructions](https://jasonfleetwoodboldt.com/courses/stepping-up-rails/importmap-rails-with-bootstrap-sprockets-stimulus-and-turbo-long-tutorial/))
|
78
78
|
|
79
79
|
(2) To use JSBundling, start with
|
80
80
|
`rails new --javascript=jsbundling`
|
81
81
|
|
82
82
|
|
83
83
|
**If using JSBundling, make sure to use the new `./bin/dev` to start your server instead of the old `rails server` or else your Turbo interactions will not work correctly.**
|
84
|
-
If you want Bootstrap, install it following these instructions
|
84
|
+
(If you want Bootstrap for a JSBundling app, install it following [these instructions](https://jasonfleetwoodboldt.com/courses/stepping-up-rails/rails-7-up-running-with-jsbundling-esbuild-stimulus-turbo-bootstrap-circleci/))
|
85
|
+
|
86
|
+
(3) To use Shakapacker, start with `rails new --skip-javascript` and [see this post](https://jasonfleetwoodboldt.com/courses/react-heart-rails/rails-7-shakapacker-and-reactonrails-quick-setup-part-1/)
|
87
|
+
|
88
|
+
(For the old method of installing Bootstrap [see this post](https://jasonfleetwoodboldt.com/courses/stepping-up-rails/rails-7-bootstrap/))
|
85
89
|
|
86
|
-
(
|
87
|
-
`rails new --skip-javascript`
|
90
|
+
(Remember, for Rails 6 you must go through the [LEGACY SETUP FOR RAILS 6](https://github.com/jasonfb/hot-glue/blob/main/README2.md) before continuing.)
|
88
91
|
|
89
|
-
If you
|
92
|
+
If you doing the 'Super-Quick Setup', you can skip the additional blog posts linked above because the steps in them are covered in the shell script(s) below.
|
90
93
|
|
94
|
+
## The Super-Quick Setup
|
91
95
|
|
92
|
-
|
96
|
+
Be sure to do `git add .` and `git commit -m "initial commit"` after creating your new Rails 7 app.
|
93
97
|
|
94
|
-
|
98
|
+
```
|
99
|
+
bundle add rspec-rails factory_bot_rails ffaker --group "development, test" &&
|
100
|
+
git add . && git commit -m "adds gems" &&
|
101
|
+
rails generate rspec:install &&
|
102
|
+
git add . && git commit -m "adds rspec" &&
|
103
|
+
rm app/assets/stylesheets/application.css &&
|
104
|
+
echo "" > app/assets/stylesheets/application.scss &&
|
105
|
+
sed -i '' -e 's/# gem "sassc-rails"//g' Gemfile && sed -i '' -e 's/# Use Sass to process CSS//g' Gemfile &&
|
106
|
+
bundle install && bundle add sassc-rails && git add . && git commit -m "adds sassc-rails" &&
|
107
|
+
rm -rf test/ && git add . && git commit -m "removes minitest" &&
|
108
|
+
bundle add hot-glue && git add . && git commit -m "adds hot-glue" &&
|
109
|
+
rails generate hot_glue:install --layout=bootstrap &&
|
110
|
+
git add . && git commit -m "hot glue setup" &&
|
111
|
+
bundle add bootstrap &&
|
112
|
+
echo "\n@import 'bootstrap';\n" >> app/assets/stylesheets/application.scss
|
113
|
+
sed -i '' -e 's/# Rails.application.config.assets.precompile += %w( admin.js admin.css )/Rails.application.config.assets.precompile += %w( application.scss )/g' config/initializers/assets.rb &&
|
114
|
+
sed -i '' -e 's/Rails.application.configure do/Rails.application.configure do\n config.sass.inline_source_maps = true/g' config/environments/development.rb
|
115
|
+
git add . && git commit -m "bootstrap install" &&
|
116
|
+
bundle add font_awesome5_rails &&
|
117
|
+
echo "\n@import 'font_awesome5_webfont';\n" >> app/assets/stylesheets/application.scss
|
118
|
+
git add . && git commit -m "adds fontawesome" &&
|
119
|
+
bundle add kaminari &&
|
120
|
+
rails generate kaminari:views bootstrap4 &&
|
121
|
+
git add . && git commit -m "adding kaminari and views" &&
|
122
|
+
bundle add devise && bundle install &&
|
123
|
+
git add . && git commit -m "adding devise gem" &&
|
124
|
+
rails generate devise:install &&
|
125
|
+
rails g devise:views &&
|
126
|
+
sed -i '' -e 's/Rails.application.configure do/Rails.application.configure do\n config.action_mailer.default_url_options = { host: "localhost", port: 3000 }/g' config/environments/development.rb &&
|
127
|
+
sed -i '' -e 's/# root "articles#index"//g' config/routes.rb &&
|
128
|
+
sed -i '' -e 's/Rails.application.routes.draw do/Rails.application.routes.draw do\n root to: "welcome#index"/g' config/routes.rb &&
|
129
|
+
git add . && git commit -m 'devise view fixes' &&
|
130
|
+
rails generate controller Welcome &&
|
131
|
+
sed -i '' -e 's/class WelcomeController < ApplicationController/class WelcomeController < ApplicationController\n def index\n\n end/g' app/controllers/welcome_controller.rb &&
|
132
|
+
echo "hello world" > app/views/welcome/index.erb &&
|
133
|
+
git add . && git commit -m "generates Welcome controller" &&
|
134
|
+
sed -i '' -e 's/html: { method: :post }/html: { method: :post, 'data-turbo': false}/g' app/views/devise/confirmations/new.html.erb &&
|
135
|
+
sed -i '' -e 's/ url: session_path(resource_name))/ url: session_path(resource_name), html: {"data-turbo": false})/g' app/views/devise/sessions/new.html.erb &&
|
136
|
+
sed -i '' -e 's/ url: registration_path(resource_name))/ url: registration_path(resource_name), html: {"data-turbo": false})/g' app/views/devise/registrations/new.html.erb &&
|
137
|
+
sed -i '' -e 's/, html: { method: :post })/, html: { method: :post, "data-turbo": false })/g' app/views/devise/passwords/new.html.erb &&
|
138
|
+
git add . && git commit -m 'devise view fixes' &&
|
139
|
+
rails generate model User name:string &&
|
140
|
+
rails generate devise User && git add . && git commit -m "adds Users model with devise" &&
|
141
|
+
&& ./bin/setup && rails db:migrate &&
|
142
|
+
git add . && git commit -m "schema file"
|
143
|
+
```
|
144
|
+
|
145
|
+
|
146
|
+
For Importmap apps:
|
147
|
+
```
|
148
|
+
./bin/importmap pin "bootstrap@5.1.3" &&
|
149
|
+
./bin/importmap pin "@popperjs/core@2.11.2" &&
|
150
|
+
git add . && git commit -m "pinning boostrap and popper js for bootstrap"
|
151
|
+
```
|
152
|
+
|
153
|
+
For JSBundling & Shakapacker:
|
154
|
+
```
|
155
|
+
echo "\ncss: yarn build:css --watch\n" >> Procfile.dev &&
|
156
|
+
yarn add @popperjs/core bootstrap bootstrap-icons sass &&
|
157
|
+
sed -i '' -e 's/\/\/= link_directory ..\/stylesheets .css//g' app/assets/config/manifest.js &&
|
158
|
+
sed -i '' -e 's/ "scripts": {/ "scripts": {\n "build:css": "sass .\/app\/assets\/stylesheets\/application.scss:.\/app\/assets\/builds\/application.css --no-source-map --load-path=node_modules",/g' package.json &&
|
159
|
+
yarn install &&
|
160
|
+
git add . && git commit -m "adding bootstrap packages"
|
161
|
+
```
|
162
|
+
|
163
|
+
|
164
|
+
## Step-By-Step Setup
|
95
165
|
|
96
|
-
|
166
|
+
### 2. ADD RSPEC, FACTORY-BOT, AND FFAKER
|
97
167
|
|
98
168
|
add these 3 gems to your gemfile **inside a group for both :development and :test*.
|
99
169
|
Do not add these gems to *only* the :test group or else your Rspec installer and generators will not work correctly.
|
@@ -105,19 +175,19 @@ group :development, :test do
|
|
105
175
|
end
|
106
176
|
```
|
107
177
|
|
108
|
-
|
178
|
+
#### Rspec Installer
|
109
179
|
- run `rails generate rspec:install`
|
110
180
|
|
111
181
|
- Because you are not using Minitest, you can delete the `test/` folder at the root of your repository.
|
112
182
|
|
113
183
|
|
114
184
|
|
115
|
-
|
185
|
+
### 3. HOTGLUE INSTALLER
|
116
186
|
Add `gem 'hot-glue'` to your Gemfile & `bundle install`
|
117
187
|
|
118
188
|
During in installation, you MUST supply a `--layout` flag.
|
119
189
|
|
120
|
-
|
190
|
+
#### `--layout` flag (only two options: `hotglue` or `bootstrap`; default is `bootstrap`)
|
121
191
|
Here you will set up and install Hot Glue for the first time.
|
122
192
|
|
123
193
|
It will install a config file that will save two preferences: layout (`hotglue` or `bootstrap`)
|
@@ -125,7 +195,7 @@ It will install a config file that will save two preferences: layout (`hotglue`
|
|
125
195
|
The installer will create `config/hot_glue.yml`.
|
126
196
|
|
127
197
|
|
128
|
-
|
198
|
+
#### `--theme` flag
|
129
199
|
During the installation, **if** your `--layout` flag is set to `hotglue` you must also pass `--theme` flag.
|
130
200
|
|
131
201
|
the themes are:
|
@@ -136,21 +206,21 @@ the themes are:
|
|
136
206
|
• like_cupertino (modern Apple-UX inspired)
|
137
207
|
|
138
208
|
|
139
|
-
|
209
|
+
#### `--markup` flag (NOTE: haml and slim are no longer supported at this time)
|
140
210
|
|
141
211
|
default is `erb`. IMPORTANT: As of right now, HAML and SLIM are not currently supported so the only option is also the default `erb`.
|
142
212
|
|
143
213
|
|
144
|
-
|
214
|
+
#### example installing ERB using Bootstrap layout:
|
145
215
|
`rails generate hot_glue:install --markup=erb --layout=bootstrap`
|
146
216
|
|
147
|
-
|
217
|
+
#### Example installing using Hot Glue layout and the 'like_mountain_view' (Gmail-inspired) theme:
|
148
218
|
`rails generate hot_glue:install --markup=erb --layout=hotglue --theme=like_mountain_view`
|
149
219
|
|
150
220
|
The Hot Glue installer did several things for you in this step. Examine the git diffs or see 'Hot Glue Installer Notes' below.
|
151
221
|
|
152
222
|
|
153
|
-
|
223
|
+
### 4. Font-awesome (optional)
|
154
224
|
|
155
225
|
I recommend
|
156
226
|
https://github.com/tomkra/font_awesome5_rails
|
@@ -158,7 +228,7 @@ or
|
|
158
228
|
https://github.com/FortAwesome/font-awesome-sass
|
159
229
|
|
160
230
|
|
161
|
-
|
231
|
+
### 5. Devise
|
162
232
|
(If you are on Rails 6, you must do ALL of the steps in the Legacy Setup steps. Be sure not to skip **Legacy Step #5** below)
|
163
233
|
https://github.com/jasonfb/hot-glue/blob/main/README2.md
|
164
234
|
|
@@ -203,11 +273,11 @@ Add the data-turbo false option in the html key of the form, shown in bold here:
|
|
203
273
|
form_for(resource, as: resource_name, **html: {'data-turbo' => "false"},** url: session_path(resource_name) ) do |f|
|
204
274
|
|
205
275
|
|
206
|
-
|
276
|
+
#### Hot Glue Installer Notes
|
207
277
|
|
208
278
|
These things were **done for you** in Step #3 (above). You don't need to think about them but if you are familiar with Capybara and/or adding Hot Glue to an existing app, you may want to:
|
209
279
|
|
210
|
-
|
280
|
+
##### Hot Glue modified `application.html.erb`
|
211
281
|
Note: if you have some kind of non-standard application layout, like one at a different file
|
212
282
|
or if you have modified your opening <body> tag, this may not have been automatically applied by the installer.
|
213
283
|
|
@@ -216,7 +286,7 @@ or if you have modified your opening <body> tag, this may not have been automati
|
|
216
286
|
<%= render partial: 'layouts/flash_notices' %>
|
217
287
|
```
|
218
288
|
|
219
|
-
|
289
|
+
##### Hot Glue modified `rails_helper.rb`
|
220
290
|
Note: if you have some kind of non-standard rails_helper.rb, like one that does not use the standard ` do |config|` syntax after your `RSpec.configure`
|
221
291
|
this may not have been automatically applied by the installer.
|
222
292
|
|
@@ -229,7 +299,7 @@ this may not have been automatically applied by the installer.
|
|
229
299
|
```
|
230
300
|
|
231
301
|
|
232
|
-
|
302
|
+
##### Hot Glue switched Capybara from RACK-TEST to HEADLESS CHROME
|
233
303
|
|
234
304
|
- By default Capybara is installed with :rack_test as its driver.
|
235
305
|
- This does not support Javascript. Hot Glue is not targeted for fallback browsers.
|
@@ -269,7 +339,7 @@ Alternatively, you can define your own driver like so:
|
|
269
339
|
|
270
340
|
```
|
271
341
|
|
272
|
-
|
342
|
+
##### Hot Glue Added a Quick (Old-School) Capybara Login For Devise
|
273
343
|
|
274
344
|
- for a quick Capybara login, create a support helper in `spec/support/` and log-in as your user
|
275
345
|
- in the default code, the devise login would be for an object called account and lives at the route `/accounts/sign_in`
|
@@ -287,7 +357,7 @@ Alternatively, you can define your own driver like so:
|
|
287
357
|
|
288
358
|
---
|
289
359
|
---
|
290
|
-
|
360
|
+
---
|
291
361
|
|
292
362
|
# HOT GLUE DOCS
|
293
363
|
|
@@ -296,6 +366,9 @@ Alternatively, you can define your own driver like so:
|
|
296
366
|
|
297
367
|
TitleCase class name of the thing you want to build a scaffoling for.
|
298
368
|
|
369
|
+
rails generate hot_glue:scaffold Thing
|
370
|
+
|
371
|
+
(note: Your Thing object must belong_to an authenticated User or alternatively you must create a Gd controller, see below.)
|
299
372
|
|
300
373
|
## Options With Arguments
|
301
374
|
|
@@ -520,14 +593,12 @@ An better alternative is to define the non-standard plurlizations globally in yo
|
|
520
593
|
Make a file at `config/initializers/inflections.rb`
|
521
594
|
|
522
595
|
# Add new inflection rules using the following format
|
596
|
+
```
|
523
597
|
ActiveSupport::Inflector.inflections do |inflect|
|
524
598
|
inflect.irregular 'clothing', 'clothes'
|
525
599
|
inflect.irregular 'human', 'humans'
|
526
|
-
|
527
|
-
|
528
|
-
# the standard pluralization is pretty sexist and will pluralize `human` to `humen`
|
529
600
|
end
|
530
|
-
|
601
|
+
```
|
531
602
|
|
532
603
|
### `--form-labels-position` (default: `after`; options are **before**, **after**, and **omit**)
|
533
604
|
By default form labels appear after the form inputs. To make them appear before or omit them, use this flag.
|
@@ -546,8 +617,6 @@ If you specify any exclude list, those excluded **and** the default exclude list
|
|
546
617
|
|
547
618
|
`rails generate hot_glue:scaffold Account --exclude=password`
|
548
619
|
|
549
|
-
(The default excluded list is: If you want to edit any fields with the same name, you must use the include flag instead.)
|
550
|
-
|
551
620
|
|
552
621
|
### `--include=`
|
553
622
|
Separate field names by COMMA
|
@@ -784,8 +853,19 @@ Sometimes you might want to redisplay the entire list after you make an update (
|
|
784
853
|
|
785
854
|
To do this, use flag `--display-list-after-update`. The update will behave like delete and re-fetch all the records in the result and tell Turbo to swap out the entire list.
|
786
855
|
|
856
|
+
### `--with-turbo-streams`
|
857
|
+
|
858
|
+
If and only if you specify `--with-turbo-streams`, your views will contain `turbo_stream_from` directives. Whereas your views will always contain `turbo_frame_tags` (wether or not this flag is specified) and will use the Turbo stream replacement mechanism for non-idempotent actions (create & update). This flag just brings the magic of live-reload to the scaffold interfaces themselves.
|
787
859
|
|
860
|
+
**_To test_**: Open the same interface in two separate browser windows. Make an edit in one window and watch your edit appear in the other window instantly.
|
788
861
|
|
862
|
+
This happens using two interconnected mechanisms:
|
863
|
+
|
864
|
+
1) by default, all Hot Glue scaffold is wrapped in `turbo_frame_tag`s. The id of these tags is your namespace + the Rails dom_id(...). That means all Hot Glue scaffold is namespaced to the namespaces you use and won't collide with other turbo_frame_tag you might be using elsewhere
|
865
|
+
|
866
|
+
2) by appending **model callbacks**, we can automatically broadcast updates to the users who are using the Hot Glue scaffold. The model callbacks (after_update_commit and after_destroy_commit) get appended automatically to the top of your model file. Each model callback targets the scaffold being built (so just this scaffold), using its namespace, and renders the line partial (or destroys the content in the case of delete) from the scaffolding.
|
867
|
+
|
868
|
+
please note that *creating* and *deleting* do not yet have a full & complete implementation: Your pages won't re-render the pages being viewed cross-peer (that is, between two users using the app at the same time) if the insertion or deletion causes the pagination to be off for another user.
|
789
869
|
|
790
870
|
|
791
871
|
## Automatic Base Controller
|
@@ -825,6 +905,46 @@ Child portals have the headings omitted automatically (there is a heading identi
|
|
825
905
|
|
826
906
|
# VERSION HISTORY
|
827
907
|
|
908
|
+
#### 2022-12-27 - v0.5.5
|
909
|
+
|
910
|
+
- Experimental support for Tailwind. Note I was not able to get Tailwind actually working in my app, and I'm not sure about how to think about the many flavors of Tailwind (all of which seem to be paid?). If anyone can lend a hand, the objects are now cleanly refactored so that the CSS logic is separated.
|
911
|
+
|
912
|
+
- Support for UUIDs. Database UUIDs are treated as foreign keys and behave like integers ending with _id (they are treated as foreign keys whether or not they end with _id where as integers are treated as foreign keys only if they end with _id)
|
913
|
+
|
914
|
+
- At the namespace level, you can now have a file called `_nav.html.erb` like this example for a two-tab bootstrap nav (you'll need to create this file manually).
|
915
|
+
- Here, our two tabs are called "Domains" and "Widgets"
|
916
|
+
|
917
|
+
```
|
918
|
+
<ul class="nav nav-tabs">
|
919
|
+
<li class="nav-item">
|
920
|
+
<%= link_to "Domains", domains_path, class: "nav-link #{'active' if nav == 'domains'}" %>
|
921
|
+
</li>
|
922
|
+
<li class="nav-item">
|
923
|
+
<%= link_to "Widgets", widgets_path, class: "nav-link #{'active' if nav == 'widget'}" %>
|
924
|
+
</li>
|
925
|
+
</ul>
|
926
|
+
```
|
927
|
+
|
928
|
+
If the file is present, Hot Glue will automatically add this to the top of, for example, the "domains" index page:
|
929
|
+
|
930
|
+
```
|
931
|
+
<%= render partial: "owner/nav", locals: {nav: "domains"} %>
|
932
|
+
```
|
933
|
+
Use this to build a Bootstrap nav that correctly turns each tab active when navigated to.
|
934
|
+
|
935
|
+
#### 2022-11-27 - v0.5.4 - new flag --with-turbo-streams will append callbacks after_update_commit and after_destroy_commit to the MODEL you are building with to use turbo to target the scaffolding being built and programmatically update it
|
936
|
+
|
937
|
+
Adds `--with-turbo-streams`. Use `--with-turbo-streams` to create hot (live reload) interfaces. See docs above.
|
938
|
+
|
939
|
+
|
940
|
+
#### 2022-11-24 - v0.5.3 - New testing paradigm & removes license requirements
|
941
|
+
|
942
|
+
New testing paradigm
|
943
|
+
Code cleanup
|
944
|
+
Testing on CircleCI
|
945
|
+
License check has been removed (Hot Glue is now free to use for hobbyists and individuals. Business licenses are still available at https://heliosdev.shop/hot-glue-license)
|
946
|
+
|
947
|
+
|
828
948
|
#### 2022-03-23 - v0.5.2 - Hawked Foreign Keys
|
829
949
|
|
830
950
|
- You can now protect your foreign keys from malicious input and also restrict the scope of drop downs to show only records with the specified access control restriction.
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'rails/generators/erb/scaffold/scaffold_generator'
|
2
|
-
|
2
|
+
|
3
3
|
require 'ffaker'
|
4
4
|
|
5
5
|
module HotGlue
|
@@ -15,15 +15,15 @@ module HotGlue
|
|
15
15
|
|
16
16
|
def initialize(*args) #:nodoc:
|
17
17
|
super
|
18
|
-
|
18
|
+
layout = options['layout'] || "hotglue"
|
19
19
|
@theme = options['theme']
|
20
|
-
if
|
20
|
+
if layout == "hotglue" && options['theme'].nil?
|
21
21
|
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"
|
22
22
|
return
|
23
23
|
end
|
24
24
|
|
25
|
-
if
|
26
|
-
puts "IMPORTANT: You have selected to install Hot Glue with Bootstrap layout
|
25
|
+
if layout == 'boostrap'
|
26
|
+
puts "IMPORTANT: You have selected to install Hot Glue with Bootstrap layout.` "
|
27
27
|
end
|
28
28
|
|
29
29
|
|
@@ -56,7 +56,7 @@ module HotGlue
|
|
56
56
|
|
57
57
|
|
58
58
|
begin
|
59
|
-
rails_helper_contents = File.read("spec/rails_helper.rb")
|
59
|
+
rails_helper_contents = File.read("#{'spec/dummy/' if Rails.env.test?}spec/rails_helper.rb")
|
60
60
|
if !rails_helper_contents.include?("Capybara.default_driver =")
|
61
61
|
rails_helper_contents << "\nCapybara.default_driver = :selenium_chrome_headless "
|
62
62
|
puts " HOTGLUE --> added to spec/rails_helper.rb: `Capybara.default_driver = :selenium_chrome_headless` "
|
@@ -66,14 +66,14 @@ module HotGlue
|
|
66
66
|
rails_helper_contents.gsub!("RSpec.configure do |config|", "RSpec.configure do |config| \n
|
67
67
|
config.include FactoryBot::Syntax::Methods
|
68
68
|
")
|
69
|
-
puts " HOTGLUE --> added to spec/rails_helper.rb: `config.include FactoryBot::Syntax::Methods` "
|
69
|
+
puts " HOTGLUE --> added to #{'spec/dummy/' if Rails.env.test?}spec/rails_helper.rb: `config.include FactoryBot::Syntax::Methods` "
|
70
70
|
end
|
71
71
|
|
72
72
|
if ! rails_helper_contents.include?("require 'support/capybara_login.rb'")
|
73
73
|
rails_helper_contents.gsub!("require 'rspec/rails'","require 'rspec/rails' \nrequire 'support/capybara_login.rb'")
|
74
74
|
puts " HOTGLUE --> added to spec/rails_helper.rb: `require 'support/capybara_login.rb'` "
|
75
75
|
end
|
76
|
-
File.write("spec/rails_helper.rb", rails_helper_contents)
|
76
|
+
File.write("#{'spec/dummy/' if Rails.env.test?}spec/rails_helper.rb", rails_helper_contents)
|
77
77
|
|
78
78
|
rescue StandardError => e
|
79
79
|
puts "WARNING: error writing to spec/rails_helper --- #{e.message}"
|
@@ -96,7 +96,7 @@ module HotGlue
|
|
96
96
|
|
97
97
|
|
98
98
|
begin
|
99
|
-
if
|
99
|
+
if layout == "hotglue"
|
100
100
|
theme_location = "themes/hotglue_scaffold_#{@theme}.scss"
|
101
101
|
theme_file = "hotglue_scaffold_#{@theme}.scss"
|
102
102
|
|
@@ -119,8 +119,8 @@ module HotGlue
|
|
119
119
|
|
120
120
|
|
121
121
|
begin
|
122
|
-
if !File.exists?("config/hot_glue.yml")
|
123
|
-
yaml = {layout:
|
122
|
+
if !File.exists?("#{'spec/dummy/' if Rails.env.test?}config/hot_glue.yml")
|
123
|
+
yaml = {layout: layout,
|
124
124
|
markup: @markup}.to_yaml
|
125
125
|
File.write("#{'spec/dummy/' if Rails.env.test?}config/hot_glue.yml", yaml)
|
126
126
|
|
@@ -131,11 +131,11 @@ module HotGlue
|
|
131
131
|
|
132
132
|
|
133
133
|
begin
|
134
|
-
if !File.exists?("spec/support/capybara_login.rb")
|
134
|
+
if !File.exists?("#{'spec/dummy/' if Rails.env.test?}spec/support/capybara_login.rb")
|
135
135
|
copy_file "capybara_login.rb", "#{'spec/dummy/' if Rails.env.test?}spec/support/capybara_login.rb"
|
136
136
|
end
|
137
137
|
rescue StandardError => e
|
138
|
-
puts "WARNING: error writing to spec/support/capybara_login.rb --- #{e.message}"
|
138
|
+
puts "WARNING: error writing to #{Rails.env.test? ? 'spec/dummmy/' : ''}spec/support/capybara_login.rb --- #{e.message}"
|
139
139
|
end
|
140
140
|
end
|
141
141
|
end
|
@@ -8,15 +8,18 @@ module HotGlue
|
|
8
8
|
:buttons_width, :columns,
|
9
9
|
:smart_layout, :specified_grouping_mode
|
10
10
|
|
11
|
-
def initialize(
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
def initialize(include_setting: nil,
|
12
|
+
downnest_object: nil,
|
13
|
+
buttons_width: nil,
|
14
|
+
smart_layout: nil,
|
15
|
+
columns: nil)
|
16
|
+
@include_setting = include_setting
|
17
|
+
@downnest_object = downnest_object
|
18
|
+
@buttons_width = buttons_width
|
19
|
+
@columns = columns
|
20
|
+
@smart_layout = smart_layout
|
16
21
|
|
17
22
|
@no_buttons = @buttons_width == 0
|
18
|
-
@columns = params[:columns]
|
19
|
-
@smart_layout = params[:smart_layout]
|
20
23
|
@specified_grouping_mode = include_setting.include?(":")
|
21
24
|
end
|
22
25
|
|
@@ -132,4 +135,4 @@ module HotGlue
|
|
132
135
|
|
133
136
|
end
|
134
137
|
end
|
135
|
-
end
|
138
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module LayoutStrategy
|
2
|
+
class Base
|
3
|
+
attr_accessor :builder
|
4
|
+
def initialize(scaffold_builder)
|
5
|
+
@builder = scaffold_builder
|
6
|
+
end
|
7
|
+
|
8
|
+
def button_classes; ""; end
|
9
|
+
def button_column_style; "" ; end
|
10
|
+
def button_style ; ""; end
|
11
|
+
def column_headings_col_style; "" ; end
|
12
|
+
def column_width; ""; end
|
13
|
+
def column_classes_for_line_fields; ""; end
|
14
|
+
def column_classes_for_form_fields; ""; end
|
15
|
+
def column_classes_for_column_headings; ""; end
|
16
|
+
def col_width; 100; end
|
17
|
+
def container_name; ""; end
|
18
|
+
def downnest_style ; ""; end
|
19
|
+
def downnest_column_style ; "" ; end
|
20
|
+
def each_col
|
21
|
+
return col_width if builder.columns.count == 0
|
22
|
+
(col_width/(builder.columns.count)).to_i
|
23
|
+
end
|
24
|
+
def list_classes; ""; end
|
25
|
+
def row_classes; ""; end
|
26
|
+
def row_heading_classes; ""; end
|
27
|
+
def page_begin; '<div> '; end
|
28
|
+
def page_end ; '</div> '; end
|
29
|
+
def style_with_flex_basis(x); "" ; end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class LayoutStrategy::Bootstrap < LayoutStrategy::Base
|
2
|
+
def button_classes
|
3
|
+
" " + column_classes_for_line_fields
|
4
|
+
end
|
5
|
+
|
6
|
+
def column_classes_for_form_fields
|
7
|
+
"col-md-#{builder.layout_object[:columns][:size_each]}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def column_classes_for_column_headings
|
11
|
+
column_classes_for_line_fields
|
12
|
+
end
|
13
|
+
|
14
|
+
def container_name
|
15
|
+
"container-fluid"
|
16
|
+
end
|
17
|
+
|
18
|
+
def column_classes_for_line_fields
|
19
|
+
"col-sm-#{builder.layout_object[:columns][:size_each]}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def column_width
|
23
|
+
builder.layout_object[:columns][:size_each]
|
24
|
+
end
|
25
|
+
|
26
|
+
def downnest_portal_column_width(downnest)
|
27
|
+
"col-sm-#{ builder.layout_object[:portals][downnest][:size] }"
|
28
|
+
end
|
29
|
+
|
30
|
+
def page_begin
|
31
|
+
'<div class="row"> <div class="col-md-12">'
|
32
|
+
end
|
33
|
+
|
34
|
+
def row_classes
|
35
|
+
"row"
|
36
|
+
end
|
37
|
+
|
38
|
+
def page_end
|
39
|
+
'</div> </div>'
|
40
|
+
end
|
41
|
+
end
|