b4um_generators 0.1.1 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b55f9667cdd536bfa19d947e9139130300d4dfd5a95d3e4a8c52b37042022fa9
4
- data.tar.gz: 0ba19080c73de429e1b4f0b2e025d03aad4f0eec88963c26e5817e718677d1d6
3
+ metadata.gz: ab89fe09deda48a796523b69839e38cacce98d2d91e417b0de179c3263b45be2
4
+ data.tar.gz: b7c7173b4d447cd2a068fd84c06f268b4cdfd0eabfdd76115a6fdb4342b03a48
5
5
  SHA512:
6
- metadata.gz: 1ba384cba95037febae27de129297021507ec8eecc7806ae767b3761e395641c918576d42c58190a73cf3838f3a7c6569ed27f5d20074d4ded083f7270d07192
7
- data.tar.gz: 94e5ce838a05e85e4c18cd7f582b9981d1c80dc8aa30bad5e68f55298588a4544a3dcf9a45adbcfe8ff622d86e57e1a240ebc30dd6d8b1817b3512bd05f6b7b3
6
+ metadata.gz: 38240797ad404a9ed5092ce1222b4e02a07bed73a217d16d72d2b3dbf22beafc29e3667031bd06a732b3ab5fa22d81ee1cf5ee670ce1d380868ec5364d93aea1
7
+ data.tar.gz: 982dc00957e65b8f38233184369a8cfbce9ad00236fef09f750f029f22e4b64926e1ad194e4d785ab5a492c8ff197930eb62cccce766c882714d9275640b3971
data/.rubocop.yml CHANGED
@@ -15,14 +15,14 @@ Style/StringLiteralsInInterpolation:
15
15
  EnforcedStyle: double_quotes
16
16
 
17
17
  Metrics/MethodLength:
18
- Max: 550
18
+ Max: 650
19
19
 
20
20
  Metrics/BlockLength:
21
21
  Exclude:
22
22
  - 'spec/**/*'
23
23
 
24
24
  Metrics/ClassLength:
25
- Max: 550
25
+ Max: 650
26
26
 
27
27
  Metrics/AbcSize:
28
28
  Max: 100
data/README.de.md CHANGED
@@ -6,7 +6,8 @@ b4um Generators ist eine Sammlung wiederverwendbarer Rails-Generatoren, Template
6
6
  für b4um-Rails-Projekte.
7
7
 
8
8
  Das Gem bietet eine einheitliche Grundlage für Rails-Anwendungen und enthält Generatoren für Scaffolds, Controller,
9
- Bento-Layouts, Tabellen, Pagination, Infinite Scroll, Suche, Kommentare und Rich-Text-Bearbeitung.
9
+ Bento-Layouts, Tabellen, Pagination, Infinite Scroll, Suche, Kommentare, Authentifizierung, Attachments und
10
+ Rich-Text-Bearbeitung.
10
11
 
11
12
  Die generierten Komponenten verwenden ein gemeinsames b4um-Styling und sind darauf ausgelegt, miteinander zu
12
13
  funktionieren.
@@ -23,7 +24,7 @@ b4um Generators wird während der Entwicklung derzeit als lokales Gem verwendet.
23
24
  Füge das Gem zur `Gemfile` der Rails-Anwendung hinzu:
24
25
 
25
26
  ```ruby
26
- gem "b4um_generators", "~> 0.1.0", path: "/pfad/zu/b4um_generators"
27
+ gem "b4um_generators", "~> 0.2.0", path: "/pfad/zu/b4um_generators"
27
28
  ```
28
29
 
29
30
  Führe anschließend aus:
@@ -73,6 +74,7 @@ Das Gem stellt derzeit folgende Generatoren bereit:
73
74
  ```text
74
75
  b4um:install
75
76
  b4um:scaffold
77
+ b4um:attachment
76
78
  b4um:bento
77
79
  b4um:table
78
80
  b4um:controller
@@ -80,7 +82,9 @@ b4um:pagination
80
82
  b4um:infinite_scroll
81
83
  b4um:search
82
84
  b4um:comments
85
+ b4um:authentication
83
86
  b4um:trix
87
+ b4um:readable
84
88
  b4um:help
85
89
  ```
86
90
 
@@ -164,6 +168,12 @@ Die ID bleibt Bestandteil der URL, sodass die normale Rails-Ressourcensuche weit
164
168
  Der lesbare Teil wird aus dem ausgewählten Attribut erzeugt und ändert sich automatisch, wenn sich dieses Attribut
165
169
  ändert.
166
170
 
171
+ Lesbare URLs können auch später zu einem bestehenden Modell hinzugefügt werden:
172
+
173
+ ```bash
174
+ bin/rails generate b4um:readable Product name
175
+ ```
176
+
167
177
  ## Bento und Karten
168
178
 
169
179
  b4um enthält ein responsives Kartensystem, das auch unabhängig von den Generatoren verwendet werden kann.
@@ -356,6 +366,112 @@ bin/rails generate b4um:install
356
366
 
357
367
  Falls erforderlich, fügt b4um bcrypt zur `Gemfile` der Anwendung hinzu und installiert es.
358
368
 
369
+ ## Authentifizierung
370
+
371
+ Füge einem bestehenden Modell eine sitzungsbasierte Authentifizierung hinzu:
372
+
373
+ ```bash
374
+ bin/rails generate b4um:authentication MODEL
375
+ ```
376
+
377
+ Beispiel:
378
+
379
+ ```bash
380
+ bin/rails generate b4um:authentication User
381
+ ```
382
+
383
+ Das Authentifizierungsmodell kann einen beliebigen Namen haben, zum Beispiel:
384
+
385
+ ```text
386
+ User
387
+ Admin
388
+ Member
389
+ ```
390
+
391
+ Das ausgewählte Modell muss:
392
+
393
+ - Bereits vorhanden sein
394
+ - `has_secure_password` verwenden
395
+ - Eine `password_digest`-Spalte besitzen
396
+ - bcrypt verwenden
397
+
398
+ Für die Anmeldung verwendet die Authentifizierung ein `email`-Attribut.
399
+
400
+ Ein vollständiges Beispiel:
401
+
402
+ ```bash
403
+ bin/rails generate b4um:scaffold User name:string email:string password_digest:string
404
+ bin/rails generate b4um:authentication User
405
+ ```
406
+
407
+ Der Authentifizierungs-Generator fügt Folgendes hinzu:
408
+
409
+ - Sessions-Controller
410
+ - Anmeldeformular
411
+ - Login- und Logout-Routen
412
+ - Sitzungsbasierten Helper für das aktuell angemeldete Konto
413
+ - `logged_in?`-Helper
414
+ - `require_login`-Helper
415
+ - Login- und Logout-Elemente in der Navigation
416
+
417
+ Der Name des generierten Helpers richtet sich nach dem ausgewählten Modell.
418
+
419
+ Für `User`:
420
+
421
+ ```ruby
422
+ current_user
423
+ ```
424
+
425
+ Für `Admin`:
426
+
427
+ ```ruby
428
+ current_admin
429
+ ```
430
+
431
+ ### Controller schützen
432
+
433
+ Bestehende Controller können bei der Einrichtung der Authentifizierung optional geschützt werden.
434
+
435
+ Verwende `--protect` mit dem Namen des Controllers:
436
+
437
+ ```bash
438
+ bin/rails generate b4um:authentication User --protect=Products
439
+ ```
440
+
441
+ Der Generator fügt dem ausgewählten Controller folgende Authentifizierungsanforderung hinzu:
442
+
443
+ ```ruby
444
+ before_action :require_login, except: [:index, :show]
445
+ ```
446
+
447
+ Dadurch bleiben `index` und `show` öffentlich erreichbar. Für Aktionen wie `new`, `create`, `edit`, `update` und
448
+ `destroy` ist dagegen eine Anmeldung erforderlich.
449
+
450
+ Mehrere Controller können gleichzeitig geschützt werden, indem ihre Namen durch Kommas getrennt werden:
451
+
452
+ ```bash
453
+ bin/rails generate b4um:authentication User --protect=Products,Articles
454
+ ```
455
+
456
+ Weitere Controller können auch später geschützt werden, indem der Authentifizierungs-Generator erneut ausgeführt wird:
457
+
458
+ ```bash
459
+ bin/rails generate b4um:authentication User --protect=Comments
460
+ ```
461
+
462
+ Die bereits vorhandene Authentifizierung wird dabei weiterverwendet. Authentifizierungs-Helper, Routen,
463
+ Navigationselemente und Controller-Schutz werden nicht dupliziert.
464
+
465
+ Der Generator prüft die angegebenen Controller, bevor Änderungen an der Anwendung vorgenommen werden. Existiert ein
466
+ angeforderter Controller nicht, bricht der Generator mit einer Fehlermeldung ab, bevor Dateien verändert werden.
467
+
468
+ Der Generator prüft außerdem seine Authentifizierungsvoraussetzungen, bevor Änderungen an der Anwendung vorgenommen
469
+ werden. Fehlt eine erforderliche Voraussetzung, bricht der Generator mit einer hilfreichen Fehlermeldung und einem
470
+ passenden Vorschlag für einen b4um-Scaffold-Befehl ab.
471
+
472
+ Bei wiederholter Ausführung werden Authentifizierungs-Helper, Routen, Navigationselemente und Controller-Schutz nicht
473
+ dupliziert.
474
+
359
475
  ## Active Storage und Bilder
360
476
 
361
477
  Bildanhänge verwenden Rails Active Storage.
@@ -368,7 +484,7 @@ bin/rails generate b4um:install
368
484
 
369
485
  Wenn Active Storage noch nicht installiert ist, installiert b4um es und führt die erforderliche Migration aus.
370
486
 
371
- ### Einzelnes Bild
487
+ ### Einzelnes Bild in einem neuen Scaffold
372
488
 
373
489
  Verwende:
374
490
 
@@ -382,7 +498,7 @@ Beispiel:
382
498
  bin/rails generate b4um:scaffold Article title:string image:attachment
383
499
  ```
384
500
 
385
- ### Mehrere Bilder
501
+ ### Mehrere Bilder in einem neuen Scaffold
386
502
 
387
503
  Verwende:
388
504
 
@@ -396,6 +512,62 @@ Beispiel:
396
512
  bin/rails generate b4um:scaffold Gallery title:string images:attachments
397
513
  ```
398
514
 
515
+ ### Attachment-Generator
516
+
517
+ Attachments können auch später zu einer bestehenden b4um-Ressource hinzugefügt werden.
518
+
519
+ Für ein einzelnes Attachment:
520
+
521
+ ```bash
522
+ bin/rails generate b4um:attachment MODEL ATTACHMENT
523
+ ```
524
+
525
+ Beispiel:
526
+
527
+ ```bash
528
+ bin/rails generate b4um:attachment Admin avatar
529
+ ```
530
+
531
+ Dadurch wird hinzugefügt:
532
+
533
+ ```ruby
534
+ has_one_attached :avatar
535
+ ```
536
+
537
+ Für mehrere Attachments verwende `--multiple`:
538
+
539
+ ```bash
540
+ bin/rails generate b4um:attachment MODEL ATTACHMENT --multiple
541
+ ```
542
+
543
+ Beispiel:
544
+
545
+ ```bash
546
+ bin/rails generate b4um:attachment Product images --multiple
547
+ ```
548
+
549
+ Dadurch wird hinzugefügt:
550
+
551
+ ```ruby
552
+ has_many_attached :images
553
+ ```
554
+
555
+ Wenn die entsprechenden b4um-Dateien vorhanden sind, aktualisiert der Attachment-Generator außerdem:
556
+
557
+ - Das bestehende Modell
558
+ - Das bestehende b4um-Formular
559
+ - Die Controller-Parameter
560
+ - Das bestehende b4um-Ressourcen-Partial
561
+
562
+ Mehrere Attachments unterstützen zusätzlich:
563
+
564
+ - Hinzufügen neuer Bilder, ohne bestehende Bilder zu ersetzen
565
+ - Entfernen einzelner bestehender Bilder
566
+ - Vorschau mehrerer Bilder
567
+ - Bildergalerie mit Lightbox-Navigation
568
+
569
+ Bei wiederholter Ausführung wird eine bestehende Attachment-Konfiguration nicht dupliziert.
570
+
399
571
  Die Bildunterstützung umfasst:
400
572
 
401
573
  - Active-Storage-Integration
@@ -806,7 +978,7 @@ wird.
806
978
 
807
979
  ## Version
808
980
 
809
- Aktuelle Version: `0.1.0`
981
+ Aktuelle Version: `0.2.6`
810
982
 
811
983
  ## Autor
812
984
 
data/README.md CHANGED
@@ -6,7 +6,8 @@ b4um Generators is a collection of reusable Rails generators, templates, compone
6
6
  Rails projects.
7
7
 
8
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.
9
+ Bento layouts, tables, pagination, infinite scrolling, search, comments, authentication, attachments and rich-text
10
+ editing.
10
11
 
11
12
  Generated components share the same b4um styling and are designed to work together.
12
13
 
@@ -22,7 +23,7 @@ b4um Generators is currently used as a local gem during development.
22
23
  Add the gem to the Rails application's `Gemfile`:
23
24
 
24
25
  ```ruby
25
- gem "b4um_generators", "~> 0.1.0", path: "/path/to/b4um_generators"
26
+ gem "b4um_generators", "~> 0.2.0", path: "/path/to/b4um_generators"
26
27
  ```
27
28
 
28
29
  Then run:
@@ -71,6 +72,7 @@ The gem currently provides the following generators:
71
72
  ```text
72
73
  b4um:install
73
74
  b4um:scaffold
75
+ b4um:attachment
74
76
  b4um:bento
75
77
  b4um:table
76
78
  b4um:controller
@@ -78,7 +80,9 @@ b4um:pagination
78
80
  b4um:infinite_scroll
79
81
  b4um:search
80
82
  b4um:comments
83
+ b4um:authentication
81
84
  b4um:trix
85
+ b4um:readable
82
86
  b4um:help
83
87
  ```
84
88
 
@@ -161,6 +165,12 @@ The ID remains part of the URL, so the standard Rails resource lookup continues
161
165
 
162
166
  The readable part is generated from the selected attribute and changes automatically when that attribute changes.
163
167
 
168
+ Readable URLs can also be added later to an existing model:
169
+
170
+ ```bash
171
+ bin/rails generate b4um:readable Product name
172
+ ```
173
+
164
174
  ## Bento and Cards
165
175
 
166
176
  b4um includes a responsive card system that can be used independently of the generators.
@@ -353,6 +363,110 @@ bin/rails generate b4um:install
353
363
 
354
364
  If necessary, b4um adds bcrypt to the application's `Gemfile` and installs it.
355
365
 
366
+ ## Authentication
367
+
368
+ Add session-based authentication for an existing model:
369
+
370
+ ```bash
371
+ bin/rails generate b4um:authentication MODEL
372
+ ```
373
+
374
+ Example:
375
+
376
+ ```bash
377
+ bin/rails generate b4um:authentication User
378
+ ```
379
+
380
+ The authentication model can have any name, for example:
381
+
382
+ ```text
383
+ User
384
+ Admin
385
+ Member
386
+ ```
387
+
388
+ The selected model must:
389
+
390
+ - Already exist
391
+ - Use `has_secure_password`
392
+ - Have a `password_digest` column
393
+ - Use bcrypt
394
+
395
+ Authentication uses an `email` attribute for login.
396
+
397
+ A complete example:
398
+
399
+ ```bash
400
+ bin/rails generate b4um:scaffold User name:string email:string password_digest:string
401
+ bin/rails generate b4um:authentication User
402
+ ```
403
+
404
+ The authentication generator adds:
405
+
406
+ - Sessions controller
407
+ - Login form
408
+ - Login and logout routes
409
+ - Session-based current account helper
410
+ - `logged_in?` helper
411
+ - `require_login` helper
412
+ - Login and logout navigation controls
413
+
414
+ The generated helper name follows the selected model.
415
+
416
+ For `User`:
417
+
418
+ ```ruby
419
+ current_user
420
+ ```
421
+
422
+ For `Admin`:
423
+
424
+ ```ruby
425
+ current_admin
426
+ ```
427
+
428
+ ### Protecting Controllers
429
+
430
+ Existing controllers can optionally be protected when authentication is installed.
431
+
432
+ Use `--protect` with the controller name:
433
+
434
+ ```bash
435
+ bin/rails generate b4um:authentication User --protect=Products
436
+ ```
437
+
438
+ The generator adds the following authentication requirement to the selected controller:
439
+
440
+ ```ruby
441
+ before_action :require_login, except: [:index, :show]
442
+ ```
443
+
444
+ This keeps `index` and `show` publicly accessible while requiring authentication for actions such as `new`, `create`,
445
+ `edit`, `update` and `destroy`.
446
+
447
+ Multiple controllers can be protected at the same time by separating their names with commas:
448
+
449
+ ```bash
450
+ bin/rails generate b4um:authentication User --protect=Products,Articles
451
+ ```
452
+
453
+ Additional controllers can also be protected later by running the authentication generator again:
454
+
455
+ ```bash
456
+ bin/rails generate b4um:authentication User --protect=Comments
457
+ ```
458
+
459
+ Existing authentication setup is reused. Authentication helpers, routes, navigation controls and controller protection
460
+ are not duplicated.
461
+
462
+ The generator validates protected controllers before changing the application. If a requested controller does not exist,
463
+ the generator stops with an error before making changes.
464
+
465
+ The generator also validates its authentication requirements before changing the application. If required authentication
466
+ setup is missing, the generator stops with a helpful error message and a suggested b4um scaffold command.
467
+
468
+ Repeated generator runs do not duplicate authentication helpers, routes, navigation controls or controller protection.
469
+
356
470
  ## Active Storage and Images
357
471
 
358
472
  Image attachments use Rails Active Storage.
@@ -365,7 +479,7 @@ bin/rails generate b4um:install
365
479
 
366
480
  If Active Storage is not already installed, b4um installs it and runs the required migration.
367
481
 
368
- ### Single Image
482
+ ### Single Image in a New Scaffold
369
483
 
370
484
  Use:
371
485
 
@@ -379,7 +493,7 @@ Example:
379
493
  bin/rails generate b4um:scaffold Article title:string image:attachment
380
494
  ```
381
495
 
382
- ### Multiple Images
496
+ ### Multiple Images in a New Scaffold
383
497
 
384
498
  Use:
385
499
 
@@ -393,6 +507,62 @@ Example:
393
507
  bin/rails generate b4um:scaffold Gallery title:string images:attachments
394
508
  ```
395
509
 
510
+ ### Attachment Generator
511
+
512
+ Attachments can also be added later to an existing b4um resource.
513
+
514
+ For a single attachment:
515
+
516
+ ```bash
517
+ bin/rails generate b4um:attachment MODEL ATTACHMENT
518
+ ```
519
+
520
+ Example:
521
+
522
+ ```bash
523
+ bin/rails generate b4um:attachment Admin avatar
524
+ ```
525
+
526
+ This adds:
527
+
528
+ ```ruby
529
+ has_one_attached :avatar
530
+ ```
531
+
532
+ For multiple attachments, use `--multiple`:
533
+
534
+ ```bash
535
+ bin/rails generate b4um:attachment MODEL ATTACHMENT --multiple
536
+ ```
537
+
538
+ Example:
539
+
540
+ ```bash
541
+ bin/rails generate b4um:attachment Product images --multiple
542
+ ```
543
+
544
+ This adds:
545
+
546
+ ```ruby
547
+ has_many_attached :images
548
+ ```
549
+
550
+ When the corresponding b4um files exist, the attachment generator also updates:
551
+
552
+ - The existing model
553
+ - The existing b4um form
554
+ - The controller parameters
555
+ - The existing b4um resource partial
556
+
557
+ Multiple attachments additionally support:
558
+
559
+ - Adding new images without replacing existing images
560
+ - Removing individual existing images
561
+ - Multiple image preview
562
+ - Image gallery with lightbox navigation
563
+
564
+ Repeated generator runs do not duplicate existing attachment setup.
565
+
396
566
  Image support includes:
397
567
 
398
568
  - Active Storage integration
@@ -800,7 +970,7 @@ The gem can be tested locally by referencing the repository with `path:` from a
800
970
 
801
971
  ## Version
802
972
 
803
- Current version: `0.1.0`
973
+ Current version: `0.2.7`
804
974
 
805
975
  ## Author
806
976
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module B4umGenerators
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.7"
5
5
  end