spina 2.3.2 → 2.4.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 (33) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -1
  3. data/app/assets/javascripts/spina/application.js +1 -0
  4. data/app/assets/javascripts/spina/libraries/trix.js +1 -1
  5. data/app/assets/javascripts/spina/libraries/trix@1.3.1.esm.js +5278 -0
  6. data/app/components/spina/media_picker/image_component.html.erb +1 -1
  7. data/app/components/spina/pages/new_page_button_component.html.erb +32 -0
  8. data/app/components/spina/pages/new_page_button_component.rb +19 -0
  9. data/app/controllers/spina/admin/pages_controller.rb +1 -2
  10. data/app/controllers/spina/admin/password_resets_controller.rb +2 -4
  11. data/app/helpers/spina/images_helper.rb +1 -1
  12. data/app/helpers/spina/spina_helper.rb +4 -5
  13. data/app/mailers/spina/application_mailer.rb +7 -0
  14. data/app/mailers/spina/user_mailer.rb +6 -14
  15. data/app/models/spina/user.rb +6 -0
  16. data/app/views/layouts/spina/mail.html.erb +476 -1
  17. data/app/views/spina/admin/pages/edit_template.html.erb +1 -1
  18. data/app/views/spina/admin/pages/index.html.erb +1 -21
  19. data/app/views/spina/user_mailer/forgot_password.html.erb +57 -1
  20. data/app/views/spina/user_mailer/forgot_password.text.erb +9 -0
  21. data/config/initializers/importmap.rb +12 -0
  22. data/config/locales/en.yml +12 -0
  23. data/config/locales/nl.yml +1 -0
  24. data/lib/generators/spina/templates/app/views/default/pages/homepage.html.erb +1 -1
  25. data/lib/generators/spina/templates/config/initializers/spina.rb +7 -0
  26. data/lib/generators/spina/templates/config/initializers/themes/demo.rb +1 -1
  27. data/lib/spina/engine.rb +2 -13
  28. data/lib/spina/theme.rb +4 -2
  29. data/lib/spina/version.rb +1 -1
  30. data/lib/spina.rb +2 -0
  31. metadata +38 -14
  32. data/app/assets/javascripts/spina/libraries/trix@1.3.1.js +0 -21
  33. data/app/views/spina/user_mailer/forgot_password.txt.erb +0 -1
@@ -2,7 +2,7 @@
2
2
  <button type="button"
3
3
  data-action="media-picker-modal#selectImage selectable#select dblclick->media-picker-modal#instantInsert"
4
4
  data-image-id="<%= @image.id %>"
5
- data-signed-blob-id="<%= @image.file.blob.signed_id %>"
5
+ data-signed-blob-id="<%= @image.file.blob&.signed_id %>"
6
6
  data-filename="<%= @image.file.filename %>"
7
7
  data-thumbnail="<%= helpers.thumbnail_url(@image) %>"
8
8
  data-embedded-url="<%= helpers.embedded_image_url(@image) %>"
@@ -0,0 +1,32 @@
1
+ <% if view_templates.many? %>
2
+
3
+ <%= render Spina::UserInterface::DropdownComponent.new do |dropdown| %>
4
+ <% dropdown.button(classes: "btn btn-primary w-full") do %>
5
+ <%= helpers.heroicon("plus", style: :solid, class: "w-7 h-7 -ml-2") %>
6
+ <%=t 'spina.pages.new' %>
7
+ <% end %>
8
+
9
+ <% dropdown.menu do %>
10
+ <% view_templates.each do |template| %>
11
+ <%= link_to helpers.spina.new_admin_page_path(view_template: template.name, resource_id: @resource&.id), class: "block px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus:bg-gray-100 focus:text-gray-900", data: {turbo_frame: "modal", action: "reveal#hide"} do %>
12
+ <div class="font-medium text-gray-700">
13
+ <%= template.title %>
14
+
15
+ <% if template.recommended %>
16
+ <span class="text-green-500 text-xs"><%=t 'spina.pages.recommended' %></span>
17
+ <% end %>
18
+ </div>
19
+ <div class="text-gray-400"><%= template.description %></div>
20
+ <% end %>
21
+ <% end %>
22
+ <% end %>
23
+ <% end %>
24
+
25
+ <% else %>
26
+
27
+ <%= link_to helpers.spina.new_admin_page_path(view_template: view_template.name, resource_id: resource&.id), class: "btn btn-primary w-full", data: {turbo_frame: "modal"} do %>
28
+ <%= helpers.heroicon("plus", style: :solid, class: "w-7 h-7 -ml-2") %>
29
+ <%=t 'spina.pages.new' %>
30
+ <% end %>
31
+
32
+ <% end %>
@@ -0,0 +1,19 @@
1
+ module Spina::Pages
2
+ class NewPageButtonComponent < Spina::ApplicationComponent
3
+ attr_reader :view_templates, :resource
4
+
5
+ def initialize(view_templates = [], resource: nil)
6
+ @view_templates = view_templates
7
+ @resource = resource
8
+ end
9
+
10
+ def view_template
11
+ view_templates.first
12
+ end
13
+
14
+ def render?
15
+ view_templates.any?
16
+ end
17
+
18
+ end
19
+ end
@@ -8,10 +8,9 @@ module Spina
8
8
  def index
9
9
  add_breadcrumb I18n.t('spina.website.pages'), spina.admin_pages_path
10
10
 
11
-
12
11
  if params[:resource_id]
13
12
  @resource = Resource.find(params[:resource_id])
14
- @page_templates = Spina::Current.theme.new_page_templates(recommended: @resource.view_template)
13
+ @page_templates = Spina::Current.theme.new_page_templates(resource: @resource)
15
14
  @pages = @resource.pages.active.roots.includes(:translations)
16
15
  else
17
16
  @pages = Page.active.sorted.roots.main.includes(:translations)
@@ -11,10 +11,8 @@ module Spina
11
11
  def create
12
12
  user = User.find_by(email: params[:email])
13
13
 
14
- if user.present?
15
- user.regenerate_password_reset_token
16
- user.touch(:password_reset_sent_at)
17
- UserMailer.forgot_password(user).deliver_now
14
+ if user&.reset_passord!
15
+ UserMailer.forgot_password(user, request.user_agent).deliver_later
18
16
  redirect_to admin_login_path, flash: {success: t('spina.forgot_password.instructions_sent')}
19
17
  else
20
18
  flash.now[:alert] = t('spina.forgot_password.unknown_user')
@@ -32,7 +32,7 @@ module Spina
32
32
  end
33
33
 
34
34
  def content_type(image)
35
- image.file.content_type.split("/").last
35
+ image.file.content_type&.split("/")&.last || I18n.t("spina.images.missing_image")
36
36
  end
37
37
 
38
38
  end
@@ -1,13 +1,12 @@
1
1
  module Spina::SpinaHelper
2
2
 
3
- def spina_importmap_tags
3
+ def spina_importmap_tags(entry_point = "application")
4
4
  safe_join [
5
- javascript_inline_importmap_tag(Spina.config.importmap),
5
+ javascript_inline_importmap_tag(Spina.config.importmap.to_json(resolver: self)),
6
+ javascript_importmap_module_preload_tags(Spina.config.importmap),
6
7
  javascript_importmap_shim_tag,
7
- javascript_include_tag("spina/libraries/trix"),
8
- javascript_import_module_tag("application")
8
+ javascript_import_module_tag(entry_point)
9
9
  ], "\n"
10
10
  end
11
-
12
11
 
13
12
  end
@@ -0,0 +1,7 @@
1
+ module Spina
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default Spina.config.mailer_defaults
4
+
5
+ layout 'spina/mail'
6
+ end
7
+ end
@@ -1,21 +1,13 @@
1
1
  module Spina
2
- class UserMailer < ActionMailer::Base
3
- layout 'spina/mail'
2
+ class UserMailer < ApplicationMailer
4
3
 
5
- def forgot_password(user)
4
+ def forgot_password(user, user_agent_string = nil)
6
5
  @user = user
7
-
8
- mail(
9
- to: @user.email,
10
- from: current_account.email,
11
- subject: t('spina.forgot_password.mail_subject')
12
- )
6
+ @browser = Browser.new(user_agent_string)
7
+
8
+ mail to: @user.email,
9
+ subject: t('spina.user_mailer.forgot_password.subject')
13
10
  end
14
11
 
15
- private
16
-
17
- def current_account
18
- Spina::Account.first
19
- end
20
12
  end
21
13
  end
@@ -15,6 +15,12 @@ module Spina
15
15
  def to_s
16
16
  name
17
17
  end
18
+
19
+ def reset_passord!
20
+ regenerate_password_reset_token
21
+ self.password_reset_sent_at = Time.current
22
+ save!
23
+ end
18
24
 
19
25
  end
20
26
  end
@@ -1 +1,476 @@
1
- <%= yield %>
1
+ <!-- The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Wildbit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE. -->
22
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
23
+ <html xmlns="http://www.w3.org/1999/xhtml">
24
+ <head>
25
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
26
+ <meta name="x-apple-disable-message-reformatting" />
27
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
28
+ <meta name="color-scheme" content="light dark" />
29
+ <meta name="supported-color-schemes" content="light dark" />
30
+ <title></title>
31
+ <style type="text/css" rel="stylesheet" media="all">
32
+ /* Base ------------------------------ */
33
+
34
+ @import url("https://fonts.googleapis.com/css?family=Nunito+Sans:400,700&amp;display=swap");
35
+ body {
36
+ width: 100% !important;
37
+ height: 100%;
38
+ margin: 0;
39
+ -webkit-text-size-adjust: none;
40
+ }
41
+
42
+ a {
43
+ color: #3869D4;
44
+ }
45
+
46
+ a img {
47
+ border: none;
48
+ }
49
+
50
+ td {
51
+ word-break: break-word;
52
+ }
53
+
54
+ .preheader {
55
+ display: none !important;
56
+ visibility: hidden;
57
+ mso-hide: all;
58
+ font-size: 1px;
59
+ line-height: 1px;
60
+ max-height: 0;
61
+ max-width: 0;
62
+ opacity: 0;
63
+ overflow: hidden;
64
+ }
65
+ /* Type ------------------------------ */
66
+
67
+ body,
68
+ td,
69
+ th {
70
+ font-family: "Nunito Sans", Helvetica, Arial, sans-serif;
71
+ }
72
+
73
+ h1 {
74
+ margin-top: 0;
75
+ color: #333333;
76
+ font-size: 22px;
77
+ font-weight: bold;
78
+ text-align: left;
79
+ }
80
+
81
+ h2 {
82
+ margin-top: 0;
83
+ color: #333333;
84
+ font-size: 16px;
85
+ font-weight: bold;
86
+ text-align: left;
87
+ }
88
+
89
+ h3 {
90
+ margin-top: 0;
91
+ color: #333333;
92
+ font-size: 14px;
93
+ font-weight: bold;
94
+ text-align: left;
95
+ }
96
+
97
+ td,
98
+ th {
99
+ font-size: 16px;
100
+ }
101
+
102
+ p,
103
+ ul,
104
+ ol,
105
+ blockquote {
106
+ margin: .4em 0 1.1875em;
107
+ font-size: 16px;
108
+ line-height: 1.625;
109
+ }
110
+
111
+ p.sub {
112
+ font-size: 13px;
113
+ }
114
+ /* Utilities ------------------------------ */
115
+
116
+ .align-right {
117
+ text-align: right;
118
+ }
119
+
120
+ .align-left {
121
+ text-align: left;
122
+ }
123
+
124
+ .align-center {
125
+ text-align: center;
126
+ }
127
+ /* Buttons ------------------------------ */
128
+
129
+ .button {
130
+ background-color: #3869D4;
131
+ border-top: 10px solid #3869D4;
132
+ border-right: 18px solid #3869D4;
133
+ border-bottom: 10px solid #3869D4;
134
+ border-left: 18px solid #3869D4;
135
+ display: inline-block;
136
+ color: #FFF;
137
+ text-decoration: none;
138
+ border-radius: 7px;
139
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16);
140
+ -webkit-text-size-adjust: none;
141
+ box-sizing: border-box;
142
+ }
143
+
144
+ .button--green {
145
+ background-color: #22BC66;
146
+ border-top: 10px solid #22BC66;
147
+ border-right: 18px solid #22BC66;
148
+ border-bottom: 10px solid #22BC66;
149
+ border-left: 18px solid #22BC66;
150
+ }
151
+
152
+ .button--spina {
153
+ background-color: #6865b4;
154
+ border-top: 10px solid #6865b4;
155
+ border-right: 18px solid #6865b4;
156
+ border-bottom: 10px solid #6865b4;
157
+ border-left: 18px solid #6865b4;
158
+ }
159
+
160
+ .button--red {
161
+ background-color: #FF6136;
162
+ border-top: 10px solid #FF6136;
163
+ border-right: 18px solid #FF6136;
164
+ border-bottom: 10px solid #FF6136;
165
+ border-left: 18px solid #FF6136;
166
+ }
167
+
168
+ @media only screen and (max-width: 500px) {
169
+ .button {
170
+ width: 100% !important;
171
+ text-align: center !important;
172
+ }
173
+ }
174
+ /* Attribute list ------------------------------ */
175
+
176
+ .attributes {
177
+ margin: 0 0 21px;
178
+ }
179
+
180
+ .attributes_content {
181
+ background-color: #F4F4F7;
182
+ padding: 16px;
183
+ }
184
+
185
+ .attributes_item {
186
+ padding: 0;
187
+ }
188
+ /* Related Items ------------------------------ */
189
+
190
+ .related {
191
+ width: 100%;
192
+ margin: 0;
193
+ padding: 25px 0 0 0;
194
+ -premailer-width: 100%;
195
+ -premailer-cellpadding: 0;
196
+ -premailer-cellspacing: 0;
197
+ }
198
+
199
+ .related_item {
200
+ padding: 10px 0;
201
+ color: #CBCCCF;
202
+ font-size: 15px;
203
+ line-height: 18px;
204
+ }
205
+
206
+ .related_item-title {
207
+ display: block;
208
+ margin: .5em 0 0;
209
+ }
210
+
211
+ .related_item-thumb {
212
+ display: block;
213
+ padding-bottom: 10px;
214
+ }
215
+
216
+ .related_heading {
217
+ border-top: 1px solid #CBCCCF;
218
+ text-align: center;
219
+ padding: 25px 0 10px;
220
+ }
221
+ /* Discount Code ------------------------------ */
222
+
223
+ .discount {
224
+ width: 100%;
225
+ margin: 0;
226
+ padding: 24px;
227
+ -premailer-width: 100%;
228
+ -premailer-cellpadding: 0;
229
+ -premailer-cellspacing: 0;
230
+ background-color: #F4F4F7;
231
+ border: 2px dashed #CBCCCF;
232
+ }
233
+
234
+ .discount_heading {
235
+ text-align: center;
236
+ }
237
+
238
+ .discount_body {
239
+ text-align: center;
240
+ font-size: 15px;
241
+ }
242
+ /* Social Icons ------------------------------ */
243
+
244
+ .social {
245
+ width: auto;
246
+ }
247
+
248
+ .social td {
249
+ padding: 0;
250
+ width: auto;
251
+ }
252
+
253
+ .social_icon {
254
+ height: 20px;
255
+ margin: 0 8px 10px 8px;
256
+ padding: 0;
257
+ }
258
+ /* Data table ------------------------------ */
259
+
260
+ .purchase {
261
+ width: 100%;
262
+ margin: 0;
263
+ padding: 35px 0;
264
+ -premailer-width: 100%;
265
+ -premailer-cellpadding: 0;
266
+ -premailer-cellspacing: 0;
267
+ }
268
+
269
+ .purchase_content {
270
+ width: 100%;
271
+ margin: 0;
272
+ padding: 25px 0 0 0;
273
+ -premailer-width: 100%;
274
+ -premailer-cellpadding: 0;
275
+ -premailer-cellspacing: 0;
276
+ }
277
+
278
+ .purchase_item {
279
+ padding: 10px 0;
280
+ color: #51545E;
281
+ font-size: 15px;
282
+ line-height: 18px;
283
+ }
284
+
285
+ .purchase_heading {
286
+ padding-bottom: 8px;
287
+ border-bottom: 1px solid #EAEAEC;
288
+ }
289
+
290
+ .purchase_heading p {
291
+ margin: 0;
292
+ color: #85878E;
293
+ font-size: 12px;
294
+ }
295
+
296
+ .purchase_footer {
297
+ padding-top: 15px;
298
+ border-top: 1px solid #EAEAEC;
299
+ }
300
+
301
+ .purchase_total {
302
+ margin: 0;
303
+ text-align: right;
304
+ font-weight: bold;
305
+ color: #333333;
306
+ }
307
+
308
+ .purchase_total--label {
309
+ padding: 0 15px 0 0;
310
+ }
311
+
312
+ body {
313
+ background-color: #FFF;
314
+ color: #333;
315
+ }
316
+
317
+ p {
318
+ color: #333;
319
+ }
320
+
321
+ .email-wrapper {
322
+ width: 100%;
323
+ margin: 0;
324
+ padding: 0;
325
+ -premailer-width: 100%;
326
+ -premailer-cellpadding: 0;
327
+ -premailer-cellspacing: 0;
328
+ }
329
+
330
+ .email-content {
331
+ width: 100%;
332
+ margin: 0;
333
+ padding: 0;
334
+ -premailer-width: 100%;
335
+ -premailer-cellpadding: 0;
336
+ -premailer-cellspacing: 0;
337
+ }
338
+ /* Masthead ----------------------- */
339
+
340
+ .email-masthead {
341
+ padding: 25px 0;
342
+ text-align: center;
343
+ }
344
+
345
+ .email-masthead_logo {
346
+ width: 94px;
347
+ }
348
+
349
+ .email-masthead_name {
350
+ font-size: 16px;
351
+ font-weight: bold;
352
+ color: #A8AAAF;
353
+ text-decoration: none;
354
+ text-shadow: 0 1px 0 white;
355
+ }
356
+ /* Body ------------------------------ */
357
+
358
+ .email-body {
359
+ width: 100%;
360
+ margin: 0;
361
+ padding: 0;
362
+ -premailer-width: 100%;
363
+ -premailer-cellpadding: 0;
364
+ -premailer-cellspacing: 0;
365
+ }
366
+
367
+ .email-body_inner {
368
+ width: 570px;
369
+ margin: 0 auto;
370
+ padding: 0;
371
+ -premailer-width: 570px;
372
+ -premailer-cellpadding: 0;
373
+ -premailer-cellspacing: 0;
374
+ }
375
+
376
+ .email-footer {
377
+ width: 570px;
378
+ margin: 0 auto;
379
+ padding: 0;
380
+ -premailer-width: 570px;
381
+ -premailer-cellpadding: 0;
382
+ -premailer-cellspacing: 0;
383
+ text-align: center;
384
+ }
385
+
386
+ .email-footer p {
387
+ color: #A8AAAF;
388
+ }
389
+
390
+ .body-action {
391
+ width: 100%;
392
+ margin: 30px auto;
393
+ padding: 0;
394
+ -premailer-width: 100%;
395
+ -premailer-cellpadding: 0;
396
+ -premailer-cellspacing: 0;
397
+ text-align: center;
398
+ }
399
+
400
+ .body-sub {
401
+ margin-top: 25px;
402
+ padding-top: 25px;
403
+ border-top: 1px solid #EAEAEC;
404
+ }
405
+
406
+ .content-cell {
407
+ padding: 35px;
408
+ }
409
+ /*Media Queries ------------------------------ */
410
+
411
+ @media only screen and (max-width: 600px) {
412
+ .email-body_inner,
413
+ .email-footer {
414
+ width: 100% !important;
415
+ }
416
+ }
417
+
418
+ @media (prefers-color-scheme: dark) {
419
+ body {
420
+ background-color: #333333 !important;
421
+ color: #FFF !important;
422
+ }
423
+ p,
424
+ ul,
425
+ ol,
426
+ blockquote,
427
+ h1,
428
+ h2,
429
+ h3,
430
+ span,
431
+ .purchase_item {
432
+ color: #FFF !important;
433
+ }
434
+ .attributes_content,
435
+ .discount {
436
+ background-color: #222 !important;
437
+ }
438
+ .email-masthead_name {
439
+ text-shadow: none !important;
440
+ }
441
+ }
442
+
443
+ :root {
444
+ color-scheme: light dark;
445
+ supported-color-schemes: light dark;
446
+ }
447
+ </style>
448
+ <!--[if mso]>
449
+ <style type="text/css">
450
+ .f-fallback {
451
+ font-family: Arial, sans-serif;
452
+ }
453
+ </style>
454
+ <![endif]-->
455
+ <style type="text/css" rel="stylesheet" media="all">
456
+ body {
457
+ width: 100% !important;
458
+ height: 100%;
459
+ margin: 0;
460
+ -webkit-text-size-adjust: none;
461
+ }
462
+
463
+ body {
464
+ font-family: "Nunito Sans", Helvetica, Arial, sans-serif;
465
+ }
466
+
467
+ body {
468
+ background-color: #FFF;
469
+ color: #333;
470
+ }
471
+ </style>
472
+ </head>
473
+ <body style="width: 100% !important; height: 100%; -webkit-text-size-adjust: none; font-family: &quot;Nunito Sans&quot;, Helvetica, Arial, sans-serif; background-color: #FFF; color: #333; margin: 0;" bgcolor="#FFF">
474
+ <%= yield %>
475
+ </body>
476
+ </html>