b4um_generators 0.1.0 → 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 +4 -4
- data/.rubocop.yml +2 -2
- data/README.de.md +177 -5
- data/README.md +175 -5
- data/lib/b4um_generators/version.rb +1 -1
- data/lib/generators/b4um/attachment/attachment_generator.rb +514 -0
- data/lib/generators/b4um/authentication/authentication_generator.rb +414 -0
- data/lib/generators/b4um/authentication/templates/new.html.erb.tt +35 -0
- data/lib/generators/b4um/authentication/templates/sessions_controller.rb.tt +25 -0
- data/lib/generators/b4um/help/help_generator.rb +210 -5
- data/lib/generators/b4um/infinite_scroll/infinite_scroll_generator.rb +31 -0
- data/lib/generators/b4um/infinite_scroll/templates/infinite_scroll_controller.js +19 -9
- data/lib/generators/b4um/install/install_generator.rb +141 -2
- data/lib/generators/b4um/install/templates/b4um/forms.css +161 -1
- data/lib/generators/b4um/install/templates/b4um/navigation.css +13 -0
- data/lib/generators/b4um/install/templates/b4um/resources.css +18 -0
- data/lib/generators/b4um/install/templates/b4um.css +14 -0
- data/lib/generators/b4um/install/templates/navigation_helper.rb +13 -0
- data/lib/generators/b4um/readable/readable_generator.rb +77 -0
- data/lib/generators/b4um/search/search_generator.rb +58 -0
- metadata +7 -2
|
@@ -48,15 +48,28 @@
|
|
|
48
48
|
.navigation__link {
|
|
49
49
|
position: relative;
|
|
50
50
|
padding: 0.5rem 0;
|
|
51
|
+
|
|
52
|
+
border: 0;
|
|
53
|
+
background: transparent;
|
|
54
|
+
|
|
51
55
|
color: var(--b4um-text);
|
|
56
|
+
font: inherit;
|
|
52
57
|
font-weight: 500;
|
|
53
58
|
text-decoration: none;
|
|
59
|
+
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
|
|
54
62
|
transition:
|
|
55
63
|
color 0.18s ease,
|
|
56
64
|
background-color 0.18s ease,
|
|
57
65
|
transform 0.18s ease;
|
|
58
66
|
}
|
|
59
67
|
|
|
68
|
+
.navigation__form {
|
|
69
|
+
margin: 0;
|
|
70
|
+
padding: 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
60
73
|
.navigation__link:visited {
|
|
61
74
|
color: var(--b4um-text);
|
|
62
75
|
}
|
|
@@ -119,3 +119,21 @@
|
|
|
119
119
|
.resource-list-item:last-child {
|
|
120
120
|
border-bottom: none;
|
|
121
121
|
}
|
|
122
|
+
|
|
123
|
+
/* -------------------------------------------------------
|
|
124
|
+
Responsive resource details
|
|
125
|
+
------------------------------------------------------- */
|
|
126
|
+
|
|
127
|
+
@media (max-width: 768px) {
|
|
128
|
+
.resource-field {
|
|
129
|
+
grid-template-columns: minmax(0, 1fr);
|
|
130
|
+
row-gap: 0.5rem;
|
|
131
|
+
column-gap: 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.resource-label,
|
|
135
|
+
.resource-value {
|
|
136
|
+
min-width: 0;
|
|
137
|
+
width: 100%;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* B4UM stylesheet imports
|
|
3
|
+
*
|
|
4
|
+
* Rails 8 loads all stylesheets in app/assets/stylesheets automatically
|
|
5
|
+
* when using:
|
|
6
|
+
*
|
|
7
|
+
* <%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
|
|
8
|
+
*
|
|
9
|
+
* Therefore these imports are disabled by default.
|
|
10
|
+
* Uncomment them if your application's asset setup requires explicit imports.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/*
|
|
1
14
|
@import 'b4um/theme.css';
|
|
2
15
|
@import 'b4um/base.css';
|
|
3
16
|
@import 'b4um/layout.css';
|
|
@@ -18,3 +31,4 @@
|
|
|
18
31
|
@import 'b4um/footer.css';
|
|
19
32
|
@import 'b4um/cookie-consent.css';
|
|
20
33
|
@import 'b4um/theme-switcher.css';
|
|
34
|
+
*/
|
|
@@ -23,4 +23,17 @@ module NavigationHelper
|
|
|
23
23
|
data: { action: "click->navigation#close" }
|
|
24
24
|
)
|
|
25
25
|
end
|
|
26
|
+
|
|
27
|
+
def navigation_button_to(name, path, method:)
|
|
28
|
+
button_to(
|
|
29
|
+
name,
|
|
30
|
+
path,
|
|
31
|
+
method: method,
|
|
32
|
+
class: "navigation__link",
|
|
33
|
+
form: {
|
|
34
|
+
class: "navigation__form",
|
|
35
|
+
data: { action: "click->navigation#close" }
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
end
|
|
26
39
|
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails/generators"
|
|
4
|
+
require "rails/generators/named_base"
|
|
5
|
+
|
|
6
|
+
module B4um
|
|
7
|
+
module Generators
|
|
8
|
+
class ReadableGenerator < Rails::Generators::NamedBase
|
|
9
|
+
argument :attribute,
|
|
10
|
+
type: :string,
|
|
11
|
+
required: true,
|
|
12
|
+
banner: "ATTRIBUTE"
|
|
13
|
+
|
|
14
|
+
class << self
|
|
15
|
+
def desc(_description = nil)
|
|
16
|
+
"Adds a readable URL parameter to an existing model."
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def validate_model
|
|
21
|
+
return if File.exist?(model_path)
|
|
22
|
+
|
|
23
|
+
raise Thor::Error,
|
|
24
|
+
"Model not found: app/models/#{file_name}.rb"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def validate_attribute
|
|
28
|
+
return if model_class.column_names.include?(attribute)
|
|
29
|
+
|
|
30
|
+
raise Thor::Error,
|
|
31
|
+
"Attribute not found: #{class_name}##{attribute}"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def add_readable_param
|
|
35
|
+
model_content = File.read(model_path)
|
|
36
|
+
|
|
37
|
+
if model_content.match?(/^\s*def\s+to_param\b/)
|
|
38
|
+
raise Thor::Error,
|
|
39
|
+
"#{class_name} already defines to_param."
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
inject_into_class(
|
|
43
|
+
model_path,
|
|
44
|
+
class_name,
|
|
45
|
+
<<~RUBY
|
|
46
|
+
def to_param
|
|
47
|
+
"\#{id} \#{#{attribute}}".parameterize
|
|
48
|
+
end
|
|
49
|
+
RUBY
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
say_status(
|
|
53
|
+
:readable,
|
|
54
|
+
"#{class_name} URLs now use #{attribute}",
|
|
55
|
+
:green
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
private
|
|
60
|
+
|
|
61
|
+
def model_path
|
|
62
|
+
File.join(
|
|
63
|
+
destination_root,
|
|
64
|
+
"app/models",
|
|
65
|
+
"#{file_name}.rb"
|
|
66
|
+
)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def model_class
|
|
70
|
+
class_name.constantize
|
|
71
|
+
rescue NameError
|
|
72
|
+
raise Thor::Error,
|
|
73
|
+
"Could not load model: #{class_name}"
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -137,6 +137,64 @@ module B4um
|
|
|
137
137
|
)
|
|
138
138
|
end
|
|
139
139
|
|
|
140
|
+
def update_empty_state
|
|
141
|
+
view_file = File.join(
|
|
142
|
+
destination_root,
|
|
143
|
+
index_view_path
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
view_content = File.read(view_file)
|
|
147
|
+
|
|
148
|
+
return if view_content.include?(
|
|
149
|
+
"<% if params[:q].present? %>"
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
title = file_name.pluralize.humanize.downcase
|
|
153
|
+
singular = file_name.humanize.downcase
|
|
154
|
+
|
|
155
|
+
empty_state_pattern = %r{
|
|
156
|
+
(?<indent>[ \t]*)
|
|
157
|
+
<section\ class="b4um-empty-state">\s*
|
|
158
|
+
<h2\ class="b4um-empty-state__title">\s*
|
|
159
|
+
No\ #{Regexp.escape(title)}\ yet\.\s*
|
|
160
|
+
</h2>\s*
|
|
161
|
+
<p\ class="b4um-empty-state__text">\s*
|
|
162
|
+
Create\ your\ first\ #{Regexp.escape(singular)}\ to\ get\ started\.\s*
|
|
163
|
+
</p>\s*
|
|
164
|
+
</section>
|
|
165
|
+
}x
|
|
166
|
+
|
|
167
|
+
return unless view_content.match?(empty_state_pattern)
|
|
168
|
+
|
|
169
|
+
new_empty_state = <<~ERB.chomp
|
|
170
|
+
<section class="b4um-empty-state">
|
|
171
|
+
<% if params[:q].present? %>
|
|
172
|
+
<h2 class="b4um-empty-state__title">
|
|
173
|
+
No #{title} found.
|
|
174
|
+
</h2>
|
|
175
|
+
|
|
176
|
+
<p class="b4um-empty-state__text">
|
|
177
|
+
Try a different search term.
|
|
178
|
+
</p>
|
|
179
|
+
<% else %>
|
|
180
|
+
<h2 class="b4um-empty-state__title">
|
|
181
|
+
No #{title} yet.
|
|
182
|
+
</h2>
|
|
183
|
+
|
|
184
|
+
<p class="b4um-empty-state__text">
|
|
185
|
+
Create your first #{singular} to get started.
|
|
186
|
+
</p>
|
|
187
|
+
<% end %>
|
|
188
|
+
</section>
|
|
189
|
+
ERB
|
|
190
|
+
|
|
191
|
+
gsub_file(
|
|
192
|
+
index_view_path,
|
|
193
|
+
empty_state_pattern,
|
|
194
|
+
new_empty_state
|
|
195
|
+
)
|
|
196
|
+
end
|
|
197
|
+
|
|
140
198
|
private
|
|
141
199
|
|
|
142
200
|
def model_path
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: b4um_generators
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexander Baum
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-09-
|
|
10
|
+
date: 2026-09-28 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: railties
|
|
@@ -49,6 +49,10 @@ files:
|
|
|
49
49
|
- bin/setup
|
|
50
50
|
- lib/b4um_generators.rb
|
|
51
51
|
- lib/b4um_generators/version.rb
|
|
52
|
+
- lib/generators/b4um/attachment/attachment_generator.rb
|
|
53
|
+
- lib/generators/b4um/authentication/authentication_generator.rb
|
|
54
|
+
- lib/generators/b4um/authentication/templates/new.html.erb.tt
|
|
55
|
+
- lib/generators/b4um/authentication/templates/sessions_controller.rb.tt
|
|
52
56
|
- lib/generators/b4um/bento/bento_generator.rb
|
|
53
57
|
- lib/generators/b4um/bento/templates/_alternating.html.erb.tt
|
|
54
58
|
- lib/generators/b4um/bento/templates/_bento.html.erb.tt
|
|
@@ -104,6 +108,7 @@ files:
|
|
|
104
108
|
- lib/generators/b4um/pagination/pagination_generator.rb
|
|
105
109
|
- lib/generators/b4um/pagination/templates/_pagination.html.erb.tt
|
|
106
110
|
- lib/generators/b4um/pagination/templates/pagination.rb
|
|
111
|
+
- lib/generators/b4um/readable/readable_generator.rb
|
|
107
112
|
- lib/generators/b4um/scaffold/scaffold_generator.rb
|
|
108
113
|
- lib/generators/b4um/scaffold/templates/_bento.html.erb.tt
|
|
109
114
|
- lib/generators/b4um/scaffold/templates/_form.html.erb.tt
|