spina 0.12.0 → 1.0.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 +5 -5
- data/README.md +65 -7
- data/app/assets/fonts/spina/ics_spina.eot +0 -0
- data/app/assets/fonts/spina/ics_spina.svg +65 -61
- 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/export.svg +10 -0
- data/app/assets/icons/spina/preview/ics_spina-preview.html +17 -1
- data/app/assets/images/spina/media_folder_placeholder.png +0 -0
- data/app/assets/images/spina/{admin/spina.png → spina-large.png} +0 -0
- data/app/assets/javascripts/spina/admin/application.js +50 -0
- data/app/assets/javascripts/spina/admin/controllers/infinite_scroll_controller.js +40 -0
- data/app/assets/javascripts/spina/admin/media_gallery.coffee +65 -0
- data/app/assets/javascripts/spina/admin/modal.coffee +0 -1
- data/app/assets/javascripts/spina/admin/pages.coffee.erb +2 -2
- data/app/assets/javascripts/spina/admin/{application.coffee.erb → scaffold.coffee} +20 -61
- data/app/assets/javascripts/spina/admin/trix.coffee.erb +5 -8
- data/app/assets/javascripts/spina/admin/uploads.coffee +2 -2
- data/app/assets/stylesheets/spina.sass +3 -3
- data/app/assets/stylesheets/spina/_buttons.sass +0 -1
- data/app/assets/stylesheets/spina/{_configuration.sass → _configuration.sass.erb} +5 -1
- data/app/assets/stylesheets/spina/_forms.sass +79 -20
- data/app/assets/stylesheets/spina/_gallery.sass +91 -3
- data/app/assets/stylesheets/spina/_ics_spina.scss +1 -0
- data/app/assets/stylesheets/spina/_tables.sass +4 -0
- data/app/assets/stylesheets/spina/_trix.sass +7 -4
- data/app/assets/stylesheets/spina_front_end.sass +19 -0
- data/app/controllers/concerns/spina/frontend.rb +29 -12
- data/app/controllers/spina/admin/admin_controller.rb +1 -1
- data/app/controllers/spina/admin/attachments_controller.rb +10 -5
- data/app/controllers/spina/admin/images_controller.rb +51 -0
- data/app/controllers/spina/admin/media_folders_controller.rb +37 -0
- data/app/controllers/spina/admin/media_picker_controller.rb +28 -0
- data/app/controllers/spina/admin/pages_controller.rb +16 -6
- data/app/controllers/spina/admin/resources_controller.rb +33 -0
- data/app/controllers/spina/admin/settings_controller.rb +56 -0
- data/app/controllers/spina/pages_controller.rb +0 -6
- data/app/helpers/spina/admin/pages_helper.rb +2 -2
- data/app/helpers/spina/admin_nav_helper.rb +7 -0
- data/app/helpers/spina/files_helper.rb +9 -0
- data/app/helpers/spina/images_helper.rb +17 -0
- data/app/helpers/spina/pages_helper.rb +17 -0
- data/app/models/concerns/spina/image_collectable.rb +23 -0
- data/app/models/concerns/spina/part.rb +7 -4
- data/app/models/spina/account.rb +10 -14
- data/app/models/spina/attachment.rb +8 -10
- data/app/models/spina/attachment_collection.rb +6 -1
- data/app/models/spina/current.rb +5 -0
- data/app/models/spina/image.rb +26 -0
- data/app/models/spina/{photo_collection.rb → image_collection.rb} +6 -6
- data/app/models/spina/image_collections_image.rb +6 -0
- data/app/models/spina/line.rb +1 -0
- data/app/models/spina/media_folder.rb +7 -0
- data/app/models/spina/navigation.rb +4 -0
- data/app/models/spina/navigation_item.rb +1 -1
- data/app/models/spina/page.rb +18 -13
- data/app/models/spina/page_part.rb +1 -0
- data/app/models/spina/resource.rb +16 -0
- data/app/models/spina/setting.rb +7 -0
- data/app/models/spina/structure.rb +2 -0
- data/app/models/spina/structure_item.rb +2 -0
- data/app/models/spina/structure_part.rb +2 -1
- data/app/models/spina/text.rb +1 -0
- data/app/views/dummy/show.html.haml +1 -0
- data/app/views/layouts/spina/admin/media_library.html.haml +6 -3
- data/app/views/layouts/spina/admin/pages.html.haml +4 -1
- data/app/views/layouts/spina/admin/resources.html.haml +10 -0
- data/app/views/spina/admin/accounts/style.html.haml +3 -2
- data/app/views/spina/admin/attachments/_attachment.html.haml +3 -3
- data/app/views/spina/admin/attachments/_select.html.haml +7 -15
- data/app/views/spina/admin/attachments/_select_collection.html.haml +7 -14
- data/app/views/spina/admin/attachments/create.js.erb +1 -3
- data/app/views/spina/admin/attachments/index.html.haml +4 -3
- data/app/views/spina/admin/attachments/insert.js.erb +5 -0
- data/app/views/spina/admin/image_collections/_image_collection.html.haml +5 -0
- data/app/views/spina/admin/images/_form.html.haml +5 -0
- data/app/views/spina/admin/images/_image.html.haml +10 -0
- data/app/views/spina/admin/images/create.js.erb +8 -0
- data/app/views/spina/admin/images/index.html.haml +22 -0
- data/app/views/spina/admin/images/index.js.erb +7 -0
- data/app/views/spina/admin/media_folders/_form.html.haml +14 -0
- data/app/views/spina/admin/media_folders/_media_folder.html.haml +8 -0
- data/app/views/spina/admin/media_folders/new.js.erb +1 -0
- data/app/views/spina/admin/media_folders/show.html.haml +17 -0
- data/app/views/spina/admin/media_picker/_modal.html.haml +26 -0
- data/app/views/spina/admin/media_picker/infinite_scroll.js.erb +5 -0
- data/app/views/spina/admin/media_picker/select.js.erb +28 -0
- data/app/views/spina/admin/media_picker/show.js.erb +1 -0
- data/app/views/spina/admin/navigations/_page.html.haml +2 -2
- data/app/views/spina/admin/navigations/edit.html.haml +1 -1
- data/app/views/spina/admin/pages/_form.html.haml +21 -15
- data/app/views/spina/admin/pages/_form_advanced.html.haml +53 -43
- data/app/views/spina/admin/pages/_form_page_content.html.haml +1 -1
- data/app/views/spina/admin/pages/_form_page_seo.html.haml +1 -1
- data/app/views/spina/admin/pages/_page_nested_list.html.haml +3 -3
- data/app/views/spina/admin/pages/index.html.haml +1 -1
- data/app/views/spina/admin/{page_partables → partables}/attachment_collections/_form.html.haml +1 -1
- data/app/views/spina/admin/{page_partables → partables}/attachments/_form.html.haml +4 -4
- data/app/views/spina/admin/partables/image_collections/_form.html.haml +16 -0
- data/app/views/spina/admin/partables/images/_form.html.haml +14 -0
- data/app/views/spina/admin/{page_partables → partables}/lines/_form.html.haml +1 -1
- data/app/views/spina/admin/{structure_partables → partables}/options/_form.html.haml +1 -1
- data/app/views/spina/admin/partables/photo_collections/_form.html.haml +4 -0
- data/app/views/spina/admin/partables/photos/_form.html.haml +4 -0
- data/app/views/spina/admin/{page_partables → partables}/structures/_form.html.haml +3 -3
- data/app/views/spina/admin/{page_partables → partables}/texts/_form.html.haml +1 -1
- data/app/views/spina/admin/password_resets/edit.html.haml +1 -1
- data/app/views/spina/admin/password_resets/new.html.haml +1 -1
- data/app/views/spina/admin/resources/edit.html.haml +49 -0
- data/app/views/spina/admin/resources/show.html.haml +14 -0
- data/app/views/spina/admin/sessions/new.html.haml +1 -1
- data/app/views/spina/admin/settings/_string_field.html.haml +4 -0
- data/app/views/spina/admin/settings/_wysiwyg_field.html.haml +4 -0
- data/app/views/spina/admin/settings/edit.html.haml +13 -0
- data/app/views/spina/admin/shared/_primary_navigation.html.haml +13 -5
- data/app/views/spina/admin/shared/_rich_text_field.html.haml +10 -10
- data/app/views/spina/admin/structure_items/_fields.html.haml +1 -1
- data/app/views/spina/admin/structure_partables/attachment_collections/_form.html.haml +14 -0
- data/app/views/spina/admin/structure_partables/attachments/_form.html.haml +13 -0
- data/app/views/spina/shared/_analytics.html.erb +8 -8
- data/app/views/spina/shared/_navigation.html.haml +3 -3
- data/app/views/spina/shared/_spina_link.html.haml +2 -0
- data/app/views/spina/sitemaps/show.xml.builder +2 -2
- data/config/initializers/assets.rb +6 -1
- data/config/locales/TH.yml +243 -0
- data/config/locales/bg.yml +250 -0
- data/config/locales/de.yml +67 -22
- data/config/locales/en.yml +29 -2
- data/config/locales/es.yml +58 -1
- data/config/locales/fr.yml +80 -32
- data/config/locales/id.yml +228 -0
- data/config/locales/nl.yml +32 -0
- data/config/locales/pl.yml +225 -0
- data/config/locales/pt-BR.yml +34 -3
- data/config/locales/ro.yml +225 -0
- data/config/locales/ru.yml +10 -0
- data/config/locales/sv.yml +223 -0
- data/config/routes.rb +13 -13
- data/db/migrate/10_create_spina_image_collections.rb +16 -0
- data/db/migrate/11_create_spina_resources.rb +15 -0
- data/db/migrate/1_create_spina_tables.rb +0 -19
- data/db/migrate/2_create_spina_translation_tables.rb +36 -6
- data/db/migrate/7_create_spina_settings.rb +11 -0
- data/db/migrate/8_create_spina_media_folders.rb +8 -0
- data/db/migrate/9_create_spina_images.rb +10 -0
- data/lib/generators/spina/install_generator.rb +2 -2
- data/lib/generators/spina/templates/app/views/default/pages/homepage.html.haml +3 -2
- data/lib/generators/spina/templates/app/views/default/pages/show.html.haml +2 -2
- data/lib/generators/spina/templates/app/views/default/shared/_navigation.html.haml +3 -5
- data/lib/generators/spina/templates/app/views/demo/pages/demo.html.haml +20 -23
- data/lib/generators/spina/templates/app/views/demo/pages/homepage.html.haml +2 -2
- data/lib/generators/spina/templates/app/views/demo/pages/show.html.haml +2 -2
- data/lib/generators/spina/templates/app/views/demo/shared/_navigation.html.haml +3 -5
- data/lib/generators/spina/templates/config/initializers/mobility.rb +6 -0
- data/lib/generators/spina/templates/config/initializers/spina.rb +3 -0
- data/lib/generators/spina/templates/config/initializers/themes/demo.rb +7 -7
- data/lib/spina.rb +0 -1
- data/lib/spina/engine.rb +6 -7
- data/lib/spina/plugin.rb +48 -3
- data/lib/spina/version.rb +1 -1
- data/vendor/assets/javascripts/spina/stimulus.umd.js +5 -0
- data/vendor/assets/javascripts/spina/trix.js +10 -9
- metadata +106 -103
- data/app/assets/images/spina/danger-zone-ribbon.png +0 -0
- data/app/assets/images/spina/spina_small.png +0 -0
- data/app/assets/javascripts/spina/admin/infinite_scroll.coffee +0 -25
- data/app/controllers/spina/admin/photos_controller.rb +0 -100
- data/app/models/concerns/spina/photo_collectable.rb +0 -24
- data/app/models/spina/photo.rb +0 -29
- data/app/models/spina/photo_collections_photo.rb +0 -6
- data/app/presenters/spina/pages/menu_presenter.rb +0 -63
- data/app/uploaders/spina/default_store_uploader.rb +0 -15
- data/app/uploaders/spina/file_uploader.rb +0 -6
- data/app/uploaders/spina/logo_uploader.rb +0 -13
- data/app/uploaders/spina/photo_uploader.rb +0 -23
- data/app/views/spina/admin/attachments/_fields.html.haml +0 -8
- data/app/views/spina/admin/attachments/insert.js.coffee +0 -5
- data/app/views/spina/admin/page_partables/options/_form.html.haml +0 -6
- data/app/views/spina/admin/page_partables/photo_collections/_form.html.haml +0 -17
- data/app/views/spina/admin/page_partables/photos/_form.html.haml +0 -14
- data/app/views/spina/admin/photos/_photo.html.haml +0 -8
- data/app/views/spina/admin/photos/_photo_collection.html.haml +0 -5
- data/app/views/spina/admin/photos/_photo_collection_select.html.haml +0 -23
- data/app/views/spina/admin/photos/_photo_link.html.haml +0 -11
- data/app/views/spina/admin/photos/_photo_multi_picker.html.haml +0 -3
- data/app/views/spina/admin/photos/_photo_select.html.haml +0 -16
- data/app/views/spina/admin/photos/_photo_single_picker.html.haml +0 -3
- data/app/views/spina/admin/photos/_photo_uploaded.html.haml +0 -4
- data/app/views/spina/admin/photos/_trix_select.html.haml +0 -11
- data/app/views/spina/admin/photos/create.js.erb +0 -4
- data/app/views/spina/admin/photos/index.html.haml +0 -13
- data/app/views/spina/admin/photos/index.js.erb +0 -5
- data/app/views/spina/admin/photos/insert_photo.js.erb +0 -10
- data/app/views/spina/admin/photos/insert_photo_collection.js.erb +0 -25
- data/app/views/spina/admin/photos/link.js.erb +0 -2
- data/app/views/spina/admin/photos/multi_picker_infinite_scroll.js.erb +0 -6
- data/app/views/spina/admin/photos/photo_collection_select.js.erb +0 -3
- data/app/views/spina/admin/photos/photo_select.js.erb +0 -3
- data/app/views/spina/admin/photos/single_picker_infinite_scroll.js.erb +0 -6
- data/app/views/spina/admin/photos/trix_infinite_scroll.js.erb +0 -4
- data/app/views/spina/admin/photos/trix_insert.js.erb +0 -2
- data/app/views/spina/admin/photos/trix_select.js.erb +0 -3
- data/app/views/spina/admin/structure_partables/lines/_form.html.haml +0 -5
- data/app/views/spina/admin/structure_partables/photo_collections/_form.html.haml +0 -17
- data/app/views/spina/admin/structure_partables/photos/_form.html.haml +0 -11
- data/app/views/spina/admin/structure_partables/texts/_form.html.haml +0 -5
- data/config/initializers/spina.rb +0 -0
- data/lib/generators/spina/templates/config/initializers/carrierwave.rb +0 -17
- data/lib/spina/railtie.rb +0 -9
@@ -16,7 +16,7 @@ module Spina
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def authorize_spina_user
|
19
|
-
redirect_to
|
19
|
+
redirect_to admin_login_path, flash: {information: I18n.t('spina.notifications.login')} unless current_spina_user
|
20
20
|
end
|
21
21
|
|
22
22
|
def authorize_admin
|
@@ -7,12 +7,15 @@ module Spina
|
|
7
7
|
|
8
8
|
def index
|
9
9
|
add_breadcrumb I18n.t('spina.website.documents'), spina.admin_attachments_path
|
10
|
-
@attachments = Attachment.
|
11
|
-
@attachment = Attachment.new
|
10
|
+
@attachments = Attachment.sorted
|
12
11
|
end
|
13
12
|
|
14
13
|
def create
|
15
|
-
@
|
14
|
+
@attachments = params[:attachment][:files].map do |file|
|
15
|
+
attachment = Attachment.create(attachment_params)
|
16
|
+
attachment.file.attach(file)
|
17
|
+
attachment
|
18
|
+
end
|
16
19
|
end
|
17
20
|
|
18
21
|
def destroy
|
@@ -23,17 +26,19 @@ module Spina
|
|
23
26
|
|
24
27
|
def select
|
25
28
|
@selected_attachment_id = Attachment.find_by(id: params[:selected_attachment_id]).try(:id)
|
26
|
-
@
|
29
|
+
@hidden_field_id = params[:hidden_field_id]
|
30
|
+
@attachments = Attachment.sorted
|
27
31
|
@attachment = Attachment.new
|
28
32
|
end
|
29
33
|
|
30
34
|
def insert
|
31
35
|
@attachment = Attachment.find(params[:attachment_id])
|
36
|
+
Rails.logger.info "HAHA HA HA #{@attachment.id}"
|
32
37
|
end
|
33
38
|
|
34
39
|
def select_collection
|
35
40
|
@selected_attachment_ids = Attachment.where(id: params[:selected_attachment_ids]).ids
|
36
|
-
@attachments = Attachment.
|
41
|
+
@attachments = Attachment.sorted
|
37
42
|
@attachment = Attachment.new
|
38
43
|
end
|
39
44
|
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Spina
|
2
|
+
module Admin
|
3
|
+
class ImagesController < AdminController
|
4
|
+
before_action :set_breadcrumbs
|
5
|
+
|
6
|
+
layout "spina/admin/media_library"
|
7
|
+
|
8
|
+
def index
|
9
|
+
add_breadcrumb I18n.t('spina.website.images'), admin_images_path
|
10
|
+
@media_folders = MediaFolder.order(:name)
|
11
|
+
@images = Image.sorted.where(media_folder_id: nil).with_attached_file.page(params[:page])
|
12
|
+
end
|
13
|
+
|
14
|
+
# There's no file validation yet in ActiveStorage
|
15
|
+
# We do two things to reduce errors right now:
|
16
|
+
# 1. We add accept="image/*" to the image form
|
17
|
+
# 2. We destroy the entire record if the uploaded file is not an image
|
18
|
+
def create
|
19
|
+
@images = params[:image][:files].map do |file|
|
20
|
+
# Create the image and attach the file
|
21
|
+
image = Image.create
|
22
|
+
image.file.attach(file)
|
23
|
+
|
24
|
+
# Was it not an image after all? DESTROY IT
|
25
|
+
image.destroy and next unless image.file.image?
|
26
|
+
|
27
|
+
image
|
28
|
+
end.compact
|
29
|
+
end
|
30
|
+
|
31
|
+
def destroy
|
32
|
+
@image = Image.find(params[:id])
|
33
|
+
@image.destroy
|
34
|
+
redirect_back fallback_location: spina.admin_images_url
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_to_media_folder
|
38
|
+
@media_folder = MediaFolder.find(params[:id])
|
39
|
+
@media_folder.images << Image.find(params[:image_id])
|
40
|
+
render json: @media_folder
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def set_breadcrumbs
|
46
|
+
add_breadcrumb I18n.t('spina.website.media_library'), admin_media_library_path
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Spina
|
2
|
+
module Admin
|
3
|
+
class MediaFoldersController < AdminController
|
4
|
+
layout "spina/admin/media_library"
|
5
|
+
|
6
|
+
def new
|
7
|
+
@media_folder = MediaFolder.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def show
|
11
|
+
add_breadcrumb I18n.t('spina.website.media_library'), admin_media_library_path
|
12
|
+
add_breadcrumb I18n.t('spina.website.images'), spina.admin_images_path
|
13
|
+
@media_folder = MediaFolder.find(params[:id])
|
14
|
+
add_breadcrumb @media_folder.name
|
15
|
+
@images = @media_folder.images.sorted.page(params[:page])
|
16
|
+
end
|
17
|
+
|
18
|
+
def create
|
19
|
+
@media_folder = MediaFolder.new(media_folder_params)
|
20
|
+
@media_folder.save
|
21
|
+
redirect_to spina.admin_images_path
|
22
|
+
end
|
23
|
+
|
24
|
+
def destroy
|
25
|
+
@media_folder = MediaFolder.find(params[:id])
|
26
|
+
@media_folder.destroy
|
27
|
+
redirect_to spina.admin_images_path
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def media_folder_params
|
33
|
+
params.require(:media_folder).permit(:name)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Spina
|
2
|
+
module Admin
|
3
|
+
class MediaPickerController < AdminController
|
4
|
+
|
5
|
+
def show
|
6
|
+
@images = Image.page(params[:page])
|
7
|
+
|
8
|
+
if params[:selected_ids].present?
|
9
|
+
ids = params[:selected_ids].map(&:to_i).join(', ')
|
10
|
+
@images = @images.order(Arel.sql("CASE WHEN id IN(#{ids}) THEN 0 ELSE 1 END, created_at DESC"))
|
11
|
+
else
|
12
|
+
@images = @images.sorted
|
13
|
+
end
|
14
|
+
|
15
|
+
render params[:page].present? ? :infinite_scroll : :show
|
16
|
+
end
|
17
|
+
|
18
|
+
def select
|
19
|
+
if params[:multiple]
|
20
|
+
@images = Image.find(params[:image_ids])
|
21
|
+
else
|
22
|
+
@image = Image.find(params[:image_id])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,17 +1,19 @@
|
|
1
1
|
module Spina
|
2
2
|
module Admin
|
3
3
|
class PagesController < AdminController
|
4
|
-
before_action :set_breadcrumb
|
5
4
|
before_action :set_tabs, only: [:new, :create, :edit, :update]
|
6
5
|
before_action :set_locale
|
7
6
|
|
8
7
|
def index
|
8
|
+
add_breadcrumb I18n.t('spina.website.pages'), spina.admin_pages_path
|
9
9
|
redirect_to admin_pages_path unless current_admin_path.starts_with?('/pages')
|
10
|
-
@pages = Page.active.sorted.roots
|
10
|
+
@pages = Page.active.sorted.roots.regular_pages
|
11
11
|
end
|
12
12
|
|
13
13
|
def new
|
14
|
-
@
|
14
|
+
@resource = Resource.find_by(id: params[:resource_id])
|
15
|
+
@page = Page.new(resource: @resource, parent: @resource&.parent_page)
|
16
|
+
add_index_breadcrumb
|
15
17
|
if current_theme.new_page_templates.any? { |template| template[0] == params[:view_template] }
|
16
18
|
@page.view_template = params[:view_template]
|
17
19
|
end
|
@@ -34,6 +36,7 @@ module Spina
|
|
34
36
|
|
35
37
|
def edit
|
36
38
|
@page = Page.find(params[:id])
|
39
|
+
add_index_breadcrumb
|
37
40
|
add_breadcrumb @page.title
|
38
41
|
@page_parts = @page.view_template_page_parts(current_theme).map { |part| @page.part(part) }
|
39
42
|
render layout: 'spina/admin/admin'
|
@@ -50,6 +53,9 @@ module Spina
|
|
50
53
|
format.html { redirect_to spina.edit_admin_page_url(@page, params: {locale: @locale}), flash: {success: t('spina.pages.saved')} }
|
51
54
|
format.js
|
52
55
|
else
|
56
|
+
50.times do
|
57
|
+
Rails.logger.info @page.errors.inspect
|
58
|
+
end
|
53
59
|
format.html do
|
54
60
|
@page_parts = @page.view_template_page_parts(current_theme).map { |part| @page.part(part) }
|
55
61
|
render :edit, layout: 'spina/admin/admin'
|
@@ -78,8 +84,12 @@ module Spina
|
|
78
84
|
@locale = params[:locale] || I18n.default_locale
|
79
85
|
end
|
80
86
|
|
81
|
-
def
|
82
|
-
|
87
|
+
def add_index_breadcrumb
|
88
|
+
if @page.resource.present?
|
89
|
+
add_breadcrumb @page.resource.label, spina.admin_resource_path(@page.resource)
|
90
|
+
else
|
91
|
+
add_breadcrumb I18n.t('spina.website.pages'), spina.admin_pages_path
|
92
|
+
end
|
83
93
|
end
|
84
94
|
|
85
95
|
def set_tabs
|
@@ -100,7 +110,7 @@ module Spina
|
|
100
110
|
end
|
101
111
|
|
102
112
|
def page_params
|
103
|
-
params.require(:page).permit
|
113
|
+
params.require(:page).permit!
|
104
114
|
end
|
105
115
|
|
106
116
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Spina
|
2
|
+
module Admin
|
3
|
+
class ResourcesController < AdminController
|
4
|
+
|
5
|
+
def show
|
6
|
+
@resource = Resource.find(params[:id])
|
7
|
+
add_breadcrumb @resource.label
|
8
|
+
end
|
9
|
+
|
10
|
+
def edit
|
11
|
+
@resource = Resource.find(params[:id])
|
12
|
+
add_breadcrumb @resource.label, spina.admin_resource_path(@resource)
|
13
|
+
add_breadcrumb t('spina.edit')
|
14
|
+
end
|
15
|
+
|
16
|
+
def update
|
17
|
+
@resource = Resource.find(params[:id])
|
18
|
+
if @resource.update_attributes(resource_params)
|
19
|
+
redirect_to spina.admin_resource_path(@resource)
|
20
|
+
else
|
21
|
+
render :edit
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def resource_params
|
28
|
+
params.require(:resource).permit(:label, :view_template, :order_by, :parent_page_id)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Spina
|
2
|
+
module Admin
|
3
|
+
class SettingsController < AdminController
|
4
|
+
|
5
|
+
before_action :find_or_set_settings
|
6
|
+
before_action :set_breadcrumbs
|
7
|
+
|
8
|
+
def edit
|
9
|
+
add_breadcrumb t("spina.#{plugin.namespace}.title")
|
10
|
+
end
|
11
|
+
|
12
|
+
def update
|
13
|
+
if @setting.update_attributes(settings_params)
|
14
|
+
redirect_to spina.admin_edit_settings_path(plugin.namespace)
|
15
|
+
else
|
16
|
+
add_breadcrumb t("spina.#{plugin.namespace}.title")
|
17
|
+
render :edit
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def setting_class
|
24
|
+
"spina/#{plugin.namespace}/setting".classify.constantize
|
25
|
+
end
|
26
|
+
|
27
|
+
def plugin
|
28
|
+
Spina::Plugin.find_by(namespace: params[:plugin])
|
29
|
+
end
|
30
|
+
helper_method :plugin
|
31
|
+
|
32
|
+
def find_or_set_settings
|
33
|
+
@setting = setting_class.first_or_create do |setting|
|
34
|
+
plugin.settings.each do |attribute, type|
|
35
|
+
setting.send("#{attribute}=", (type.is_a?(Hash) ? type.first.last : nil))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
plugin.settings.keys.reject do |x|
|
39
|
+
@setting.preferences.keys.map(&:to_sym).include? x
|
40
|
+
end.each do |key|
|
41
|
+
value = plugin.settings[key].is_a?(Hash) ? plugin.settings[key].first.last : nil
|
42
|
+
@setting.send("#{key}=", value)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def set_breadcrumbs
|
47
|
+
add_breadcrumb t('spina.settings.title')
|
48
|
+
end
|
49
|
+
|
50
|
+
def settings_params
|
51
|
+
params.require(:setting).permit(plugin.settings.keys)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -2,8 +2,6 @@ module Spina
|
|
2
2
|
class PagesController < Spina::ApplicationController
|
3
3
|
include Spina::Frontend
|
4
4
|
|
5
|
-
rescue_from ActiveRecord::RecordNotFound, with: :render_404
|
6
|
-
|
7
5
|
before_action :current_spina_user_can_view_page?, except: [:robots]
|
8
6
|
|
9
7
|
helper_method :page
|
@@ -20,9 +18,5 @@ module Spina
|
|
20
18
|
current_spina_user.present?
|
21
19
|
end
|
22
20
|
|
23
|
-
def render_404
|
24
|
-
render file: "#{Rails.root}/public/404.html", status: 404
|
25
|
-
end
|
26
|
-
|
27
21
|
end
|
28
22
|
end
|
@@ -36,8 +36,8 @@ module Spina
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def page_ancestry_options(page)
|
39
|
-
pages = Spina::Page.active
|
40
|
-
pages = pages.where.not(id: page.subtree.ids) unless page.new_record?
|
39
|
+
pages = Spina::Page.active.regular_pages
|
40
|
+
pages = pages.where.not(id: page.subtree.ids) unless page.new_record? || !page.methods.include?(:subtree)
|
41
41
|
|
42
42
|
flatten_nested_hash(pages.arrange(order: :position)).map do |page|
|
43
43
|
next if page.depth >= Spina.config.max_page_depth - 1
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Spina
|
2
|
+
module ImagesHelper
|
3
|
+
|
4
|
+
# We wrap some Rails logic inside our own helper method
|
5
|
+
# because the resolve directive in ActiveStorage's routes
|
6
|
+
# doesn't work outside the main app in 5.2.0.rc2
|
7
|
+
def variant(image, options)
|
8
|
+
if image.attached?
|
9
|
+
variant = image.variant(options)
|
10
|
+
main_app.rails_blob_representation_path(variant.blob.signed_id, variant.variation.key, variant.blob.filename)
|
11
|
+
else
|
12
|
+
"https://placehold.it/100x100.png"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module Spina
|
4
|
+
module ImageCollectable
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
attr_reader :image_tokens, :image_positions
|
9
|
+
end
|
10
|
+
|
11
|
+
def image_tokens=(ids)
|
12
|
+
self.image_ids = ids.split(",")
|
13
|
+
end
|
14
|
+
|
15
|
+
def image_positions=(positions)
|
16
|
+
positions = positions.split(",")
|
17
|
+
self.image_collections_images.each do |image|
|
18
|
+
image.position = positions.index(image.image.try(:id).try(:to_s))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -9,6 +9,8 @@ module Spina
|
|
9
9
|
|
10
10
|
validates :name, :title, :partable_type, presence: true
|
11
11
|
|
12
|
+
after_save -> { partable.try(:save) }
|
13
|
+
|
12
14
|
scope :sorted, -> { order(:position) }
|
13
15
|
end
|
14
16
|
|
@@ -17,19 +19,20 @@ module Spina
|
|
17
19
|
end
|
18
20
|
|
19
21
|
def content
|
20
|
-
|
22
|
+
(partable || partable_type.constantize.new).content
|
21
23
|
end
|
22
24
|
|
23
25
|
def value
|
24
|
-
|
26
|
+
partable.try(:value)
|
25
27
|
end
|
26
28
|
|
27
29
|
def partable_attributes=(attributes)
|
28
|
-
if
|
29
|
-
|
30
|
+
if partable.present?
|
31
|
+
partable.assign_attributes(attributes)
|
30
32
|
else
|
31
33
|
self.partable = self.partable_type.constantize.new(attributes)
|
32
34
|
end
|
33
35
|
end
|
36
|
+
|
34
37
|
end
|
35
38
|
end
|