spina 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of spina might be problematic. Click here for more details.

Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +41 -12
  3. data/Rakefile +1 -0
  4. data/app/assets/fonts/spina/ics_spina.eot +0 -0
  5. data/app/assets/fonts/spina/ics_spina.svg +5 -3
  6. data/app/assets/fonts/spina/ics_spina.ttf +0 -0
  7. data/app/assets/fonts/spina/ics_spina.woff +0 -0
  8. data/app/assets/icons/spina/lock.svg +3 -0
  9. data/app/assets/icons/spina/preview/ics_spina-preview.html +16 -1
  10. data/app/assets/javascripts/spina/admin/application.coffee.erb +3 -25
  11. data/app/assets/javascripts/spina/admin/navigation.coffee +7 -0
  12. data/app/assets/javascripts/spina/admin/pages.coffee.erb +1 -13
  13. data/app/assets/javascripts/spina/admin/trix.coffee.erb +2 -1
  14. data/app/assets/stylesheets/spina/_admin_editing.sass +0 -4
  15. data/app/assets/stylesheets/spina/_buttons.sass +8 -8
  16. data/app/assets/stylesheets/spina/_configuration.sass +5 -1
  17. data/app/assets/stylesheets/spina/_custom_animations.sass +26 -26
  18. data/app/assets/stylesheets/spina/_fonts.sass +5 -1
  19. data/app/assets/stylesheets/spina/_forms.sass +66 -33
  20. data/app/assets/stylesheets/spina/_gallery.sass +32 -15
  21. data/app/assets/stylesheets/spina/_ics_spina.scss +1 -0
  22. data/app/assets/stylesheets/spina/_login.sass +10 -4
  23. data/app/assets/stylesheets/spina/_mixins.sass +5 -0
  24. data/app/assets/stylesheets/spina/_modal.sass +4 -4
  25. data/app/assets/stylesheets/spina/_notifications.sass +5 -5
  26. data/app/assets/stylesheets/spina/_sortable_lists.sass +9 -9
  27. data/app/assets/stylesheets/spina/_tables.sass +9 -9
  28. data/app/assets/stylesheets/spina/_wizard.sass +5 -5
  29. data/app/assets/stylesheets/spina/admin/application.sass +4 -1
  30. data/app/assets/stylesheets/spina/application.sass +0 -1
  31. data/app/assets/stylesheets/spina.sass +23 -27
  32. data/app/controllers/spina/admin/accounts_controller.rb +2 -7
  33. data/app/controllers/spina/admin/admin_controller.rb +8 -3
  34. data/app/controllers/spina/admin/attachments_controller.rb +0 -2
  35. data/app/controllers/spina/admin/navigations_controller.rb +3 -2
  36. data/app/controllers/spina/admin/pages_controller.rb +7 -8
  37. data/app/controllers/spina/admin/password_resets_controller.rb +49 -0
  38. data/app/controllers/spina/admin/photos_controller.rb +15 -34
  39. data/app/controllers/spina/admin/sessions_controller.rb +1 -1
  40. data/app/controllers/spina/admin/users_controller.rb +8 -9
  41. data/app/controllers/spina/application_controller.rb +3 -9
  42. data/app/controllers/spina/pages_controller.rb +3 -3
  43. data/app/helpers/spina/admin/pages_helper.rb +16 -23
  44. data/app/mailers/spina/user_mailer.rb +21 -0
  45. data/app/models/concerns/spina/optionable.rb +12 -0
  46. data/app/models/concerns/spina/part.rb +5 -1
  47. data/app/models/concerns/spina/partable.rb +20 -5
  48. data/app/models/concerns/spina/photo_collectable.rb +24 -0
  49. data/app/models/spina/account.rb +16 -6
  50. data/app/models/spina/layout_part.rb +1 -0
  51. data/app/models/spina/option.rb +17 -0
  52. data/app/models/spina/page.rb +36 -63
  53. data/app/models/spina/page_part.rb +1 -0
  54. data/app/models/spina/photo_collection.rb +1 -13
  55. data/app/models/spina/structure_item.rb +4 -8
  56. data/app/models/spina/structure_part.rb +2 -13
  57. data/app/models/spina/user.rb +1 -0
  58. data/app/presenters/spina/pages/menu_presenter.rb +18 -49
  59. data/app/views/layouts/spina/mail.html.erb +1 -0
  60. data/app/views/spina/admin/page_partables/{colors → options}/_form.html.haml +2 -3
  61. data/app/views/spina/admin/page_partables/photo_collections/_form.html.haml +7 -7
  62. data/app/views/spina/admin/page_partables/structures/_form.html.haml +7 -8
  63. data/app/views/spina/admin/pages/_form.html.haml +2 -2
  64. data/app/views/spina/admin/pages/_form_advanced.html.haml +2 -2
  65. data/app/views/spina/admin/password_resets/edit.html.haml +13 -0
  66. data/app/views/spina/admin/password_resets/new.html.haml +13 -0
  67. data/app/views/spina/admin/photos/_photo.html.haml +2 -1
  68. data/app/views/spina/admin/photos/{_wysihtml5_select.html.haml → _trix_select.html.haml} +2 -4
  69. data/app/views/spina/admin/photos/create.js.erb +3 -5
  70. data/app/views/spina/admin/photos/{wysihtml5_infinite_scroll.js.erb → trix_infinite_scroll.js.erb} +0 -2
  71. data/app/views/spina/admin/photos/{wysihtml5_insert.js.coffee → trix_insert.js.erb} +2 -2
  72. data/app/views/spina/admin/photos/trix_select.js.erb +3 -0
  73. data/app/views/spina/admin/sessions/new.html.haml +3 -1
  74. data/app/views/spina/admin/shared/_primary_navigation.html.haml +1 -1
  75. data/app/views/spina/admin/shared/_rich_text_field.html.haml +2 -1
  76. data/app/views/spina/admin/structure_items/_fields.html.haml +3 -3
  77. data/app/views/spina/admin/structure_partables/lines/_form.html.haml +5 -2
  78. data/app/views/spina/admin/structure_partables/options/_form.html.haml +7 -0
  79. data/app/views/spina/admin/structure_partables/photo_collections/_form.html.haml +12 -9
  80. data/app/views/spina/admin/structure_partables/photos/_form.html.haml +10 -7
  81. data/app/views/spina/admin/structure_partables/texts/_form.html.haml +5 -2
  82. data/app/views/spina/admin/users/_form.html.haml +1 -1
  83. data/app/views/spina/shared/_admin_bar.html.haml +1 -1
  84. data/app/views/spina/shared/_navigation.html.haml +1 -1
  85. data/app/views/spina/user_mailer/forgot_password.html.erb +1 -0
  86. data/app/views/spina/user_mailer/forgot_password.txt.erb +1 -0
  87. data/config/locales/en.yml +10 -0
  88. data/config/locales/nl.yml +2 -0
  89. data/config/routes.rb +5 -9
  90. data/db/migrate/1_create_spina_tables.rb +8 -7
  91. data/db/migrate/2_create_spina_translation_tables.rb +7 -26
  92. data/db/migrate/3_create_spina_navigations.rb +1 -1
  93. data/db/migrate/4_add_password_reset_token_to_spina_users.rb +6 -0
  94. data/db/migrate/5_remove_translated_columns.rb +11 -0
  95. data/db/migrate/6_create_spina_options.rb +8 -0
  96. data/lib/generators/spina/install_generator.rb +0 -22
  97. data/lib/generators/spina/templates/app/views/default/shared/_navigation.html.haml +1 -1
  98. data/lib/generators/spina/templates/app/views/demo/shared/_navigation.html.haml +1 -1
  99. data/lib/generators/spina/templates/config/initializers/themes/default.rb +9 -0
  100. data/lib/generators/spina/templates/config/initializers/themes/demo.rb +1 -9
  101. data/lib/spina/engine.rb +4 -3
  102. data/lib/spina/theme.rb +2 -1
  103. data/lib/spina/version.rb +1 -1
  104. data/lib/spina.rb +0 -23
  105. metadata +32 -69
  106. data/app/assets/images/spina/marker.png +0 -0
  107. data/app/assets/images/spina/mask.png +0 -0
  108. data/app/assets/images/spina/wheel.png +0 -0
  109. data/app/assets/stylesheets/spina/_cards.sass +0 -54
  110. data/app/assets/stylesheets/spina/_farbtastic.sass +0 -37
  111. data/app/assets/stylesheets/spina/_wysihtml5.sass +0 -79
  112. data/app/assets/stylesheets/spina/wysihtml5_textarea.sass +0 -14
  113. data/app/controllers/spina/admin/page_parts_controller.rb +0 -11
  114. data/app/helpers/spina/application_helper.rb +0 -30
  115. data/app/models/spina/ability.rb +0 -20
  116. data/app/models/spina/color.rb +0 -7
  117. data/app/presenters/spina/pages/breadcrumb.rb +0 -102
  118. data/app/views/layouts/spina/email.html.erb +0 -124
  119. data/app/views/spina/admin/layout_partables/colors/_form.html.haml +0 -4
  120. data/app/views/spina/admin/page_parts/_wysihtml5_link.html.haml +0 -12
  121. data/app/views/spina/admin/page_parts/insert_wysihtml5_link.js +0 -5
  122. data/app/views/spina/admin/page_parts/wysihtml5_link.js +0 -2
  123. data/app/views/spina/admin/photos/create_and_select.js.erb +0 -7
  124. data/app/views/spina/admin/photos/create_multiple.js.erb +0 -4
  125. data/app/views/spina/admin/photos/wysihtml5_select.js.erb +0 -3
  126. data/vendor/assets/javascripts/spina/jquery.farbtastic.js +0 -345
  127. data/vendor/assets/javascripts/spina/morris.js +0 -1767
  128. data/vendor/assets/javascripts/spina/raphael.js +0 -8111
  129. data/vendor/assets/javascripts/spina/wysihtml5.js +0 -269
  130. data/vendor/assets/javascripts/spina/wysihtml5_parser_rules.js +0 -551
  131. data/vendor/assets/stylesheets/spina/_morris.scss +0 -2
@@ -1,12 +1,12 @@
1
1
  .wizard-steps
2
+ display: flex
2
3
  margin: 30px 0 54px 0
3
- @include display(flex)
4
4
 
5
5
  .wizard-step
6
- @include display(flex)
6
+ display: flex
7
7
 
8
8
  &:not(:last-child)
9
- @include flex(1)
9
+ flex: 1
10
10
 
11
11
  .wizard-step-circle
12
12
  background: #e7e7ee
@@ -36,7 +36,7 @@
36
36
  left: 0
37
37
  position: absolute
38
38
  top: 56px
39
- @include transform(translateX(-50%))
39
+ transform: translateX(-50%)
40
40
 
41
41
  i.icon
42
42
  color: #dddde5
@@ -52,12 +52,12 @@
52
52
  background: #e7e7ee
53
53
  border-bottom: 1px solid #d6d6db
54
54
  border-top: 1px solid #d6d6db
55
+ flex: 1
55
56
  height: 12px
56
57
  margin: 0 -1px
57
58
  margin-top: 18px
58
59
  position: relative
59
60
  z-index: 3
60
- @include flex(1)
61
61
 
62
62
  .wizard-step.done
63
63
  .wizard-step-circle:before
@@ -1,4 +1,7 @@
1
1
  @import spina
2
2
 
3
3
  .infinite-scroll
4
- @include clearfix
4
+ &:after
5
+ clear: both
6
+ content: " "
7
+ display: block
@@ -1,5 +1,4 @@
1
1
  @import normalize.css
2
- @import bourbon
3
2
  @import spina/admin_editing
4
3
 
5
4
  // Customize below
@@ -1,10 +1,9 @@
1
- // Frameworks
2
- @import bourbon
3
- @import neat
4
-
5
1
  // Configuration
6
2
  @import spina/configuration
7
3
 
4
+ // Mixins
5
+ @import spina/mixins
6
+
8
7
  // Normalizing
9
8
  @import spina/normalize
10
9
 
@@ -25,15 +24,10 @@
25
24
  @import spina/sortable_lists
26
25
  @import spina/gallery
27
26
  @import spina/login
28
- @import spina/cards
29
27
  @import spina/trix
30
28
  @import spina/wizard
31
29
  @import spina/notifications
32
30
 
33
- // Plugins
34
- @import spina/morris
35
- @import spina/wysihtml5
36
- @import spina/farbtastic
37
31
 
38
32
  html
39
33
  box-sizing: border-box
@@ -53,12 +47,12 @@ body
53
47
 
54
48
  // Primary navigation
55
49
  nav#primary
50
+ background: linear-gradient(#3b3f74, #7a76ad)
56
51
  height: 100%
57
52
  overflow: hidden
58
53
  position: fixed
59
54
  width: 300px
60
55
  z-index: 5
61
- @include linear-gradient(#3b3f74, #7a76ad)
62
56
 
63
57
  & > ul
64
58
  height: 100%
@@ -106,15 +100,15 @@ nav#primary
106
100
  opacity: 1
107
101
 
108
102
  ul li ul
103
+ background: linear-gradient(#3b3f74, #7a76ad)
109
104
  bottom: 0
110
105
  left: 80px
111
106
  padding-top: 20px
112
107
  position: absolute
113
108
  top: 0
109
+ transform: translateX(100%)
114
110
  width: calc(100% - 80px)
115
111
  z-index: 1
116
- @include linear-gradient(#3b3f74, #7a76ad)
117
- @include transform(translateX(100%))
118
112
 
119
113
  li a
120
114
  line-height: 40px
@@ -151,9 +145,9 @@ nav#primary
151
145
  right: 20px
152
146
  text-align: center
153
147
  top: 50%
148
+ transform: translateY(-50%)
154
149
  vertical-align: middle
155
150
  z-index: 1
156
- @include transform(translateY(-50%))
157
151
 
158
152
  ul li ul li[data-badge] a
159
153
  z-index: 2
@@ -163,30 +157,30 @@ nav#primary
163
157
  background: rgba(255, 255, 255, .9)
164
158
 
165
159
  &.animated > ul
166
- @include transition(background .3s ease)
160
+ transition: background .3s ease
167
161
 
168
162
  & > li > a
169
- @include transition(all .3s ease)
163
+ transition: all .3s ease
170
164
 
171
165
  .icon
172
- @include transition(all .3s ease)
166
+ transition: all .3s ease
173
167
 
174
168
  li.active ul
175
- @include transition(all .3s ease)
169
+ transition: all .3s ease
176
170
 
177
171
  &.transformed > ul
178
172
  background: rgba(0, 0, 0, .4)
179
173
 
180
174
  & > li > a
181
175
  color: transparent
182
- @include transform(translateX(-10px))
176
+ transform: translateX(-10px)
183
177
 
184
178
  .icon
185
179
  color: #f5f5fa
186
- @include transform(translateX(10px))
180
+ transform: translateX(10px)
187
181
 
188
182
  li.active ul
189
- @include transform(translateX(0%))
183
+ transform: translateX(0%)
190
184
 
191
185
  // Secondary navigation
192
186
  nav#secondary
@@ -216,8 +210,8 @@ nav#secondary
216
210
  left: 0px
217
211
  opacity: 0
218
212
  position: absolute
213
+ transform: scale(0)
219
214
  width: 100%
220
- @include transform(scale(0))
221
215
 
222
216
  ul li a:hover
223
217
  opacity: 1
@@ -230,9 +224,9 @@ nav#secondary
230
224
 
231
225
  &:after
232
226
  opacity: 1
233
- @include transform(scale(1))
234
- @include transition(all .2s ease)
235
- @include transition-delay(.05s)
227
+ transform: scale(1)
228
+ transition: all .2s ease
229
+ transition-delay: .05s
236
230
 
237
231
  ul li:first-child a
238
232
  margin-left: 0
@@ -527,8 +521,10 @@ hr.divider
527
521
  .pull-right
528
522
  float: right
529
523
 
530
- .clearfix
531
- @include clearfix()
524
+ .clearfix:after
525
+ clear: both
526
+ content: " "
527
+ display: block
532
528
 
533
529
  .spina-logo
534
530
  bottom: 0px
@@ -536,7 +532,7 @@ hr.divider
536
532
  padding: 20px
537
533
  position: fixed
538
534
  right: 0px
539
- @include transition(opacity .2s ease)
535
+ transition: opacity .2s ease
540
536
 
541
537
  &:hover
542
538
  opacity: 1
@@ -2,18 +2,13 @@ module Spina
2
2
  module Admin
3
3
  class AccountsController < AdminController
4
4
 
5
- authorize_resource class: Account
6
-
7
5
  def edit
8
6
  add_breadcrumb I18n.t('spina.preferences.account'), spina.edit_admin_account_path
9
7
  end
10
8
 
11
9
  def update
12
- if current_account.update_attributes(account_params)
13
- redirect_to :back
14
- else
15
- redirect_to :back
16
- end
10
+ current_account.update_attributes(account_params)
11
+ redirect_back fallback_location: spina.edit_admin_account_path
17
12
  end
18
13
 
19
14
  def analytics
@@ -2,7 +2,7 @@ module Spina
2
2
  module Admin
3
3
  class AdminController < ::Spina::ApplicationController
4
4
  before_action :set_admin_locale
5
- before_action :authorize_user
5
+ before_action :authorize_spina_user
6
6
 
7
7
  def current_admin_path
8
8
  request.fullpath[%r{/#{ Spina.config.backend_path }(.*)}, 1]
@@ -15,9 +15,14 @@ module Spina
15
15
  I18n.locale = I18n.default_locale
16
16
  end
17
17
 
18
- def authorize_user
19
- redirect_to spina.admin_login_url, flash: {information: I18n.t('spina.notifications.login')} unless current_user
18
+ def authorize_spina_user
19
+ redirect_to spina.admin_login_url, flash: {information: I18n.t('spina.notifications.login')} unless current_spina_user
20
20
  end
21
+
22
+ def authorize_admin
23
+ render status: 401 unless current_spina_user.admin?
24
+ end
25
+
21
26
  end
22
27
  end
23
28
  end
@@ -3,8 +3,6 @@ module Spina
3
3
  class AttachmentsController < AdminController
4
4
  before_action :set_breadcrumbs
5
5
 
6
- authorize_resource class: Attachment
7
-
8
6
  layout "spina/admin/media_library"
9
7
 
10
8
  def index
@@ -5,19 +5,20 @@ module Spina
5
5
 
6
6
  before_action :set_breadcrumb, except: [:show]
7
7
 
8
- load_and_authorize_resource class: Navigation
9
-
10
8
  def show
9
+ @navigation = Navigation.find(params[:id])
11
10
  add_breadcrumb t('spina.website.pages')
12
11
  end
13
12
 
14
13
  def edit
14
+ @navigation = Navigation.find(params[:id])
15
15
  add_breadcrumb @navigation.label, spina.admin_navigation_path(@navigation)
16
16
  add_breadcrumb t('spina.edit')
17
17
  render layout: 'spina/admin/admin'
18
18
  end
19
19
 
20
20
  def update
21
+ @navigation = Navigation.find(params[:id])
21
22
  if @navigation.update_attributes(navigation_params)
22
23
  redirect_to spina.admin_navigation_path(@navigation)
23
24
  else
@@ -5,8 +5,6 @@ module Spina
5
5
  before_action :set_tabs, only: [:new, :create, :edit, :update]
6
6
  before_action :set_locale
7
7
 
8
- authorize_resource class: Page
9
-
10
8
  def index
11
9
  redirect_to admin_pages_path unless current_admin_path.starts_with?('/pages')
12
10
  @pages = Page.active.sorted.roots
@@ -18,7 +16,7 @@ module Spina
18
16
  @page.view_template = params[:view_template]
19
17
  end
20
18
  add_breadcrumb I18n.t('spina.pages.new')
21
- @page_parts = @page.view_template_page_parts(current_theme).map { |part| @page.page_part(part) }
19
+ @page_parts = @page.view_template_page_parts(current_theme).map { |part| @page.part(part) }
22
20
  render layout: 'spina/admin/admin'
23
21
  end
24
22
 
@@ -26,9 +24,10 @@ module Spina
26
24
  @page = Page.new(page_params)
27
25
  add_breadcrumb I18n.t('spina.pages.new')
28
26
  if @page.save
29
- redirect_to spina.edit_admin_page_url(@page)
27
+ @page.navigations << Spina::Navigation.where(auto_add_pages: true)
28
+ redirect_to spina.edit_admin_page_url(@page), flash: {success: t('spina.pages.saved')}
30
29
  else
31
- @page_parts = @page.page_parts
30
+ @page_parts = @page.view_template_page_parts(current_theme).map { |part| @page.part(part) }
32
31
  render :new, layout: 'spina/admin/admin'
33
32
  end
34
33
  end
@@ -36,7 +35,7 @@ module Spina
36
35
  def edit
37
36
  @page = Page.find(params[:id])
38
37
  add_breadcrumb @page.title
39
- @page_parts = @page.view_template_page_parts(current_theme).map { |part| @page.page_part(part) }
38
+ @page_parts = @page.view_template_page_parts(current_theme).map { |part| @page.part(part) }
40
39
  render layout: 'spina/admin/admin'
41
40
  end
42
41
 
@@ -48,11 +47,11 @@ module Spina
48
47
  add_breadcrumb @page.title
49
48
  @page.touch
50
49
  I18n.locale = I18n.default_locale
51
- format.html { redirect_to spina.edit_admin_page_url(@page, params: {locale: @locale}) }
50
+ format.html { redirect_to spina.edit_admin_page_url(@page, params: {locale: @locale}), flash: {success: t('spina.pages.saved')} }
52
51
  format.js
53
52
  else
54
53
  format.html do
55
- @page_parts = @page.page_parts
54
+ @page_parts = @page.view_template_page_parts(current_theme).map { |part| @page.part(part) }
56
55
  render :edit, layout: 'spina/admin/admin'
57
56
  end
58
57
  end
@@ -0,0 +1,49 @@
1
+ module Spina
2
+ module Admin
3
+ class PasswordResetsController < AdminController
4
+ layout "spina/login"
5
+
6
+ skip_before_action :authorize_spina_user
7
+
8
+ def new
9
+ end
10
+
11
+ def create
12
+ user = User.find_by(email: params[:email])
13
+
14
+ if user.present?
15
+ user.regenerate_password_reset_token
16
+ user.update_attributes!(password_reset_sent_at: Time.zone.now)
17
+ UserMailer.forgot_password(user).deliver_now
18
+ redirect_to admin_login_path, flash: {success: t('spina.forgot_password.instructions_sent')}
19
+ else
20
+ flash.now[:alert] = t('spina.forgot_password.unknown_user')
21
+ render :new
22
+ end
23
+ end
24
+
25
+ def edit
26
+ @user = User.find_by!(password_reset_token: params[:id])
27
+ end
28
+
29
+ def update
30
+ @user = User.find_by(password_reset_token: params[:id])
31
+
32
+ if @user.password_reset_sent_at < 2.hours.ago
33
+ redirect_to new_admin_password_reset_path, flash: {alert: t('spina.forgot_password.expired')}
34
+ elsif @user.update_attributes(user_params)
35
+ redirect_to admin_login_path, flash: {success: t('spina.forgot_password.success')}
36
+ else
37
+ render :edit
38
+ end
39
+ end
40
+
41
+ private
42
+
43
+ def user_params
44
+ params.require(:user).permit(:password, :password_confirmation)
45
+ end
46
+
47
+ end
48
+ end
49
+ end
@@ -3,8 +3,6 @@ module Spina
3
3
  class PhotosController < AdminController
4
4
  before_action :set_breadcrumbs
5
5
 
6
- authorize_resource class: Photo
7
-
8
6
  layout "spina/admin/media_library"
9
7
 
10
8
  def index
@@ -18,25 +16,8 @@ module Spina
18
16
  end
19
17
 
20
18
  def create
21
- if photo_params[:files].present?
22
- @photos = photo_params[:files].map do |file|
23
- Photo.create!(file: file)
24
- end
25
- respond_to do |format|
26
- format.js do
27
- render :create_multiple
28
- end
29
- end
30
- else
31
- @photo = Photo.create!(photo_params)
32
- respond_to do |format|
33
- format.js do
34
- render params[:media_library] ? :create : :create_and_select
35
- end
36
- format.json do
37
- render json: { file_url: @photo.file_url }
38
- end
39
- end
19
+ @photos = photo_params[:files].map do |file|
20
+ Photo.create!(file: file)
40
21
  end
41
22
  end
42
23
 
@@ -89,19 +70,19 @@ module Spina
89
70
  @photos = Photo.find(params[:photo_ids]) if params[:photo_ids].present?
90
71
  end
91
72
 
92
- def wysihtml5_insert
93
- @photo = Photo.find(params[:photo_id])
73
+ def trix_insert
74
+ @photo = Photo.find(params[:photo_id])
94
75
  end
95
-
96
- def wysihtml5_select
97
- @photos = Photo.sorted.page(params[:page])
98
- @photo = Photo.new
99
-
100
- if params[:page].present?
101
- render :wysihtml5_infinite_scroll
102
- else
103
- render :wysihtml5_select
104
- end
76
+
77
+ def trix_select
78
+ @photos = Photo.sorted.page(params[:page])
79
+ @photo = Photo.new
80
+
81
+ if params[:page].present?
82
+ render :trix_infinite_scroll
83
+ else
84
+ render :trix_select
85
+ end
105
86
  end
106
87
 
107
88
  private
@@ -111,7 +92,7 @@ module Spina
111
92
  end
112
93
 
113
94
  def photo_params
114
- params.require(:photo).permit(:file, files: [])
95
+ params.require(:photo).permit(files: [])
115
96
  end
116
97
 
117
98
  end
@@ -4,7 +4,7 @@ module Spina
4
4
 
5
5
  layout "spina/login"
6
6
 
7
- skip_before_action :authorize_user
7
+ skip_before_action :authorize_spina_user
8
8
 
9
9
  def new
10
10
  end
@@ -2,8 +2,7 @@ module Spina
2
2
  module Admin
3
3
  class UsersController < AdminController
4
4
  before_action :set_breadcrumbs
5
-
6
- authorize_resource class: User
5
+ before_action :authorize_admin, except: [:index]
7
6
 
8
7
  def index
9
8
  @users = User.all
@@ -43,19 +42,19 @@ module Spina
43
42
 
44
43
  def destroy
45
44
  @user = User.find(params[:id])
46
- @user.destroy unless @user == current_user
45
+ @user.destroy unless @user == current_spina_user
47
46
  redirect_to admin_users_url
48
47
  end
49
48
 
50
49
  private
51
50
 
52
- def set_breadcrumbs
53
- add_breadcrumb I18n.t('spina.preferences.users'), spina.admin_users_path
54
- end
51
+ def set_breadcrumbs
52
+ add_breadcrumb I18n.t('spina.preferences.users'), spina.admin_users_path
53
+ end
55
54
 
56
- def user_params
57
- params.require(:user).permit(:admin, :email, :name, :password_digest, :password, :password_confirmation, :last_logged_in)
58
- end
55
+ def user_params
56
+ params.require(:user).permit(:admin, :email, :name, :password_digest, :password, :password_confirmation, :last_logged_in)
57
+ end
59
58
 
60
59
  end
61
60
  end
@@ -3,23 +3,17 @@ module Spina
3
3
 
4
4
  protect_from_forgery with: :exception
5
5
 
6
- include ApplicationHelper
7
-
8
6
  private
9
7
 
10
- def current_ability
11
- @current_ability ||= Ability.new(current_user)
12
- end
13
-
14
8
  def current_theme
15
9
  @current_theme = ::Spina::Theme.find_by_name(current_account.theme)
16
10
  end
17
11
  helper_method :current_theme
18
12
 
19
- def current_user
20
- @current_user ||= ::Spina::User.where(id: session[:user_id]).first if session[:user_id]
13
+ def current_spina_user
14
+ @current_spina_user ||= ::Spina::User.where(id: session[:user_id]).first if session[:user_id]
21
15
  end
22
- helper_method :current_user
16
+ helper_method :current_spina_user
23
17
 
24
18
  def current_account
25
19
  @current_account ||= ::Spina::Account.first
@@ -4,7 +4,7 @@ module Spina
4
4
 
5
5
  rescue_from ActiveRecord::RecordNotFound, with: :render_404
6
6
 
7
- before_action :current_user_can_view_page?, except: [:robots]
7
+ before_action :current_spina_user_can_view_page?, except: [:robots]
8
8
 
9
9
  helper_method :page
10
10
 
@@ -14,10 +14,10 @@ module Spina
14
14
 
15
15
  private
16
16
 
17
- def current_user_can_view_page?
17
+ def current_spina_user_can_view_page?
18
18
  raise ActiveRecord::RecordNotFound if page.nil? || !page.live?
19
19
 
20
- current_user.present?
20
+ current_spina_user.present?
21
21
  end
22
22
 
23
23
  def render_404
@@ -1,35 +1,24 @@
1
1
  module Spina
2
2
  module Admin
3
3
  module PagesHelper
4
- def link_to_add_structure_item_fields(f, association, &block)
5
- new_object = f.object.send(association).klass.new
6
- id = new_object.object_id
7
- fields = f.fields_for(association, new_object, child_index: id) do |builder|
8
- build_structure_parts(f.object.page_part.name, new_object) if structure_item?(new_object)
9
- render("spina/admin/#{ partable_partial_namespace(new_object) }/fields", f: builder)
4
+ def link_to_add_structure_item_fields(f, &block)
5
+ item = StructureItem.new
6
+ fields = f.fields_for(:structure_items, item, child_index: item.object_id) do |builder|
7
+ build_structure_parts(f.object.page_part.name, item)
8
+ render("spina/admin/structure_items/fields", f: builder)
10
9
  end
11
- link_to '#', class: "#{add_structure_item_fields_class(new_object)} button button-link", data: {id: id, fields: fields.gsub("\n", "")} do
12
- block.yield
10
+ link_to '#', class: "add_structure_item_fields button button-link", data: {id: item.object_id, fields: fields.gsub("\n", "")} do
11
+ icon('plus')
13
12
  end
14
13
  end
15
14
 
16
- def add_structure_item_fields_class(object)
17
- structure_item?(object) ? 'add_structure' : 'add_structure_item_fields'
18
- end
19
-
20
- def structure_item?(object)
21
- object.class.name.demodulize == "StructureItem"
22
- end
23
-
24
15
  def build_structure_parts(name, item)
25
16
  structure = current_theme.structures.find { |structure| structure[:name] == name }
26
- return item.structure_parts unless structure.present?
27
- structure[:structure_parts].map do |structure_part|
28
- part = item.structure_parts.where(name: structure_part[:name]).first
29
- if part.nil?
30
- part = item.structure_parts.build(structure_part)
31
- part.structure_partable = structure_part[:partable_type].constantize.new
32
- end
17
+ return item.parts unless structure.present?
18
+ structure[:structure_parts].map do |attributes|
19
+ part = item.parts.where(name: attributes[:name]).first_or_initialize(attributes)
20
+ part.partable = part.partable_type.constantize.new if part.partable.blank?
21
+ part.options = attributes[:options]
33
22
  part
34
23
  end
35
24
  end
@@ -57,6 +46,10 @@ module Spina
57
46
  end.compact
58
47
  end
59
48
 
49
+ def option_label(part, value)
50
+ t(['options',part.name,value].compact.join('.'))
51
+ end
52
+
60
53
  end
61
54
  end
62
55
  end
@@ -0,0 +1,21 @@
1
+ module Spina
2
+ class UserMailer < ActionMailer::Base
3
+ layout 'spina/mail'
4
+
5
+ def forgot_password(user)
6
+ @user = user
7
+
8
+ mail(
9
+ to: @user.email,
10
+ from: current_account.email,
11
+ subject: t('spina.forgot_password.mail_subject')
12
+ )
13
+ end
14
+
15
+ private
16
+
17
+ def current_account
18
+ Spina::Account.first
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,12 @@
1
+ require 'active_support/concern'
2
+
3
+ module Spina
4
+ module Optionable
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ attr_accessor :options
9
+ end
10
+
11
+ end
12
+ end
@@ -20,6 +20,10 @@ module Spina
20
20
  self.partable.try(:content)
21
21
  end
22
22
 
23
+ def value
24
+ self.partable.try(:value)
25
+ end
26
+
23
27
  def partable_attributes=(attributes)
24
28
  if self.partable.present?
25
29
  self.partable.assign_attributes(attributes)
@@ -28,4 +32,4 @@ module Spina
28
32
  end
29
33
  end
30
34
  end
31
- end
35
+ end