spina 1.1.2 → 2.0.0.beta
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/app/assets/fonts/spina/ics_spina.eot +0 -0
- data/app/assets/fonts/spina/ics_spina.svg +285 -267
- data/app/assets/fonts/spina/ics_spina.ttf +0 -0
- data/app/assets/fonts/spina/ics_spina.woff +0 -0
- data/app/assets/fonts/spina/ics_spina.woff2 +0 -0
- data/app/assets/icons/spina/bold.svg +1 -1
- data/app/assets/icons/spina/code.svg +1 -1
- data/app/assets/icons/spina/image.svg +1 -10
- data/app/assets/icons/spina/indent.svg +1 -0
- data/app/assets/icons/spina/italic.svg +1 -1
- data/app/assets/icons/spina/link.svg +1 -1
- data/app/assets/icons/spina/list-ol.svg +1 -0
- data/app/assets/icons/spina/list.svg +1 -0
- data/app/assets/icons/spina/outdent.svg +1 -0
- data/app/assets/icons/spina/preview/icons_spina-preview.html +0 -2
- data/app/assets/icons/spina/preview/ics_spina-preview.html +121 -3
- data/app/assets/icons/spina/quote-right.svg +1 -0
- data/app/assets/icons/spina/redo.svg +1 -0
- data/app/assets/icons/spina/strikethrough.svg +1 -0
- data/app/assets/icons/spina/undo.svg +1 -0
- data/app/assets/images/spina/favicon.png +0 -0
- data/app/assets/javascripts/spina/admin/application.js +1 -2
- data/app/assets/javascripts/spina/admin/controllers/attachment_picker_controller.js +15 -0
- data/app/assets/javascripts/spina/admin/controllers/image_form_controller.js +5 -4
- data/app/assets/javascripts/spina/admin/controllers/infinite_scroll_controller.js +20 -22
- data/app/assets/javascripts/spina/admin/controllers/media_picker_controller.js +171 -0
- data/app/assets/javascripts/spina/admin/controllers/modal_controller.js +18 -0
- data/app/assets/javascripts/spina/admin/controllers/repeater_form_controller.js +38 -0
- data/app/assets/javascripts/spina/admin/media_gallery.coffee +0 -3
- data/app/assets/javascripts/spina/admin/notifications.coffee +1 -1
- data/app/assets/javascripts/spina/admin/pages.coffee.erb +3 -20
- data/app/assets/javascripts/spina/admin/scaffold.coffee +1 -3
- data/app/assets/javascripts/spina/admin/trix.coffee.erb +14 -18
- data/app/assets/stylesheets/spina.sass +10 -8
- data/app/assets/stylesheets/spina/_buttons.sass +57 -31
- data/app/assets/stylesheets/spina/_configuration.sass.erb +1 -1
- data/app/assets/stylesheets/spina/_forms.sass +72 -77
- data/app/assets/stylesheets/spina/_gallery.sass +22 -4
- data/app/assets/stylesheets/spina/_ics_spina.scss +8 -0
- data/app/assets/stylesheets/spina/_media_picker.sass +133 -0
- data/app/assets/stylesheets/spina/_modal.sass +35 -2
- data/app/assets/stylesheets/spina/_notifications.sass +20 -14
- data/app/assets/stylesheets/spina/_pages.sass +131 -0
- data/app/assets/stylesheets/spina/_sortable_lists.sass +14 -8
- data/app/assets/stylesheets/spina/_tables.sass +7 -4
- data/app/assets/stylesheets/spina/_trix_custom.sass +29 -32
- data/app/controllers/concerns/spina/current_methods.rb +26 -0
- data/app/controllers/concerns/spina/frontend.rb +9 -0
- data/app/controllers/spina/admin/accounts_controller.rb +9 -13
- data/app/controllers/spina/admin/admin_controller.rb +5 -1
- data/app/controllers/spina/admin/attachments_controller.rb +0 -22
- data/app/controllers/spina/admin/images_controller.rb +1 -1
- data/app/controllers/spina/admin/media_picker_controller.rb +18 -19
- data/app/controllers/spina/admin/pages_controller.rb +3 -7
- data/app/controllers/spina/admin/resources_controller.rb +9 -4
- data/app/controllers/spina/application_controller.rb +6 -23
- data/app/controllers/spina/pages_controller.rb +11 -13
- data/app/controllers/spina/sitemaps_controller.rb +6 -6
- data/app/helpers/spina/admin/pages_helper.rb +22 -20
- data/app/helpers/spina/{files_helper.rb → attachments_helper.rb} +1 -1
- data/app/helpers/spina/images_helper.rb +9 -10
- data/app/helpers/spina/pages_helper.rb +23 -4
- data/app/models/concerns/spina/partable.rb +19 -7
- data/app/models/concerns/spina/translated_content.rb +19 -0
- data/app/models/spina/account.rb +3 -10
- data/app/models/spina/attachment.rb +0 -4
- data/app/models/spina/current.rb +1 -0
- data/app/models/spina/image.rb +0 -4
- data/app/models/spina/page.rb +31 -23
- data/app/models/spina/parts/attachment.rb +22 -0
- data/app/models/spina/parts/base.rb +12 -0
- data/app/models/spina/parts/image.rb +39 -0
- data/app/models/spina/parts/image_collection.rb +23 -0
- data/app/models/spina/parts/image_variant.rb +19 -0
- data/app/models/spina/parts/line.rb +7 -0
- data/app/models/spina/parts/multi_line.rb +7 -0
- data/app/models/spina/parts/option.rb +13 -0
- data/app/models/spina/parts/repeater.rb +10 -0
- data/app/models/spina/parts/repeater_content.rb +15 -0
- data/app/models/spina/parts/text.rb +7 -0
- data/app/models/spina/resource.rb +4 -12
- data/app/presenters/spina/content_presenter.rb +51 -0
- data/app/presenters/spina/menu_presenter.rb +2 -1
- data/app/views/layouts/spina/admin/admin.html.haml +3 -7
- data/app/views/layouts/spina/admin/pages.html.haml +5 -4
- data/app/views/layouts/spina/login.html.haml +0 -3
- data/app/views/spina/admin/accounts/_form.html.haml +13 -7
- data/app/views/spina/admin/accounts/analytics.html.haml +5 -3
- data/app/views/spina/admin/accounts/social.html.haml +13 -7
- data/app/views/spina/admin/accounts/style.html.haml +26 -21
- data/app/views/spina/admin/attachments/index.html.haml +1 -1
- data/app/views/spina/admin/images/_image.html.haml +1 -1
- data/app/views/spina/admin/images/index.html.haml +7 -5
- data/app/views/spina/admin/media_folders/_media_folder.html.haml +1 -1
- data/app/views/spina/admin/media_folders/show.html.haml +2 -2
- data/app/views/spina/admin/media_picker/_image.html.haml +3 -0
- data/app/views/spina/admin/media_picker/_media_picker.html.haml +32 -0
- data/app/views/spina/admin/media_picker/_media_picker_grid.html.haml +25 -0
- data/app/views/spina/admin/media_picker/_modal.html.haml +1 -1
- data/app/views/spina/admin/media_picker/infinite_scroll.js.erb +4 -4
- data/app/views/spina/admin/media_picker/select.js.erb +2 -0
- data/app/views/spina/admin/media_picker/show.html.haml +1 -0
- data/app/views/spina/admin/media_picker/show.js.erb +1 -1
- data/app/views/spina/admin/pages/_form.html.haml +9 -7
- data/app/views/spina/admin/pages/_form_advanced.html.haml +19 -17
- data/app/views/spina/admin/pages/_form_page_content.html.haml +14 -13
- data/app/views/spina/admin/pages/_form_page_seo.html.haml +15 -4
- data/app/views/spina/admin/pages/_page.html.haml +5 -3
- data/app/views/spina/admin/pages/_page_nested_list.html.haml +2 -3
- data/app/views/spina/admin/pages/index.html.haml +5 -4
- data/app/views/spina/admin/parts/attachments/_form.html.haml +6 -0
- data/app/views/spina/admin/parts/image_collections/_fields.html.haml +7 -0
- data/app/views/spina/admin/parts/image_collections/_form.html.haml +12 -0
- data/app/views/spina/admin/parts/images/_form.html.haml +18 -0
- data/app/views/spina/admin/parts/lines/_form.html.haml +2 -0
- data/app/views/spina/admin/parts/multi_lines/_form.html.haml +2 -0
- data/app/views/spina/admin/parts/options/_form.html.haml +3 -0
- data/app/views/spina/admin/parts/repeaters/_fields.html.haml +15 -0
- data/app/views/spina/admin/parts/repeaters/_form.html.haml +17 -0
- data/app/views/spina/admin/parts/texts/_form.html.haml +6 -0
- data/app/views/spina/admin/resources/edit.html.haml +28 -12
- data/app/views/spina/admin/resources/show.html.haml +6 -3
- data/app/views/spina/admin/shared/_notifications.html.haml +4 -4
- data/config/locales/TH.yml +10 -0
- data/config/locales/bg.yml +10 -0
- data/config/locales/de.yml +10 -0
- data/config/locales/en.yml +10 -0
- data/config/locales/es.yml +39 -29
- data/config/locales/fr.yml +10 -0
- data/config/locales/id.yml +10 -0
- data/config/locales/it.yml +10 -0
- data/config/locales/nl.yml +10 -0
- data/config/locales/pl.yml +24 -14
- data/config/locales/pt-BR.yml +10 -0
- data/config/locales/ro.yml +10 -0
- data/config/locales/ru.yml +10 -0
- data/config/locales/sv.yml +10 -0
- data/config/locales/tr.yml +10 -0
- data/config/locales/zh-CN.yml +10 -0
- data/config/routes.rb +13 -0
- data/db/migrate/11_create_spina_resources.rb +0 -2
- data/db/migrate/12_add_url_title_to_spina_page_translations.rb +5 -0
- data/db/migrate/13_add_json_attributes_to_spina_accounts.rb +5 -0
- data/db/migrate/14_add_json_attributes_to_spina_pages.rb +5 -0
- data/db/migrate/15_add_slug_to_spina_resources.rb +5 -0
- data/lib/generators/spina/templates/app/views/demo/pages/demo.html.haml +13 -21
- data/lib/generators/spina/templates/app/views/demo/pages/homepage.html.haml +1 -1
- data/lib/generators/spina/templates/config/initializers/mobility.rb +13 -4
- data/lib/generators/spina/templates/config/initializers/spina.rb +4 -0
- data/lib/generators/spina/templates/config/initializers/themes/default.rb +7 -7
- data/lib/generators/spina/templates/config/initializers/themes/demo.rb +32 -44
- data/lib/spina.rb +18 -3
- data/lib/spina/attr_json_spina_parts_model.rb +29 -0
- data/lib/spina/engine.rb +14 -6
- data/lib/spina/part.rb +19 -0
- data/lib/spina/theme.rb +1 -1
- data/lib/spina/version.rb +1 -1
- data/lib/tasks/spina_tasks.rake +1 -1
- data/vendor/assets/javascripts/spina/sortable.js +2 -2
- metadata +83 -53
- data/app/assets/javascripts/spina/admin/account.coffee +0 -16
- data/app/models/concerns/spina/image_collectable.rb +0 -23
- data/app/models/concerns/spina/optionable.rb +0 -12
- data/app/models/concerns/spina/part.rb +0 -38
- data/app/models/spina/attachment_collection.rb +0 -20
- data/app/models/spina/image_collection.rb +0 -23
- data/app/models/spina/image_collections_image.rb +0 -6
- data/app/models/spina/layout_part.rb +0 -22
- data/app/models/spina/line.rb +0 -10
- data/app/models/spina/option.rb +0 -17
- data/app/models/spina/page_part.rb +0 -22
- data/app/models/spina/structure.rb +0 -14
- data/app/models/spina/structure_item.rb +0 -22
- data/app/models/spina/structure_part.rb +0 -20
- data/app/models/spina/text.rb +0 -10
- data/app/views/dummy/show.html.haml +0 -1
- data/app/views/spina/admin/attachments/_attachment_collection.html.haml +0 -2
- data/app/views/spina/admin/attachments/_select.html.haml +0 -17
- data/app/views/spina/admin/attachments/_select_collection.html.haml +0 -18
- data/app/views/spina/admin/attachments/insert.js.erb +0 -5
- data/app/views/spina/admin/attachments/insert_collection.js.coffee +0 -7
- data/app/views/spina/admin/attachments/select.js.erb +0 -2
- data/app/views/spina/admin/attachments/select_collection.js.erb +0 -2
- data/app/views/spina/admin/image_collections/_image_collection.html.haml +0 -5
- data/app/views/spina/admin/layout_partables/lines/_form.html.haml +0 -2
- data/app/views/spina/admin/partables/attachment_collections/_form.html.haml +0 -14
- data/app/views/spina/admin/partables/attachments/_form.html.haml +0 -13
- data/app/views/spina/admin/partables/image_collections/_form.html.haml +0 -16
- data/app/views/spina/admin/partables/images/_form.html.haml +0 -21
- data/app/views/spina/admin/partables/lines/_form.html.haml +0 -5
- data/app/views/spina/admin/partables/options/_form.html.haml +0 -7
- data/app/views/spina/admin/partables/photo_collections/_form.html.haml +0 -4
- data/app/views/spina/admin/partables/photos/_form.html.haml +0 -4
- data/app/views/spina/admin/partables/structures/_form.html.haml +0 -21
- data/app/views/spina/admin/partables/texts/_form.html.haml +0 -8
- data/app/views/spina/admin/structure_items/_fields.html.haml +0 -15
- data/app/views/spina/admin/structure_partables/attachment_collections/_form.html.haml +0 -14
- data/app/views/spina/admin/structure_partables/attachments/_form.html.haml +0 -13
@@ -0,0 +1,26 @@
|
|
1
|
+
module Spina
|
2
|
+
module CurrentMethods
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
helper_method :current_theme
|
7
|
+
helper_method :current_spina_user
|
8
|
+
helper_method :current_account
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def current_theme
|
14
|
+
@current_theme ||= Spina::Theme.find_by_name(current_account.theme)
|
15
|
+
end
|
16
|
+
|
17
|
+
def current_spina_user
|
18
|
+
@current_spina_user ||= Spina::User.where(id: session[:user_id]).first if session[:user_id]
|
19
|
+
end
|
20
|
+
|
21
|
+
def current_account
|
22
|
+
@current_account ||= Spina::Account.first
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -4,9 +4,12 @@ module Spina
|
|
4
4
|
|
5
5
|
included do
|
6
6
|
rescue_from ActiveRecord::RecordNotFound, with: :redirect_or_render_404
|
7
|
+
|
8
|
+
helper Spina::PagesHelper
|
7
9
|
|
8
10
|
before_action :set_locale
|
9
11
|
before_action :set_current_page
|
12
|
+
before_action :set_current_account
|
10
13
|
end
|
11
14
|
|
12
15
|
def show
|
@@ -27,6 +30,12 @@ module Spina
|
|
27
30
|
|
28
31
|
def set_current_page
|
29
32
|
Spina::Current.page = page
|
33
|
+
Spina::Current.page.view_context = view_context
|
34
|
+
end
|
35
|
+
|
36
|
+
def set_current_account
|
37
|
+
Spina::Current.account = Spina::Account.first
|
38
|
+
Spina::Current.account.view_context = view_context
|
30
39
|
end
|
31
40
|
|
32
41
|
def page_by_locale(locale)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Spina
|
2
2
|
module Admin
|
3
3
|
class AccountsController < AdminController
|
4
|
+
before_action :set_locale
|
4
5
|
|
5
6
|
def edit
|
6
7
|
add_breadcrumb I18n.t('spina.preferences.account'), spina.edit_admin_account_path
|
@@ -22,23 +23,18 @@ module Spina
|
|
22
23
|
def style
|
23
24
|
add_breadcrumb I18n.t('spina.preferences.style'), spina.style_admin_account_path
|
24
25
|
@themes = ::Spina::Theme.all
|
25
|
-
@layout_parts = current_theme.layout_parts.map { |layout_part| current_account.layout_part(layout_part) }
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
:name, :title, :position, :content, :page_id,
|
39
|
-
layout_partable_attributes:
|
40
|
-
[:content, :photo_tokens, :attachment_tokens, :id]])
|
41
|
-
end
|
30
|
+
def account_params
|
31
|
+
params.require(:account).permit!
|
32
|
+
end
|
33
|
+
|
34
|
+
def set_locale
|
35
|
+
@locale = params[:locale] || I18n.default_locale
|
36
|
+
end
|
37
|
+
|
42
38
|
end
|
43
39
|
end
|
44
40
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module Spina
|
2
2
|
module Admin
|
3
|
-
class AdminController < ::
|
3
|
+
class AdminController < ActionController::Base
|
4
|
+
include Spina::CurrentMethods
|
5
|
+
|
6
|
+
helper Spina::Engine.helpers
|
7
|
+
|
4
8
|
before_action :set_admin_locale
|
5
9
|
before_action :authorize_spina_user
|
6
10
|
|
@@ -24,28 +24,6 @@ module Spina
|
|
24
24
|
redirect_to spina.admin_attachments_url
|
25
25
|
end
|
26
26
|
|
27
|
-
def select
|
28
|
-
@selected_attachment_id = Attachment.find_by(id: params[:selected_attachment_id]).try(:id)
|
29
|
-
@hidden_field_id = params[:hidden_field_id]
|
30
|
-
@attachments = Attachment.sorted
|
31
|
-
@attachment = Attachment.new
|
32
|
-
end
|
33
|
-
|
34
|
-
def insert
|
35
|
-
@attachment = Attachment.find(params[:attachment_id])
|
36
|
-
Rails.logger.info "HAHA HA HA #{@attachment.id}"
|
37
|
-
end
|
38
|
-
|
39
|
-
def select_collection
|
40
|
-
@selected_attachment_ids = Attachment.where(id: params[:selected_attachment_ids]).ids
|
41
|
-
@attachments = Attachment.sorted
|
42
|
-
@attachment = Attachment.new
|
43
|
-
end
|
44
|
-
|
45
|
-
def insert_collection
|
46
|
-
@attachments = Attachment.where(id: params[:attachment_ids])
|
47
|
-
end
|
48
|
-
|
49
27
|
private
|
50
28
|
|
51
29
|
def set_breadcrumbs
|
@@ -8,7 +8,7 @@ module Spina
|
|
8
8
|
def index
|
9
9
|
add_breadcrumb I18n.t('spina.website.images'), admin_images_path
|
10
10
|
@media_folders = MediaFolder.order(:name)
|
11
|
-
@images = Image.sorted.where(media_folder_id: nil).with_attached_file.page(params[:page])
|
11
|
+
@images = Image.sorted.where(media_folder_id: nil).with_attached_file.page(params[:page]).per(25)
|
12
12
|
end
|
13
13
|
|
14
14
|
# There's no file validation yet in ActiveStorage
|
@@ -2,39 +2,38 @@ module Spina
|
|
2
2
|
module Admin
|
3
3
|
class MediaPickerController < AdminController
|
4
4
|
before_action :set_media_folders
|
5
|
+
before_action :set_selected_images
|
5
6
|
|
6
7
|
def show
|
7
|
-
|
8
|
-
|
9
|
-
else
|
10
|
-
@images = Image.where(media_folder_id: nil).page(params[:page])
|
11
|
-
end
|
8
|
+
@images = Image.where(media_folder: @media_folder).order(created_at: :desc).page(params[:page]).per(25)
|
9
|
+
@mode = params[:mode]
|
12
10
|
|
13
|
-
if
|
14
|
-
|
15
|
-
@images = @images.order(Arel.sql("CASE WHEN id IN(#{ids}) THEN 0 ELSE 1 END, created_at DESC"))
|
16
|
-
else
|
17
|
-
@images = @images.sorted
|
11
|
+
if selected_ids.any?
|
12
|
+
@images = @images.reorder(Arel.sql("CASE WHEN id IN(#{selected_ids.join(', ')}) THEN 0 ELSE 1 END, created_at DESC"))
|
18
13
|
end
|
19
14
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
def select
|
24
|
-
if params[:multiple]
|
25
|
-
@images = Image.where(id: params[:image_ids].split("-"))
|
26
|
-
else
|
27
|
-
@image = Image.find(params[:image_id])
|
15
|
+
respond_to do |format|
|
16
|
+
format.html { render layout: false }
|
17
|
+
format.js { render :infinite_scroll if params[:page].present? }
|
28
18
|
end
|
29
19
|
end
|
30
20
|
|
31
21
|
private
|
32
22
|
|
33
23
|
def set_media_folders
|
34
|
-
@media_folders = MediaFolder.order(:name)
|
24
|
+
@media_folders = MediaFolder.order(:name).joins(:images).uniq
|
35
25
|
@media_folder = MediaFolder.find(params[:media_folder_id]) if params[:media_folder_id].present?
|
36
26
|
end
|
37
27
|
|
28
|
+
def set_selected_images
|
29
|
+
@selected_images = Image.where(id: selected_ids).sort_by{|image| selected_ids.index(image.id)}
|
30
|
+
end
|
31
|
+
|
32
|
+
def selected_ids
|
33
|
+
params[:selected_ids].present? ? params[:selected_ids].map(&:to_i) : []
|
34
|
+
end
|
35
|
+
helper_method :selected_ids
|
36
|
+
|
38
37
|
end
|
39
38
|
end
|
40
39
|
end
|
@@ -8,18 +8,17 @@ module Spina
|
|
8
8
|
def index
|
9
9
|
add_breadcrumb I18n.t('spina.website.pages'), spina.admin_pages_path
|
10
10
|
redirect_to admin_pages_path unless current_admin_path.starts_with?('/pages')
|
11
|
-
@pages = Page.active.sorted.roots.regular_pages
|
11
|
+
@pages = Page.active.sorted.roots.regular_pages.includes(:translations)
|
12
12
|
end
|
13
13
|
|
14
14
|
def new
|
15
15
|
@resource = Resource.find_by(id: params[:resource_id])
|
16
|
-
@page = Page.new(resource: @resource, parent: Page.find_by(id: params[:parent_id])
|
16
|
+
@page = Page.new(resource: @resource, parent: Page.find_by(id: params[:parent_id]))
|
17
17
|
add_index_breadcrumb
|
18
18
|
if current_theme.new_page_templates.any? { |template| template[0] == params[:view_template] }
|
19
19
|
@page.view_template = params[:view_template]
|
20
20
|
end
|
21
21
|
add_breadcrumb I18n.t('spina.pages.new')
|
22
|
-
@page_parts = @page.view_template_page_parts(current_theme).map { |part| @page.part(part) }
|
23
22
|
render layout: 'spina/admin/admin'
|
24
23
|
end
|
25
24
|
|
@@ -30,7 +29,6 @@ module Spina
|
|
30
29
|
@page.navigations << Spina::Navigation.where(auto_add_pages: true)
|
31
30
|
redirect_to spina.edit_admin_page_url(@page), flash: {success: t('spina.pages.saved')}
|
32
31
|
else
|
33
|
-
@page_parts = @page.view_template_page_parts(current_theme).map { |part| @page.part(part) }
|
34
32
|
render :new, layout: 'spina/admin/admin'
|
35
33
|
end
|
36
34
|
end
|
@@ -38,11 +36,10 @@ module Spina
|
|
38
36
|
def edit
|
39
37
|
add_index_breadcrumb
|
40
38
|
add_breadcrumb @page.title
|
41
|
-
@page_parts = @page.view_template_page_parts(current_theme).map { |part| @page.part(part) }
|
42
39
|
render layout: 'spina/admin/admin'
|
43
40
|
end
|
44
41
|
|
45
|
-
def update
|
42
|
+
def update
|
46
43
|
respond_to do |format|
|
47
44
|
Mobility.locale = @locale
|
48
45
|
if @page.update(page_params)
|
@@ -51,7 +48,6 @@ module Spina
|
|
51
48
|
format.js
|
52
49
|
else
|
53
50
|
format.html do
|
54
|
-
@page_parts = @page.view_template_page_parts(current_theme).map { |part| @page.part(part) }
|
55
51
|
Mobility.locale = I18n.default_locale
|
56
52
|
render :edit, layout: 'spina/admin/admin'
|
57
53
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Spina
|
2
2
|
module Admin
|
3
3
|
class ResourcesController < AdminController
|
4
|
-
|
4
|
+
before_action :set_locale
|
5
5
|
before_action :set_resource, only: [:show, :edit, :update]
|
6
6
|
|
7
7
|
def show
|
@@ -13,8 +13,8 @@ module Spina
|
|
13
13
|
add_breadcrumb t('spina.edit')
|
14
14
|
end
|
15
15
|
|
16
|
-
def update
|
17
|
-
if @resource.update(resource_params)
|
16
|
+
def update
|
17
|
+
if Mobility.with_locale(@locale) { @resource.update(resource_params) }
|
18
18
|
redirect_to spina.admin_resource_path(@resource)
|
19
19
|
else
|
20
20
|
render :edit
|
@@ -24,12 +24,17 @@ module Spina
|
|
24
24
|
private
|
25
25
|
|
26
26
|
def resource_params
|
27
|
-
params.require(:resource).permit(:label, :view_template, :order_by, :parent_page_id)
|
27
|
+
params.require(:resource).permit(:label, :slug, :view_template, :order_by, :parent_page_id)
|
28
28
|
end
|
29
29
|
|
30
30
|
def set_resource
|
31
31
|
@resource = Resource.find(params[:id])
|
32
32
|
end
|
33
|
+
|
34
|
+
def set_locale
|
35
|
+
@locale = params[:locale] || I18n.default_locale
|
36
|
+
end
|
37
|
+
|
33
38
|
end
|
34
39
|
end
|
35
40
|
end
|
@@ -1,24 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
def current_theme
|
9
|
-
@current_theme = ::Spina::Theme.find_by_name(current_account.theme)
|
10
|
-
end
|
11
|
-
helper_method :current_theme
|
12
|
-
|
13
|
-
def current_spina_user
|
14
|
-
@current_spina_user ||= ::Spina::User.where(id: session[:user_id]).first if session[:user_id]
|
15
|
-
end
|
16
|
-
helper_method :current_spina_user
|
17
|
-
|
18
|
-
def current_account
|
19
|
-
@current_account ||= ::Spina::Account.first
|
20
|
-
end
|
21
|
-
helper_method :current_account
|
22
|
-
|
23
|
-
end
|
1
|
+
class Spina::ApplicationController < Spina.frontend_parent_controller.constantize
|
2
|
+
include Spina::CurrentMethods
|
3
|
+
|
4
|
+
helper Spina::Engine.helpers
|
5
|
+
|
6
|
+
protect_from_forgery with: :exception
|
24
7
|
end
|
@@ -1,20 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
include Spina::Frontend
|
1
|
+
class Spina::PagesController < Spina::ApplicationController
|
2
|
+
include Spina::Frontend
|
4
3
|
|
5
|
-
|
4
|
+
before_action :current_spina_user_can_view_page?, except: [:robots]
|
6
5
|
|
7
|
-
|
6
|
+
helper_method :page
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
def homepage
|
9
|
+
render_with_template(page)
|
10
|
+
end
|
12
11
|
|
13
|
-
|
12
|
+
private
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
def current_spina_user_can_view_page?
|
15
|
+
raise ActiveRecord::RecordNotFound unless current_spina_user.present? || page.live?
|
16
|
+
end
|
18
17
|
|
19
|
-
end
|
20
18
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
end
|
1
|
+
class Spina::SitemapsController < Spina::ApplicationController
|
2
|
+
|
3
|
+
def show
|
4
|
+
I18n.locale = I18n.default_locale
|
5
|
+
@pages = Spina::Page.live.sorted
|
7
6
|
end
|
7
|
+
|
8
8
|
end
|
@@ -1,34 +1,36 @@
|
|
1
1
|
module Spina
|
2
2
|
module Admin
|
3
3
|
module PagesHelper
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
render("spina/admin/
|
4
|
+
|
5
|
+
def link_to_add_repeater_fields(f)
|
6
|
+
repeater_content = Spina::Parts::RepeaterContent.new(name: f.object.name, title: f.object.title)
|
7
|
+
fields = f.fields_for(:content, [repeater_content], child_index: repeater_content.object_id) do |builder|
|
8
|
+
render("spina/admin/parts/repeaters/fields", f: builder)
|
9
9
|
end
|
10
|
-
link_to '#', class: "add_structure_item_fields button button-link", data: {id:
|
10
|
+
link_to '#', class: "add_structure_item_fields button button-link", data: {id: repeater_content.object_id, fields: fields.gsub("\n", "")} do
|
11
11
|
icon('plus')
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
16
|
-
|
17
|
-
|
18
|
-
|
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]
|
22
|
-
part
|
15
|
+
def data_attrs_for_image_collection(f)
|
16
|
+
image = Spina::Parts::Image.new
|
17
|
+
fields = f.fields_for(:images, [image], child_index: image.object_id) do |builder|
|
18
|
+
render("spina/admin/parts/image_collections/fields", f: builder)
|
23
19
|
end
|
20
|
+
{fields: fields.gsub("\n", ""), id: image.object_id}
|
24
21
|
end
|
25
22
|
|
26
|
-
def
|
27
|
-
|
23
|
+
def build_parts(partable, parts)
|
24
|
+
I18n.with_locale(@locale) do
|
25
|
+
parts.map do |part|
|
26
|
+
part_attributes = current_theme.parts.find{|p|p[:name].to_s == part.to_s}
|
27
|
+
partable.part(part_attributes)
|
28
|
+
end
|
29
|
+
end
|
28
30
|
end
|
29
31
|
|
30
|
-
def
|
31
|
-
|
32
|
+
def parts_partial_namespace(part_type)
|
33
|
+
part_type.tableize.sub(/\Aspina\/parts\//, '')
|
32
34
|
end
|
33
35
|
|
34
36
|
def flatten_nested_hash(hash)
|
@@ -36,14 +38,14 @@ module Spina
|
|
36
38
|
end
|
37
39
|
|
38
40
|
def page_ancestry_options(page)
|
39
|
-
pages = Spina::Page.active.regular_pages
|
41
|
+
pages = Spina::Page.active.regular_pages.includes(:translations)
|
40
42
|
pages = pages.where.not(id: page.subtree.ids) unless page.new_record? || !page.methods.include?(:subtree)
|
41
43
|
|
42
44
|
(flatten_nested_hash(pages.arrange(order: :position)).map do |page|
|
43
45
|
next if page.depth >= Spina.config.max_page_depth - 1
|
44
46
|
page_menu_title = page.depth.zero? ? page.menu_title : " #{page.menu_title}".indent(page.depth, '-')
|
45
47
|
[page_menu_title, page.id]
|
46
|
-
end << [page.parent&.menu_title, page&.parent_id].compact).uniq.compact
|
48
|
+
end << [page.parent&.menu_title, page&.parent_id].compact).map(&:presence).uniq.compact
|
47
49
|
end
|
48
50
|
|
49
51
|
def option_label(part, value)
|