b4um_generators 0.1.0
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 +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +28 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.de.md +821 -0
- data/README.md +815 -0
- data/Rakefile +12 -0
- data/b4um_generators.gemspec +30 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/lib/b4um_generators/version.rb +5 -0
- data/lib/b4um_generators.rb +8 -0
- data/lib/generators/b4um/bento/bento_generator.rb +81 -0
- data/lib/generators/b4um/bento/templates/_alternating.html.erb.tt +15 -0
- data/lib/generators/b4um/bento/templates/_bento.html.erb.tt +26 -0
- data/lib/generators/b4um/bento/templates/_grid.html.erb.tt +13 -0
- data/lib/generators/b4um/bento/templates/_list.html.erb.tt +15 -0
- data/lib/generators/b4um/comments/comments_generator.rb +259 -0
- data/lib/generators/b4um/comments/templates/_comments.html.erb.tt +63 -0
- data/lib/generators/b4um/comments/templates/comment.rb.tt +5 -0
- data/lib/generators/b4um/comments/templates/comments_controller.rb.tt +45 -0
- data/lib/generators/b4um/comments/templates/create_comments.rb.tt +14 -0
- data/lib/generators/b4um/controller/controller_generator.rb +397 -0
- data/lib/generators/b4um/help/help_generator.rb +755 -0
- data/lib/generators/b4um/infinite_scroll/infinite_scroll_generator.rb +199 -0
- data/lib/generators/b4um/infinite_scroll/templates/infinite_scroll_controller.js +61 -0
- data/lib/generators/b4um/install/install_generator.rb +492 -0
- data/lib/generators/b4um/install/templates/_cookie_consent.html.erb +27 -0
- data/lib/generators/b4um/install/templates/_footer.html.erb +17 -0
- data/lib/generators/b4um/install/templates/_hero.html.erb +33 -0
- data/lib/generators/b4um/install/templates/_navigation.html.erb +31 -0
- data/lib/generators/b4um/install/templates/_sitemap.html.erb +48 -0
- data/lib/generators/b4um/install/templates/_theme_switcher.html.erb +57 -0
- data/lib/generators/b4um/install/templates/b4um/badges.css +43 -0
- data/lib/generators/b4um/install/templates/b4um/base.css +42 -0
- data/lib/generators/b4um/install/templates/b4um/callouts.css +58 -0
- data/lib/generators/b4um/install/templates/b4um/cards.css +401 -0
- data/lib/generators/b4um/install/templates/b4um/comments.css +52 -0
- data/lib/generators/b4um/install/templates/b4um/cookie-consent.css +83 -0
- data/lib/generators/b4um/install/templates/b4um/empty-state.css +26 -0
- data/lib/generators/b4um/install/templates/b4um/flash.css +86 -0
- data/lib/generators/b4um/install/templates/b4um/footer.css +338 -0
- data/lib/generators/b4um/install/templates/b4um/forms.css +924 -0
- data/lib/generators/b4um/install/templates/b4um/hero.css +149 -0
- data/lib/generators/b4um/install/templates/b4um/layout.css +166 -0
- data/lib/generators/b4um/install/templates/b4um/lightbox.css +268 -0
- data/lib/generators/b4um/install/templates/b4um/navigation.css +257 -0
- data/lib/generators/b4um/install/templates/b4um/pagination.css +85 -0
- data/lib/generators/b4um/install/templates/b4um/resources.css +121 -0
- data/lib/generators/b4um/install/templates/b4um/search.css +41 -0
- data/lib/generators/b4um/install/templates/b4um/tables.css +67 -0
- data/lib/generators/b4um/install/templates/b4um/theme-switcher.css +178 -0
- data/lib/generators/b4um/install/templates/b4um/theme.css +132 -0
- data/lib/generators/b4um/install/templates/b4um.css +20 -0
- data/lib/generators/b4um/install/templates/b4um.yml +12 -0
- data/lib/generators/b4um/install/templates/b4um_helper.rb +27 -0
- data/lib/generators/b4um/install/templates/cookie_consent_controller.js +76 -0
- data/lib/generators/b4um/install/templates/dismissible_controller.js +7 -0
- data/lib/generators/b4um/install/templates/image_lightbox_controller.js +414 -0
- data/lib/generators/b4um/install/templates/image_preview_controller.js +85 -0
- data/lib/generators/b4um/install/templates/navigation_controller.js +25 -0
- data/lib/generators/b4um/install/templates/navigation_helper.rb +26 -0
- data/lib/generators/b4um/install/templates/sitemap_controller.js +35 -0
- data/lib/generators/b4um/install/templates/theme_controller.js +122 -0
- data/lib/generators/b4um/pagination/pagination_generator.rb +179 -0
- data/lib/generators/b4um/pagination/templates/_pagination.html.erb.tt +48 -0
- data/lib/generators/b4um/pagination/templates/pagination.rb +36 -0
- data/lib/generators/b4um/scaffold/scaffold_generator.rb +333 -0
- data/lib/generators/b4um/scaffold/templates/_bento.html.erb.tt +26 -0
- data/lib/generators/b4um/scaffold/templates/_form.html.erb.tt +218 -0
- data/lib/generators/b4um/scaffold/templates/_resource.html.erb.tt +144 -0
- data/lib/generators/b4um/scaffold/templates/_table.html.erb.tt +40 -0
- data/lib/generators/b4um/scaffold/templates/edit.html.erb.tt +21 -0
- data/lib/generators/b4um/scaffold/templates/index.html.erb.tt +24 -0
- data/lib/generators/b4um/scaffold/templates/new.html.erb.tt +17 -0
- data/lib/generators/b4um/scaffold/templates/show.html.erb.tt +31 -0
- data/lib/generators/b4um/search/search_generator.rb +165 -0
- data/lib/generators/b4um/search/templates/search.rb +34 -0
- data/lib/generators/b4um/search/templates/search_form.html.erb.tt +15 -0
- data/lib/generators/b4um/table/table_generator.rb +63 -0
- data/lib/generators/b4um/table/templates/_table.html.erb.tt +40 -0
- data/lib/generators/b4um/trix/templates/b4um_rich_text_helper.rb +58 -0
- data/lib/generators/b4um/trix/templates/b4um_trix.js +551 -0
- data/lib/generators/b4um/trix/trix_generator.rb +383 -0
- data/sig/b4um_generators.rbs +4 -0
- metadata +148 -0
|
@@ -0,0 +1,755 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails/generators"
|
|
4
|
+
|
|
5
|
+
module B4um
|
|
6
|
+
module Generators
|
|
7
|
+
class HelpGenerator < Rails::Generators::Base
|
|
8
|
+
desc "Shows an overview of the available b4um generators and features"
|
|
9
|
+
|
|
10
|
+
def show_help
|
|
11
|
+
say <<~TEXT
|
|
12
|
+
|
|
13
|
+
b4um Generators
|
|
14
|
+
===============
|
|
15
|
+
|
|
16
|
+
INSTALLATION
|
|
17
|
+
|
|
18
|
+
bin/rails generate b4um:install
|
|
19
|
+
|
|
20
|
+
Installs the b4um base setup:
|
|
21
|
+
|
|
22
|
+
- b4um component stylesheets
|
|
23
|
+
- Navigation
|
|
24
|
+
- Navigation Stimulus controller
|
|
25
|
+
- Image preview Stimulus controller
|
|
26
|
+
- Image lightbox Stimulus controller
|
|
27
|
+
- Helper methods
|
|
28
|
+
- Layout integration
|
|
29
|
+
- Bento / card components
|
|
30
|
+
|
|
31
|
+
During installation, optional features can be selected:
|
|
32
|
+
|
|
33
|
+
- bcrypt for password support
|
|
34
|
+
- Active Storage for image attachments
|
|
35
|
+
- Hero section
|
|
36
|
+
- Footer
|
|
37
|
+
- Footer sitemap
|
|
38
|
+
- Cookie consent
|
|
39
|
+
|
|
40
|
+
The sitemap can only be installed when the footer is installed.
|
|
41
|
+
|
|
42
|
+
If an optional Gem is selected and is not already installed,
|
|
43
|
+
b4um adds it to the Gemfile and runs bundle install.
|
|
44
|
+
|
|
45
|
+
If Active Storage is selected and is not already installed,
|
|
46
|
+
b4um installs Active Storage and runs the database migration.
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
HERO
|
|
50
|
+
|
|
51
|
+
The installer can add an optional hero section.
|
|
52
|
+
|
|
53
|
+
Select the hero when running:
|
|
54
|
+
|
|
55
|
+
bin/rails generate b4um:install
|
|
56
|
+
|
|
57
|
+
The hero partial is created at:
|
|
58
|
+
|
|
59
|
+
app/views/shared/_hero.html.erb
|
|
60
|
+
|
|
61
|
+
The generated hero works without an image by default.
|
|
62
|
+
|
|
63
|
+
The template contains examples for:
|
|
64
|
+
|
|
65
|
+
- Hero title and text
|
|
66
|
+
- Optional action link
|
|
67
|
+
- Optional hero image
|
|
68
|
+
|
|
69
|
+
Hero CSS classes use the b4um-hero prefix.
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
BENTO / CARDS
|
|
73
|
+
|
|
74
|
+
b4um includes a responsive Bento-style card system.
|
|
75
|
+
|
|
76
|
+
Basic example:
|
|
77
|
+
|
|
78
|
+
<div class="b4um-grid">
|
|
79
|
+
<article class="b4um-card">
|
|
80
|
+
...
|
|
81
|
+
</article>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
Available card variants:
|
|
85
|
+
|
|
86
|
+
b4um-card
|
|
87
|
+
b4um-card--wide
|
|
88
|
+
b4um-card--large
|
|
89
|
+
b4um-card--full
|
|
90
|
+
b4um-card--soft
|
|
91
|
+
|
|
92
|
+
Card content classes include:
|
|
93
|
+
|
|
94
|
+
b4um-card__eyebrow
|
|
95
|
+
b4um-card__title
|
|
96
|
+
b4um-card__text
|
|
97
|
+
b4um-card__actions
|
|
98
|
+
b4um-card__media
|
|
99
|
+
b4um-card__image
|
|
100
|
+
|
|
101
|
+
The Bento grid is responsive and automatically adapts
|
|
102
|
+
to tablet and mobile layouts.
|
|
103
|
+
|
|
104
|
+
b4um scaffolds automatically use the Bento card system
|
|
105
|
+
for generated index pages.
|
|
106
|
+
|
|
107
|
+
Cards use a repeating layout pattern:
|
|
108
|
+
|
|
109
|
+
1 - wide
|
|
110
|
+
2 - soft
|
|
111
|
+
3 - normal
|
|
112
|
+
4 - large
|
|
113
|
+
5 - normal
|
|
114
|
+
|
|
115
|
+
Long text fields are shortened on index cards while the
|
|
116
|
+
complete content remains visible on the show page.
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
FOOTER
|
|
120
|
+
|
|
121
|
+
The installer can add an optional footer.
|
|
122
|
+
|
|
123
|
+
Select the footer when running:
|
|
124
|
+
|
|
125
|
+
bin/rails generate b4um:install
|
|
126
|
+
|
|
127
|
+
The footer partial is created at:
|
|
128
|
+
|
|
129
|
+
app/views/shared/_footer.html.erb
|
|
130
|
+
|
|
131
|
+
The generated footer includes:
|
|
132
|
+
|
|
133
|
+
- Automatic current year
|
|
134
|
+
- Application name placeholder
|
|
135
|
+
- Automatic legal page links generated by b4um:controller
|
|
136
|
+
- Optional sitemap partial
|
|
137
|
+
- Optional cookie settings control
|
|
138
|
+
|
|
139
|
+
Footer CSS classes use the b4um-footer prefix.
|
|
140
|
+
|
|
141
|
+
The sitemap is not hard-coded into the footer. When the
|
|
142
|
+
sitemap is selected during installation, b4um creates a
|
|
143
|
+
separate sitemap partial and renders it inside the footer.
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
SITEMAP
|
|
147
|
+
|
|
148
|
+
The installer can optionally add a sitemap to the footer.
|
|
149
|
+
|
|
150
|
+
The footer must be installed before the sitemap can be selected.
|
|
151
|
+
|
|
152
|
+
During installation, b4um asks:
|
|
153
|
+
|
|
154
|
+
Add a sitemap to the footer? (y/n)
|
|
155
|
+
|
|
156
|
+
When the sitemap is enabled, the number of sitemap columns
|
|
157
|
+
can be selected:
|
|
158
|
+
|
|
159
|
+
Number of sitemap columns [4]:
|
|
160
|
+
|
|
161
|
+
The sitemap supports between 2 and 5 columns.
|
|
162
|
+
|
|
163
|
+
Press Enter to use the default of 4 columns.
|
|
164
|
+
|
|
165
|
+
After selecting the number of columns, b4um asks for the
|
|
166
|
+
title of each selected column.
|
|
167
|
+
|
|
168
|
+
With the default four-column setup:
|
|
169
|
+
|
|
170
|
+
Sitemap column 1 title [Kontakt]:
|
|
171
|
+
Sitemap column 2 title [Inhalte]:
|
|
172
|
+
Sitemap column 3 title [Service]:
|
|
173
|
+
Sitemap column 4 title [Mehr]:
|
|
174
|
+
|
|
175
|
+
When five columns are selected, an additional title is
|
|
176
|
+
requested:
|
|
177
|
+
|
|
178
|
+
Sitemap column 5 title [Weitere]:
|
|
179
|
+
|
|
180
|
+
Press Enter to keep the default title shown in brackets.
|
|
181
|
+
|
|
182
|
+
Only the selected number of sitemap columns is written to
|
|
183
|
+
the configuration.
|
|
184
|
+
|
|
185
|
+
The sitemap partial is created at:
|
|
186
|
+
|
|
187
|
+
app/views/shared/_sitemap.html.erb
|
|
188
|
+
|
|
189
|
+
The sitemap Stimulus controller is created at:
|
|
190
|
+
|
|
191
|
+
app/javascript/controllers/sitemap_controller.js
|
|
192
|
+
|
|
193
|
+
The sitemap partial is rendered inside:
|
|
194
|
+
|
|
195
|
+
app/views/shared/_footer.html.erb
|
|
196
|
+
|
|
197
|
+
The sitemap configuration is stored in:
|
|
198
|
+
|
|
199
|
+
config/b4um.yml
|
|
200
|
+
|
|
201
|
+
Example using the default four columns:
|
|
202
|
+
|
|
203
|
+
sitemap:
|
|
204
|
+
- key: column_1
|
|
205
|
+
title: Kontakt
|
|
206
|
+
- key: column_2
|
|
207
|
+
title: Inhalte
|
|
208
|
+
- key: column_3
|
|
209
|
+
title: Service
|
|
210
|
+
- key: column_4
|
|
211
|
+
title: Mehr
|
|
212
|
+
|
|
213
|
+
legal_links:
|
|
214
|
+
placement: footer
|
|
215
|
+
|
|
216
|
+
A two-column sitemap contains only column_1 and column_2.
|
|
217
|
+
|
|
218
|
+
A five-column sitemap additionally contains:
|
|
219
|
+
|
|
220
|
+
column_5
|
|
221
|
+
|
|
222
|
+
The sitemap column titles can also be changed later by
|
|
223
|
+
editing config/b4um.yml.
|
|
224
|
+
|
|
225
|
+
Available column keys range from:
|
|
226
|
+
|
|
227
|
+
column_1
|
|
228
|
+
|
|
229
|
+
through:
|
|
230
|
+
|
|
231
|
+
column_5
|
|
232
|
+
|
|
233
|
+
Only keys for columns that exist in the current sitemap
|
|
234
|
+
configuration should be used.
|
|
235
|
+
|
|
236
|
+
The keys identify the sitemap columns independently of their
|
|
237
|
+
visible titles.
|
|
238
|
+
|
|
239
|
+
On larger screens, the available sitemap columns are
|
|
240
|
+
distributed automatically across the footer.
|
|
241
|
+
|
|
242
|
+
On smaller screens, the sitemap uses its responsive
|
|
243
|
+
collapsible layout.
|
|
244
|
+
|
|
245
|
+
Controller actions can be added directly to a sitemap column
|
|
246
|
+
with --sitemap:
|
|
247
|
+
|
|
248
|
+
bin/rails generate b4um:controller Pages faq support --sitemap=column_3
|
|
249
|
+
|
|
250
|
+
When --sitemap is used, the generated actions are added to the
|
|
251
|
+
selected sitemap column instead of the main navigation.
|
|
252
|
+
|
|
253
|
+
Generated sitemap links use Rails route helpers.
|
|
254
|
+
|
|
255
|
+
Example:
|
|
256
|
+
|
|
257
|
+
links:
|
|
258
|
+
- title: FAQ
|
|
259
|
+
route: faq_path
|
|
260
|
+
|
|
261
|
+
Only valid Rails path helpers ending in _path are resolved
|
|
262
|
+
by the b4um sitemap helper.
|
|
263
|
+
|
|
264
|
+
Legal pages can remain in the separate legal footer area:
|
|
265
|
+
|
|
266
|
+
legal_links:
|
|
267
|
+
placement: footer
|
|
268
|
+
|
|
269
|
+
This is the default configuration.
|
|
270
|
+
|
|
271
|
+
Legal pages can alternatively be placed in any existing
|
|
272
|
+
sitemap column:
|
|
273
|
+
|
|
274
|
+
legal_links:
|
|
275
|
+
placement: column_4
|
|
276
|
+
|
|
277
|
+
When legal pages are assigned to a sitemap column, b4um adds
|
|
278
|
+
them to that column automatically and does not duplicate them
|
|
279
|
+
in the separate legal footer area.
|
|
280
|
+
|
|
281
|
+
The placement uses the sitemap column key, not its visible
|
|
282
|
+
title. This allows sitemap column titles to be changed freely.
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
COOKIE CONSENT
|
|
286
|
+
|
|
287
|
+
The installer can optionally add cookie consent.
|
|
288
|
+
|
|
289
|
+
During installation, b4um asks:
|
|
290
|
+
|
|
291
|
+
Add cookie consent? (y/n)
|
|
292
|
+
|
|
293
|
+
Cookie consent can be installed independently of the footer.
|
|
294
|
+
|
|
295
|
+
The cookie consent partial is created at:
|
|
296
|
+
|
|
297
|
+
app/views/shared/_cookie_consent.html.erb
|
|
298
|
+
|
|
299
|
+
The cookie consent Stimulus controller is created at:
|
|
300
|
+
|
|
301
|
+
app/javascript/controllers/cookie_consent_controller.js
|
|
302
|
+
|
|
303
|
+
The visitor's consent choice is stored in the browser's
|
|
304
|
+
local storage.
|
|
305
|
+
|
|
306
|
+
If both the footer and cookie consent are installed, b4um
|
|
307
|
+
automatically adds a Cookie-Einstellungen control to the
|
|
308
|
+
footer.
|
|
309
|
+
|
|
310
|
+
This control allows visitors to reopen the cookie consent
|
|
311
|
+
banner and change their choice later.
|
|
312
|
+
|
|
313
|
+
Cookie consent can also be installed without a footer. In
|
|
314
|
+
that case, the cookie consent banner still works, but no
|
|
315
|
+
cookie settings control is added to the footer.
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
SCAFFOLD
|
|
319
|
+
|
|
320
|
+
bin/rails generate b4um:scaffold MODEL ATTRIBUTES
|
|
321
|
+
|
|
322
|
+
Example:
|
|
323
|
+
|
|
324
|
+
bin/rails generate b4um:scaffold User name:string email:string
|
|
325
|
+
|
|
326
|
+
b4um scaffold features:
|
|
327
|
+
|
|
328
|
+
- b4um forms
|
|
329
|
+
- b4um index, show, new and edit views
|
|
330
|
+
- Bento index layout by default
|
|
331
|
+
- Optional table index layout
|
|
332
|
+
- Automatic navigation entry
|
|
333
|
+
- Active navigation state
|
|
334
|
+
- Form validation errors
|
|
335
|
+
- Flash messages
|
|
336
|
+
- Password field support
|
|
337
|
+
- Optional readable URL parameters
|
|
338
|
+
|
|
339
|
+
The default index uses the b4um Bento card layout.
|
|
340
|
+
|
|
341
|
+
To generate a table index instead, use:
|
|
342
|
+
|
|
343
|
+
--layout=table
|
|
344
|
+
|
|
345
|
+
Example:
|
|
346
|
+
|
|
347
|
+
bin/rails generate b4um:scaffold Product name:string description:text price:decimal status:string --layout=table
|
|
348
|
+
|
|
349
|
+
Table layouts automatically:
|
|
350
|
+
|
|
351
|
+
- Use the responsive b4um table component
|
|
352
|
+
- Shorten text fields to 100 characters
|
|
353
|
+
- Display a status field as a b4um badge
|
|
354
|
+
- Include an actions column
|
|
355
|
+
- Include the b4um empty state
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
READABLE URL PARAMETERS
|
|
359
|
+
|
|
360
|
+
b4um scaffolds can generate readable URLs while keeping
|
|
361
|
+
the database ID in the URL.
|
|
362
|
+
|
|
363
|
+
Use:
|
|
364
|
+
|
|
365
|
+
--param=ATTRIBUTE
|
|
366
|
+
|
|
367
|
+
Example:
|
|
368
|
+
|
|
369
|
+
bin/rails generate b4um:scaffold Article title:string body:text --param=title
|
|
370
|
+
|
|
371
|
+
This generates:
|
|
372
|
+
|
|
373
|
+
def to_param
|
|
374
|
+
"\#{id} \#{title}".parameterize
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
Example URL:
|
|
378
|
+
|
|
379
|
+
/articles/17-my-first-article
|
|
380
|
+
|
|
381
|
+
The ID remains part of the URL, so the standard Rails
|
|
382
|
+
resource lookup can still be used.
|
|
383
|
+
|
|
384
|
+
The readable part of the URL is updated automatically
|
|
385
|
+
when the selected attribute changes.
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
PASSWORDS
|
|
389
|
+
|
|
390
|
+
For password authentication, use:
|
|
391
|
+
|
|
392
|
+
password_digest:string
|
|
393
|
+
|
|
394
|
+
Example:
|
|
395
|
+
|
|
396
|
+
bin/rails generate b4um:scaffold User name:string email:string password_digest:string
|
|
397
|
+
|
|
398
|
+
The b4um scaffold automatically creates password fields
|
|
399
|
+
instead of displaying password_digest directly.
|
|
400
|
+
|
|
401
|
+
Password support requires bcrypt.
|
|
402
|
+
|
|
403
|
+
Select bcrypt when running:
|
|
404
|
+
|
|
405
|
+
bin/rails generate b4um:install
|
|
406
|
+
|
|
407
|
+
b4um adds bcrypt to the Gemfile if necessary and installs
|
|
408
|
+
the selected Gem automatically.
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
ACTIVE STORAGE / IMAGES
|
|
412
|
+
|
|
413
|
+
Image attachments require Active Storage.
|
|
414
|
+
|
|
415
|
+
Select Active Storage when running:
|
|
416
|
+
|
|
417
|
+
bin/rails generate b4um:install
|
|
418
|
+
|
|
419
|
+
b4um installs Active Storage and runs the required database
|
|
420
|
+
migration automatically if Active Storage is not already installed.
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
Single image:
|
|
424
|
+
|
|
425
|
+
image:attachment
|
|
426
|
+
|
|
427
|
+
Example:
|
|
428
|
+
|
|
429
|
+
bin/rails generate b4um:scaffold Article title:string image:attachment
|
|
430
|
+
|
|
431
|
+
Multiple images:
|
|
432
|
+
|
|
433
|
+
images:attachments
|
|
434
|
+
|
|
435
|
+
Example:
|
|
436
|
+
|
|
437
|
+
bin/rails generate b4um:scaffold Gallery title:string images:attachments
|
|
438
|
+
|
|
439
|
+
Image features:
|
|
440
|
+
|
|
441
|
+
- Active Storage integration
|
|
442
|
+
- Image preview before saving
|
|
443
|
+
- Existing image preview while editing
|
|
444
|
+
- Add new images without removing existing images
|
|
445
|
+
- Remove individual existing images
|
|
446
|
+
- Image lightbox
|
|
447
|
+
- Previous / next navigation
|
|
448
|
+
- Mouse and touch swipe
|
|
449
|
+
- Keyboard navigation
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
BENTO
|
|
453
|
+
|
|
454
|
+
bin/rails generate b4um:bento MODEL
|
|
455
|
+
|
|
456
|
+
Generates a reusable b4um Bento partial for an existing model.
|
|
457
|
+
|
|
458
|
+
Example:
|
|
459
|
+
|
|
460
|
+
bin/rails generate b4um:bento Product
|
|
461
|
+
|
|
462
|
+
The default layout is Grid.
|
|
463
|
+
|
|
464
|
+
Available layouts:
|
|
465
|
+
|
|
466
|
+
bin/rails generate b4um:bento Product
|
|
467
|
+
bin/rails generate b4um:bento Product --layout=grid
|
|
468
|
+
bin/rails generate b4um:bento Product --layout=list
|
|
469
|
+
bin/rails generate b4um:bento Product --layout=alternating
|
|
470
|
+
bin/rails generate b4um:bento Product --layout=bento
|
|
471
|
+
|
|
472
|
+
Layouts:
|
|
473
|
+
|
|
474
|
+
grid
|
|
475
|
+
The default three-column card grid.
|
|
476
|
+
Adapts to two columns on tablets and one column on mobile.
|
|
477
|
+
|
|
478
|
+
list
|
|
479
|
+
A compact horizontal list layout.
|
|
480
|
+
Actions move below the content on mobile.
|
|
481
|
+
|
|
482
|
+
alternating
|
|
483
|
+
A spacious alternating layout with the action area
|
|
484
|
+
switching between the left and right side.
|
|
485
|
+
Uses a single-column layout on mobile.
|
|
486
|
+
|
|
487
|
+
bento
|
|
488
|
+
The classic Bento layout with mixed card sizes.
|
|
489
|
+
|
|
490
|
+
Use --layout=bento to explicitly generate the classic
|
|
491
|
+
Bento design.
|
|
492
|
+
|
|
493
|
+
The model and its resource partial must already exist.
|
|
494
|
+
|
|
495
|
+
Example resource partial:
|
|
496
|
+
|
|
497
|
+
app/views/products/_product.html.erb
|
|
498
|
+
|
|
499
|
+
b4um scaffold resource partials support compact mode.
|
|
500
|
+
In Bento cards, text fields are shortened to 160 characters.
|
|
501
|
+
|
|
502
|
+
The generated partial is created at:
|
|
503
|
+
|
|
504
|
+
app/views/products/_bento.html.erb
|
|
505
|
+
|
|
506
|
+
Bento features:
|
|
507
|
+
|
|
508
|
+
- Responsive b4um Bento grid
|
|
509
|
+
- Repeating card layout with different card sizes
|
|
510
|
+
- Uses the existing resource partial for card content
|
|
511
|
+
- Actions area with a Show button
|
|
512
|
+
- No migrations, routes or controllers are generated
|
|
513
|
+
|
|
514
|
+
Render the partial from an index view with:
|
|
515
|
+
|
|
516
|
+
<%= render "bento", products: @products %>
|
|
517
|
+
|
|
518
|
+
The partial uses a local collection, so it can also be
|
|
519
|
+
reused with another collection:
|
|
520
|
+
|
|
521
|
+
<%= render "products/bento", products: @featured_products %>
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
TABLE
|
|
525
|
+
|
|
526
|
+
bin/rails generate b4um:table MODEL FIELDS
|
|
527
|
+
|
|
528
|
+
Generates a reusable b4um table partial for an existing model.
|
|
529
|
+
|
|
530
|
+
Example:
|
|
531
|
+
|
|
532
|
+
bin/rails generate b4um:table Product name:string description:text price:decimal status:string
|
|
533
|
+
|
|
534
|
+
The model must already exist.
|
|
535
|
+
|
|
536
|
+
The generated partial is created at:
|
|
537
|
+
|
|
538
|
+
app/views/products/_table.html.erb
|
|
539
|
+
|
|
540
|
+
Table features:
|
|
541
|
+
|
|
542
|
+
- Responsive b4um table component
|
|
543
|
+
- Typed field definitions
|
|
544
|
+
- Text fields shortened to 100 characters
|
|
545
|
+
- Status field displayed as a b4um badge
|
|
546
|
+
- Actions column with a Show button
|
|
547
|
+
- No migrations, routes or controllers are generated
|
|
548
|
+
|
|
549
|
+
Render the partial from an index view with:
|
|
550
|
+
|
|
551
|
+
<%= render "table", products: @products %>
|
|
552
|
+
|
|
553
|
+
The partial uses a local collection, so it can also be
|
|
554
|
+
reused with another collection:
|
|
555
|
+
|
|
556
|
+
<%= render "products/table", products: @featured_products %>
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
CONTROLLER
|
|
560
|
+
|
|
561
|
+
bin/rails generate b4um:controller NAME ACTIONS
|
|
562
|
+
|
|
563
|
+
Example:
|
|
564
|
+
|
|
565
|
+
bin/rails generate b4um:controller Pages home about impressum agb
|
|
566
|
+
|
|
567
|
+
b4um controller features:
|
|
568
|
+
|
|
569
|
+
- Uses the standard Rails controller generator
|
|
570
|
+
- Creates the requested actions and views
|
|
571
|
+
- Adds regular action links to the b4um navigation automatically
|
|
572
|
+
- Adds legal pages to the b4um footer automatically
|
|
573
|
+
- German legal pages: impressum, datenschutz, agb
|
|
574
|
+
- English legal pages: imprint, privacy, privacy_policy,
|
|
575
|
+
terms, terms_and_conditions
|
|
576
|
+
- Legal pages are not added to the main navigation
|
|
577
|
+
- Footer links require the b4um footer to be installed
|
|
578
|
+
|
|
579
|
+
Controller actions can also be assigned directly to a sitemap
|
|
580
|
+
column with --sitemap.
|
|
581
|
+
|
|
582
|
+
Example:
|
|
583
|
+
|
|
584
|
+
bin/rails generate b4um:controller Pages faq support --sitemap=column_3
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
PAGINATION
|
|
588
|
+
|
|
589
|
+
bin/rails generate b4um:pagination MODEL
|
|
590
|
+
|
|
591
|
+
Adds server-side b4um pagination to an existing resource.
|
|
592
|
+
|
|
593
|
+
Example:
|
|
594
|
+
|
|
595
|
+
bin/rails generate b4um:pagination Product
|
|
596
|
+
|
|
597
|
+
By default, 20 records are displayed per page.
|
|
598
|
+
|
|
599
|
+
Use a custom page size with:
|
|
600
|
+
|
|
601
|
+
bin/rails generate b4um:pagination Product --per-page=50
|
|
602
|
+
|
|
603
|
+
The model, controller and index view must already exist.
|
|
604
|
+
|
|
605
|
+
Pagination features:
|
|
606
|
+
|
|
607
|
+
- Server-side pagination using Active Record limit and offset
|
|
608
|
+
- No additional pagination gem required
|
|
609
|
+
- Previous and Next navigation
|
|
610
|
+
- Numbered page navigation
|
|
611
|
+
- Preserves existing query parameters
|
|
612
|
+
- Works with b4um Bento and Table layouts
|
|
613
|
+
- Invalid or excessive page numbers are handled safely
|
|
614
|
+
- Shared pagination core can be reused by other b4um features
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
INFINITE SCROLL
|
|
618
|
+
|
|
619
|
+
bin/rails generate b4um:infinite_scroll MODEL
|
|
620
|
+
|
|
621
|
+
Adds automatic infinite scrolling to an existing resource.
|
|
622
|
+
|
|
623
|
+
Example:
|
|
624
|
+
|
|
625
|
+
bin/rails generate b4um:infinite_scroll Product
|
|
626
|
+
|
|
627
|
+
By default, 20 records are loaded per page.
|
|
628
|
+
|
|
629
|
+
Use a custom page size with:
|
|
630
|
+
|
|
631
|
+
bin/rails generate b4um:infinite_scroll Product --per-page=50
|
|
632
|
+
|
|
633
|
+
The model, controller and index view must already exist.
|
|
634
|
+
|
|
635
|
+
Infinite Scroll features:
|
|
636
|
+
|
|
637
|
+
- Loads additional records automatically while scrolling
|
|
638
|
+
- Server-side pagination using Active Record limit and offset
|
|
639
|
+
- No additional pagination gem required
|
|
640
|
+
- Works with b4um Bento and Table layouts
|
|
641
|
+
- Preserves existing query parameters
|
|
642
|
+
- Stops automatically after the final page
|
|
643
|
+
- Replaces existing b4um pagination navigation
|
|
644
|
+
- Safe repeated generator runs
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
SEARCH
|
|
648
|
+
|
|
649
|
+
bin/rails generate b4um:search MODEL
|
|
650
|
+
|
|
651
|
+
Adds database-backed search to an existing resource.
|
|
652
|
+
|
|
653
|
+
Example:
|
|
654
|
+
|
|
655
|
+
bin/rails generate b4um:search Product
|
|
656
|
+
|
|
657
|
+
The model, controller and index view must already exist.
|
|
658
|
+
|
|
659
|
+
Search features:
|
|
660
|
+
|
|
661
|
+
- Searches all string and text columns
|
|
662
|
+
- Case-insensitive partial matching
|
|
663
|
+
- Safely escapes search terms
|
|
664
|
+
- Blank searches return the complete collection
|
|
665
|
+
- Works with b4um Bento and Table layouts
|
|
666
|
+
- Works with b4um Pagination and Infinite Scroll
|
|
667
|
+
- Preserves the search query while navigating pages
|
|
668
|
+
- No additional search gem required
|
|
669
|
+
- Safe repeated generator runs
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
COMMENTS
|
|
673
|
+
|
|
674
|
+
bin/rails generate b4um:comments MODEL
|
|
675
|
+
|
|
676
|
+
Example:
|
|
677
|
+
|
|
678
|
+
bin/rails generate b4um:comments Article
|
|
679
|
+
|
|
680
|
+
Adds polymorphic comments to an existing model.
|
|
681
|
+
|
|
682
|
+
b4um comments features:
|
|
683
|
+
|
|
684
|
+
- Polymorphic Comment model
|
|
685
|
+
- Comment association on the selected model
|
|
686
|
+
- Nested create and destroy routes
|
|
687
|
+
- Comments controller
|
|
688
|
+
- Comment list and form
|
|
689
|
+
- Delete confirmation
|
|
690
|
+
- b4um form and card styling
|
|
691
|
+
- Support for multiple commentable models
|
|
692
|
+
- Safe repeated generator runs
|
|
693
|
+
|
|
694
|
+
Additional models can use the same comments system:
|
|
695
|
+
|
|
696
|
+
bin/rails generate b4um:comments Product
|
|
697
|
+
|
|
698
|
+
Existing b4um comments controllers are extended automatically.
|
|
699
|
+
Unknown custom comments controllers are left unchanged and cause
|
|
700
|
+
the generator to stop with an error.
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
TRIX / RICH TEXT
|
|
704
|
+
|
|
705
|
+
bin/rails generate b4um:trix MODEL ATTRIBUTE
|
|
706
|
+
|
|
707
|
+
Adds Action Text with Trix to an existing b4um resource.
|
|
708
|
+
|
|
709
|
+
Example:
|
|
710
|
+
|
|
711
|
+
bin/rails generate b4um:trix Article content
|
|
712
|
+
|
|
713
|
+
The model and form must already exist.
|
|
714
|
+
|
|
715
|
+
The generator adds:
|
|
716
|
+
|
|
717
|
+
has_rich_text :content
|
|
718
|
+
|
|
719
|
+
and replaces the selected form field with a rich text editor:
|
|
720
|
+
|
|
721
|
+
form.rich_text_area :content
|
|
722
|
+
|
|
723
|
+
Trix / Rich Text features:
|
|
724
|
+
|
|
725
|
+
- Installs Action Text automatically when necessary
|
|
726
|
+
- Adds the rich text association to the model
|
|
727
|
+
- Replaces only the selected form field
|
|
728
|
+
- Preserves compact Bento text using plain text
|
|
729
|
+
- Image lightbox for images inside rich text
|
|
730
|
+
- Previous / next image navigation
|
|
731
|
+
- Mouse and touch swipe
|
|
732
|
+
- Keyboard navigation
|
|
733
|
+
- Responsive image galleries
|
|
734
|
+
- Sticky Trix toolbar
|
|
735
|
+
- Headings H1 through H6
|
|
736
|
+
- Left, center, and right text alignment
|
|
737
|
+
- Text and background colors
|
|
738
|
+
- Horizontal rules
|
|
739
|
+
- Editable DIV, SECTION, and ARTICLE containers with IDs
|
|
740
|
+
- Container formatting remains fully editable
|
|
741
|
+
- Active container buttons can remove the wrapper again
|
|
742
|
+
- Safe repeated generator runs
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
HELP
|
|
746
|
+
|
|
747
|
+
bin/rails generate b4um:help
|
|
748
|
+
|
|
749
|
+
Shows this overview.
|
|
750
|
+
|
|
751
|
+
TEXT
|
|
752
|
+
end
|
|
753
|
+
end
|
|
754
|
+
end
|
|
755
|
+
end
|