spina 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of spina might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/app/assets/javascripts/spina/admin/account.js.coffee +1 -1
- data/app/assets/javascripts/spina/admin/pages.js.coffee.erb +1 -1
- data/app/assets/javascripts/spina/admin/spina.infinite_scroll.coffee +6 -2
- data/app/assets/javascripts/spina/admin/spina.scaffold.coffee +2 -2
- data/app/assets/javascripts/spina/admin/{spina.trix.js.coffee → spina.trix.js.coffee.erb} +1 -1
- data/app/assets/stylesheets/spina/admin/application.sass +3 -0
- data/app/controllers/spina/admin/accounts_controller.rb +0 -2
- data/app/controllers/spina/admin/admin_controller.rb +0 -2
- data/app/controllers/spina/admin/attachments_controller.rb +5 -3
- data/app/controllers/spina/admin/pages_controller.rb +1 -2
- data/app/controllers/spina/admin/photos_controller.rb +9 -6
- data/app/controllers/spina/admin/users_controller.rb +0 -2
- data/app/controllers/spina/pages_controller.rb +17 -6
- data/app/helpers/spina/admin/pages_helper.rb +15 -0
- data/app/models/spina/account.rb +8 -7
- data/app/models/spina/application_record.rb +5 -0
- data/app/models/spina/attachment.rb +6 -1
- data/app/models/spina/attachment_collection.rb +1 -1
- data/app/models/spina/color.rb +1 -1
- data/app/models/spina/layout_part.rb +1 -1
- data/app/models/spina/line.rb +1 -1
- data/app/models/spina/page.rb +10 -2
- data/app/models/spina/page_part.rb +1 -1
- data/app/models/spina/photo.rb +2 -2
- data/app/models/spina/photo_collection.rb +1 -1
- data/app/models/spina/photo_collections_photo.rb +1 -1
- data/app/models/spina/rewrite_rule.rb +1 -1
- data/app/models/spina/structure.rb +1 -1
- data/app/models/spina/structure_item.rb +9 -4
- data/app/models/spina/structure_part.rb +1 -1
- data/app/models/spina/text.rb +1 -1
- data/app/models/spina/user.rb +1 -1
- data/app/presenters/spina/pages/breadcrumb.rb +102 -0
- data/app/presenters/spina/pages/menu_presenter.rb +16 -5
- data/app/views/layouts/spina/admin/admin.html.haml +31 -0
- data/app/views/layouts/spina/admin/media_library.html.haml +11 -9
- data/app/views/spina/admin/accounts/_form.html.haml +29 -23
- data/app/views/spina/admin/accounts/analytics.html.haml +19 -15
- data/app/views/spina/admin/accounts/social.html.haml +19 -15
- data/app/views/spina/admin/accounts/style.html.haml +19 -15
- data/app/views/spina/admin/attachments/_select.html.haml +1 -1
- data/app/views/spina/admin/attachments/_select_collection.html.haml +1 -1
- data/app/views/spina/admin/attachments/insert.js.coffee +5 -0
- data/app/views/spina/admin/attachments/insert_collection.js.coffee +7 -0
- data/app/views/spina/admin/page_partables/attachment_collections/_form.html.haml +8 -9
- data/app/views/spina/admin/page_partables/attachments/_form.html.haml +7 -8
- data/app/views/spina/admin/page_partables/photo_collections/_form.html.haml +2 -2
- data/app/views/spina/admin/page_partables/photos/_form.html.haml +6 -10
- data/app/views/spina/admin/pages/_form.html.haml +25 -6
- data/app/views/spina/admin/pages/_form_advanced.html.haml +45 -45
- 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/edit.html.haml +0 -19
- data/app/views/spina/admin/pages/index.html.haml +36 -29
- data/app/views/spina/admin/pages/new.html.haml +0 -10
- data/app/views/spina/admin/photos/_photo_collection_select.html.haml +4 -4
- data/app/views/spina/admin/photos/_photo_multi_picker.html.haml +2 -2
- data/app/views/spina/admin/photos/_photo_select.html.haml +4 -1
- data/app/views/spina/admin/photos/_photo_single_picker.html.haml +2 -2
- data/app/views/spina/admin/photos/index.html.haml +3 -2
- data/app/views/spina/admin/photos/insert_photo.js.erb +4 -4
- data/app/views/spina/admin/photos/insert_photo_collection.js.erb +6 -3
- data/app/views/spina/admin/photos/multi_picker_infinite_scroll.js.erb +1 -1
- data/app/views/spina/admin/photos/single_picker_infinite_scroll.js.erb +1 -1
- data/app/views/spina/admin/shared/_breadcrumbs.html.haml +1 -0
- data/app/views/spina/admin/shared/_notifications.html.haml +23 -12
- data/app/views/spina/admin/shared/_primary_navigation.html.haml +43 -3
- data/app/views/spina/admin/structure_partables/photos/_form.html.haml +3 -6
- data/app/views/spina/admin/users/_form.html.haml +37 -33
- data/app/views/spina/admin/users/index.html.haml +27 -23
- data/config/initializers/assets.rb +1 -1
- data/config/locales/de.yml +4 -0
- data/config/locales/en.yml +6 -1
- data/config/locales/es.yml +4 -0
- data/config/locales/fr.yml +4 -0
- data/config/locales/it.yml +4 -0
- data/config/locales/nl.yml +8 -0
- data/config/locales/pt-BR.yml +4 -0
- data/config/locales/ru.yml +16 -4
- data/config/locales/tr.yml +4 -0
- data/config/locales/zh-CN.yml +4 -0
- data/config/routes.rb +3 -3
- data/lib/generators/spina/install_generator.rb +31 -11
- data/lib/generators/spina/templates/app/views/default/pages/homepage.html.haml +1 -1
- data/lib/generators/spina/templates/app/views/default/pages/show.html.haml +1 -1
- data/lib/generators/spina/templates/app/views/demo/pages/homepage.html.haml +1 -1
- data/lib/generators/spina/templates/app/views/demo/pages/show.html.haml +1 -1
- data/lib/generators/spina/templates/config/initializers/spina.rb +1 -0
- data/lib/spina.rb +2 -1
- data/lib/spina/version.rb +1 -1
- data/lib/tasks/spina_tasks.rake +9 -1
- metadata +33 -18
- data/app/views/layouts/spina/admin/application.html.haml +0 -40
- data/app/views/layouts/spina/admin/settings.html.haml +0 -45
- data/app/views/layouts/spina/admin/website.html.haml +0 -26
- data/app/views/spina/admin/attachments/insert.js.erb +0 -5
- data/app/views/spina/admin/attachments/insert_collection.js.erb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45b73e285b4b35cf4782e720d0277ae1af6a0776
|
4
|
+
data.tar.gz: 65eb2d13073be2d35ff85c1e1644dce083cc8e31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6996c1d9b49a2e0f277bba4b00e954b6830236af42e0d58cb7605eb91d951a3df27dceb93081d730689dc820dc89121286b5aa9b0914b93f2ef0d4efb4a43eb9
|
7
|
+
data.tar.gz: 9ab874f94373d00377c03b4c65aca1a82c59644c2bfd911f8375384ee527fa7ecf7b80f41c56e992d22808f784441890440bcadd28b822d00405d88ec5d490c7
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
![Spina CMS](http://www.
|
1
|
+
![Spina CMS](http://www.spinacms.com/spinacms.png)
|
2
2
|
|
3
3
|
[Visit the website](http://www.spinacms.com)
|
4
4
|
|
@@ -156,7 +156,7 @@ Finally, let's go to `views/default/pages/show.html.erb` and add the following:
|
|
156
156
|
```ruby
|
157
157
|
<h1><%= @page.title %></h1>
|
158
158
|
|
159
|
-
<%= @page.content(:
|
159
|
+
<%= @page.content(:text).try(:html_safe) %>
|
160
160
|
<%= @page.content(:portfolio).try(:html_safe) %> # added this line
|
161
161
|
```
|
162
162
|
|
@@ -179,6 +179,10 @@ The views for these templates are stored in `app/views/default/pages`.
|
|
179
179
|
|
180
180
|
You can define custom pages for your theme that will be generated when bootstrapping your website. You can define whether or not they're deletable. By default Spina creates a custom page named Homepage which is not deletable.
|
181
181
|
|
182
|
+
# Contributing
|
183
|
+
|
184
|
+
Check our [Contributing Guide](CONTRIBUTING.md) for instructions on how to help the project.
|
185
|
+
|
182
186
|
# License
|
183
187
|
|
184
188
|
Spina is released under the [MIT license](LICENSE.md).
|
@@ -3,7 +3,7 @@ ready = ->
|
|
3
3
|
layout_parts = $('.account-theme').data('layout-parts')
|
4
4
|
show_layout_parts(layout_parts)
|
5
5
|
|
6
|
-
$(document).on '
|
6
|
+
$(document).on 'turbolinks:load', ready
|
7
7
|
|
8
8
|
$(document).on 'change', '.account-theme select', ->
|
9
9
|
layout_parts = $(this).find('option:selected').data('layout-parts').split(" ")
|
@@ -18,7 +18,7 @@ ready = ->
|
|
18
18
|
id = $(this).data('structure-item-id')
|
19
19
|
$(".structure_form_pane_#{id}_position").val(index)
|
20
20
|
|
21
|
-
$(document).on '
|
21
|
+
$(document).on 'turbolinks:load', ready
|
22
22
|
|
23
23
|
# Change templates makes page parts appear and disappear
|
24
24
|
$(document).on 'change', '.page-template select', ->
|
@@ -1,20 +1,24 @@
|
|
1
1
|
class Spina.InfiniteScroll
|
2
2
|
@init: (link) ->
|
3
3
|
$(window).off('scroll.infiniteScroll')
|
4
|
+
$('#main, #overlay section').off('scroll.infiniteScroll')
|
4
5
|
|
5
6
|
$link = $(link)
|
6
7
|
if (url = $link.find('a').attr('href'))
|
7
8
|
$(window).on 'scroll.infiniteScroll', => @loadNextPage($link)
|
8
|
-
$(
|
9
|
+
$('#main, #overlay section').on('scroll.infiniteScroll', -> $(window).trigger 'scroll.infiniteScroll')
|
10
|
+
$(window).trigger('scroll.infiniteScroll')
|
9
11
|
|
10
12
|
@loadNextPage: ($link) ->
|
11
13
|
if ($(window).scrollTop() > $link.offset().top - $(window).height() - 500)
|
12
14
|
$(window).off('scroll.infiniteScroll')
|
15
|
+
$('#main, #overlay section').off('scroll.infiniteScroll')
|
13
16
|
$.rails.disableElement($link.find('a'))
|
14
17
|
$.getScript($link.find('a').attr('href'))
|
15
18
|
|
16
19
|
$.fn.infiniteScroll = () ->
|
17
20
|
Spina.InfiniteScroll.init(this)
|
18
21
|
|
19
|
-
$(document).on '
|
22
|
+
$(document).on 'turbolinks:load', ->
|
20
23
|
$(window).off('scroll.infiniteScroll')
|
24
|
+
$('#main, #overlay section').off('scroll.infiniteScroll')
|
@@ -30,7 +30,7 @@ Trix.config.blockAttributes = $.extend Trix.config.blockAttributes, {
|
|
30
30
|
class Spina.TrixAttachment
|
31
31
|
@photoSelect: (e) ->
|
32
32
|
editor_id = $(this).closest('trix-toolbar').data('editor-id')
|
33
|
-
$.get("
|
33
|
+
$.get("<%= Spina::Engine.routes.url_helpers.wysihtml5_select_admin_photos_path('') %>/#{editor_id}")
|
34
34
|
|
35
35
|
@photoInsert: (e, url) ->
|
36
36
|
length = this.editor.getDocument().toString().length
|
@@ -24,7 +24,8 @@ module Spina
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def select
|
27
|
-
@
|
27
|
+
@selected_attachment_id = Attachment.find_by(id: params[:selected_attachment_id]).try(:id)
|
28
|
+
@attachments = Attachment.order_by_ids(@selected_attachment_id).file_attached.sorted
|
28
29
|
@attachment = Attachment.new
|
29
30
|
end
|
30
31
|
|
@@ -33,12 +34,13 @@ module Spina
|
|
33
34
|
end
|
34
35
|
|
35
36
|
def select_collection
|
36
|
-
@
|
37
|
+
@selected_attachment_ids = Attachment.where(id: params[:selected_attachment_ids]).ids
|
38
|
+
@attachments = Attachment.order_by_ids(@selected_attachment_ids).file_attached.sorted
|
37
39
|
@attachment = Attachment.new
|
38
40
|
end
|
39
41
|
|
40
42
|
def insert_collection
|
41
|
-
@attachments = Attachment.
|
43
|
+
@attachments = Attachment.where(id: params[:attachment_ids])
|
42
44
|
end
|
43
45
|
|
44
46
|
private
|
@@ -13,6 +13,10 @@ module Spina
|
|
13
13
|
@photo = Photo.new
|
14
14
|
end
|
15
15
|
|
16
|
+
def media_library
|
17
|
+
redirect_to spina.admin_photos_path
|
18
|
+
end
|
19
|
+
|
16
20
|
def create
|
17
21
|
@photo = Photo.create!(photo_params)
|
18
22
|
respond_to do |format|
|
@@ -42,9 +46,9 @@ module Spina
|
|
42
46
|
end
|
43
47
|
|
44
48
|
def photo_select
|
45
|
-
|
46
|
-
@
|
47
|
-
@
|
49
|
+
@selected_photo_id = Photo.find_by(id: params[:selected_photo_id]).try(:id)
|
50
|
+
@hidden_field_id = params[:hidden_field_id]
|
51
|
+
@photos = Photo.order_by_ids(@selected_photo_id).sorted.page(params[:page])
|
48
52
|
@photo = Photo.new
|
49
53
|
|
50
54
|
if params[:page].present?
|
@@ -55,9 +59,8 @@ module Spina
|
|
55
59
|
end
|
56
60
|
|
57
61
|
def photo_collection_select
|
58
|
-
|
59
|
-
@photos = Photo.order_by_ids(
|
60
|
-
@selected_photos = Photo.where(id: selected)
|
62
|
+
@selected_photo_ids = Photo.where(id: params[:selected_photo_ids]).ids
|
63
|
+
@photos = Photo.order_by_ids(@selected_photo_ids).sorted.page(params[:page])
|
61
64
|
@photo = Photo.new
|
62
65
|
|
63
66
|
if params[:page].present?
|
@@ -27,19 +27,30 @@ module Spina
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def rewrite_page
|
30
|
-
|
31
|
-
|
32
|
-
redirect_to @rule.new_path, status: :moved_permanently if @rule.present?
|
30
|
+
if page.nil? && rule = RewriteRule.find_by(old_path: "/" + params[:id])
|
31
|
+
redirect_to rule.new_path, status: :moved_permanently
|
33
32
|
end
|
34
33
|
end
|
35
34
|
|
35
|
+
def page_by_locale(locale)
|
36
|
+
Page.with_translations(locale).find_by(materialized_path: spina_request_path)
|
37
|
+
end
|
38
|
+
|
36
39
|
def page
|
37
|
-
|
40
|
+
current_page = page_by_locale(I18n.locale) || page_by_locale(I18n.default_locale)
|
41
|
+
@page ||= (action_name == 'homepage') ? Page.find_by!(name: 'homepage') : current_page
|
38
42
|
end
|
39
43
|
helper_method :page
|
40
44
|
|
45
|
+
def spina_request_path
|
46
|
+
segments = ['/', params[:locale], params[:id]].compact
|
47
|
+
File.join(*segments)
|
48
|
+
end
|
49
|
+
|
41
50
|
def current_user_can_view_page?
|
42
|
-
raise ActiveRecord::RecordNotFound
|
51
|
+
raise ActiveRecord::RecordNotFound if page.nil? || !page.live?
|
52
|
+
|
53
|
+
current_user.present?
|
43
54
|
end
|
44
55
|
|
45
56
|
def should_skip_to_first_child?
|
@@ -51,7 +62,7 @@ module Spina
|
|
51
62
|
end
|
52
63
|
|
53
64
|
def render_with_template(page)
|
54
|
-
render layout: "#{current_theme.name.parameterize.underscore}
|
65
|
+
render layout: "#{current_theme.name.parameterize.underscore}/#{page.layout_template || 'application'}", template: "#{current_theme.name.parameterize.underscore}/pages/#{page.view_template || 'show'}"
|
55
66
|
end
|
56
67
|
|
57
68
|
def render_404
|
@@ -37,6 +37,21 @@ module Spina
|
|
37
37
|
partable_type.tableize.sub(/\Aspina\//, '')
|
38
38
|
end
|
39
39
|
|
40
|
+
def flatten_nested_hash(hash)
|
41
|
+
hash.flat_map{|k, v| [k, *flatten_nested_hash(v)]}
|
42
|
+
end
|
43
|
+
|
44
|
+
def page_ancestry_options(page)
|
45
|
+
pages = Spina::Page.active
|
46
|
+
pages = pages.where.not(id: page.subtree.ids) unless page.new_record?
|
47
|
+
|
48
|
+
flatten_nested_hash(pages.arrange(order: :position)).map do |page|
|
49
|
+
next if page.depth >= Spina.config.max_page_depth - 1
|
50
|
+
page_menu_title = page.depth.zero? ? page.menu_title : " #{page.menu_title}".indent(page.depth, '-')
|
51
|
+
[page_menu_title, page.id]
|
52
|
+
end.compact
|
53
|
+
end
|
54
|
+
|
40
55
|
end
|
41
56
|
end
|
42
57
|
end
|
data/app/models/spina/account.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Spina
|
2
|
-
class Account <
|
2
|
+
class Account < ApplicationRecord
|
3
3
|
serialize :preferences
|
4
4
|
include Spina::Partable
|
5
5
|
|
@@ -18,15 +18,14 @@ module Spina
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def content(layout_part)
|
21
|
-
|
22
|
-
layout_part.try(:content)
|
21
|
+
layout_parts.find_by(name: layout_part).try(:content)
|
23
22
|
end
|
24
23
|
|
25
24
|
def self.serialized_attr_accessor(*args)
|
26
25
|
args.each do |method_name|
|
27
26
|
eval "
|
28
27
|
def #{method_name}
|
29
|
-
|
28
|
+
self.preferences.try(:[], :#{method_name})
|
30
29
|
end
|
31
30
|
|
32
31
|
def #{method_name}=(value)
|
@@ -54,16 +53,18 @@ module Spina
|
|
54
53
|
|
55
54
|
def find_or_create_custom_pages(theme)
|
56
55
|
theme.custom_pages.each do |page|
|
57
|
-
Page.
|
56
|
+
Page.by_name(page[:name])
|
57
|
+
.first_or_create(title: page[:title])
|
58
|
+
.update_columns(view_template: page[:view_template], deletable: page[:deletable])
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
61
62
|
def deactivate_unused_view_templates(theme)
|
62
|
-
Page.
|
63
|
+
Page.active.not_by_config_theme(theme).update_all(active: false)
|
63
64
|
end
|
64
65
|
|
65
66
|
def activate_used_view_templates(theme)
|
66
|
-
Page.
|
67
|
+
Page.not_active.by_config_theme(theme).update_all(active: true)
|
67
68
|
end
|
68
69
|
|
69
70
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Spina
|
2
|
-
class Attachment <
|
2
|
+
class Attachment < ApplicationRecord
|
3
3
|
|
4
4
|
has_one :page_part, as: :page_partable
|
5
5
|
has_and_belongs_to_many :attachment_collections, join_table: 'spina_attachment_collections_attachments'
|
@@ -24,5 +24,10 @@ module Spina
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
def self.order_by_ids(ids)
|
28
|
+
sql = sanitize_sql_for_assignment({id: ids})
|
29
|
+
order("CASE WHEN #{sql} THEN 0 ELSE 1 END")
|
30
|
+
end
|
31
|
+
|
27
32
|
end
|
28
33
|
end
|
data/app/models/spina/color.rb
CHANGED
data/app/models/spina/line.rb
CHANGED
data/app/models/spina/page.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Spina
|
2
|
-
class Page <
|
2
|
+
class Page < ApplicationRecord
|
3
3
|
include Spina::Partable
|
4
4
|
|
5
5
|
translates :title, :menu_title, :seo_title, :description, :materialized_path
|
@@ -25,6 +25,10 @@ module Spina
|
|
25
25
|
scope :live, -> { where(draft: false, active: true) }
|
26
26
|
scope :in_menu, -> { where(show_in_menu: true) }
|
27
27
|
scope :active, -> { where(active: true) }
|
28
|
+
scope :not_active, -> { where(active: false) }
|
29
|
+
scope :by_name, ->(name) { where(name: name) }
|
30
|
+
scope :not_by_config_theme, ->(theme) { where.not(view_template: theme.view_templates.map { |h| h[:name] }) }
|
31
|
+
scope :by_config_theme, ->(theme) { where(view_template: theme.view_templates.map { |h| h[:name] }) }
|
28
32
|
|
29
33
|
alias_attribute :page_part, :part
|
30
34
|
alias_attribute :parts, :page_parts
|
@@ -90,6 +94,10 @@ module Spina
|
|
90
94
|
theme.view_templates.find { |template| template[:name] == view_template_name }
|
91
95
|
end
|
92
96
|
|
97
|
+
def full_materialized_path
|
98
|
+
File.join(Spina::Engine.routes.url_helpers.root_path, materialized_path)
|
99
|
+
end
|
100
|
+
|
93
101
|
private
|
94
102
|
|
95
103
|
def rewrite_rule
|
@@ -109,7 +117,7 @@ module Spina
|
|
109
117
|
name == 'homepage' ? '' : "#{url_title}"
|
110
118
|
else
|
111
119
|
ancestors.collect(&:url_title).append(url_title).join('/')
|
112
|
-
end
|
120
|
+
end
|
113
121
|
end
|
114
122
|
|
115
123
|
def ancestry_is_nil
|
data/app/models/spina/photo.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Spina
|
2
|
-
class Photo <
|
2
|
+
class Photo < ApplicationRecord
|
3
3
|
mount_uploader :file, PhotoUploader
|
4
4
|
|
5
5
|
has_many :page_parts, as: :page_partable
|
@@ -21,7 +21,7 @@ module Spina
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.order_by_ids(ids)
|
24
|
-
sql =
|
24
|
+
sql = sanitize_sql_for_assignment({id: ids})
|
25
25
|
order("CASE WHEN #{sql} THEN 0 ELSE 1 END")
|
26
26
|
end
|
27
27
|
|