caboose-cms 0.2.68 → 0.2.70

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjUxZjM2ZTc2YWJlNTEzYzE1ZDY4MDU5NWJjYjM3NGM2NmQxOWNmYw==
4
+ MWE2N2IxNDliN2ZmNjM3MDk5NzNkYjgxMWY0NGQ0NzhjZTFjMjkwMA==
5
5
  data.tar.gz: !binary |-
6
- ZGZhZGEwMWU0YTRhM2U1YzI4MzY0M2E3ZWJiMjA5Mjg3MmZiNDVjNw==
6
+ YjI3MDM4NmU3MWI5YmEyMjM3N2MzZjdhMzFiOGEwNzBiNzNmM2I3Mg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MjNhNDhmNTdkZTI1Y2U4NjE1ZDFjOTg3NjRjYWEwMmRlY2Q1NThmZTU0OGU1
10
- ZmQyNjYxZThkYTllNjQ4NjA5ODg2MTE0NTgwM2NkODcwYTgzZGM2ZWE0MjJj
11
- YzU1M2QxNTRhNjIwYjI0YzVjZWQzZjUxMWE2YWM3NzZkMTA5NmE=
9
+ NGJkMmY5NWQxZjFjNDdmMDUwNDYwZGU3MTU3MmQ4Y2FkNDZmOGE1Y2VkYWQ3
10
+ NjViZWE0NmRkZjEyMGNlZDJhODQzYWQ2NzdjNjY0YWY0YWNmZmUwMTEwODQ5
11
+ ODZjYTc3MTMyODQ2YzUzNTk5Mjk0NWQ0MWZkOThmMTFmYjUzMzk=
12
12
  data.tar.gz: !binary |-
13
- MmMzZjgyYThiMzA0ZTYzNGE5YjIwMmMyYTY1Nzc3YjY3OGI5MWEwMjU4NzM2
14
- MmYwMWY4ZTM2ZDg4ODhiYjY4MDA4NTkyMWE1ZTI4YTYzZDc1YmMxOTg5MGMw
15
- ZmQzOWI4ZGNhY2UxNWQ5OWM0NzVlMmUxNzZlNmZjZTdhNmRlNzk=
13
+ OTkwYjM4NmU4ZTMyNDEzODkzNmU2YTEyOGZiMTczOGYyOTYxZDk5MmEzNjYy
14
+ OTk3YTY5NmNlNmJhNTM1MWU2NDMzODFmYWQ4MTVhNDE4YzRiZDhkMTAxODRl
15
+ NThlNzYwZmI1MzI3ZjhmMmIxNDQ5MjYwMmE0NmY4NzQ1NmQzYjI=
@@ -3,7 +3,6 @@ module Caboose
3
3
 
4
4
  protect_from_forgery
5
5
  before_filter :before_before_action
6
- helper :all
7
6
 
8
7
  def before_before_action
9
8
 
@@ -2,6 +2,8 @@
2
2
  module Caboose
3
3
  class PagesController < ApplicationController
4
4
 
5
+ helper :application
6
+
5
7
  def before_action
6
8
  @page = Page.page_with_uri('/admin')
7
9
  end
@@ -209,30 +211,32 @@ module Caboose
209
211
  user = logged_in_user
210
212
  params.each do |name, value|
211
213
  case name
212
- when 'parent_id'
213
- if (page.id == value)
214
+ when 'parent_id'
215
+ value = value.to_i
216
+ if page.id == value
214
217
  resp.error = "The page's parent cannot be itself."
215
- elsif (Page.is_child(page.id, value))
218
+ elsif Page.is_child(page.id, value)
216
219
  resp.error = "You can't set the current page's parent to be one of its child pages."
217
- elsif (value != page.parent_id)
220
+ elsif value != page.parent_id
218
221
  p = Page.find(value)
219
- if (!user.is_allowed(p, 'edit'))
222
+ if !user.is_allowed(p, 'edit')
220
223
  resp.error = "You don't have access to put the current page there."
221
224
  end
222
225
  end
223
- if (resp.error.length > 0)
226
+ if resp.error
224
227
  save = false
225
228
  else
226
- parent = Page.find(value)
227
- Page.update_parent(page.id, value)
228
- resp.attributes['parent_id'] = { 'text' => parent.title }
229
+ page.parent = Page.find(value)
230
+ page.save
231
+ Page.update_uri(page)
232
+ resp.attributes['parent_id'] = { 'text' => page.parent.title }
229
233
  end
230
234
 
231
235
  when 'custom_css', 'custom_js'
232
236
  value.strip!
233
237
  page[name.to_sym] = value
234
238
 
235
- when 'title', 'menu_title', 'alias', 'hide', 'layout', 'redirect_url',
239
+ when 'title', 'menu_title', 'hide', 'layout', 'redirect_url',
236
240
  'seo_title', 'meta_description', 'fb_description', 'gp_description', 'canonical_url'
237
241
  page[name.to_sym] = value
238
242
 
@@ -273,7 +277,17 @@ module Caboose
273
277
 
274
278
  when 'slug'
275
279
  page.slug = Page.slug(value.strip.length > 0 ? value : page.title)
280
+ page.save
281
+ Page.update_uri(page)
282
+ resp.attributes['slug'] = { 'value' => page.slug }
283
+ resp.attributes['uri'] = { 'value' => page.uri }
284
+
285
+ when 'alias'
286
+ page.alias = Page.slug(value.strip)
287
+ page.save
288
+ Page.update_uri(page)
276
289
  resp.attributes['slug'] = { 'value' => page.slug }
290
+ resp.attributes['uri'] = { 'value' => page.uri }
277
291
 
278
292
  when 'custom_sort_children'
279
293
  if (value == 0)
@@ -364,6 +378,13 @@ module Caboose
364
378
  ]
365
379
  render json: options
366
380
  end
381
+
382
+ # GET /admin/pages/:id/uri
383
+ def admin_page_uri
384
+ return unless user_is_allowed('pages', 'view')
385
+ p = Page.find(params[:id])
386
+ render :json => { 'uri' => p.uri }
387
+ end
367
388
 
368
389
  end
369
390
  end
@@ -1,6 +1,5 @@
1
1
  module Caboose
2
2
  module PagesHelper
3
-
4
3
  def pages_list(page)
5
4
  str = "<ul>"
6
5
  str << pages_list_helper(page)
@@ -8,7 +8,8 @@ class Caboose::Page < ActiveRecord::Base
8
8
  attr_accessible :parent_id,
9
9
  :title,
10
10
  :menu_title,
11
- :content,
11
+ :content,
12
+ :blocks,
12
13
  :slug,
13
14
  :alias,
14
15
  :uri,
@@ -86,46 +87,23 @@ class Caboose::Page < ActiveRecord::Base
86
87
  return self.page_with_uri_helper(parts, level+1, page_ids[0])
87
88
  end
88
89
 
89
- def self.update_child_uris(page_id)
90
- page = self.find(page_id)
91
- parent = self.find(page.parent_id)
92
- parent_uri = parent.nil? ? '/' : parent.uri
93
- self.update_child_uris_helper(ppage, parent_uri)
94
- end
95
-
96
- def self.update_child_uris_helper(page, parent_uri)
97
- return if page.redirect_url.length > 0
98
-
99
- slug = page.slug
100
- if (slug.trim.length == 0)
101
- slug = self.get_slug(page.title)
102
- self.update_detail_field(page.id, 'slug', slug)
103
- end
104
-
105
- slug = page.slug.trim.length > 0 ? page.slug : self.get_slug(page.title)
106
-
107
- uri= "#{parent_uri}/#{slug}"
108
- if (page.alias.length > 0)
109
- uri = "/#{page.alias}"
110
- elsif (self.is_top_level(page.parent_id))
111
- uri = "/#{page.slug}"
112
- end
113
- self.update_detail_field(page.id, 'uri', uri)
114
-
115
- page.children.each do |kid|
116
- self.update_child_uris_helper(kid, uri)
117
- end
90
+ def self.update_uri(page)
91
+ #return if page.redirect_url && page.redirect_url.length > 0
92
+
93
+ page.slug = self.slug(page.title) if page.slug.nil? || page.slug.strip.length == 0
94
+ page.uri = page.alias && page.alias.strip.length > 0 ? page.alias : (page.parent ? "#{page.parent.uri}/#{page.slug}" : "#{page.slug}")
95
+ page.uri[0] = '' if page.uri.starts_with?('/')
96
+ page.save
97
+
98
+ page.children.each { |p2| self.update_uri(p2) }
118
99
  end
119
100
 
120
101
  def self.update_child_perms(page_id)
121
102
  page = self.find(page_id)
122
103
 
123
- viewers = Role.roles_with_page_permission(page_id, 'view')
124
- editors = Role.roles_with_page_permission(page_id, 'edit')
125
- approvers = Role.roles_with_page_permission(page_id, 'approve')
126
- viewer_ids = viewers.collect {|r| r.id }
127
- editor_ids = editors.collect {|r| r.id }
128
- approver_id = approvers.collect {|r| r.id }
104
+ viewers_ids = Role.roles_with_page_permission(page_id, 'view').collect {|r| r.id }
105
+ editors_ids = Role.roles_with_page_permission(page_id, 'edit').collect {|r| r.id }
106
+ approvers_ids = Role.roles_with_page_permission(page_id, 'approve').collect {|r| r.id }
129
107
 
130
108
  self.update_child_perms_helper(page, viewer_ids, editor_ids, approver_ids)
131
109
  end
@@ -321,8 +299,8 @@ class Caboose::Page < ActiveRecord::Base
321
299
  end
322
300
 
323
301
  def self.is_child(parent_id, child_id)
324
- pid = self.where(:page_id => child_id).first.pluck(:parent_id)
325
- return false if pid <= 0
302
+ pid = self.where(:id => child_id).limit(1).pluck(:parent_id)[0]
303
+ return false if pid.nil? || pid <= 0
326
304
  return true if pid == parent_id
327
305
  return self.is_child(parent_id, pid)
328
306
  end
@@ -0,0 +1,8 @@
1
+
2
+ class Caboose::PageBlock < ActiveRecord::Base
3
+ self.table_name = "page_blocks"
4
+
5
+ belongs_to :page
6
+ attr_accessible :id, :page_id, :type, :sort_order, :value
7
+
8
+ end
@@ -2,7 +2,7 @@
2
2
  <%= render :partial => 'caboose/pages/admin_header' %>
3
3
 
4
4
  <div id='message'>
5
- <p class='note error'>Are you sure you want to delet the page? This can't be undone.<br /><br />
5
+ <p class='note error'>Are you sure you want to delete the page? This can't be undone.<br /><br />
6
6
  <input type='button' value='Yes' onclick='delete_page(<%= @page.id %>, true);' />
7
7
  <input type='button' value='No' onclick="window.location='/admin/pages/<%= @page.id %>/edit';" />
8
8
  </p>
@@ -1,6 +1,7 @@
1
1
 
2
2
  <%= render :partial => 'caboose/pages/admin_header' %>
3
3
 
4
+ <p>URI: /<span id='uri'><%= @page.uri %></span></p>
4
5
  <p><div id='page_<%= @page.id %>_title' ></div></p>
5
6
  <p><div id='page_<%= @page.id %>_menu_title' ></div></p>
6
7
  <p><div id='page_<%= @page.id %>_parent_id' ></div></p>
@@ -29,10 +30,10 @@ $(document).ready(function() {
29
30
  authenticity_token: '<%= form_authenticity_token %>',
30
31
  attributes: [
31
32
  { name: 'title' , nice_name: 'Title' , type: 'text' , value: <%= raw Caboose.json(@page.title ) %> , width: 400 },
32
- { name: 'parent_id' , nice_name: 'Parent' , type: 'select' , value: <%= @page.parent_id %> , width: 400, text: <%= raw (@page.parent_id == -1 ? "[No Parent]" : @page.parent.title).to_json %>, options_url: '/pages/sitemap-options' },
33
- { name: 'menu_title' , nice_name: 'Menu title' , type: 'text' , value: <%= raw Caboose.json(@page.menu_title ) %> , width: 400 },
34
- { name: 'slug' , nice_name: 'Slug' , type: 'text' , value: <%= raw Caboose.json(@page.slug ) %> , width: 400 },
35
- { name: 'alias' , nice_name: 'Alias' , type: 'text' , value: <%= raw Caboose.json(@page.alias ) %> , width: 400 },
33
+ { name: 'menu_title' , nice_name: 'Menu title' , type: 'text' , value: <%= raw Caboose.json(@page.menu_title ) %> , width: 400 },
34
+ { name: 'parent_id' , nice_name: 'Parent' , type: 'select' , value: <%= @page.parent_id %> , width: 400, after_update: function() { update_uri(<%= @page.id %>); }, text: <%= raw (@page.parent_id == -1 ? "[No Parent]" : @page.parent.title).to_json %>, options_url: '/admin/pages/sitemap-options' },
35
+ { name: 'slug' , nice_name: 'Slug' , type: 'text' , value: <%= raw Caboose.json(@page.slug ) %> , width: 400, after_update: function() { update_uri(<%= @page.id %>); } },
36
+ { name: 'alias' , nice_name: 'Alias' , type: 'text' , value: <%= raw Caboose.json(@page.alias ) %> , width: 400, after_update: function() { update_uri(<%= @page.id %>); } },
36
37
  { name: 'redirect_url' , nice_name: 'Redirect URL' , type: 'text' , value: <%= raw Caboose.json(@page.redirect_url ) %> , width: 400 },
37
38
  { name: 'hide' , nice_name: 'Hide' , type: 'checkbox' , value: <%= raw @page.hide %> , width: 400 },
38
39
  { name: 'layout' , nice_name: 'Layout' , type: 'text' , value: <%= raw Caboose.json(@page.layout ) %> , width: 400 },
@@ -42,5 +43,13 @@ $(document).ready(function() {
42
43
  });
43
44
  });
44
45
 
46
+ function update_uri(page_id)
47
+ {
48
+ $.ajax({
49
+ url: '/admin/pages/' + page_id + '/uri',
50
+ success: function(resp) { $('#uri').html(resp.uri); }
51
+ });
52
+ }
53
+
45
54
  </script>
46
55
  <% end %>
@@ -51,6 +51,7 @@ Caboose::Engine.routes.draw do
51
51
  get "admin/pages/robots-options" => "pages#admin_robots_options"
52
52
  get "admin/pages/format-options" => "pages#admin_content_format_options"
53
53
  get "admin/pages/new" => "pages#admin_new"
54
+ get "admin/pages/:id/uri" => "pages#admin_page_uri"
54
55
  get "admin/pages/:id/delete" => "pages#admin_delete_form"
55
56
  get "admin/pages/:id/sitemap" => "pages#admin_sitemap"
56
57
  get "admin/pages/:id/edit" => "pages#admin_edit_general"
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.2.68'
2
+ VERSION = '0.2.70'
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.2.68
4
+ version: 0.2.70
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-14 00:00:00.000000000 Z
11
+ date: 2013-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -197,6 +197,7 @@ files:
197
197
  - app/models/caboose/menu_block.rb
198
198
  - app/models/caboose/page.rb
199
199
  - app/models/caboose/page_bar_generator.rb
200
+ - app/models/caboose/page_block.rb
200
201
  - app/models/caboose/page_permission.rb
201
202
  - app/models/caboose/pager.rb
202
203
  - app/models/caboose/permission.rb