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.
- checksums.yaml +4 -4
- data/README.md +41 -12
- data/Rakefile +1 -0
- data/app/assets/fonts/spina/ics_spina.eot +0 -0
- data/app/assets/fonts/spina/ics_spina.svg +5 -3
- data/app/assets/fonts/spina/ics_spina.ttf +0 -0
- data/app/assets/fonts/spina/ics_spina.woff +0 -0
- data/app/assets/icons/spina/lock.svg +3 -0
- data/app/assets/icons/spina/preview/ics_spina-preview.html +16 -1
- data/app/assets/javascripts/spina/admin/application.coffee.erb +3 -25
- data/app/assets/javascripts/spina/admin/navigation.coffee +7 -0
- data/app/assets/javascripts/spina/admin/pages.coffee.erb +1 -13
- data/app/assets/javascripts/spina/admin/trix.coffee.erb +2 -1
- data/app/assets/stylesheets/spina/_admin_editing.sass +0 -4
- data/app/assets/stylesheets/spina/_buttons.sass +8 -8
- data/app/assets/stylesheets/spina/_configuration.sass +5 -1
- data/app/assets/stylesheets/spina/_custom_animations.sass +26 -26
- data/app/assets/stylesheets/spina/_fonts.sass +5 -1
- data/app/assets/stylesheets/spina/_forms.sass +66 -33
- data/app/assets/stylesheets/spina/_gallery.sass +32 -15
- data/app/assets/stylesheets/spina/_ics_spina.scss +1 -0
- data/app/assets/stylesheets/spina/_login.sass +10 -4
- data/app/assets/stylesheets/spina/_mixins.sass +5 -0
- data/app/assets/stylesheets/spina/_modal.sass +4 -4
- data/app/assets/stylesheets/spina/_notifications.sass +5 -5
- data/app/assets/stylesheets/spina/_sortable_lists.sass +9 -9
- data/app/assets/stylesheets/spina/_tables.sass +9 -9
- data/app/assets/stylesheets/spina/_wizard.sass +5 -5
- data/app/assets/stylesheets/spina/admin/application.sass +4 -1
- data/app/assets/stylesheets/spina/application.sass +0 -1
- data/app/assets/stylesheets/spina.sass +23 -27
- data/app/controllers/spina/admin/accounts_controller.rb +2 -7
- data/app/controllers/spina/admin/admin_controller.rb +8 -3
- data/app/controllers/spina/admin/attachments_controller.rb +0 -2
- data/app/controllers/spina/admin/navigations_controller.rb +3 -2
- data/app/controllers/spina/admin/pages_controller.rb +7 -8
- data/app/controllers/spina/admin/password_resets_controller.rb +49 -0
- data/app/controllers/spina/admin/photos_controller.rb +15 -34
- data/app/controllers/spina/admin/sessions_controller.rb +1 -1
- data/app/controllers/spina/admin/users_controller.rb +8 -9
- data/app/controllers/spina/application_controller.rb +3 -9
- data/app/controllers/spina/pages_controller.rb +3 -3
- data/app/helpers/spina/admin/pages_helper.rb +16 -23
- data/app/mailers/spina/user_mailer.rb +21 -0
- data/app/models/concerns/spina/optionable.rb +12 -0
- data/app/models/concerns/spina/part.rb +5 -1
- data/app/models/concerns/spina/partable.rb +20 -5
- data/app/models/concerns/spina/photo_collectable.rb +24 -0
- data/app/models/spina/account.rb +16 -6
- data/app/models/spina/layout_part.rb +1 -0
- data/app/models/spina/option.rb +17 -0
- data/app/models/spina/page.rb +36 -63
- data/app/models/spina/page_part.rb +1 -0
- data/app/models/spina/photo_collection.rb +1 -13
- data/app/models/spina/structure_item.rb +4 -8
- data/app/models/spina/structure_part.rb +2 -13
- data/app/models/spina/user.rb +1 -0
- data/app/presenters/spina/pages/menu_presenter.rb +18 -49
- data/app/views/layouts/spina/mail.html.erb +1 -0
- data/app/views/spina/admin/page_partables/{colors → options}/_form.html.haml +2 -3
- data/app/views/spina/admin/page_partables/photo_collections/_form.html.haml +7 -7
- data/app/views/spina/admin/page_partables/structures/_form.html.haml +7 -8
- data/app/views/spina/admin/pages/_form.html.haml +2 -2
- data/app/views/spina/admin/pages/_form_advanced.html.haml +2 -2
- data/app/views/spina/admin/password_resets/edit.html.haml +13 -0
- data/app/views/spina/admin/password_resets/new.html.haml +13 -0
- data/app/views/spina/admin/photos/_photo.html.haml +2 -1
- data/app/views/spina/admin/photos/{_wysihtml5_select.html.haml → _trix_select.html.haml} +2 -4
- data/app/views/spina/admin/photos/create.js.erb +3 -5
- data/app/views/spina/admin/photos/{wysihtml5_infinite_scroll.js.erb → trix_infinite_scroll.js.erb} +0 -2
- data/app/views/spina/admin/photos/{wysihtml5_insert.js.coffee → trix_insert.js.erb} +2 -2
- data/app/views/spina/admin/photos/trix_select.js.erb +3 -0
- data/app/views/spina/admin/sessions/new.html.haml +3 -1
- data/app/views/spina/admin/shared/_primary_navigation.html.haml +1 -1
- data/app/views/spina/admin/shared/_rich_text_field.html.haml +2 -1
- data/app/views/spina/admin/structure_items/_fields.html.haml +3 -3
- data/app/views/spina/admin/structure_partables/lines/_form.html.haml +5 -2
- data/app/views/spina/admin/structure_partables/options/_form.html.haml +7 -0
- data/app/views/spina/admin/structure_partables/photo_collections/_form.html.haml +12 -9
- data/app/views/spina/admin/structure_partables/photos/_form.html.haml +10 -7
- data/app/views/spina/admin/structure_partables/texts/_form.html.haml +5 -2
- data/app/views/spina/admin/users/_form.html.haml +1 -1
- data/app/views/spina/shared/_admin_bar.html.haml +1 -1
- data/app/views/spina/shared/_navigation.html.haml +1 -1
- data/app/views/spina/user_mailer/forgot_password.html.erb +1 -0
- data/app/views/spina/user_mailer/forgot_password.txt.erb +1 -0
- data/config/locales/en.yml +10 -0
- data/config/locales/nl.yml +2 -0
- data/config/routes.rb +5 -9
- data/db/migrate/1_create_spina_tables.rb +8 -7
- data/db/migrate/2_create_spina_translation_tables.rb +7 -26
- data/db/migrate/3_create_spina_navigations.rb +1 -1
- data/db/migrate/4_add_password_reset_token_to_spina_users.rb +6 -0
- data/db/migrate/5_remove_translated_columns.rb +11 -0
- data/db/migrate/6_create_spina_options.rb +8 -0
- data/lib/generators/spina/install_generator.rb +0 -22
- data/lib/generators/spina/templates/app/views/default/shared/_navigation.html.haml +1 -1
- data/lib/generators/spina/templates/app/views/demo/shared/_navigation.html.haml +1 -1
- data/lib/generators/spina/templates/config/initializers/themes/default.rb +9 -0
- data/lib/generators/spina/templates/config/initializers/themes/demo.rb +1 -9
- data/lib/spina/engine.rb +4 -3
- data/lib/spina/theme.rb +2 -1
- data/lib/spina/version.rb +1 -1
- data/lib/spina.rb +0 -23
- metadata +32 -69
- data/app/assets/images/spina/marker.png +0 -0
- data/app/assets/images/spina/mask.png +0 -0
- data/app/assets/images/spina/wheel.png +0 -0
- data/app/assets/stylesheets/spina/_cards.sass +0 -54
- data/app/assets/stylesheets/spina/_farbtastic.sass +0 -37
- data/app/assets/stylesheets/spina/_wysihtml5.sass +0 -79
- data/app/assets/stylesheets/spina/wysihtml5_textarea.sass +0 -14
- data/app/controllers/spina/admin/page_parts_controller.rb +0 -11
- data/app/helpers/spina/application_helper.rb +0 -30
- data/app/models/spina/ability.rb +0 -20
- data/app/models/spina/color.rb +0 -7
- data/app/presenters/spina/pages/breadcrumb.rb +0 -102
- data/app/views/layouts/spina/email.html.erb +0 -124
- data/app/views/spina/admin/layout_partables/colors/_form.html.haml +0 -4
- data/app/views/spina/admin/page_parts/_wysihtml5_link.html.haml +0 -12
- data/app/views/spina/admin/page_parts/insert_wysihtml5_link.js +0 -5
- data/app/views/spina/admin/page_parts/wysihtml5_link.js +0 -2
- data/app/views/spina/admin/photos/create_and_select.js.erb +0 -7
- data/app/views/spina/admin/photos/create_multiple.js.erb +0 -4
- data/app/views/spina/admin/photos/wysihtml5_select.js.erb +0 -3
- data/vendor/assets/javascripts/spina/jquery.farbtastic.js +0 -345
- data/vendor/assets/javascripts/spina/morris.js +0 -1767
- data/vendor/assets/javascripts/spina/raphael.js +0 -8111
- data/vendor/assets/javascripts/spina/wysihtml5.js +0 -269
- data/vendor/assets/javascripts/spina/wysihtml5_parser_rules.js +0 -551
- 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
|
-
|
6
|
+
display: flex
|
7
7
|
|
8
8
|
&:not(:last-child)
|
9
|
-
|
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
|
-
|
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,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
|
-
|
160
|
+
transition: background .3s ease
|
167
161
|
|
168
162
|
& > li > a
|
169
|
-
|
163
|
+
transition: all .3s ease
|
170
164
|
|
171
165
|
.icon
|
172
|
-
|
166
|
+
transition: all .3s ease
|
173
167
|
|
174
168
|
li.active ul
|
175
|
-
|
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
|
-
|
176
|
+
transform: translateX(-10px)
|
183
177
|
|
184
178
|
.icon
|
185
179
|
color: #f5f5fa
|
186
|
-
|
180
|
+
transform: translateX(10px)
|
187
181
|
|
188
182
|
li.active ul
|
189
|
-
|
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
|
-
|
234
|
-
|
235
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
13
|
-
|
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 :
|
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
|
19
|
-
redirect_to spina.admin_login_url, flash: {information: I18n.t('spina.notifications.login')} unless
|
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
|
@@ -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.
|
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
|
-
|
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.
|
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.
|
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.
|
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
|
-
|
22
|
-
|
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
|
93
|
-
@photo = Photo.find(params[:photo_id])
|
73
|
+
def trix_insert
|
74
|
+
@photo = Photo.find(params[:photo_id])
|
94
75
|
end
|
95
|
-
|
96
|
-
def
|
97
|
-
@photos = Photo.sorted.page(params[:page])
|
98
|
-
@photo = Photo.new
|
99
|
-
|
100
|
-
if params[:page].present?
|
101
|
-
render :
|
102
|
-
else
|
103
|
-
render :
|
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(
|
95
|
+
params.require(:photo).permit(files: [])
|
115
96
|
end
|
116
97
|
|
117
98
|
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 ==
|
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
|
-
|
53
|
-
|
54
|
-
|
51
|
+
def set_breadcrumbs
|
52
|
+
add_breadcrumb I18n.t('spina.preferences.users'), spina.admin_users_path
|
53
|
+
end
|
55
54
|
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
20
|
-
@
|
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 :
|
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 :
|
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
|
17
|
+
def current_spina_user_can_view_page?
|
18
18
|
raise ActiveRecord::RecordNotFound if page.nil? || !page.live?
|
19
19
|
|
20
|
-
|
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,
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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: "
|
12
|
-
|
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.
|
27
|
-
structure[:structure_parts].map do |
|
28
|
-
part = item.
|
29
|
-
if part.
|
30
|
-
|
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
|
@@ -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
|