b4um_generators 0.2.11 → 0.2.14
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 +127 -1
- data/README.md +126 -1
- data/lib/b4um_generators/version.rb +1 -1
- data/lib/generators/b4um/attachment/attachment_generator.rb +83 -23
- data/lib/generators/b4um/authentication/authentication_generator.rb +63 -0
- data/lib/generators/b4um/help/help_generator.rb +100 -3
- data/lib/generators/b4um/in_place/in_place_generator.rb +1231 -0
- data/lib/generators/b4um/in_place/templates/_flash.html.erb +15 -0
- data/lib/generators/b4um/in_place/templates/b4um_in_place_helper.rb +7 -0
- data/lib/generators/b4um/in_place/templates/display_attachment.html.erb.tt +154 -0
- data/lib/generators/b4um/in_place/templates/display_attachments.html.erb.tt +165 -0
- data/lib/generators/b4um/in_place/templates/display_boolean.html.erb.tt +18 -0
- data/lib/generators/b4um/in_place/templates/display_number.html.erb.tt +18 -0
- data/lib/generators/b4um/in_place/templates/display_radio.html.erb.tt +23 -0
- data/lib/generators/b4um/in_place/templates/display_rich_text.html.erb.tt +123 -0
- data/lib/generators/b4um/in_place/templates/display_select.html.erb.tt +23 -0
- data/lib/generators/b4um/in_place/templates/display_text.html.erb.tt +18 -0
- data/lib/generators/b4um/in_place/templates/edit_attachment.html.erb.tt +83 -0
- data/lib/generators/b4um/in_place/templates/edit_attachments.html.erb.tt +65 -0
- data/lib/generators/b4um/in_place/templates/edit_boolean.html.erb.tt +32 -0
- data/lib/generators/b4um/in_place/templates/edit_number.html.erb.tt +26 -0
- data/lib/generators/b4um/in_place/templates/edit_radio.html.erb.tt +32 -0
- data/lib/generators/b4um/in_place/templates/edit_rich_text.html.erb.tt +25 -0
- data/lib/generators/b4um/in_place/templates/edit_select.html.erb.tt +28 -0
- data/lib/generators/b4um/in_place/templates/edit_text.html.erb.tt +25 -0
- data/lib/generators/b4um/in_place/templates/in_place.css +935 -0
- data/lib/generators/b4um/in_place/templates/in_place_controller.js +115 -0
- data/lib/generators/b4um/install/install_generator.rb +18 -13
- data/lib/generators/b4um/install/templates/_flash.html.erb +15 -0
- data/lib/generators/b4um/install/templates/_footer.html.erb +6 -1
- data/lib/generators/b4um/install/templates/b4um/forms.css +127 -0
- data/lib/generators/b4um/install/templates/image_lightbox_controller.js +29 -0
- data/lib/generators/b4um/install/templates/rich_text_controller.js +22 -0
- data/lib/generators/b4um/install/templates/scroll_to_top_controller.js +12 -0
- data/lib/generators/b4um/scaffold/scaffold_generator.rb +106 -0
- data/lib/generators/b4um/scaffold/templates/_form.html.erb.tt +29 -0
- data/lib/generators/b4um/scaffold/templates/_resource.html.erb.tt +35 -0
- data/lib/generators/b4um/scaffold/templates/_table.html.erb.tt +31 -0
- data/lib/generators/b4um/trix/trix_generator.rb +104 -6
- metadata +25 -1
|
@@ -133,16 +133,75 @@ module B4um
|
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
def update_form
|
|
136
|
-
|
|
136
|
+
form = File.read(form_path)
|
|
137
|
+
|
|
138
|
+
return if form.include?("form.rich_text_area :#{attribute}")
|
|
139
|
+
|
|
140
|
+
if form.include?("form.text_area :#{attribute}")
|
|
141
|
+
gsub_file(
|
|
142
|
+
form_path,
|
|
143
|
+
"form.text_area :#{attribute}",
|
|
144
|
+
"form.rich_text_area :#{attribute}"
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
gsub_file(
|
|
148
|
+
form_path,
|
|
149
|
+
/<div class="form-field form-field--textarea">(?=\s*<%= form\.rich_text_area :#{Regexp.escape(attribute)})/,
|
|
150
|
+
'<div class="form-field form-field--rich-text">'
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
return
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
insert_into_file(
|
|
137
157
|
form_path,
|
|
138
|
-
|
|
139
|
-
|
|
158
|
+
<<~ERB,
|
|
159
|
+
<div class="form-field form-field--rich-text">
|
|
160
|
+
<%= form.rich_text_area :#{attribute} %>
|
|
161
|
+
<%= form.label :#{attribute}, class: "form-label" %>
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
ERB
|
|
165
|
+
before: ' <div class="form-actions">'
|
|
140
166
|
)
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def update_controller_params
|
|
170
|
+
return unless File.exist?(controller_path)
|
|
171
|
+
|
|
172
|
+
controller = File.read(controller_path)
|
|
173
|
+
|
|
174
|
+
params_method = controller[
|
|
175
|
+
/def #{Regexp.escape(name.underscore)}_params.*?^\s*end/m,
|
|
176
|
+
0
|
|
177
|
+
]
|
|
178
|
+
|
|
179
|
+
unless params_method
|
|
180
|
+
raise Thor::Error,
|
|
181
|
+
"Could not find #{name.underscore}_params in #{controller_path}"
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
parameter = ":#{attribute}"
|
|
185
|
+
|
|
186
|
+
return if params_method.include?(parameter)
|
|
187
|
+
|
|
188
|
+
updated_method =
|
|
189
|
+
if params_method.match?(/\w+:\s*\[\]/)
|
|
190
|
+
params_method.sub(
|
|
191
|
+
/(?=\w+:\s*\[\])/,
|
|
192
|
+
"#{parameter}, "
|
|
193
|
+
)
|
|
194
|
+
else
|
|
195
|
+
params_method.sub(
|
|
196
|
+
/\s*\]\s*\)\s*$/,
|
|
197
|
+
", #{parameter} ])"
|
|
198
|
+
)
|
|
199
|
+
end
|
|
141
200
|
|
|
142
201
|
gsub_file(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
202
|
+
controller_path,
|
|
203
|
+
params_method,
|
|
204
|
+
updated_method
|
|
146
205
|
)
|
|
147
206
|
end
|
|
148
207
|
|
|
@@ -151,6 +210,8 @@ module B4um
|
|
|
151
210
|
|
|
152
211
|
resource_name = name.underscore
|
|
153
212
|
|
|
213
|
+
add_rich_text_resource_field(resource_name)
|
|
214
|
+
|
|
154
215
|
preview_length =
|
|
155
216
|
'local_assigns\.fetch\(:preview_length,\s*160\)'
|
|
156
217
|
|
|
@@ -374,6 +435,36 @@ module B4um
|
|
|
374
435
|
|
|
375
436
|
private
|
|
376
437
|
|
|
438
|
+
def add_rich_text_resource_field(resource_name)
|
|
439
|
+
partial = File.read(resource_partial_path)
|
|
440
|
+
|
|
441
|
+
return if partial.include?("#{resource_name}.#{attribute}")
|
|
442
|
+
|
|
443
|
+
field = <<~ERB
|
|
444
|
+
<div class="resource-field">
|
|
445
|
+
<strong class="resource-label">#{attribute.humanize}:</strong>
|
|
446
|
+
<span class="resource-value">
|
|
447
|
+
<% if local_assigns[:compact] %>
|
|
448
|
+
<%= b4um_rich_text_preview(
|
|
449
|
+
#{resource_name}.#{attribute},
|
|
450
|
+
length: local_assigns.fetch(:preview_length, 160)
|
|
451
|
+
) %>
|
|
452
|
+
<% else %>
|
|
453
|
+
<%= #{resource_name}.#{attribute} %>
|
|
454
|
+
<% end %>
|
|
455
|
+
</span>
|
|
456
|
+
</div>
|
|
457
|
+
ERB
|
|
458
|
+
|
|
459
|
+
closing_div = partial.rindex("</div>")
|
|
460
|
+
|
|
461
|
+
return unless closing_div
|
|
462
|
+
|
|
463
|
+
partial.insert(closing_div, field)
|
|
464
|
+
|
|
465
|
+
File.write(resource_partial_path, partial)
|
|
466
|
+
end
|
|
467
|
+
|
|
377
468
|
def action_text_installed?
|
|
378
469
|
Dir.glob(
|
|
379
470
|
File.join(
|
|
@@ -401,6 +492,13 @@ module B4um
|
|
|
401
492
|
)
|
|
402
493
|
end
|
|
403
494
|
|
|
495
|
+
def controller_path
|
|
496
|
+
File.join(
|
|
497
|
+
destination_root,
|
|
498
|
+
"app/controllers/#{name.underscore.pluralize}_controller.rb"
|
|
499
|
+
)
|
|
500
|
+
end
|
|
501
|
+
|
|
404
502
|
def resource_partial_path
|
|
405
503
|
File.join(
|
|
406
504
|
destination_root,
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: b4um_generators
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.14
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexander Baum
|
|
@@ -65,10 +65,32 @@ files:
|
|
|
65
65
|
- lib/generators/b4um/comments/templates/create_comments.rb.tt
|
|
66
66
|
- lib/generators/b4um/controller/controller_generator.rb
|
|
67
67
|
- lib/generators/b4um/help/help_generator.rb
|
|
68
|
+
- lib/generators/b4um/in_place/in_place_generator.rb
|
|
69
|
+
- lib/generators/b4um/in_place/templates/_flash.html.erb
|
|
70
|
+
- lib/generators/b4um/in_place/templates/b4um_in_place_helper.rb
|
|
71
|
+
- lib/generators/b4um/in_place/templates/display_attachment.html.erb.tt
|
|
72
|
+
- lib/generators/b4um/in_place/templates/display_attachments.html.erb.tt
|
|
73
|
+
- lib/generators/b4um/in_place/templates/display_boolean.html.erb.tt
|
|
74
|
+
- lib/generators/b4um/in_place/templates/display_number.html.erb.tt
|
|
75
|
+
- lib/generators/b4um/in_place/templates/display_radio.html.erb.tt
|
|
76
|
+
- lib/generators/b4um/in_place/templates/display_rich_text.html.erb.tt
|
|
77
|
+
- lib/generators/b4um/in_place/templates/display_select.html.erb.tt
|
|
78
|
+
- lib/generators/b4um/in_place/templates/display_text.html.erb.tt
|
|
79
|
+
- lib/generators/b4um/in_place/templates/edit_attachment.html.erb.tt
|
|
80
|
+
- lib/generators/b4um/in_place/templates/edit_attachments.html.erb.tt
|
|
81
|
+
- lib/generators/b4um/in_place/templates/edit_boolean.html.erb.tt
|
|
82
|
+
- lib/generators/b4um/in_place/templates/edit_number.html.erb.tt
|
|
83
|
+
- lib/generators/b4um/in_place/templates/edit_radio.html.erb.tt
|
|
84
|
+
- lib/generators/b4um/in_place/templates/edit_rich_text.html.erb.tt
|
|
85
|
+
- lib/generators/b4um/in_place/templates/edit_select.html.erb.tt
|
|
86
|
+
- lib/generators/b4um/in_place/templates/edit_text.html.erb.tt
|
|
87
|
+
- lib/generators/b4um/in_place/templates/in_place.css
|
|
88
|
+
- lib/generators/b4um/in_place/templates/in_place_controller.js
|
|
68
89
|
- lib/generators/b4um/infinite_scroll/infinite_scroll_generator.rb
|
|
69
90
|
- lib/generators/b4um/infinite_scroll/templates/infinite_scroll_controller.js
|
|
70
91
|
- lib/generators/b4um/install/install_generator.rb
|
|
71
92
|
- lib/generators/b4um/install/templates/_cookie_consent.html.erb
|
|
93
|
+
- lib/generators/b4um/install/templates/_flash.html.erb
|
|
72
94
|
- lib/generators/b4um/install/templates/_footer.html.erb
|
|
73
95
|
- lib/generators/b4um/install/templates/_hero.html.erb
|
|
74
96
|
- lib/generators/b4um/install/templates/_navigation.html.erb
|
|
@@ -103,6 +125,8 @@ files:
|
|
|
103
125
|
- lib/generators/b4um/install/templates/image_preview_controller.js
|
|
104
126
|
- lib/generators/b4um/install/templates/navigation_controller.js
|
|
105
127
|
- lib/generators/b4um/install/templates/navigation_helper.rb
|
|
128
|
+
- lib/generators/b4um/install/templates/rich_text_controller.js
|
|
129
|
+
- lib/generators/b4um/install/templates/scroll_to_top_controller.js
|
|
106
130
|
- lib/generators/b4um/install/templates/sitemap_controller.js
|
|
107
131
|
- lib/generators/b4um/install/templates/theme_controller.js
|
|
108
132
|
- lib/generators/b4um/pagination/pagination_generator.rb
|