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.

Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -2
  3. data/app/assets/javascripts/spina/admin/account.js.coffee +1 -1
  4. data/app/assets/javascripts/spina/admin/pages.js.coffee.erb +1 -1
  5. data/app/assets/javascripts/spina/admin/spina.infinite_scroll.coffee +6 -2
  6. data/app/assets/javascripts/spina/admin/spina.scaffold.coffee +2 -2
  7. data/app/assets/javascripts/spina/admin/{spina.trix.js.coffee → spina.trix.js.coffee.erb} +1 -1
  8. data/app/assets/stylesheets/spina/admin/application.sass +3 -0
  9. data/app/controllers/spina/admin/accounts_controller.rb +0 -2
  10. data/app/controllers/spina/admin/admin_controller.rb +0 -2
  11. data/app/controllers/spina/admin/attachments_controller.rb +5 -3
  12. data/app/controllers/spina/admin/pages_controller.rb +1 -2
  13. data/app/controllers/spina/admin/photos_controller.rb +9 -6
  14. data/app/controllers/spina/admin/users_controller.rb +0 -2
  15. data/app/controllers/spina/pages_controller.rb +17 -6
  16. data/app/helpers/spina/admin/pages_helper.rb +15 -0
  17. data/app/models/spina/account.rb +8 -7
  18. data/app/models/spina/application_record.rb +5 -0
  19. data/app/models/spina/attachment.rb +6 -1
  20. data/app/models/spina/attachment_collection.rb +1 -1
  21. data/app/models/spina/color.rb +1 -1
  22. data/app/models/spina/layout_part.rb +1 -1
  23. data/app/models/spina/line.rb +1 -1
  24. data/app/models/spina/page.rb +10 -2
  25. data/app/models/spina/page_part.rb +1 -1
  26. data/app/models/spina/photo.rb +2 -2
  27. data/app/models/spina/photo_collection.rb +1 -1
  28. data/app/models/spina/photo_collections_photo.rb +1 -1
  29. data/app/models/spina/rewrite_rule.rb +1 -1
  30. data/app/models/spina/structure.rb +1 -1
  31. data/app/models/spina/structure_item.rb +9 -4
  32. data/app/models/spina/structure_part.rb +1 -1
  33. data/app/models/spina/text.rb +1 -1
  34. data/app/models/spina/user.rb +1 -1
  35. data/app/presenters/spina/pages/breadcrumb.rb +102 -0
  36. data/app/presenters/spina/pages/menu_presenter.rb +16 -5
  37. data/app/views/layouts/spina/admin/admin.html.haml +31 -0
  38. data/app/views/layouts/spina/admin/media_library.html.haml +11 -9
  39. data/app/views/spina/admin/accounts/_form.html.haml +29 -23
  40. data/app/views/spina/admin/accounts/analytics.html.haml +19 -15
  41. data/app/views/spina/admin/accounts/social.html.haml +19 -15
  42. data/app/views/spina/admin/accounts/style.html.haml +19 -15
  43. data/app/views/spina/admin/attachments/_select.html.haml +1 -1
  44. data/app/views/spina/admin/attachments/_select_collection.html.haml +1 -1
  45. data/app/views/spina/admin/attachments/insert.js.coffee +5 -0
  46. data/app/views/spina/admin/attachments/insert_collection.js.coffee +7 -0
  47. data/app/views/spina/admin/page_partables/attachment_collections/_form.html.haml +8 -9
  48. data/app/views/spina/admin/page_partables/attachments/_form.html.haml +7 -8
  49. data/app/views/spina/admin/page_partables/photo_collections/_form.html.haml +2 -2
  50. data/app/views/spina/admin/page_partables/photos/_form.html.haml +6 -10
  51. data/app/views/spina/admin/pages/_form.html.haml +25 -6
  52. data/app/views/spina/admin/pages/_form_advanced.html.haml +45 -45
  53. data/app/views/spina/admin/pages/_form_page_content.html.haml +1 -1
  54. data/app/views/spina/admin/pages/_form_page_seo.html.haml +1 -1
  55. data/app/views/spina/admin/pages/edit.html.haml +0 -19
  56. data/app/views/spina/admin/pages/index.html.haml +36 -29
  57. data/app/views/spina/admin/pages/new.html.haml +0 -10
  58. data/app/views/spina/admin/photos/_photo_collection_select.html.haml +4 -4
  59. data/app/views/spina/admin/photos/_photo_multi_picker.html.haml +2 -2
  60. data/app/views/spina/admin/photos/_photo_select.html.haml +4 -1
  61. data/app/views/spina/admin/photos/_photo_single_picker.html.haml +2 -2
  62. data/app/views/spina/admin/photos/index.html.haml +3 -2
  63. data/app/views/spina/admin/photos/insert_photo.js.erb +4 -4
  64. data/app/views/spina/admin/photos/insert_photo_collection.js.erb +6 -3
  65. data/app/views/spina/admin/photos/multi_picker_infinite_scroll.js.erb +1 -1
  66. data/app/views/spina/admin/photos/single_picker_infinite_scroll.js.erb +1 -1
  67. data/app/views/spina/admin/shared/_breadcrumbs.html.haml +1 -0
  68. data/app/views/spina/admin/shared/_notifications.html.haml +23 -12
  69. data/app/views/spina/admin/shared/_primary_navigation.html.haml +43 -3
  70. data/app/views/spina/admin/structure_partables/photos/_form.html.haml +3 -6
  71. data/app/views/spina/admin/users/_form.html.haml +37 -33
  72. data/app/views/spina/admin/users/index.html.haml +27 -23
  73. data/config/initializers/assets.rb +1 -1
  74. data/config/locales/de.yml +4 -0
  75. data/config/locales/en.yml +6 -1
  76. data/config/locales/es.yml +4 -0
  77. data/config/locales/fr.yml +4 -0
  78. data/config/locales/it.yml +4 -0
  79. data/config/locales/nl.yml +8 -0
  80. data/config/locales/pt-BR.yml +4 -0
  81. data/config/locales/ru.yml +16 -4
  82. data/config/locales/tr.yml +4 -0
  83. data/config/locales/zh-CN.yml +4 -0
  84. data/config/routes.rb +3 -3
  85. data/lib/generators/spina/install_generator.rb +31 -11
  86. data/lib/generators/spina/templates/app/views/default/pages/homepage.html.haml +1 -1
  87. data/lib/generators/spina/templates/app/views/default/pages/show.html.haml +1 -1
  88. data/lib/generators/spina/templates/app/views/demo/pages/homepage.html.haml +1 -1
  89. data/lib/generators/spina/templates/app/views/demo/pages/show.html.haml +1 -1
  90. data/lib/generators/spina/templates/config/initializers/spina.rb +1 -0
  91. data/lib/spina.rb +2 -1
  92. data/lib/spina/version.rb +1 -1
  93. data/lib/tasks/spina_tasks.rake +9 -1
  94. metadata +33 -18
  95. data/app/views/layouts/spina/admin/application.html.haml +0 -40
  96. data/app/views/layouts/spina/admin/settings.html.haml +0 -45
  97. data/app/views/layouts/spina/admin/website.html.haml +0 -26
  98. data/app/views/spina/admin/attachments/insert.js.erb +0 -5
  99. 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: 457fad6084480ec4091b8dba28d0f799dbd097dd
4
- data.tar.gz: a3fb127947659c26b7583459ff2766891a51e6f5
3
+ metadata.gz: 45b73e285b4b35cf4782e720d0277ae1af6a0776
4
+ data.tar.gz: 65eb2d13073be2d35ff85c1e1644dce083cc8e31
5
5
  SHA512:
6
- metadata.gz: 4fc1056660d8c8cbd510508e426187be991ca7c0d50228eb1376ab17f1ed4a1320731f4c146554206ec9f3e11c2f9ae679e0d2695efdc50276e756bd5aca1345
7
- data.tar.gz: 2559f8f9966ffde4febf060be5b2e455592f886bef922febc738a20abe59d70dd37992fa1c98fe6ae35dacad33907abf9b10b009990d83cfa827a3ee92bb40db
6
+ metadata.gz: 6996c1d9b49a2e0f277bba4b00e954b6830236af42e0d58cb7605eb91d951a3df27dceb93081d730689dc820dc89121286b5aa9b0914b93f2ef0d4efb4a43eb9
7
+ data.tar.gz: 9ab874f94373d00377c03b4c65aca1a82c59644c2bfd911f8375384ee527fa7ecf7b80f41c56e992d22808f784441890440bcadd28b822d00405d88ec5d490c7
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ![Spina CMS](http://www.denkwebsite.nl/spinacms.png)
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(:content).try(:html_safe) %>
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 'ready page:load', ready
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 'ready page:load', ready
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
- $(window).scroll()
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 'page:change', ->
22
+ $(document).on 'turbolinks:load', ->
20
23
  $(window).off('scroll.infiniteScroll')
24
+ $('#main, #overlay section').off('scroll.infiniteScroll')
@@ -11,5 +11,5 @@ class Spina.Scaffold
11
11
  $.fn.enhance = () ->
12
12
  Spina.Scaffold.enhance(this)
13
13
 
14
- $(document).on 'page:change', ->
15
- Spina.Scaffold.init()
14
+ $(document).on 'turbolinks:load', ->
15
+ Spina.Scaffold.init()
@@ -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("/admin/photos/wysihtml5_select/#{editor_id}")
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
@@ -1 +1,4 @@
1
1
  @import spina
2
+
3
+ .infinite-scroll
4
+ @include clearfix
@@ -4,8 +4,6 @@ module Spina
4
4
 
5
5
  authorize_resource class: Account
6
6
 
7
- layout "spina/admin/settings"
8
-
9
7
  def edit
10
8
  add_breadcrumb I18n.t('spina.preferences.account'), spina.edit_admin_account_path
11
9
  end
@@ -4,8 +4,6 @@ module Spina
4
4
  before_action :set_admin_locale
5
5
  before_action :authorize_user
6
6
 
7
- layout 'spina/admin/application'
8
-
9
7
  def current_admin_path
10
8
  request.fullpath[%r{/#{ Spina.config.backend_path }(.*)}, 1]
11
9
  end
@@ -24,7 +24,8 @@ module Spina
24
24
  end
25
25
 
26
26
  def select
27
- @attachments = Attachment.file_attached.sorted
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
- @attachments = Attachment.file_attached.sorted
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.find(params[:attachment_ids])
43
+ @attachments = Attachment.where(id: params[:attachment_ids])
42
44
  end
43
45
 
44
46
  private
@@ -8,9 +8,8 @@ module Spina
8
8
 
9
9
  authorize_resource class: Page
10
10
 
11
- layout "spina/admin/website"
12
-
13
11
  def index
12
+ redirect_to admin_pages_path unless current_admin_path.starts_with?('/pages')
14
13
  @pages = Page.active.sorted.roots
15
14
  end
16
15
 
@@ -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
- selected = params[:selected_photo_id] || Array.new
46
- @photos = Photo.order_by_ids(selected).sorted.page(params[:page])
47
- @selected_photo = Photo.find(selected)
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
- selected = params[:selected_photo_ids] || Array.new
59
- @photos = Photo.order_by_ids(selected).sorted.page(params[:page])
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?
@@ -5,8 +5,6 @@ module Spina
5
5
 
6
6
  authorize_resource class: User
7
7
 
8
- layout "spina/admin/settings"
9
-
10
8
  def index
11
9
  @users = User.all
12
10
  end
@@ -27,19 +27,30 @@ module Spina
27
27
  end
28
28
 
29
29
  def rewrite_page
30
- unless page.present?
31
- @rule = RewriteRule.find_by(old_path: "/" + params[:id])
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
- @page ||= (action_name == 'homepage') ? Page.find_by!(name: 'homepage') : Page.with_translations(I18n.locale).find_by!(materialized_path: request.path) || Page.with_translations(I18n.default_locale).find_by!(materialized_path: request.path)
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 unless page.live? || current_user.present?
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}/application", template: "#{current_theme.name.parameterize.underscore}/pages/#{page.view_template || 'show'}"
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
@@ -1,5 +1,5 @@
1
1
  module Spina
2
- class Account < ActiveRecord::Base
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
- layout_part = layout_parts.where(name: layout_part).first
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
- (self.preferences || {})[:#{method_name}]
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.where(name: page[:name]).first_or_create(title: page[:title]).update_columns(view_template: page[:view_template], deletable: page[:deletable])
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.where(active: true).where.not(view_template: theme.view_templates.map { |h| h[:name] }).update_all(active: false)
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.where(active: false).where(view_template: theme.view_templates.map { |h| h[:name] }).update_all(active: true)
67
+ Page.not_active.by_config_theme(theme).update_all(active: true)
67
68
  end
68
69
 
69
70
  end
@@ -0,0 +1,5 @@
1
+ module Spina
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
1
  module Spina
2
- class Attachment < ActiveRecord::Base
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
@@ -1,5 +1,5 @@
1
1
  module Spina
2
- class AttachmentCollection < ActiveRecord::Base
2
+ class AttachmentCollection < ApplicationRecord
3
3
 
4
4
  has_one :page_part, as: :page_partable
5
5
  has_and_belongs_to_many :attachments, join_table: 'spina_attachment_collections_attachments'
@@ -1,5 +1,5 @@
1
1
  module Spina
2
- class Color < ActiveRecord::Base
2
+ class Color < ApplicationRecord
3
3
  has_many :page_parts, as: :page_partable
4
4
  has_many :layout_parts, as: :layout_partable
5
5
  has_many :structure_parts, as: :structure_partable
@@ -1,5 +1,5 @@
1
1
  module Spina
2
- class LayoutPart < ActiveRecord::Base
2
+ class LayoutPart < ApplicationRecord
3
3
  include Part
4
4
 
5
5
  belongs_to :account
@@ -1,5 +1,5 @@
1
1
  module Spina
2
- class Line < ActiveRecord::Base
2
+ class Line < ApplicationRecord
3
3
  translates :content
4
4
 
5
5
  has_many :page_parts, as: :page_partable
@@ -1,5 +1,5 @@
1
1
  module Spina
2
- class Page < ActiveRecord::Base
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
@@ -1,5 +1,5 @@
1
1
  module Spina
2
- class PagePart < ActiveRecord::Base
2
+ class PagePart < ApplicationRecord
3
3
  include Part
4
4
 
5
5
  belongs_to :page, inverse_of: :page_parts
@@ -1,5 +1,5 @@
1
1
  module Spina
2
- class Photo < ActiveRecord::Base
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 = sanitize_sql_for_conditions({id: ids})
24
+ sql = sanitize_sql_for_assignment({id: ids})
25
25
  order("CASE WHEN #{sql} THEN 0 ELSE 1 END")
26
26
  end
27
27