caboose-cms 0.9.64 → 0.9.65

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c05e137cd6e27972d585cb2a92b3da5d0a953d4c
4
- data.tar.gz: 1f84a4eb9232ef323d070bf225e4b8c571451364
3
+ metadata.gz: 43c2ed33475916c5efe2be842f8e5a137df67193
4
+ data.tar.gz: 8a007a1ba9b5c3ad862556e5b8f73f51a1c56a6c
5
5
  SHA512:
6
- metadata.gz: 00effcc5fc52ef32a1d7990a807276ab3162e4a4ba5e85b61a3fde70e0d9df7d40758048a58c7762f581be201e268caf36c17b05f9cdbfc568f17eceb3407071
7
- data.tar.gz: c2fe489c22d2efd3f369491c3d8bfa275918d1cbe72504ada8f97d80ff582abaada41fa5b9c4bbc805a2ba3859de65573571a9e2d934d08e8867b21356008635
6
+ metadata.gz: 3567182432fb5692a20afacb95bf389de0aa72e111c658b1e8e46e57b46d80a2abfce355429e2daa2ffa34e4f3309e53914d7db034b274fd9a998792b51dc915
7
+ data.tar.gz: 1d27765dfd78b35fd1155f63e87716c2b3df93d42de2841bc6dbc014df0af7056659f2f80b6cbad35132eb3dad2b1d05048806bc54c1034a6ab77e9aab4ddbee
@@ -306,7 +306,7 @@ module Caboose
306
306
  # @route POST /admin/posts/:post_id/blocks
307
307
  # @route POST /admin/posts/:post_id/blocks/:id
308
308
  def admin_create
309
- return unless user_is_allowed('pages', 'add')
309
+ return unless user_is_allowed('pages', 'edit')
310
310
 
311
311
  resp = Caboose::StdClass.new
312
312
 
@@ -508,7 +508,7 @@ module Caboose
508
508
  # @route DELETE /admin/pages/:page_id/blocks/:id
509
509
  # @route DELETE /admin/posts/:post_id/blocks/:id
510
510
  def admin_delete
511
- return unless user_is_allowed('pages', 'delete')
511
+ return unless user_is_allowed('pages', 'edit')
512
512
 
513
513
  resp = StdClass.new
514
514
  b = Block.find(params[:id])
@@ -607,7 +607,7 @@ module Caboose
607
607
  # @route PUT /admin/pages/:page_id/blocks/:id/move-up
608
608
  # @route PUT /admin/posts/:post_id/blocks/:id/move-up
609
609
  def admin_move_up
610
- return unless user_is_allowed('pages', 'delete')
610
+ return unless user_is_allowed('pages', 'edit')
611
611
 
612
612
  resp = StdClass.new
613
613
  b = Block.find(params[:id])
@@ -623,7 +623,7 @@ module Caboose
623
623
  # @route PUT /admin/pages/:page_id/blocks/:id/move-down
624
624
  # @route PUT /admin/posts/:post_id/blocks/:id/move-down
625
625
  def admin_move_down
626
- return unless user_is_allowed('pages', 'delete')
626
+ return unless user_is_allowed('pages', 'edit')
627
627
 
628
628
  resp = StdClass.new
629
629
  b = Block.find(params[:id])
@@ -140,6 +140,7 @@ module Caboose
140
140
  # @route GET /admin/pages
141
141
  def admin_index
142
142
  return if !user_is_allowed('pages', 'view')
143
+ @user = @logged_in_user
143
144
  @domain = Domain.where(:domain => request.host_with_port).first
144
145
  @home_page = @domain ? Page.index_page(@domain.site_id) : nil
145
146
  if @domain && @home_page.nil?
@@ -183,9 +184,11 @@ module Caboose
183
184
 
184
185
  # @route GET /admin/pages/:id/content
185
186
  def admin_edit_content
186
- return unless user_is_allowed('pages', 'edit')
187
187
  @page = Page.find(params[:id])
188
- if @page.block.nil?
188
+ redirect_to "/login?return_url=/admin/pages/#{@page.id}/content" and return if @logged_in_user.nil?
189
+ condition = @logged_in_user && ( @logged_in_user.is_allowed('all','all') || @logged_in_user.is_allowed('pages','edit') && Page.permissible_actions(@logged_in_user, @page.id).include?('edit'))
190
+ redirect_to "/admin/pages" and return unless condition
191
+ if @page.block.nil?
189
192
  redirect_to "/admin/pages/#{@page.id}/layout"
190
193
  return
191
194
  end
@@ -203,8 +206,31 @@ module Caboose
203
206
  def admin_update_layout
204
207
  return unless user_is_allowed('pages', 'edit')
205
208
  bt = BlockType.find(params[:block_type_id])
206
- Block.where(:page_id => params[:id]).destroy_all
207
- Block.create(:page_id => params[:id], :block_type_id => params[:block_type_id], :name => bt.name)
209
+ old_block = Block.where(:page_id => params[:id], :parent_id => nil).first
210
+ old_block_ids = Block.where(:page_id => params[:id]).pluq(:id)
211
+ new_block = Block.create(:page_id => params[:id], :block_type_id => params[:block_type_id], :name => bt.name)
212
+ new_block.create_children
213
+ saved_blocks = []
214
+ if new_block && old_block && new_block.child('content') && old_block.child('content')
215
+ old_content = old_block.child('content')
216
+ new_content = new_block.child('content')
217
+ old_content.children.each do |child|
218
+ child.parent_id = new_content.id
219
+ child.save
220
+ saved_blocks << child.id
221
+ child.children.each do |c1|
222
+ saved_blocks << c1.id
223
+ c1.children.each do |c2|
224
+ saved_blocks << c2.id
225
+ c2.children.each do |c3|
226
+ saved_blocks << c3.id
227
+ end
228
+ end
229
+ end
230
+ end
231
+ end
232
+ where1 = saved_blocks.count > 0 ? "id NOT IN (#{saved_blocks.to_s.gsub('[','').gsub(']','')})" : ''
233
+ Block.where(:id => old_block_ids).where(where1).destroy_all
208
234
  resp = Caboose::StdClass.new({
209
235
  'redirect' => "/admin/pages/#{params[:id]}/content"
210
236
  })
@@ -8,7 +8,12 @@ module Caboose
8
8
  end
9
9
 
10
10
  def pages_list_helper(page)
11
- str = "<li><a href='/admin/pages/#{page.id}/content'>#{page.title}</a>"
11
+ can_edit = (@logged_in_user && (@logged_in_user.is_allowed('all', 'all') || Page.permissible_actions(@logged_in_user, page.id).include?('edit'))) ? true : false
12
+ if can_edit
13
+ str = "<li><a href='/admin/pages/#{page.id}/content'>#{page.title}</a>"
14
+ else
15
+ str = "<li><span class='disabled'>#{page.title}</span>"
16
+ end
12
17
  if page.children && page.children.count > 0
13
18
  str << "<ul>"
14
19
  page.children.each do |p|
@@ -195,12 +195,15 @@ class Caboose::Page < ActiveRecord::Base
195
195
  end
196
196
  actions = []
197
197
  user.roles.each do |role|
198
- actions + Caboose::PagePermission.where({
198
+ acts = Caboose::PagePermission.where({
199
199
  :role_id => role.id,
200
200
  :page_id => page_id
201
- }).pluck(:action)
201
+ }).pluq(:action)
202
+ acts.each do |ac|
203
+ actions << ac
204
+ end
202
205
  end
203
- return actions.uniq
206
+ return actions
204
207
  end
205
208
 
206
209
  def self.page_ids_with_permission(user, action)
@@ -8,6 +8,7 @@ width = 200
8
8
  %>
9
9
 
10
10
  <h1>Admin</h1>
11
+ <div id="admin-list">
11
12
  <ul>
12
13
  <!--
13
14
  <li id='nav_item_logout'><a href='/logout'><span class='icon'></span><span class='text'>Logout</span></a>
@@ -34,6 +35,7 @@ width = 200
34
35
  <% i + 1 %>
35
36
  <% end %>
36
37
  </ul>
38
+ </div>
37
39
 
38
40
  <%= content_for :caboose_js do %>
39
41
  <%= javascript_include_tag "caboose/station" %>
@@ -46,8 +48,25 @@ $(document).ready(function() {
46
48
  });
47
49
  </script>
48
50
  <% end %>
49
- <%= content_for :caboose_css do %>
50
- <style type='text/css'>
51
-
51
+ <% content_for :caboose_css do %>
52
+ <style>
53
+ #admin-list ul li {
54
+ line-height: 26px;
55
+ }
56
+ #admin-list ul li a {
57
+ color: #2424b1;
58
+ text-decoration: none;
59
+ }
60
+ #admin-list ul li a:visited {
61
+ color: #824daf;
62
+ }
63
+ #admin-list ul li a:hover {
64
+ color: #24b14b;
65
+ text-decoration: underline;
66
+ }
67
+ #admin-list ul li span.disabled {
68
+ text-decoration: line-through;
69
+ color: #888888;
70
+ }
52
71
  </style>
53
72
  <% end %>
@@ -40,8 +40,9 @@ tabs = {
40
40
  'Content' => "/admin/pages/#{@page.id}/content",
41
41
  'Custom CSS' => "/admin/pages/#{@page.id}/css",
42
42
  'Custom JS' => "/admin/pages/#{@page.id}/js",
43
- 'SEO' => "/admin/pages/#{@page.id}/seo",
44
- 'Sitemap' => "/admin/pages/#{@page.id}/sitemap",
43
+ 'SEO' => "/admin/pages/#{@page.id}/seo",
44
+ 'Layout' => "/admin/pages/#{@page.id}/layout",
45
+ # 'Sitemap' => "/admin/pages/#{@page.id}/sitemap",
45
46
  'Duplicate Page' => "/admin/pages/#{@page.id}/duplicate",
46
47
  'Delete Page' => "/admin/pages/#{@page.id}/delete"
47
48
  }
@@ -3,7 +3,7 @@
3
3
 
4
4
  <form action='/admin/pages/<%= @page.id %>' method='put' id='layout_form'>
5
5
  <input type='hidden' name='authenticity_token' value='<%= form_authenticity_token %>' />
6
- <h4 style="color:red;">WARNING: Changing the page layout will delete all existing content from the page.</h4>
6
+ <!-- <h4 style="color:red;">WARNING: Changing the page layout will delete all existing content from the page.</h4> -->
7
7
  <p><select name='block_type_id'>
8
8
  <option value=''>-- Select a layout --</option>
9
9
  <% cat_ids = Caboose::BlockTypeCategory.layouts.collect{ |cat| cat.id } %>
@@ -1,8 +1,35 @@
1
1
  <h1>Pages</h1>
2
2
 
3
3
  <% if @domain %>
4
+ <% if @user.is_allowed('pages','add') %>
4
5
  <p><a href='/admin/pages/new' class="caboose-btn-white">New Page</a></p>
6
+ <% end %>
7
+ <div id="page-list">
5
8
  <%= raw pages_list(@home_page) %>
9
+ </div>
6
10
  <% else %>
7
11
  <p>It doesn't look like this site is configured for the current domain. Please <a href='/admin/sites'>configure your sites</a>.</p>
8
12
  <% end %>
13
+
14
+ <% content_for :caboose_css do %>
15
+ <style>
16
+ #page-list ul li {
17
+ line-height: 26px;
18
+ }
19
+ #page-list ul li a {
20
+ color: #2424b1;
21
+ text-decoration: none;
22
+ }
23
+ #page-list ul li a:visited {
24
+ color: #824daf;
25
+ }
26
+ #page-list ul li a:hover {
27
+ color: #24b14b;
28
+ text-decoration: underline;
29
+ }
30
+ #page-list ul li span.disabled {
31
+ text-decoration: line-through;
32
+ color: #888888;
33
+ }
34
+ </style>
35
+ <% end %>
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.9.64'
2
+ VERSION = '0.9.65'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.64
4
+ version: 0.9.65
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-03 00:00:00.000000000 Z
11
+ date: 2017-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg