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