caboose-cms 0.8.51 → 0.8.52
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/caboose/admin_page_edit_content.js +1 -1
- data/app/assets/javascripts/caboose/assets_controller.js +141 -0
- data/app/assets/javascripts/caboose/block_modal_controllers/block_modal_controller.js +6 -3
- data/app/assets/javascripts/caboose/block_modal_controllers/default_block_modal_controller.js +1 -1
- data/app/assets/javascripts/caboose/block_modal_controllers/richtext_modal_controller.js +0 -2
- data/app/assets/stylesheets/caboose/admin_assets_index.css +48 -0
- data/app/controllers/caboose/assets_controller.rb +63 -0
- data/app/models/caboose/asset_manifest.rb +7 -0
- data/app/views/caboose/assets/admin_index.html.erb +28 -0
- data/lib/caboose/version.rb +1 -1
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2338ee415f739a434ccd13de4ef1ea693473ce39
|
4
|
+
data.tar.gz: db115d115fd00bcf9c27c6fe823926e91ae6224b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70266b735026e855cff40709e47e5390c384e7e1afaa026903a1c0c5270370ecafc6d853f8f23353870d3b198c28c3defe8196e29bdef8030ce22b70a018aeee
|
7
|
+
data.tar.gz: d99eb2f64cb1cd8e48fabf6fa045a93ebe2dfcc5270631eed1efed695d2645be2cbb9b17f4437a5a7cff4d51e2b4988a46d320a931427833be2206ee283b4731
|
@@ -67,7 +67,7 @@ PageContentController.prototype = {
|
|
67
67
|
new_block: function(parent_id, before_block_id, after_block_id)
|
68
68
|
{
|
69
69
|
var that = this;
|
70
|
-
console.log(parent_id);
|
70
|
+
//console.log(parent_id);
|
71
71
|
//caboose_modal_url('/admin/pages/' + this.page_id + '/blocks/' + parent_id + '/new');
|
72
72
|
that.modal = new BlockModalController({
|
73
73
|
page_id: that.page_id,
|
@@ -0,0 +1,141 @@
|
|
1
|
+
|
2
|
+
var AssetsController = Class.extend({
|
3
|
+
|
4
|
+
manifest: false,
|
5
|
+
editable_extensions: ['css', 'js', 'scss'],
|
6
|
+
|
7
|
+
init: function(params)
|
8
|
+
{
|
9
|
+
var that = this;
|
10
|
+
for (var i in params)
|
11
|
+
that[i] = params[i];
|
12
|
+
that.refresh_manifest(function() { that.print(); });
|
13
|
+
|
14
|
+
var h = $(window).outerHeight() - 52;
|
15
|
+
$('#manifest').css('height', '' + h + 'px').css('max-height', '' + h + 'px');
|
16
|
+
},
|
17
|
+
|
18
|
+
refresh_manifest: function(after)
|
19
|
+
{
|
20
|
+
var that = this;
|
21
|
+
$.ajax({
|
22
|
+
url: '/admin/assets/manifest',
|
23
|
+
type: 'get',
|
24
|
+
success: function(resp) {
|
25
|
+
that.manifest = resp;
|
26
|
+
if (after) after();
|
27
|
+
}
|
28
|
+
});
|
29
|
+
},
|
30
|
+
|
31
|
+
print: function()
|
32
|
+
{
|
33
|
+
var that = this;
|
34
|
+
that.print_manifest();
|
35
|
+
},
|
36
|
+
|
37
|
+
print_manifest: function()
|
38
|
+
{
|
39
|
+
var that = this;
|
40
|
+
var ul = $('<ul/>');
|
41
|
+
$.each(sorted_hash(that.manifest), function(name, h) {
|
42
|
+
ul.append(that.print_manifest_helper(name, h, ''));
|
43
|
+
});
|
44
|
+
$('#manifest').empty().append(ul);
|
45
|
+
},
|
46
|
+
|
47
|
+
print_manifest_helper: function(name, h, path)
|
48
|
+
{
|
49
|
+
var that = this;
|
50
|
+
var li = $('<li/>');
|
51
|
+
var a = $('<a/>').attr('href', '#').data('path', path + '/' + name).html(name);
|
52
|
+
if (typeof h == 'object')
|
53
|
+
{
|
54
|
+
a.click(function(e) {
|
55
|
+
e.preventDefault();
|
56
|
+
var ul = $(this).parent().find('ul:first');
|
57
|
+
if (ul.is(':visible'))
|
58
|
+
ul.slideUp();
|
59
|
+
else
|
60
|
+
ul.slideDown();
|
61
|
+
});
|
62
|
+
}
|
63
|
+
else
|
64
|
+
a.click(function(e) { e.preventDefault(); that.edit_file($(this).data('path')); });
|
65
|
+
li.append(a);
|
66
|
+
|
67
|
+
if (typeof h == 'object')
|
68
|
+
{
|
69
|
+
var ul2 = $('<ul/>').css('display', 'none');
|
70
|
+
$.each(sorted_hash(h), function(name2, h2) {
|
71
|
+
ul2.append(that.print_manifest_helper(name2, h2, path + '/' + name));
|
72
|
+
});
|
73
|
+
li.append(ul2);
|
74
|
+
}
|
75
|
+
return li;
|
76
|
+
},
|
77
|
+
|
78
|
+
edit_file: function(path)
|
79
|
+
{
|
80
|
+
var that = this;
|
81
|
+
var ext = path.split('.').pop();
|
82
|
+
|
83
|
+
if (that.editable_extensions.indexOf(ext) == -1)
|
84
|
+
{
|
85
|
+
$('#editor').html("<p class='note error'>That type of file is not editable.</p>");
|
86
|
+
return;
|
87
|
+
}
|
88
|
+
$('#editor').html("<p class='loading'>Getting file...</p>");
|
89
|
+
|
90
|
+
var str = false;
|
91
|
+
var error = false;
|
92
|
+
$.ajax({
|
93
|
+
url: that.assets_path + path,
|
94
|
+
type: 'get',
|
95
|
+
success: function(resp) { str = resp; },
|
96
|
+
error: function(e) { error = "Error retrieving file." },
|
97
|
+
async: false
|
98
|
+
});
|
99
|
+
if (error)
|
100
|
+
{
|
101
|
+
$('#editor').empty().html("<p class='note error'>" + error + "</p>");
|
102
|
+
return;
|
103
|
+
}
|
104
|
+
var w = $(window).outerWidth() - 380;
|
105
|
+
var h = $(window).outerHeight() - 200;
|
106
|
+
$('#editor').empty()
|
107
|
+
.append($('<p/>')
|
108
|
+
.append($('<input/>').attr('type', 'button').val('Save' ).click(function(e) { that.save_file(); })).append(' ')
|
109
|
+
.append($('<input/>').attr('type', 'button').val('Cancel' ).click(function(e) { $('#editor').empty(); }))
|
110
|
+
)
|
111
|
+
.append($('<textarea/>').attr('id', 'the_editor')
|
112
|
+
.css('width', '' + w + 'px')
|
113
|
+
.css('height', '' + h + 'px')
|
114
|
+
.append(str)
|
115
|
+
);
|
116
|
+
}
|
117
|
+
|
118
|
+
});
|
119
|
+
|
120
|
+
function sort_by_name(a, b){
|
121
|
+
var aName = a.name.toLowerCase();
|
122
|
+
var bName = b.name.toLowerCase();
|
123
|
+
return ((aName < bName) ? -1 : ((aName > bName) ? 1 : 0));
|
124
|
+
}
|
125
|
+
|
126
|
+
function sorted_hash(h)
|
127
|
+
{
|
128
|
+
var keys = [];
|
129
|
+
for (var k in h)
|
130
|
+
if (h.hasOwnProperty(k))
|
131
|
+
keys.push(k);
|
132
|
+
keys.sort();
|
133
|
+
|
134
|
+
var h2 = {};
|
135
|
+
for (i in keys)
|
136
|
+
{
|
137
|
+
var k = keys[i];
|
138
|
+
h2[k] = h[k];
|
139
|
+
}
|
140
|
+
return h2;
|
141
|
+
}
|
@@ -171,8 +171,6 @@ var BlockModalController = DefaultBlockModalController.extend({
|
|
171
171
|
add_block: function(block_type_id)
|
172
172
|
{
|
173
173
|
var that = this;
|
174
|
-
|
175
|
-
console.log(that);
|
176
174
|
|
177
175
|
that.include_inline_css(
|
178
176
|
"@font-face {\n" +
|
@@ -191,7 +189,12 @@ var BlockModalController = DefaultBlockModalController.extend({
|
|
191
189
|
'caboose/admin_new_block.css'
|
192
190
|
]);
|
193
191
|
|
194
|
-
if (!block_type_id)
|
192
|
+
if (!block_type_id && that.block.block_type.default_child_block_type_id)
|
193
|
+
{
|
194
|
+
that.add_block(that.block.block_type.default_child_block_type_id);
|
195
|
+
return;
|
196
|
+
}
|
197
|
+
else if (!block_type_id)
|
195
198
|
{
|
196
199
|
that.new_block_types = false;
|
197
200
|
$.ajax({
|
@@ -71,8 +71,6 @@ var RichtextModalController = DefaultBlockModalController.extend({
|
|
71
71
|
var that = this;
|
72
72
|
if (force || that.parent_controller.tinymce_initialized == undefined)
|
73
73
|
{
|
74
|
-
console.log("Initializing tinymce...");
|
75
|
-
|
76
74
|
tinymce.init({
|
77
75
|
selector: 'textarea.tinymce',
|
78
76
|
width: '800px',
|
@@ -0,0 +1,48 @@
|
|
1
|
+
|
2
|
+
#manifest {
|
3
|
+
position: absolute;
|
4
|
+
top: 0;
|
5
|
+
left: 0;
|
6
|
+
width: 280px;
|
7
|
+
height: 100px;
|
8
|
+
overflow-y: scroll;
|
9
|
+
}
|
10
|
+
|
11
|
+
#manifest ul {
|
12
|
+
list-style: none;
|
13
|
+
margin: 0;
|
14
|
+
padding: 0;
|
15
|
+
}
|
16
|
+
|
17
|
+
#manifest ul ul {
|
18
|
+
padding-left: 4px;
|
19
|
+
}
|
20
|
+
|
21
|
+
#manifest li {
|
22
|
+
list-style: none;
|
23
|
+
margin: 0;
|
24
|
+
padding: 0;
|
25
|
+
}
|
26
|
+
|
27
|
+
#manifest a {
|
28
|
+
display: block;
|
29
|
+
margin: 0;
|
30
|
+
padding: 4px 8px;
|
31
|
+
border: #999 1px solid;
|
32
|
+
background: #ccc;
|
33
|
+
}
|
34
|
+
|
35
|
+
#editor {
|
36
|
+
margin: 0;
|
37
|
+
padding-top: 20px;
|
38
|
+
padding-left: 280px;
|
39
|
+
}
|
40
|
+
|
41
|
+
#editor p {
|
42
|
+
margin-top: 0;
|
43
|
+
padding-top: 0;
|
44
|
+
}
|
45
|
+
|
46
|
+
#editor textarea {
|
47
|
+
margin: 0;
|
48
|
+
}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Caboose
|
2
|
+
class AssetsController < Caboose::ApplicationController
|
3
|
+
layout 'caboose/admin'
|
4
|
+
|
5
|
+
# @route GET /admin/assets
|
6
|
+
def admin_index
|
7
|
+
return if !user_is_allowed('assets', 'edit')
|
8
|
+
config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
|
9
|
+
bucket = config['bucket']
|
10
|
+
@assets_path = "http://#{bucket}.s3.amazonaws.com/assets"
|
11
|
+
end
|
12
|
+
|
13
|
+
# @route GET /admin/assets/manifest
|
14
|
+
def admin_manifest
|
15
|
+
return if !user_is_allowed('assets', 'edit')
|
16
|
+
|
17
|
+
config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
|
18
|
+
bucket = config['bucket']
|
19
|
+
resp = HTTParty.get("http://#{bucket}.s3.amazonaws.com/assets/manifest.yml")
|
20
|
+
str = resp.body
|
21
|
+
manifest = self.parse_manifest(str, true)
|
22
|
+
|
23
|
+
render :json => manifest
|
24
|
+
end
|
25
|
+
|
26
|
+
def parse_manifest(str, exclude_images = true)
|
27
|
+
lines = str.split("\n")
|
28
|
+
h = {}
|
29
|
+
lines.each_with_index do |line, i|
|
30
|
+
next if i == 0
|
31
|
+
path = line.split(": ").first.split('/')
|
32
|
+
|
33
|
+
if exclude_images
|
34
|
+
ext = line.split('.')
|
35
|
+
next if ext.count > 0 && ['png','jpg','gif','ico'].include?(ext.last.downcase)
|
36
|
+
end
|
37
|
+
self.verify_path_exists(path, h)
|
38
|
+
end
|
39
|
+
return h
|
40
|
+
end
|
41
|
+
|
42
|
+
def verify_path_exists(path, h, i = 0)
|
43
|
+
return if i >= path.count
|
44
|
+
h[path[i]] = i == (path.count - 1) ? true : {} if h[path[i]].nil?
|
45
|
+
self.verify_path_exists(path, h[path[i]], i+1)
|
46
|
+
end
|
47
|
+
|
48
|
+
#
|
49
|
+
# benttree/images/icons/apple-touch-icon.png
|
50
|
+
#
|
51
|
+
# {
|
52
|
+
# :bentree => {
|
53
|
+
# :images => {
|
54
|
+
# :icons => {
|
55
|
+
# 'apple-touch-icon.png' => true
|
56
|
+
# }
|
57
|
+
# }
|
58
|
+
# }
|
59
|
+
# }
|
60
|
+
#
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<div id='crumbtrail'>
|
2
|
+
<a href='/admin'>Admin</a> >
|
3
|
+
Assets
|
4
|
+
</div>
|
5
|
+
|
6
|
+
<div id='manifest'></div>
|
7
|
+
<div id='editor'></div>
|
8
|
+
|
9
|
+
<% content_for :caboose_js do %>
|
10
|
+
<%= javascript_include_tag 'caboose/class' %>
|
11
|
+
<%= javascript_include_tag 'caboose/model/all' %>
|
12
|
+
<%= javascript_include_tag 'caboose/assets_controller' %>
|
13
|
+
<script type='text/javascript'>
|
14
|
+
|
15
|
+
var controller = false;
|
16
|
+
$(document).ready(function() {
|
17
|
+
controller = new AssetsController({
|
18
|
+
assets_path: <%= raw Caboose.json(@assets_path) %>,
|
19
|
+
authenticity_token: "<%= raw form_authenticity_token %>"
|
20
|
+
});
|
21
|
+
});
|
22
|
+
|
23
|
+
</script>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
<% content_for :caboose_js do %>
|
27
|
+
<%= stylesheet_link_tag 'caboose/admin_assets_index' %>
|
28
|
+
<% end %>
|
data/lib/caboose/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caboose-cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.52
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
@@ -522,6 +522,7 @@ files:
|
|
522
522
|
- app/assets/javascripts/caboose/admin_post_edit_content.js
|
523
523
|
- app/assets/javascripts/caboose/admin_products.js
|
524
524
|
- app/assets/javascripts/caboose/application.js
|
525
|
+
- app/assets/javascripts/caboose/assets_controller.js
|
525
526
|
- app/assets/javascripts/caboose/authorize.net.js
|
526
527
|
- app/assets/javascripts/caboose/block_media_controller.js
|
527
528
|
- app/assets/javascripts/caboose/block_modal_controllers/block_modal_controller.js
|
@@ -687,6 +688,7 @@ files:
|
|
687
688
|
- app/assets/javascripts/plupload/plupload_with_jquery.min.js
|
688
689
|
- app/assets/javascripts/tinymce/plugins/caboose/plugin.js
|
689
690
|
- app/assets/stylesheets/caboose/admin.css
|
691
|
+
- app/assets/stylesheets/caboose/admin_assets_index.css
|
690
692
|
- app/assets/stylesheets/caboose/admin_block_edit_image.css.scss
|
691
693
|
- app/assets/stylesheets/caboose/admin_crumbtrail.css.scss
|
692
694
|
- app/assets/stylesheets/caboose/admin_main.css
|
@@ -746,6 +748,7 @@ files:
|
|
746
748
|
- app/controllers/caboose/ab_variants_controller.rb
|
747
749
|
- app/controllers/caboose/admin_controller.rb
|
748
750
|
- app/controllers/caboose/application_controller.rb
|
751
|
+
- app/controllers/caboose/assets_controller.rb
|
749
752
|
- app/controllers/caboose/billing_addresses_controller.rb
|
750
753
|
- app/controllers/caboose/block_type_categories_controller.rb
|
751
754
|
- app/controllers/caboose/block_type_sources_controller.rb
|
@@ -827,6 +830,7 @@ files:
|
|
827
830
|
- app/models/caboose/address.rb
|
828
831
|
- app/models/caboose/approval_request.rb
|
829
832
|
- app/models/caboose/asset.rb
|
833
|
+
- app/models/caboose/asset_manifest.rb
|
830
834
|
- app/models/caboose/authenticator.rb
|
831
835
|
- app/models/caboose/authnet.rb
|
832
836
|
- app/models/caboose/block.rb
|
@@ -941,6 +945,7 @@ files:
|
|
941
945
|
- app/views/caboose/admin/index.html.erb
|
942
946
|
- app/views/caboose/application/show.html.erb
|
943
947
|
- app/views/caboose/application/under_construction.html.erb
|
948
|
+
- app/views/caboose/assets/admin_index.html.erb
|
944
949
|
- app/views/caboose/block_type_sources/admin_edit.html.erb
|
945
950
|
- app/views/caboose/block_type_sources/admin_index.html.erb
|
946
951
|
- app/views/caboose/block_type_sources/admin_new.html.erb
|