spina 2.12.0 → 2.13.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/Rakefile +17 -17
- data/app/assets/builds/spina/tailwind.css +79 -47
- data/app/components/spina/application_component.rb +1 -1
- data/app/components/spina/forms/group_component.rb +2 -3
- data/app/components/spina/forms/label_component.rb +2 -3
- data/app/components/spina/forms/password_field_component.rb +1 -1
- data/app/components/spina/forms/switch_component.rb +2 -3
- data/app/components/spina/forms/text_field_component.rb +8 -9
- data/app/components/spina/forms/trix_toolbar_component.rb +1 -3
- data/app/components/spina/hooks/hook_component.rb +3 -5
- data/app/components/spina/hooks/partial_component.rb +4 -5
- data/app/components/spina/main_navigation/link_component.rb +1 -3
- data/app/components/spina/main_navigation/sub_nav_component.rb +6 -7
- data/app/components/spina/media_picker/image_component.rb +1 -3
- data/app/components/spina/media_picker/modal_component.rb +4 -6
- data/app/components/spina/pages/actions_component.rb +1 -3
- data/app/components/spina/pages/list_component.rb +3 -4
- data/app/components/spina/pages/location_component.rb +10 -11
- data/app/components/spina/pages/new_page_button_component.rb +4 -5
- data/app/components/spina/pages/page_component.rb +8 -9
- data/app/components/spina/pages/page_select_component.rb +3 -4
- data/app/components/spina/pages/tab_button_component.rb +1 -3
- data/app/components/spina/pages/translations_component.rb +9 -11
- data/app/components/spina/user_interface/dropdown_button_component.rb +4 -4
- data/app/components/spina/user_interface/dropdown_component.rb +8 -9
- data/app/components/spina/user_interface/flash_message_component.rb +3 -5
- data/app/components/spina/user_interface/header_component.rb +2 -2
- data/app/components/spina/user_interface/modal_component.rb +1 -3
- data/app/components/spina/user_interface/tab_link_component.rb +1 -3
- data/app/components/spina/user_interface/translations_component.rb +8 -10
- data/app/controllers/concerns/spina/api/paginable.rb +36 -37
- data/app/controllers/concerns/spina/current_spina_account.rb +1 -1
- data/app/controllers/concerns/spina/current_theme.rb +6 -7
- data/app/controllers/concerns/spina/frontend.rb +58 -44
- data/app/controllers/spina/admin/accounts_controller.rb +9 -10
- data/app/controllers/spina/admin/admin_controller.rb +18 -18
- data/app/controllers/spina/admin/attachments_controller.rb +15 -10
- data/app/controllers/spina/admin/embeds_controller.rb +17 -19
- data/app/controllers/spina/admin/images_controller.rb +24 -25
- data/app/controllers/spina/admin/layout_controller.rb +19 -20
- data/app/controllers/spina/admin/media_folders_controller.rb +4 -5
- data/app/controllers/spina/admin/media_picker_controller.rb +2 -4
- data/app/controllers/spina/admin/move_pages_controller.rb +8 -10
- data/app/controllers/spina/admin/navigation_items_controller.rb +13 -14
- data/app/controllers/spina/admin/navigations_controller.rb +26 -26
- data/app/controllers/spina/admin/page_translations_controller.rb +1 -3
- data/app/controllers/spina/admin/pages_controller.rb +34 -34
- data/app/controllers/spina/admin/parent_pages_controller.rb +1 -3
- data/app/controllers/spina/admin/password_resets_controller.rb +8 -9
- data/app/controllers/spina/admin/resources_controller.rb +14 -15
- data/app/controllers/spina/admin/sessions_controller.rb +2 -2
- data/app/controllers/spina/admin/settings_controller.rb +28 -29
- data/app/controllers/spina/admin/theme_controller.rb +10 -11
- data/app/controllers/spina/admin/users_controller.rb +28 -29
- data/app/controllers/spina/api/api_controller.rb +17 -17
- data/app/controllers/spina/api/images_controller.rb +1 -3
- data/app/controllers/spina/api/navigations_controller.rb +2 -4
- data/app/controllers/spina/api/pages_controller.rb +8 -9
- data/app/controllers/spina/api/resources_controller.rb +2 -4
- data/app/controllers/spina/application_controller.rb +4 -3
- data/app/controllers/spina/pages_controller.rb +4 -5
- data/app/controllers/spina/sitemaps_controller.rb +0 -2
- data/app/helpers/spina/admin/icons_helper.rb +151 -153
- data/app/helpers/spina/admin/images_helper.rb +0 -2
- data/app/helpers/spina/admin/pages_helper.rb +3 -5
- data/app/helpers/spina/attachments_helper.rb +1 -3
- data/app/helpers/spina/images_helper.rb +5 -7
- data/app/helpers/spina/pages_helper.rb +0 -2
- data/app/helpers/spina/spina_helper.rb +1 -3
- data/app/jobs/spina/replace_signed_id_job.rb +10 -11
- data/app/jobs/spina/resource_pages_update_job.rb +1 -1
- data/app/mailers/spina/application_mailer.rb +2 -2
- data/app/mailers/spina/user_mailer.rb +4 -6
- data/app/models/concerns/spina/gravatar.rb +11 -12
- data/app/models/concerns/spina/partable.rb +4 -6
- data/app/models/concerns/spina/translated_content.rb +5 -5
- data/app/models/spina/account.rb +9 -10
- data/app/models/spina/application_record.rb +2 -3
- data/app/models/spina/attachment.rb +3 -4
- data/app/models/spina/current.rb +1 -1
- data/app/models/spina/embeds/base.rb +2 -2
- data/app/models/spina/embeds/button.rb +4 -4
- data/app/models/spina/embeds/vimeo.rb +17 -18
- data/app/models/spina/embeds/youtube.rb +18 -19
- data/app/models/spina/image.rb +4 -4
- data/app/models/spina/media_folder.rb +1 -1
- data/app/models/spina/navigation.rb +1 -2
- data/app/models/spina/navigation_item.rb +2 -2
- data/app/models/spina/page.rb +32 -38
- data/app/models/spina/parts/attachment.rb +1 -2
- data/app/models/spina/parts/base.rb +5 -4
- data/app/models/spina/parts/image.rb +3 -4
- data/app/models/spina/parts/image_collection.rb +2 -3
- data/app/models/spina/parts/image_variant.rb +3 -4
- data/app/models/spina/parts/repeater_content.rb +2 -2
- data/app/models/spina/resource.rb +3 -4
- data/app/models/spina/rewrite_rule.rb +1 -1
- data/app/models/spina/setting.rb +0 -2
- data/app/models/spina/user.rb +3 -4
- data/app/presenters/spina/content_presenter.rb +11 -12
- data/app/presenters/spina/menu_presenter.rb +55 -55
- data/app/presenters/spina/rich_text_presenter.rb +28 -29
- data/app/serializers/spina/api/base_serializer.rb +1 -1
- data/app/serializers/spina/api/image_serializer.rb +6 -6
- data/app/serializers/spina/api/navigation_serializer.rb +4 -7
- data/app/serializers/spina/api/page_serializer.rb +9 -12
- data/app/serializers/spina/api/resource_serializer.rb +5 -5
- data/app/views/layouts/spina/admin/application.html.erb +1 -0
- data/app/views/spina/admin/parts/attachments/_attachment.html.erb +3 -0
- data/app/views/spina/admin/parts/attachments/_form.html.erb +22 -1
- data/app/views/spina/admin/parts/repeaters/_fields.html.erb +2 -2
- data/app/views/spina/admin/parts/repeaters/_form.html.erb +4 -4
- data/app/views/spina/admin/shared/_navigation.html.erb +3 -1
- data/app/views/spina/admin/shared/_version.html.erb +18 -0
- data/app/views/spina/sitemaps/show.xml.builder +1 -1
- data/config/initializers/importmap.rb +3 -3
- data/config/initializers/yaml_column_permitted_classes.rb +3 -3
- data/config/locales/de.yml +1 -0
- data/config/locales/en.yml +3 -0
- data/config/locales/nl.yml +4 -1
- data/config/routes.rb +10 -17
- data/db/migrate/1_create_spina_tables.rb +57 -57
- data/db/migrate/3_create_spina_navigations.rb +1 -1
- data/db/seeds.rb +0 -1
- data/lib/generators/spina/embed_generator.rb +5 -6
- data/lib/generators/spina/install_generator.rb +48 -41
- data/lib/generators/spina/tailwind_config_generator.rb +3 -4
- data/lib/generators/spina/templates/app/models/spina/embeds/embed.rb.tt +20 -18
- data/lib/generators/spina/templates/config/initializers/spina.rb +11 -11
- data/lib/generators/spina/templates/config/initializers/themes/default.rb +17 -17
- data/lib/generators/spina/templates/config/initializers/themes/demo.rb +22 -22
- data/lib/spina/admin_sectionable.rb +5 -8
- data/lib/spina/attr_json_monkeypatch.rb +4 -7
- data/lib/spina/attr_json_spina_parts_model.rb +1 -3
- data/lib/spina/authentication/basic.rb +9 -10
- data/lib/spina/authentication/sessions.rb +10 -11
- data/lib/spina/embeddable.rb +14 -17
- data/lib/spina/embeds/trix_conversion.rb +25 -26
- data/lib/spina/embeds.rb +1 -3
- data/lib/spina/engine.rb +18 -19
- data/lib/spina/part.rb +1 -6
- data/lib/spina/plugin.rb +9 -13
- data/lib/spina/railtie.rb +5 -7
- data/lib/spina/theme.rb +13 -17
- data/lib/spina/theme_reloader.rb +12 -13
- data/lib/spina/version.rb +1 -1
- data/lib/spina.rb +39 -40
- data/lib/tasks/install.rake +8 -14
- data/lib/tasks/tailwind.rake +10 -8
- metadata +18 -2
@@ -6,8 +6,8 @@ module Spina
|
|
6
6
|
before_action :set_tabs
|
7
7
|
|
8
8
|
def index
|
9
|
-
add_breadcrumb I18n.t(
|
10
|
-
|
9
|
+
add_breadcrumb I18n.t("spina.website.pages"), spina.admin_pages_path
|
10
|
+
|
11
11
|
if params[:resource_id]
|
12
12
|
@resource = Resource.find(params[:resource_id])
|
13
13
|
@page_templates = Spina::Current.theme.new_page_templates(resource: @resource)
|
@@ -51,33 +51,33 @@ module Spina
|
|
51
51
|
Mobility.locale = @locale
|
52
52
|
if @page.update(page_params)
|
53
53
|
if @page.saved_change_to_draft? && @page.live?
|
54
|
-
flash[:confetti] = t(
|
54
|
+
flash[:confetti] = t("spina.pages.published")
|
55
55
|
else
|
56
|
-
flash[:success] = t(
|
56
|
+
flash[:success] = t("spina.pages.saved")
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
redirect_to spina.edit_admin_page_url(@page, params: {locale: @locale})
|
60
60
|
else
|
61
61
|
add_index_breadcrumb
|
62
62
|
Mobility.locale = I18n.locale
|
63
63
|
add_breadcrumb @page.title
|
64
|
-
flash.now[:error] = t(
|
64
|
+
flash.now[:error] = t("spina.pages.couldnt_be_saved")
|
65
65
|
render :edit, status: :unprocessable_entity
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
def sort
|
70
|
-
params[:ids].each.with_index do |id, index|
|
70
|
+
params[:ids].each.with_index do |id, index|
|
71
71
|
Page.where(id: id).update_all(position: index + 1)
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
flash.now[:info] = t("spina.pages.sorting_saved")
|
75
75
|
render_flash
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
def sort_one
|
79
79
|
current_position = @page.position
|
80
|
-
|
80
|
+
|
81
81
|
if params[:direction] == "up"
|
82
82
|
@bottom_page = @page
|
83
83
|
@top_page = @target_page = @page.siblings.where(resource_id: @page.resource_id).sorted.where("position < ?", current_position).last
|
@@ -85,7 +85,7 @@ module Spina
|
|
85
85
|
@bottom_page = @target_page = @page.siblings.where(resource_id: @page.resource_id).sorted.where("position > ?", current_position).first
|
86
86
|
@top_page = @page
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
if @target_page
|
90
90
|
@page.transaction do
|
91
91
|
@page.update(position: @target_page.position)
|
@@ -103,37 +103,37 @@ module Spina
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def destroy
|
106
|
-
flash[:info] = t(
|
106
|
+
flash[:info] = t("spina.pages.deleted")
|
107
107
|
@page.destroy
|
108
|
-
|
108
|
+
|
109
|
+
redirect_to spina.admin_pages_url(resource_id: @page.resource_id)
|
109
110
|
end
|
110
111
|
|
111
112
|
private
|
112
113
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
def add_index_breadcrumb
|
118
|
-
if @page.resource
|
119
|
-
add_breadcrumb @page.resource.label, spina.admin_pages_path(resource_id: @page.resource_id), class: 'text-gray-400'
|
120
|
-
else
|
121
|
-
add_breadcrumb t('spina.website.pages'), spina.admin_pages_path, class: 'text-gray-400'
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def page_params
|
126
|
-
params.require(:page).permit!
|
127
|
-
end
|
128
|
-
|
129
|
-
def set_page
|
130
|
-
@page = Page.find(params[:id])
|
131
|
-
end
|
114
|
+
def set_locale
|
115
|
+
@locale = params[:locale] || I18n.default_locale
|
116
|
+
end
|
132
117
|
|
133
|
-
|
134
|
-
|
118
|
+
def add_index_breadcrumb
|
119
|
+
if @page.resource
|
120
|
+
add_breadcrumb @page.resource.label, spina.admin_pages_path(resource_id: @page.resource_id), class: "text-gray-400"
|
121
|
+
else
|
122
|
+
add_breadcrumb t("spina.website.pages"), spina.admin_pages_path, class: "text-gray-400"
|
135
123
|
end
|
124
|
+
end
|
136
125
|
|
126
|
+
def page_params
|
127
|
+
params.require(:page).permit!
|
128
|
+
end
|
129
|
+
|
130
|
+
def set_page
|
131
|
+
@page = Page.find(params[:id])
|
132
|
+
end
|
133
|
+
|
134
|
+
def set_tabs
|
135
|
+
@tabs = %w[page_content search_engines advanced]
|
136
|
+
end
|
137
137
|
end
|
138
138
|
end
|
139
139
|
end
|
@@ -13,9 +13,9 @@ module Spina
|
|
13
13
|
|
14
14
|
if user&.reset_passord!
|
15
15
|
UserMailer.forgot_password(user, request.user_agent).deliver_later
|
16
|
-
redirect_to admin_login_path, flash: {success: t(
|
16
|
+
redirect_to admin_login_path, flash: {success: t("spina.forgot_password.instructions_sent")}
|
17
17
|
else
|
18
|
-
flash.now[:alert] = t(
|
18
|
+
flash.now[:alert] = t("spina.forgot_password.unknown_user")
|
19
19
|
render :new, status: :unprocessable_entity
|
20
20
|
end
|
21
21
|
end
|
@@ -28,9 +28,9 @@ module Spina
|
|
28
28
|
@user = User.find_by(password_reset_token: params[:id])
|
29
29
|
|
30
30
|
if @user.password_reset_sent_at < 2.hours.ago
|
31
|
-
redirect_to new_admin_password_reset_path, flash: {alert: t(
|
31
|
+
redirect_to new_admin_password_reset_path, flash: {alert: t("spina.forgot_password.expired")}
|
32
32
|
elsif @user.update(user_params)
|
33
|
-
redirect_to admin_login_path, flash: {success: t(
|
33
|
+
redirect_to admin_login_path, flash: {success: t("spina.forgot_password.success")}
|
34
34
|
else
|
35
35
|
render :edit, status: :unprocessable_entity
|
36
36
|
end
|
@@ -38,10 +38,9 @@ module Spina
|
|
38
38
|
|
39
39
|
private
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
def user_params
|
42
|
+
params.require(:user).permit(:password, :password_confirmation)
|
43
|
+
end
|
45
44
|
end
|
46
45
|
end
|
47
|
-
end
|
46
|
+
end
|
@@ -4,14 +4,14 @@ module Spina
|
|
4
4
|
before_action :set_locale
|
5
5
|
before_action :set_resource, only: [:edit, :update]
|
6
6
|
|
7
|
-
def edit
|
8
|
-
add_breadcrumb @resource.label, spina.admin_pages_path(resource_id: @resource.id), class:
|
9
|
-
add_breadcrumb t(
|
7
|
+
def edit
|
8
|
+
add_breadcrumb @resource.label, spina.admin_pages_path(resource_id: @resource.id), class: "text-gray-400"
|
9
|
+
add_breadcrumb t("spina.edit")
|
10
10
|
end
|
11
11
|
|
12
12
|
def update
|
13
13
|
if Mobility.with_locale(@locale) { @resource.update(resource_params) }
|
14
|
-
flash[:success] = t(
|
14
|
+
flash[:success] = t("spina.resources.saved")
|
15
15
|
redirect_to spina.admin_pages_path(resource_id: @resource.id)
|
16
16
|
else
|
17
17
|
render :edit
|
@@ -20,18 +20,17 @@ module Spina
|
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
def set_resource
|
28
|
-
@resource = Resource.find(params[:id])
|
29
|
-
end
|
23
|
+
def resource_params
|
24
|
+
params.require(:resource).permit(:label, :slug, :view_template, :order_by, :parent_page_id)
|
25
|
+
end
|
30
26
|
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
def set_resource
|
28
|
+
@resource = Resource.find(params[:id])
|
29
|
+
end
|
34
30
|
|
31
|
+
def set_locale
|
32
|
+
@locale = params[:locale] || I18n.default_locale
|
33
|
+
end
|
35
34
|
end
|
36
35
|
end
|
37
|
-
end
|
36
|
+
end
|
@@ -8,12 +8,12 @@ module Spina
|
|
8
8
|
|
9
9
|
def create
|
10
10
|
user = User.where(email: params[:email]).first
|
11
|
-
if user
|
11
|
+
if user&.authenticate(params[:password])
|
12
12
|
session[:spina_user_id] = user.id
|
13
13
|
user.touch(:last_logged_in)
|
14
14
|
redirect_to spina.admin_root_url
|
15
15
|
else
|
16
|
-
flash.now[:alert] = I18n.t(
|
16
|
+
flash.now[:alert] = I18n.t("spina.notifications.wrong_username_or_password")
|
17
17
|
render "new", status: :unprocessable_entity
|
18
18
|
end
|
19
19
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Spina
|
2
2
|
module Admin
|
3
|
-
class SettingsController < AdminController
|
3
|
+
class SettingsController < AdminController
|
4
4
|
before_action :find_or_set_settings
|
5
5
|
before_action :set_breadcrumbs
|
6
|
-
|
6
|
+
|
7
7
|
admin_section :settings
|
8
8
|
|
9
9
|
def edit
|
@@ -21,37 +21,36 @@ module Spina
|
|
21
21
|
|
22
22
|
private
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
39
|
-
plugin.settings.keys.reject do |x|
|
40
|
-
@setting.preferences.keys.map(&:to_sym).include? x
|
41
|
-
end.each do |key|
|
42
|
-
value = plugin.settings[key].is_a?(Hash) ? plugin.settings[key].first.last : nil
|
43
|
-
@setting.send("#{key}=", value)
|
24
|
+
def setting_class
|
25
|
+
"spina/#{plugin.namespace}/setting".classify.constantize
|
26
|
+
end
|
27
|
+
|
28
|
+
def plugin
|
29
|
+
Spina::Plugin.find_by(namespace: params[:plugin])
|
30
|
+
end
|
31
|
+
helper_method :plugin
|
32
|
+
|
33
|
+
def find_or_set_settings
|
34
|
+
@setting = setting_class.first_or_create do |setting|
|
35
|
+
plugin.settings.each do |attribute, type|
|
36
|
+
setting.send("#{attribute}=", (type.is_a?(Hash) ? type.first.last : nil))
|
44
37
|
end
|
45
38
|
end
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
def settings_params
|
52
|
-
params.require(:setting).permit(plugin.settings.keys)
|
39
|
+
plugin.settings.keys.reject do |x|
|
40
|
+
@setting.preferences.keys.map(&:to_sym).include? x
|
41
|
+
end.each do |key|
|
42
|
+
value = plugin.settings[key].is_a?(Hash) ? plugin.settings[key].first.last : nil
|
43
|
+
@setting.send("#{key}=", value)
|
53
44
|
end
|
45
|
+
end
|
54
46
|
|
47
|
+
def set_breadcrumbs
|
48
|
+
add_breadcrumb t("spina.settings.title")
|
49
|
+
end
|
50
|
+
|
51
|
+
def settings_params
|
52
|
+
params.require(:setting).permit(plugin.settings.keys)
|
53
|
+
end
|
55
54
|
end
|
56
55
|
end
|
57
56
|
end
|
@@ -2,22 +2,21 @@ module Spina
|
|
2
2
|
module Admin
|
3
3
|
class ThemeController < AdminController
|
4
4
|
admin_section :settings
|
5
|
-
|
5
|
+
|
6
6
|
def edit
|
7
|
-
add_breadcrumb t(
|
7
|
+
add_breadcrumb t("spina.theme.theme")
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def update
|
11
11
|
Spina::Current.account.update(theme_params)
|
12
|
-
redirect_to spina.edit_admin_theme_path, flash: {success: t(
|
12
|
+
redirect_to spina.edit_admin_theme_path, flash: {success: t("spina.theme.saved")}
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
private
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
|
17
|
+
def theme_params
|
18
|
+
params.require(:account).permit(:theme)
|
19
|
+
end
|
21
20
|
end
|
22
21
|
end
|
23
|
-
end
|
22
|
+
end
|
@@ -4,18 +4,18 @@ module Spina
|
|
4
4
|
before_action :authorize_authentication_module
|
5
5
|
before_action :authorize_admin, except: [:index]
|
6
6
|
before_action :set_user, only: [:edit, :update, :destroy]
|
7
|
-
|
7
|
+
|
8
8
|
admin_section :settings
|
9
9
|
|
10
10
|
def index
|
11
11
|
@users = User.order(:name)
|
12
|
-
add_breadcrumb I18n.t(
|
12
|
+
add_breadcrumb I18n.t("spina.preferences.users"), spina.admin_users_path
|
13
13
|
end
|
14
14
|
|
15
15
|
def new
|
16
16
|
@user = User.new
|
17
17
|
add_index_breadcrumb
|
18
|
-
add_breadcrumb I18n.t(
|
18
|
+
add_breadcrumb I18n.t("spina.users.new")
|
19
19
|
end
|
20
20
|
|
21
21
|
def create
|
@@ -23,59 +23,58 @@ module Spina
|
|
23
23
|
if @user.save
|
24
24
|
redirect_to admin_users_url
|
25
25
|
else
|
26
|
-
flash.now[:alert] = I18n.t(
|
26
|
+
flash.now[:alert] = I18n.t("spina.users.cannot_be_created")
|
27
27
|
add_index_breadcrumb
|
28
|
-
add_breadcrumb I18n.t(
|
28
|
+
add_breadcrumb I18n.t("spina.users.new")
|
29
29
|
render :new, status: :unprocessable_entity
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
def edit
|
34
34
|
add_index_breadcrumb
|
35
|
-
add_breadcrumb
|
35
|
+
add_breadcrumb @user.to_s
|
36
36
|
end
|
37
37
|
|
38
38
|
def update
|
39
39
|
if @user.update(user_params)
|
40
|
-
flash[:success] = t(
|
40
|
+
flash[:success] = t("spina.users.saved")
|
41
41
|
redirect_to spina.admin_users_url
|
42
42
|
else
|
43
|
-
flash.now[:alert] = I18n.t(
|
43
|
+
flash.now[:alert] = I18n.t("spina.users.cannot_be_created")
|
44
44
|
add_index_breadcrumb
|
45
|
-
add_breadcrumb
|
45
|
+
add_breadcrumb @user.to_s
|
46
46
|
render :edit, status: :unprocessable_entity
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
def destroy
|
51
51
|
if @user != current_spina_user
|
52
|
-
@user.destroy
|
53
|
-
redirect_to spina.admin_users_url, flash: {success: t(
|
52
|
+
@user.destroy
|
53
|
+
redirect_to spina.admin_users_url, flash: {success: t("spina.users.deleted")}
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
private
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
def add_index_breadcrumb
|
60
|
+
add_breadcrumb I18n.t("spina.preferences.users"), spina.admin_users_path, class: "text-gray-400"
|
61
|
+
end
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
def user_params
|
64
|
+
params.require(:user).permit(:admin, :email, :name, :password_digest, :password, :password_confirmation, :last_logged_in)
|
65
|
+
end
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
67
|
+
def set_user
|
68
|
+
@user = User.find(params[:id])
|
69
|
+
end
|
70
|
+
|
71
|
+
def authorize_authentication_module
|
72
|
+
render status: 401 unless Spina.config.authentication == "Spina::Authentication::Sessions"
|
73
|
+
end
|
74
|
+
|
75
|
+
def authorize_admin
|
76
|
+
render status: 401 unless current_spina_user.admin?
|
77
|
+
end
|
79
78
|
end
|
80
79
|
end
|
81
80
|
end
|
@@ -1,29 +1,29 @@
|
|
1
1
|
module Spina
|
2
2
|
module Api
|
3
3
|
class ApiController < ActionController::Base
|
4
|
-
include Spina::
|
5
|
-
|
4
|
+
include Spina::CurrentTheme
|
5
|
+
include Spina::CurrentSpinaAccount
|
6
|
+
|
6
7
|
protect_from_forgery unless: -> { request.format.json? }
|
7
|
-
|
8
|
+
|
8
9
|
rescue_from ActiveRecord::RecordNotFound, with: :render_404
|
9
|
-
|
10
|
+
|
10
11
|
TOKEN = Spina.config.api_key
|
11
|
-
|
12
|
+
|
12
13
|
before_action :authenticate_api
|
13
|
-
|
14
|
+
|
14
15
|
private
|
15
|
-
|
16
|
-
def render_404
|
17
|
-
render json: {error: "Not Found"}, status: :not_found
|
18
|
-
end
|
19
16
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
def render_404
|
18
|
+
render json: {error: "Not Found"}, status: :not_found
|
19
|
+
end
|
20
|
+
|
21
|
+
def authenticate_api
|
22
|
+
head :not_found and return if TOKEN.blank?
|
23
|
+
authenticate_or_request_with_http_token do |token, options|
|
24
|
+
ActiveSupport::SecurityUtils.secure_compare(token, TOKEN)
|
25
25
|
end
|
26
|
-
|
26
|
+
end
|
27
27
|
end
|
28
28
|
end
|
29
|
-
end
|
29
|
+
end
|
@@ -1,12 +1,10 @@
|
|
1
1
|
module Spina
|
2
2
|
module Api
|
3
3
|
class ImagesController < ApiController
|
4
|
-
|
5
4
|
def show
|
6
5
|
@image = Spina::Image.find(params[:id])
|
7
6
|
render json: Spina::Api::ImageSerializer.new(@image, {params: {view_context: view_context}}).serializable_hash.to_json
|
8
7
|
end
|
9
|
-
|
10
8
|
end
|
11
9
|
end
|
12
|
-
end
|
10
|
+
end
|
@@ -2,19 +2,17 @@ module Spina
|
|
2
2
|
module Api
|
3
3
|
class NavigationsController < ApiController
|
4
4
|
include Paginable
|
5
|
-
|
5
|
+
|
6
6
|
def index
|
7
7
|
navigations = Navigation.order(:id)
|
8
8
|
paginated = pagination(navigations)
|
9
9
|
render json: Spina::Api::NavigationSerializer.new(paginated.first, paginated.last.merge(fields: {navigation: [:name, :label]})).serializable_hash.to_json
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def show
|
13
13
|
@navigation = Navigation.find(params[:id])
|
14
14
|
render json: Spina::Api::NavigationSerializer.new(@navigation).serializable_hash.to_json
|
15
15
|
end
|
16
|
-
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
20
|
-
|
@@ -2,25 +2,24 @@ module Spina
|
|
2
2
|
module Api
|
3
3
|
class PagesController < ApiController
|
4
4
|
include Paginable
|
5
|
-
|
5
|
+
|
6
6
|
before_action :set_resource
|
7
|
-
|
7
|
+
|
8
8
|
def index
|
9
9
|
pages = Page.live.includes(:translations).where(resource: @resource).order(:created_at)
|
10
10
|
render json: Spina::Api::PageSerializer.new(*pagination(pages)).serializable_hash.to_json
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def show
|
14
14
|
@page = Page.live.where(resource: @resource).find(params[:id])
|
15
15
|
render json: Spina::Api::PageSerializer.new(@page).serializable_hash.to_json
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
private
|
19
|
-
|
20
|
-
def set_resource
|
21
|
-
@resource = Spina::Resource.find(params[:resource_id]) if params[:resource_id].present?
|
22
|
-
end
|
23
19
|
|
20
|
+
def set_resource
|
21
|
+
@resource = Spina::Resource.find(params[:resource_id]) if params[:resource_id].present?
|
22
|
+
end
|
24
23
|
end
|
25
24
|
end
|
26
|
-
end
|
25
|
+
end
|
@@ -2,18 +2,16 @@ module Spina
|
|
2
2
|
module Api
|
3
3
|
class ResourcesController < ApiController
|
4
4
|
include Paginable
|
5
|
-
|
5
|
+
|
6
6
|
def index
|
7
7
|
resources = Resource.order(:id)
|
8
8
|
render json: Spina::Api::ResourceSerializer.new(*pagination(resources)).serializable_hash.to_json
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def show
|
12
12
|
@resource = Resource.find(params[:id])
|
13
13
|
render json: Spina::Api::ResourceSerializer.new(@resource).serializable_hash.to_json
|
14
14
|
end
|
15
|
-
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
19
|
-
|
@@ -1,8 +1,9 @@
|
|
1
1
|
class Spina::ApplicationController < Spina.frontend_parent_controller.constantize
|
2
2
|
include Spina.config.authentication.constantize
|
3
|
-
include Spina::
|
4
|
-
|
3
|
+
include Spina::CurrentTheme
|
4
|
+
include Spina::CurrentSpinaAccount
|
5
|
+
|
5
6
|
helper Spina::Engine.helpers
|
6
|
-
|
7
|
+
|
7
8
|
protect_from_forgery with: :exception
|
8
9
|
end
|
@@ -8,11 +8,10 @@ class Spina::PagesController < Spina::ApplicationController
|
|
8
8
|
def homepage
|
9
9
|
render_with_template(page)
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
private
|
13
|
-
|
14
|
-
def authorize_page
|
15
|
-
raise ActiveRecord::RecordNotFound unless page.live? || logged_in?
|
16
|
-
end
|
17
13
|
|
14
|
+
def authorize_page
|
15
|
+
raise ActiveRecord::RecordNotFound unless page.live? || logged_in?
|
16
|
+
end
|
18
17
|
end
|