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
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Spina::Theme.register do |theme|
|
7
7
|
# All views are namespaced based on the theme's name
|
8
|
-
theme.name =
|
9
|
-
theme.title =
|
8
|
+
theme.name = "demo"
|
9
|
+
theme.title = "Demo theme"
|
10
10
|
|
11
|
-
# Parts
|
11
|
+
# Parts
|
12
12
|
# Define all editable parts you want to use in your view templates
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# Built-in part types:
|
15
15
|
# - Line
|
16
16
|
# - MultiLine
|
@@ -21,13 +21,13 @@ Spina::Theme.register do |theme|
|
|
21
21
|
# - Option
|
22
22
|
# - Repeater
|
23
23
|
theme.parts = [
|
24
|
-
{name:
|
25
|
-
{name:
|
26
|
-
{name:
|
24
|
+
{name: "repeater", title: "Repeater", part_type: "Spina::Parts::Repeater", item_name: "item", parts: %w[line image headline]},
|
25
|
+
{name: "line", title: "Line", part_type: "Spina::Parts::Line"},
|
26
|
+
{name: "body", title: "Body", hint: "Your content", part_type: "Spina::Parts::Text"},
|
27
27
|
{name: "image_collection", title: "Image collection", part_type: "Spina::Parts::ImageCollection"},
|
28
|
-
{name:
|
29
|
-
{name:
|
30
|
-
{name:
|
28
|
+
{name: "image", title: "Image", part_type: "Spina::Parts::Image"},
|
29
|
+
{name: "headline", title: "Headline", hint: "Used in the header", part_type: "Spina::Parts::Line"},
|
30
|
+
{name: "footer", title: "Footer", part_type: "Spina::Parts::Text"}
|
31
31
|
]
|
32
32
|
|
33
33
|
# View templates
|
@@ -35,41 +35,41 @@ Spina::Theme.register do |theme|
|
|
35
35
|
# You define which parts you want to enable for every view template
|
36
36
|
# by referencing them from the theme.parts configuration above.
|
37
37
|
theme.view_templates = [
|
38
|
-
{name:
|
39
|
-
{name:
|
40
|
-
{name:
|
38
|
+
{name: "homepage", title: "Homepage", parts: %w[headline body image_collection]},
|
39
|
+
{name: "show", title: "Default", parts: %w[body image repeater]},
|
40
|
+
{name: "demo", title: "Demo", parts: %w[body image_collection image repeater], exclude_from: %w[articles]}
|
41
41
|
]
|
42
42
|
|
43
43
|
# Custom pages
|
44
44
|
# Some pages should not be created by the user, but generated automatically.
|
45
45
|
# By naming them you can reference them in your code.
|
46
46
|
theme.custom_pages = [
|
47
|
-
{name:
|
48
|
-
{name:
|
47
|
+
{name: "homepage", title: "Homepage", deletable: false, view_template: "homepage"},
|
48
|
+
{name: "demo", title: "Demo", deletable: true, view_template: "demo"}
|
49
49
|
]
|
50
|
-
|
50
|
+
|
51
51
|
# Navigations (optional)
|
52
52
|
# If your project has multiple navigations, it can be useful to configure multiple
|
53
53
|
# navigations.
|
54
54
|
theme.navigations = [
|
55
|
-
{name:
|
55
|
+
{name: "main", label: "Main navigation"}
|
56
56
|
]
|
57
|
-
|
57
|
+
|
58
58
|
# Layout parts (optional)
|
59
59
|
# You can create global content that doesn't belong to one specific page. We call these layout parts.
|
60
60
|
# You only have to reference the name of the parts you want to have here.
|
61
61
|
theme.layout_parts = []
|
62
|
-
|
62
|
+
|
63
63
|
# Resources (optional)
|
64
64
|
# Think of resources as a collection of pages. They are managed separately in Spina
|
65
65
|
# allowing you to separate these pages from the 'main' collection of pages.
|
66
66
|
theme.resources = [
|
67
|
-
{name:
|
67
|
+
{name: "articles", label: "Articles", view_template: "article", slug: "articles"}
|
68
68
|
]
|
69
69
|
|
70
70
|
# Plugins (optional)
|
71
|
-
theme.plugins = [
|
72
|
-
|
71
|
+
theme.plugins = ["reviews"]
|
72
|
+
|
73
73
|
# Embeds (optional)
|
74
74
|
theme.embeds = []
|
75
75
|
end
|
@@ -1,23 +1,20 @@
|
|
1
1
|
module Spina
|
2
|
-
module AdminSectionable
|
2
|
+
module AdminSectionable
|
3
3
|
extend ActiveSupport::Concern
|
4
|
-
|
4
|
+
|
5
5
|
included do |base|
|
6
6
|
extend ClassMethods
|
7
|
-
|
7
|
+
|
8
8
|
helper_method :admin_section
|
9
9
|
attr_accessor :admin_section
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
module ClassMethods
|
13
|
-
|
14
13
|
def admin_section(name)
|
15
14
|
before_action do |controller|
|
16
15
|
controller.send(:admin_section=, name.to_sym)
|
17
16
|
end
|
18
17
|
end
|
19
|
-
|
20
18
|
end
|
21
|
-
|
22
19
|
end
|
23
|
-
end
|
20
|
+
end
|
@@ -1,13 +1,12 @@
|
|
1
1
|
module Spina
|
2
|
-
module AttrJsonMonkeypatch
|
2
|
+
module AttrJsonMonkeypatch
|
3
3
|
extend ActiveSupport::Concern
|
4
|
-
|
4
|
+
|
5
5
|
included do |base|
|
6
6
|
extend ClassMethods
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
module ClassMethods
|
10
|
-
|
11
10
|
def attr_json_setter_monkeypatch(name)
|
12
11
|
# Ruby bug in 3.0.0 related to defined?(super) returning true
|
13
12
|
# https://github.com/jrochkind/attr_json/issues/112
|
@@ -21,8 +20,6 @@ module Spina
|
|
21
20
|
end
|
22
21
|
end
|
23
22
|
end
|
24
|
-
|
25
23
|
end
|
26
|
-
|
27
24
|
end
|
28
|
-
end
|
25
|
+
end
|
@@ -1,11 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require "attr_json/type/polymorphic_model"
|
2
2
|
|
3
3
|
# Extending the PolymorphicModel to use the Spina::PARTS array as input
|
4
4
|
# as opposed to arguments
|
5
5
|
module AttrJson
|
6
6
|
module Type
|
7
7
|
class SpinaPartsModel < PolymorphicModel
|
8
|
-
|
9
8
|
def model_names
|
10
9
|
spina_parts_lookup.keys
|
11
10
|
end
|
@@ -23,7 +22,6 @@ module AttrJson
|
|
23
22
|
def type_for_model_name(model_name)
|
24
23
|
spina_parts_lookup[model_name]
|
25
24
|
end
|
26
|
-
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
@@ -2,23 +2,22 @@ module Spina
|
|
2
2
|
module Authentication
|
3
3
|
module Basic
|
4
4
|
extend ActiveSupport::Concern
|
5
|
-
|
5
|
+
|
6
6
|
included do
|
7
7
|
helper_method :logged_in?
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def logged_in?
|
11
11
|
authenticate
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
private
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
15
|
+
|
16
|
+
def authenticate
|
17
|
+
authenticate_or_request_with_http_basic do |username, password|
|
18
|
+
username == Rails.application.credentials.dig(:spina, :username) && password == Rails.application.credentials.dig(:spina, :password)
|
20
19
|
end
|
21
|
-
|
20
|
+
end
|
22
21
|
end
|
23
22
|
end
|
24
|
-
end
|
23
|
+
end
|
@@ -2,31 +2,30 @@ module Spina
|
|
2
2
|
module Authentication
|
3
3
|
module Sessions
|
4
4
|
extend ActiveSupport::Concern
|
5
|
-
|
5
|
+
|
6
6
|
included do
|
7
7
|
helper_method :current_spina_user
|
8
8
|
helper_method :logged_in?
|
9
9
|
helper_method :logout_path
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def current_spina_user
|
13
13
|
Spina::Current.user ||= User.find_by(id: session[:spina_user_id]) if session[:spina_user_id]
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def logged_in?
|
17
17
|
current_spina_user
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def logout_path
|
21
21
|
spina.admin_logout_path
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
private
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
|
26
|
+
def authenticate
|
27
|
+
redirect_to admin_login_path, flash: {information: I18n.t("spina.notifications.login")} unless logged_in?
|
28
|
+
end
|
30
29
|
end
|
31
30
|
end
|
32
|
-
end
|
31
|
+
end
|
data/lib/spina/embeddable.rb
CHANGED
@@ -1,48 +1,45 @@
|
|
1
1
|
module Spina
|
2
2
|
module Embeddable
|
3
3
|
extend ActiveSupport::Concern
|
4
|
-
|
4
|
+
|
5
5
|
included do
|
6
6
|
class_attribute :embed_attributes, default: []
|
7
7
|
class_attribute :icon, default: nil
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
class_methods do
|
11
11
|
def from_json(json)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
nil
|
19
|
-
end
|
12
|
+
attributes = JSON.parse(json)
|
13
|
+
attributes.transform_keys!(&:to_sym)
|
14
|
+
new(attributes)
|
15
|
+
rescue
|
16
|
+
Rails.logger.error "[#{self.class.name}] Couldn't parse JSON"
|
17
|
+
nil
|
20
18
|
end
|
21
|
-
|
19
|
+
|
22
20
|
def attributes(*names)
|
23
21
|
attr_accessor(*names.map(&:to_sym))
|
24
22
|
self.embed_attributes += names.map(&:to_sym)
|
25
23
|
end
|
26
|
-
|
24
|
+
|
27
25
|
# Give it an icon
|
28
26
|
def heroicon(name)
|
29
27
|
self.icon = name
|
30
28
|
end
|
31
29
|
end
|
32
|
-
|
30
|
+
|
33
31
|
def initialize(attributes = {})
|
34
32
|
attributes.slice(*self.class.embed_attributes).each do |key, value|
|
35
33
|
instance_variable_set("@#{key}", value)
|
36
34
|
end
|
37
35
|
end
|
38
|
-
|
36
|
+
|
39
37
|
def to_fields_path
|
40
38
|
"#{to_partial_path}_fields"
|
41
39
|
end
|
42
|
-
|
40
|
+
|
43
41
|
def to_trix_partial_path
|
44
42
|
to_partial_path
|
45
43
|
end
|
46
|
-
|
47
44
|
end
|
48
|
-
end
|
45
|
+
end
|
@@ -2,40 +2,39 @@ module Spina
|
|
2
2
|
module Embeds
|
3
3
|
module TrixConversion
|
4
4
|
extend ActiveSupport::Concern
|
5
|
-
|
5
|
+
|
6
6
|
# Wrap rendered partial in an <embed> tag for Trix
|
7
|
-
def to_trix_attachment(content = trix_attachment_content)
|
7
|
+
def to_trix_attachment(content = trix_attachment_content)
|
8
8
|
wrap_with_embed_tag(content)
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def wrap_with_embed_tag(html)
|
12
12
|
element = html_document.create_element("spina-embed", embed_tag_attributes)
|
13
13
|
element.inner_html = html
|
14
14
|
element.to_html
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
private
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
18
|
+
|
19
|
+
def embed_tag_attributes
|
20
|
+
spina_attributes.merge({"data-embed-attributes": embed_attributes_to_json})
|
21
|
+
end
|
22
|
+
|
23
|
+
def embed_attributes_to_json
|
24
|
+
JSON.generate self.class.embed_attributes.map { |a| [a.to_s, send(a)] }.to_h
|
25
|
+
end
|
26
|
+
|
27
|
+
def spina_attributes
|
28
|
+
{"data-embed-type": self.class.name, "data-controller": "embed-tag"}
|
29
|
+
end
|
30
|
+
|
31
|
+
def trix_attachment_content
|
32
|
+
ApplicationController.render(partial: to_trix_partial_path, formats: :html, object: self, as: model_name.element)
|
33
|
+
end
|
34
|
+
|
35
|
+
def html_document
|
36
|
+
Nokogiri::HTML::Document.new.tap { |doc| doc.encoding = "UTF-8" }
|
37
|
+
end
|
39
38
|
end
|
40
39
|
end
|
41
|
-
end
|
40
|
+
end
|
data/lib/spina/embeds.rb
CHANGED
data/lib/spina/engine.rb
CHANGED
@@ -1,33 +1,33 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
1
|
+
require "importmap-rails"
|
2
|
+
require "turbo-rails"
|
3
|
+
require "stimulus-rails"
|
4
|
+
require "ancestry"
|
5
|
+
require "breadcrumbs_on_rails"
|
6
|
+
require "kaminari"
|
7
|
+
require "mobility"
|
8
|
+
require "rack-rewrite"
|
9
|
+
require "babosa"
|
10
|
+
require "attr_json"
|
11
|
+
require "view_component"
|
12
|
+
require "jsonapi/serializer"
|
13
|
+
require "browser"
|
14
|
+
require "sprockets/railtie"
|
15
15
|
|
16
16
|
module Spina
|
17
17
|
class Engine < ::Rails::Engine
|
18
18
|
isolate_namespace Spina
|
19
|
-
|
20
|
-
config.autoload_paths += %W
|
19
|
+
|
20
|
+
config.autoload_paths += %W[#{config.root}/lib]
|
21
21
|
|
22
22
|
config.to_prepare do
|
23
|
-
# Require decorators from main application
|
24
23
|
unless Spina.config.disable_decorator_load
|
25
24
|
Dir.glob(Rails.root + "app/decorators/**/*_decorator.rb").each do |decorator|
|
25
|
+
ActiveSupport::Deprecation.warn("using app/decorators is deprecated in favor of app/overrides. Read more about overriding Spina at spinacms.com/guides")
|
26
26
|
require_dependency(decorator)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
config.to_prepare do
|
32
32
|
Spina::Part.register(
|
33
33
|
Spina::Parts::Line,
|
@@ -40,6 +40,5 @@ module Spina
|
|
40
40
|
Spina::Parts::Attachment
|
41
41
|
)
|
42
42
|
end
|
43
|
-
|
44
43
|
end
|
45
44
|
end
|
data/lib/spina/part.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
module Spina
|
2
2
|
class Part
|
3
|
-
|
4
3
|
class << self
|
5
|
-
|
6
4
|
def all
|
7
5
|
::Spina::PARTS
|
8
6
|
end
|
@@ -13,15 +11,12 @@ module Spina
|
|
13
11
|
all << part
|
14
12
|
end
|
15
13
|
end
|
16
|
-
|
14
|
+
|
17
15
|
def unregister(part)
|
18
16
|
all.delete_if do |registered_part|
|
19
17
|
registered_part.name == part.name
|
20
18
|
end
|
21
19
|
end
|
22
|
-
|
23
20
|
end
|
24
|
-
|
25
21
|
end
|
26
22
|
end
|
27
|
-
|
data/lib/spina/plugin.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module Spina
|
2
2
|
class Plugin
|
3
|
-
|
4
3
|
attr_accessor :name, :namespace, :settings
|
5
4
|
|
6
5
|
def create_setting_class!
|
@@ -10,15 +9,15 @@ module Spina
|
|
10
9
|
klass = Class.new(::Spina::Setting) do
|
11
10
|
include AttrJson::Record
|
12
11
|
include Spina::AttrJsonMonkeypatch
|
13
|
-
|
12
|
+
|
14
13
|
class_settings.each do |setting|
|
15
|
-
attr_json
|
14
|
+
attr_json(*setting, container_attribute: "preferences")
|
16
15
|
attr_json_setter_monkeypatch setting.first
|
17
16
|
end
|
18
17
|
|
19
|
-
default_scope { where(plugin:
|
18
|
+
default_scope { where(plugin: plugin_name.to_s) }
|
20
19
|
end
|
21
|
-
"Spina::#{namespace_class}".constantize.const_set
|
20
|
+
"Spina::#{namespace_class}".constantize.const_set :Setting, klass
|
22
21
|
end
|
23
22
|
|
24
23
|
private
|
@@ -32,11 +31,11 @@ module Spina
|
|
32
31
|
end
|
33
32
|
|
34
33
|
def namespace_class
|
35
|
-
namespace.split(
|
34
|
+
namespace.split("_").map { |part| part.camelize }.join
|
36
35
|
end
|
37
36
|
|
38
37
|
def data_mapped_settings_hash
|
39
|
-
hash =
|
38
|
+
hash = {}
|
40
39
|
settings.each do |key, value|
|
41
40
|
hash[key] = map_data_type(value)
|
42
41
|
end
|
@@ -44,12 +43,11 @@ module Spina
|
|
44
43
|
end
|
45
44
|
|
46
45
|
class << self
|
47
|
-
|
48
46
|
def all
|
49
47
|
::Spina::PLUGINS
|
50
48
|
end
|
51
49
|
|
52
|
-
def find_by(opts={})
|
50
|
+
def find_by(opts = {})
|
53
51
|
all.find do |plugin|
|
54
52
|
matches = true
|
55
53
|
opts.each do |key, value|
|
@@ -62,8 +60,8 @@ module Spina
|
|
62
60
|
def register
|
63
61
|
plugin = new
|
64
62
|
yield plugin
|
65
|
-
raise
|
66
|
-
raise
|
63
|
+
raise "Missing plugin name" if plugin.name.nil?
|
64
|
+
raise "Missing plugin namespace" if plugin.namespace.nil?
|
67
65
|
|
68
66
|
if plugin.settings.present?
|
69
67
|
plugin.create_setting_class!
|
@@ -72,8 +70,6 @@ module Spina
|
|
72
70
|
all << plugin
|
73
71
|
plugin
|
74
72
|
end
|
75
|
-
|
76
73
|
end
|
77
|
-
|
78
74
|
end
|
79
75
|
end
|
data/lib/spina/railtie.rb
CHANGED
@@ -1,23 +1,21 @@
|
|
1
1
|
module Spina
|
2
2
|
class Railtie < Rails::Railtie
|
3
|
-
|
4
3
|
initializer "spina.assets.precompile" do |app|
|
5
|
-
app.config.assets.precompile += %w
|
4
|
+
app.config.assets.precompile += %w[spina/manifest]
|
6
5
|
end
|
7
|
-
|
6
|
+
|
8
7
|
initializer "spina.theme_reloader" do |app|
|
9
8
|
reloader = ThemeReloader.new
|
10
9
|
reloader.execute
|
11
|
-
|
10
|
+
|
12
11
|
app.reloaders << reloader
|
13
12
|
app.reloader.to_run do
|
14
13
|
reloader.execute
|
15
14
|
end
|
16
15
|
end
|
17
|
-
|
16
|
+
|
18
17
|
ActiveSupport.on_load(:action_controller) do
|
19
18
|
::ActionController::Base.send(:include, Spina::AdminSectionable)
|
20
19
|
end
|
21
|
-
|
22
20
|
end
|
23
|
-
end
|
21
|
+
end
|
data/lib/spina/theme.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
module Spina
|
2
2
|
class Theme
|
3
|
-
|
4
3
|
attr_accessor :name, :title, :parts, :page_parts, :structures, :view_templates, :layout_parts, :custom_pages, :plugins, :public_theme, :config, :navigations, :resources, :embeds
|
5
4
|
|
6
5
|
class << self
|
7
|
-
|
8
6
|
def all
|
9
7
|
::Spina::THEMES
|
10
8
|
end
|
11
|
-
|
9
|
+
|
12
10
|
def unregister(name)
|
13
11
|
theme = find_by_name(name)
|
14
12
|
all.delete(theme) if theme
|
@@ -21,30 +19,29 @@ module Spina
|
|
21
19
|
def register
|
22
20
|
theme = ::Spina::Theme.new
|
23
21
|
yield theme
|
24
|
-
raise
|
22
|
+
raise "Missing theme name" if theme.name.nil?
|
25
23
|
unregister(theme.name)
|
26
24
|
if theme.plugins.nil?
|
27
25
|
theme.plugins = ::Spina::Plugin.all.map { |plugin| plugin.name }
|
28
26
|
end
|
29
27
|
all << theme
|
30
28
|
end
|
31
|
-
|
32
29
|
end
|
33
30
|
|
34
31
|
def initialize
|
35
|
-
@page_parts
|
36
|
-
@structures
|
37
|
-
@layout_parts
|
38
|
-
@view_templates
|
39
|
-
@custom_pages
|
40
|
-
@navigations
|
41
|
-
@resources
|
42
|
-
@embeds
|
32
|
+
@page_parts = []
|
33
|
+
@structures = []
|
34
|
+
@layout_parts = []
|
35
|
+
@view_templates = []
|
36
|
+
@custom_pages = []
|
37
|
+
@navigations = []
|
38
|
+
@resources = []
|
39
|
+
@embeds = []
|
43
40
|
@public_theme = false
|
44
41
|
end
|
45
|
-
|
42
|
+
|
46
43
|
def embeddables
|
47
|
-
embeds.map{|embed| Embeds.constantize(embed)}
|
44
|
+
embeds.map { |embed| Embeds.constantize(embed) }
|
48
45
|
end
|
49
46
|
|
50
47
|
def new_page_templates(resource: nil)
|
@@ -52,7 +49,7 @@ module Spina
|
|
52
49
|
@view_templates.map do |view_template|
|
53
50
|
next if is_custom_undeletable_page?(view_template[:name])
|
54
51
|
next if view_template[:exclude_from]&.include?(page_collection)
|
55
|
-
|
52
|
+
|
56
53
|
OpenStruct.new({
|
57
54
|
name: view_template[:name],
|
58
55
|
title: view_template[:title],
|
@@ -68,6 +65,5 @@ module Spina
|
|
68
65
|
def is_custom_undeletable_page?(view_template_name)
|
69
66
|
@custom_pages.any? { |page| page[:view_template] == view_template_name && !page[:deletable] }
|
70
67
|
end
|
71
|
-
|
72
68
|
end
|
73
69
|
end
|