caboose-cms 0.5.214 → 0.5.215
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/controllers/caboose/post_categories_controller.rb +98 -0
- data/app/models/caboose/core_plugin.rb +5 -4
- data/app/models/caboose/role.rb +5 -1
- data/app/views/caboose/admin/index.html.erb +4 -1
- data/app/views/caboose/blocks/admin_edit_advanced.html.erb +4 -0
- data/app/views/caboose/pages/admin_edit_layout.html.erb +1 -0
- data/app/views/caboose/post_categories/admin_edit.html.erb +66 -0
- data/app/views/caboose/post_categories/admin_index.html.erb +16 -0
- data/app/views/caboose/post_categories/admin_new.html.erb +43 -0
- data/app/views/caboose/sites/admin_edit.html.erb +1 -1
- data/config/routes.rb +17 -0
- data/lib/caboose/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDA4ODMwZTZhOGNhYTU0NGJlMzk2NmRlMmIzM2Q0ZGQ3ODk5YzY1OQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTQxOWYwNTVmZTgyMDhlYjJiOGY3YjlhNGI0NDc4NmYyZjEyYjdhZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmZiOTNkZTQzZjI4ZmUyMzNjYWI1Y2ZjNTU2NGQxZGYxZGViM2E1NTVjNmNl
|
10
|
+
Yjc0YTViMDFkNDBmOTg5NDFhNTY2MjNiOGIxOGNjZWVjYzM5NzZhNGVhZTc4
|
11
|
+
M2MxYmNhNDFjZWVkZDg2MDU3MDc3NWI4ZDU3MGVhMTNiMzIzOWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGI2NzEyODFlOWY1MDQ1OTUwZTZlMzlhNTE2OWQyNTM0OTBlMThkMDI0NDhl
|
14
|
+
NWUxMjBkODMxMzE2ZmQ2NmZmMGQ4NTg0NzJmNzVlNmRjODhhZjA0YWQ2M2Qz
|
15
|
+
MjkxMzc5NGFiZDM2NWU2NWY3N2JkZTcyYmE0MWZhMTY0NGI5ODk=
|
@@ -0,0 +1,98 @@
|
|
1
|
+
module Caboose
|
2
|
+
class PostCategoriesController < Caboose::ApplicationController
|
3
|
+
|
4
|
+
#=============================================================================
|
5
|
+
# Admin actions
|
6
|
+
#=============================================================================
|
7
|
+
|
8
|
+
# GET /admin/post-categories
|
9
|
+
def admin_index
|
10
|
+
return unless user_is_allowed('post_categories', 'view')
|
11
|
+
|
12
|
+
@main_cat = PostCategory.where("site_id = ?", @site.id).first
|
13
|
+
if @main_cat.nil?
|
14
|
+
@main_cat = PostCategory.create(:site_id => @site.id, :name => 'General News')
|
15
|
+
end
|
16
|
+
render :layout => 'caboose/admin'
|
17
|
+
end
|
18
|
+
|
19
|
+
# GET /admin/post-categories/new
|
20
|
+
def admin_new
|
21
|
+
return unless user_is_allowed('post_categories', 'add')
|
22
|
+
render :layout => 'caboose/admin'
|
23
|
+
end
|
24
|
+
|
25
|
+
# POST /admin/post-categories
|
26
|
+
def admin_add
|
27
|
+
return unless user_is_allowed('post_categories', 'add')
|
28
|
+
|
29
|
+
resp = Caboose::StdClass.new
|
30
|
+
|
31
|
+
if params[:name].nil? || params[:name].empty?
|
32
|
+
resp.error = 'The category name cannot be empty.'
|
33
|
+
else
|
34
|
+
cat = PostCategory.new(
|
35
|
+
:site_id => @site.id,
|
36
|
+
:name => params[:name]
|
37
|
+
)
|
38
|
+
|
39
|
+
if cat.save
|
40
|
+
resp.redirect = "/admin/post-categories/#{cat.id}"
|
41
|
+
else
|
42
|
+
resp.error = 'There was an error saving the category.'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
render :json => resp
|
47
|
+
end
|
48
|
+
|
49
|
+
# GET /admin/post-categories/:id
|
50
|
+
def admin_edit
|
51
|
+
return unless user_is_allowed('post_categories', 'edit')
|
52
|
+
@category = PostCategory.find(params[:id])
|
53
|
+
render :layout => 'caboose/admin'
|
54
|
+
end
|
55
|
+
|
56
|
+
# PUT /admin/post-categories/:id
|
57
|
+
def admin_update
|
58
|
+
return unless user_is_allowed('post_categories', 'edit')
|
59
|
+
|
60
|
+
# Define category and initialize response
|
61
|
+
cat = PostCategory.find(params[:id])
|
62
|
+
resp = Caboose::StdClass.new({ :attributes => {} })
|
63
|
+
|
64
|
+
# Iterate over params and update relevant attributes
|
65
|
+
params.each do |key, value|
|
66
|
+
case key
|
67
|
+
when 'site_id' then cat.name = value
|
68
|
+
when 'name' then cat.name = value
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# Try and save category
|
73
|
+
resp.success = cat.save
|
74
|
+
|
75
|
+
# Respond to update request
|
76
|
+
render :json => resp
|
77
|
+
end
|
78
|
+
|
79
|
+
# DELETE /admin/post-categories/:id
|
80
|
+
def admin_delete
|
81
|
+
return unless user_is_allowed('post_categories', 'delete')
|
82
|
+
|
83
|
+
resp = Caboose::StdClass.new
|
84
|
+
cat = PostCategory.find(params[:id])
|
85
|
+
|
86
|
+
if cat.posts.any?
|
87
|
+
resp.error = "Can't delete a post category that has posts in it."
|
88
|
+
else
|
89
|
+
resp.success = cat.destroy
|
90
|
+
resp.redirect = '/admin/post-categories'
|
91
|
+
end
|
92
|
+
render :json => resp
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
@@ -8,15 +8,16 @@ class Caboose::CorePlugin < Caboose::CaboosePlugin
|
|
8
8
|
|
9
9
|
item = { 'id' => 'core', 'text' => 'Settings', 'children' => [] }
|
10
10
|
item['children'] << { 'id' => 'blocktypes' , 'text' => 'AB Test Variants' , 'href' => '/admin/ab-variants' , 'modal' => false } if user.is_allowed('abvariants' , 'view')
|
11
|
-
item['children'] << { 'id' => 'blocktypes' , 'text' => 'Block Types' , 'href' => '/admin/block-types' , 'modal' => false } if user.is_allowed('blocktypes' , 'view')
|
12
|
-
item['children'] << { 'id' => 'fonts' , 'text' => 'Fonts' , 'href' => '/admin/fonts' , 'modal' => false } if user.is_allowed('fonts' , 'view') if site.use_fonts
|
11
|
+
item['children'] << { 'id' => 'blocktypes' , 'text' => 'Block Types' , 'href' => '/admin/block-types' , 'modal' => false } if user.is_allowed('blocktypes' , 'view') if site.is_master == true
|
12
|
+
item['children'] << { 'id' => 'fonts' , 'text' => 'Fonts' , 'href' => '/admin/fonts' , 'modal' => false } if user.is_allowed('fonts' , 'view') if site.use_fonts == true
|
13
13
|
item['children'] << { 'id' => 'redirects' , 'text' => 'Permanent Redirects' , 'href' => '/admin/redirects' , 'modal' => false } if user.is_allowed('redirects' , 'view')
|
14
|
-
item['children'] << { 'id' => 'permissions' , 'text' => 'Permissions' , 'href' => '/admin/permissions' , 'modal' => false } if user.is_allowed('permissions' , 'view')
|
14
|
+
item['children'] << { 'id' => 'permissions' , 'text' => 'Permissions' , 'href' => '/admin/permissions' , 'modal' => false } if user.is_allowed('permissions' , 'view')
|
15
|
+
item['children'] << { 'id' => 'post_categories' , 'text' => 'Post Categories' , 'href' => '/admin/post-categories' , 'modal' => false } if user.is_allowed('post_categories', 'view')
|
15
16
|
item['children'] << { 'id' => 'roles' , 'text' => 'Roles' , 'href' => '/admin/roles' , 'modal' => false } if user.is_allowed('roles' , 'view')
|
16
17
|
item['children'] << { 'id' => 'sites' , 'text' => 'Sites' , 'href' => '/admin/sites' , 'modal' => false } if user.is_allowed('sites' , 'view') if site.is_master == true
|
17
18
|
item['children'] << { 'id' => 'smtp' , 'text' => 'SMTP (Mail)' , 'href' => '/admin/smtp' , 'modal' => false } if user.is_allowed('smtp' , 'view')
|
18
19
|
item['children'] << { 'id' => 'social' , 'text' => 'Social Media' , 'href' => '/admin/social' , 'modal' => false } if user.is_allowed('social' , 'view')
|
19
|
-
item['children'] << { 'id' => 'store' , 'text' => 'Store' , 'href' => '/admin/store' , 'modal' => false } if user.is_allowed('store' , 'view')
|
20
|
+
item['children'] << { 'id' => 'store' , 'text' => 'Store' , 'href' => '/admin/store' , 'modal' => false } if user.is_allowed('store' , 'view') if site.use_store == true
|
20
21
|
item['children'] << { 'id' => 'users' , 'text' => 'Users' , 'href' => '/admin/users' , 'modal' => false } if user.is_allowed('users' , 'view')
|
21
22
|
item['children'] << { 'id' => 'variables' , 'text' => 'Variables' , 'href' => '/admin/settings' , 'modal' => false } if user.is_allowed('settings' , 'view')
|
22
23
|
nav << item if item['children'].count > 0
|
data/app/models/caboose/role.rb
CHANGED
@@ -10,7 +10,11 @@ class Caboose::Role < ActiveRecord::Base
|
|
10
10
|
has_many :permissions, :through => :role_permissions
|
11
11
|
has_many :page_permissions
|
12
12
|
|
13
|
-
attr_accessible :
|
13
|
+
attr_accessible :id,
|
14
|
+
:name,
|
15
|
+
:description,
|
16
|
+
:parent_id,
|
17
|
+
:site_id
|
14
18
|
attr_accessor :children
|
15
19
|
|
16
20
|
def self.admin_role
|
@@ -19,7 +19,10 @@ width = 200
|
|
19
19
|
<% id = item['id'].nil? ? i.to_s : item['id'] %>
|
20
20
|
<% href = item['href'].nil? ? '#' : item['href'] %>
|
21
21
|
<% modal = item['modal'].nil? ? false : item['modal'] %>
|
22
|
-
<li id='nav_item_<%= id %>'
|
22
|
+
<li id='nav_item_<%= id %>'>
|
23
|
+
<% if href != "#" %><a href='<%= href %>'<%= raw (modal ? " rel='modal'" : "") %>><% end %>
|
24
|
+
<span class='icon'></span><span class='text'><%= item['text'] %></span>
|
25
|
+
<% if href != "#" %></a><% end %>
|
23
26
|
<% if (!item['children'].nil? && item['children'].count > 0) %>
|
24
27
|
<ul>
|
25
28
|
<% item['children'].each do |item2| %>
|
@@ -46,7 +46,11 @@ $(document).ready(function() {
|
|
46
46
|
m = new ModelBinder({
|
47
47
|
name: 'Block',
|
48
48
|
id: <%= b.id %>,
|
49
|
+
<% if b.post_id %>
|
50
|
+
update_url: '/admin/posts/<%= b.post_id %>/blocks/<%= b.id %>',
|
51
|
+
<% else %>
|
49
52
|
update_url: '/admin/pages/<%= b.page_id %>/blocks/<%= b.id %>',
|
53
|
+
<% end %>
|
50
54
|
authenticity_token: '<%= form_authenticity_token %>',
|
51
55
|
attributes: [{
|
52
56
|
name: 'block_type_id',
|
@@ -3,6 +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
7
|
<p><select name='block_type_id'>
|
7
8
|
<option value=''>-- Select a layout --</option>
|
8
9
|
<% cat_ids = Caboose::BlockTypeCategory.layouts.collect{ |cat| cat.id } %>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<h1>Edit Category</h1>
|
2
|
+
|
3
|
+
<p><div class="push-below" id="postcategory_<%= @category.id %>_name"></div></p>
|
4
|
+
|
5
|
+
<h2>Posts</h2>
|
6
|
+
|
7
|
+
<% if @category.posts.any? %>
|
8
|
+
<ul>
|
9
|
+
<% @category.posts.each do |post| %>
|
10
|
+
<li><a href="/admin/posts/<%= post.id %>"><%= post.title %></a></li>
|
11
|
+
<% end %>
|
12
|
+
</ul>
|
13
|
+
<% else %>
|
14
|
+
<p>This category has no associated posts.</p>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<div id="message"></div>
|
18
|
+
<p>
|
19
|
+
<input type="button" value="< Back" onclick="window.location='/admin/post-categories';" />
|
20
|
+
<input type="button" value="Delete Category" onclick="delete_category(<%= @category.id %>)" />
|
21
|
+
</p>
|
22
|
+
|
23
|
+
<% content_for :caboose_css do %>
|
24
|
+
<style>
|
25
|
+
.push-below { margin-bottom: 24px; }
|
26
|
+
</style>
|
27
|
+
<% end %>
|
28
|
+
|
29
|
+
<% content_for :caboose_js do %>
|
30
|
+
<%= javascript_include_tag "caboose/model/all" %>
|
31
|
+
<script type='text/javascript'>
|
32
|
+
|
33
|
+
$(document).ready(function() {
|
34
|
+
m = new ModelBinder({
|
35
|
+
name: 'PostCategory',
|
36
|
+
id: <%= @category.id %>,
|
37
|
+
update_url: '/admin/post-categories/<%= @category.id %>',
|
38
|
+
authenticity_token: '<%= form_authenticity_token %>',
|
39
|
+
attributes: [
|
40
|
+
|
41
|
+
{ name: 'name' , nice_name: 'Name' , type: 'text' , value: <%= raw Caboose.json(@category.name) %> , width: 400 }
|
42
|
+
]
|
43
|
+
});
|
44
|
+
});
|
45
|
+
|
46
|
+
function delete_category(cat_id, confirm) {
|
47
|
+
if (!confirm) {
|
48
|
+
var p = $('<p/>').addClass('note error').css('margin-bottom', '10px')
|
49
|
+
.append("Are you sure you want to delete the category?<br />This can't be undone.<br /><br />")
|
50
|
+
.append($('<input/>').attr('type', 'button').val('Yes').click(function() { delete_category(cat_id, true); })).append(' ')
|
51
|
+
.append($('<input/>').attr('type', 'button').val('No').click(function() { $('#message').empty(); }));
|
52
|
+
$('#message').empty().append(p);
|
53
|
+
return;
|
54
|
+
}
|
55
|
+
$('#message').html("<p class='loading'>Deleting the category...</p>");
|
56
|
+
$.ajax({
|
57
|
+
url: '/admin/post-categories/' + cat_id,
|
58
|
+
type: 'delete',
|
59
|
+
success: function(resp) {
|
60
|
+
if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>");
|
61
|
+
if (resp.redirect) window.location = resp.redirect;
|
62
|
+
}
|
63
|
+
});
|
64
|
+
}
|
65
|
+
</script>
|
66
|
+
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<h1>Post Categories</h1>
|
2
|
+
<a href='/admin/post-categories/new'>New Category</a>
|
3
|
+
|
4
|
+
<% cats = Caboose::PostCategory.where(:site_id => @site.id).order(:name).all %>
|
5
|
+
<ul>
|
6
|
+
<% cats.each do |c| %>
|
7
|
+
<li><a href="/admin/post-categories/<%= c.id %>" title="<%= c.name %>"><%= c.name %></a>
|
8
|
+
<% end %>
|
9
|
+
</ul>
|
10
|
+
|
11
|
+
|
12
|
+
<% content_for :caboose_js do %>
|
13
|
+
<script type='text/javascript'>
|
14
|
+
|
15
|
+
</script>
|
16
|
+
<% end %>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<h1>New Category</h1>
|
2
|
+
|
3
|
+
<form action="/admin/categories" method="post" id="new_form">
|
4
|
+
<input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>" />
|
5
|
+
<p><input type="text" name="name" id='name' placeholder="Category Name" /></p>
|
6
|
+
<div id="message"></div>
|
7
|
+
<input type="button" value="< Back" onclick="window.location='/admin/post-categories';" />
|
8
|
+
<input type="submit" value="Add Category" onclick="add_category(); return false" />
|
9
|
+
</form>
|
10
|
+
|
11
|
+
<% content_for :caboose_js do %>
|
12
|
+
<%= javascript_include_tag "caboose/model/all" %>
|
13
|
+
<script type='text/javascript'>
|
14
|
+
|
15
|
+
function add_category() {
|
16
|
+
$('#message').html("<p class='loading'>Adding category...</p>");
|
17
|
+
var stay = $('#stay').prop('checked');
|
18
|
+
|
19
|
+
$.ajax({
|
20
|
+
url: '/admin/post-categories',
|
21
|
+
type: 'post',
|
22
|
+
data: $('#new_form').serialize(),
|
23
|
+
success: function(resp) {
|
24
|
+
if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
|
25
|
+
if (resp.redirect)
|
26
|
+
{
|
27
|
+
if (stay)
|
28
|
+
{
|
29
|
+
$('#name').val('');
|
30
|
+
get_category_options();
|
31
|
+
$('#message').html("<p class='note succes'>The category has been added successfully.</p>");
|
32
|
+
setTimeout(function() { $('#message').empty(); }, 2000);
|
33
|
+
}
|
34
|
+
else if (resp.redirect)
|
35
|
+
window.location = resp.redirect;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
});
|
39
|
+
}
|
40
|
+
|
41
|
+
|
42
|
+
</script>
|
43
|
+
<% end %>
|
@@ -46,7 +46,7 @@ user_ids = [] if user_ids.nil?
|
|
46
46
|
<div id='members'>
|
47
47
|
<table class='data'>
|
48
48
|
<tr><th>User</th><th>None</th><th>User</th><th>Admin</th></tr>
|
49
|
-
<% Caboose::User.reorder('last_name, first_name').all.each do |u| %>
|
49
|
+
<% Caboose::User.where(:site_id => @site.id).reorder('last_name, first_name').all.each do |u| %>
|
50
50
|
<tr>
|
51
51
|
<td><%= u.first_name %> <%= u.last_name %> (<%= u.email %>)</td>
|
52
52
|
<td align='center'><input type='radio' name='user<%= u.id %>' <%= !admin_ids.include?(u.id) && !user_ids.include?(u.id) ? "checked='true'" : '' %> onclick="remove_site_membership(<%= s.id %>, <%= u.id %>);" /></td>
|
data/config/routes.rb
CHANGED
@@ -372,6 +372,23 @@ Caboose::Engine.routes.draw do
|
|
372
372
|
get "/admin/posts" => "posts#admin_index"
|
373
373
|
post "/admin/posts" => "posts#admin_add"
|
374
374
|
delete "/admin/posts/:id" => "posts#admin_delete"
|
375
|
+
|
376
|
+
#=============================================================================
|
377
|
+
# Post Categories
|
378
|
+
#=============================================================================
|
379
|
+
|
380
|
+
get "/admin/post-categories" => "post-categories#admin_index"
|
381
|
+
get "/admin/post-categories/new" => "post-categories#admin_new"
|
382
|
+
get "/admin/post-categories/options" => "post-categories#admin_options"
|
383
|
+
get '/admin/post-categories/status-options' => 'post-categories#admin_status_options'
|
384
|
+
get "/admin/post-categories/:id/sort-children" => "post-categories#admin_sort_children"
|
385
|
+
put "/admin/post-categories/:id/children/sort-order" => "post-categories#admin_update_sort_order"
|
386
|
+
get "/admin/post-categories/:id/products/json" => "post-categories#admin_category_products"
|
387
|
+
get "/admin/post-categories/:id" => "post-categories#admin_edit"
|
388
|
+
put "/admin/post-categories/:id" => "post-categories#admin_update"
|
389
|
+
post "/admin/post-categories/:id" => "post-categories#admin_update"
|
390
|
+
post "/admin/post-categories" => "post-categories#admin_add"
|
391
|
+
delete "/admin/post-categories/:id" => "post-categories#admin_delete"
|
375
392
|
|
376
393
|
#=============================================================================
|
377
394
|
# Google Spreadsheets
|
data/lib/caboose/version.rb
CHANGED
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.5.
|
4
|
+
version: 0.5.215
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -554,6 +554,7 @@ files:
|
|
554
554
|
- app/controllers/caboose/page_permissions_controller.rb
|
555
555
|
- app/controllers/caboose/pages_controller.rb
|
556
556
|
- app/controllers/caboose/permissions_controller.rb
|
557
|
+
- app/controllers/caboose/post_categories_controller.rb
|
557
558
|
- app/controllers/caboose/posts_controller.rb
|
558
559
|
- app/controllers/caboose/product_images_controller.rb
|
559
560
|
- app/controllers/caboose/products_controller.rb
|
@@ -847,6 +848,9 @@ files:
|
|
847
848
|
- app/views/caboose/permissions/edit.html.erb
|
848
849
|
- app/views/caboose/permissions/index.html.erb
|
849
850
|
- app/views/caboose/permissions/new.html.erb
|
851
|
+
- app/views/caboose/post_categories/admin_edit.html.erb
|
852
|
+
- app/views/caboose/post_categories/admin_index.html.erb
|
853
|
+
- app/views/caboose/post_categories/admin_new.html.erb
|
850
854
|
- app/views/caboose/posts/_admin_footer.html.erb
|
851
855
|
- app/views/caboose/posts/_admin_header.html.erb
|
852
856
|
- app/views/caboose/posts/admin_delete_form.html.erb
|