caboose-cms 0.6.18 → 0.6.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/assets/javascripts/caboose/admin_media_index.js +115 -14
- data/app/assets/stylesheets/caboose/admin_media_index.css.scss +20 -3
- data/app/controllers/caboose/media_controller.rb +42 -2
- data/app/mailers/caboose/caboose_mailer.rb +1 -0
- data/app/models/caboose/media.rb +6 -0
- data/app/views/caboose/media/admin_index.html.erb +10 -2
- data/config/routes.rb +3 -2
- data/lib/caboose/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTA2NjFiZGRkMDZiMjJhNzJmNWMzZTUwN2ZhY2FkNmU2Y2M5MjNiMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZmIxODVlNWMzZDAwZTBlN2MwMjczYjA5MmM3ODBlMzU4MjVmMjQ5ZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDQ1NTk1ZDNiMjlkNmI4ZjUyZGM0ZTE2YjlhZGNlNTU3NmU1MmNiYjJkNzU1
|
10
|
+
ODk1MGVmYjUzMmU0YTFkZmJhM2ZkZmJjMDZlNDYzMjNkODJjYjNhMDhkMGU0
|
11
|
+
ZTY4ZjdiZDQ2NTg2MWQ4ZDljZTRhM2JkNGIyZGY4YTI0ZGJkODI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzA3ZmJhZjVjNWM0MTkxMzUwNTYwMzczZDI1MTM0ZGM3OWNhMWI5MmVlNWMx
|
14
|
+
ZTc4YjlkMGU2ZTRjNWQ2NzY2Mjc2ZGI1NGNmZGE0NmEwYTNlNjZlZGQ5YjVj
|
15
|
+
MmFjOTA0MjE2NjVjYTFiNWY0YWY1NWY3YTczNmM2OTI1OWNlZmU=
|
@@ -13,11 +13,11 @@ MediaController.prototype = {
|
|
13
13
|
signature: false,
|
14
14
|
selected_media: false,
|
15
15
|
uploader: false,
|
16
|
-
refresh_unprocessed_images:
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
refresh_unprocessed_images: true,
|
17
|
+
allow_edit: false,
|
18
|
+
feather_editor: false,
|
19
|
+
media_ids: [],
|
20
|
+
processing_media_ids: [],
|
21
21
|
|
22
22
|
init: function(params) {
|
23
23
|
var that = this;
|
@@ -32,7 +32,7 @@ MediaController.prototype = {
|
|
32
32
|
.append($('<a/>').attr('href', '#').html('Select All').click(function(e) { e.preventDefault(); that.select_all_media(); }))
|
33
33
|
)
|
34
34
|
.append($('<div/>').attr('id', 'the_uploader'));
|
35
|
-
that.refresh();
|
35
|
+
that.refresh();
|
36
36
|
},
|
37
37
|
|
38
38
|
refresh: function()
|
@@ -40,8 +40,7 @@ MediaController.prototype = {
|
|
40
40
|
var that = this;
|
41
41
|
that.refresh_categories();
|
42
42
|
that.refresh_media();
|
43
|
-
that.print_controls();
|
44
|
-
|
43
|
+
that.print_controls();
|
45
44
|
},
|
46
45
|
|
47
46
|
toggle_uploader: function()
|
@@ -136,11 +135,29 @@ MediaController.prototype = {
|
|
136
135
|
type: 'get',
|
137
136
|
async: false,
|
138
137
|
data: { media_category_id: that.cat_id },
|
139
|
-
success: function(resp) {
|
138
|
+
success: function(resp) {
|
140
139
|
that.cat = resp;
|
141
140
|
that.cat_id = that.cat.id;
|
142
141
|
that.selected_media = [];
|
143
|
-
that.print_media();
|
142
|
+
//that.print_media();
|
143
|
+
|
144
|
+
var mids = [];
|
145
|
+
var pmids = [];
|
146
|
+
if (that.cat.media.length > 0)
|
147
|
+
{
|
148
|
+
$.each(that.cat.media, function(i, m) {
|
149
|
+
mids.push(m.id);
|
150
|
+
if (m.media_type == 'image' && m.processed == false)
|
151
|
+
pmids.push(m.id);
|
152
|
+
});
|
153
|
+
}
|
154
|
+
if (mids.join(',') != that.media_ids.join(',') || pmids.join(',') != that.processing_media_ids.join(','))
|
155
|
+
that.print_media();
|
156
|
+
else if (pmids.length > 0)
|
157
|
+
setTimeout(function() { that.refresh_media(); }, 2000);
|
158
|
+
|
159
|
+
that.media_ids = mids;
|
160
|
+
that.processing_media_ids = pmids;
|
144
161
|
}
|
145
162
|
});
|
146
163
|
},
|
@@ -249,17 +266,24 @@ MediaController.prototype = {
|
|
249
266
|
that.edit_media_description($(this).parent().data('media_id'));
|
250
267
|
}));
|
251
268
|
if (m.image_urls)
|
252
|
-
li.append($('<img/>').attr('src', m.image_urls.tiny_url));
|
269
|
+
li.append($('<img/>').attr('src', m.image_urls.tiny_url).attr("id","image-" + m.id));
|
253
270
|
if (that.selected_media.indexOf(m.id) > -1)
|
254
271
|
li.addClass('selected ui-selected');
|
255
|
-
|
272
|
+
if (that.allow_edit && m.image_urls)
|
273
|
+
{
|
274
|
+
li.append($("<a/>")
|
275
|
+
.html("Edit Image")
|
276
|
+
.click(function() { that.edit_image($(this).parent().data('media_id')); })
|
277
|
+
);
|
278
|
+
}
|
279
|
+
ul.append(li);
|
256
280
|
});
|
257
281
|
}
|
258
282
|
else
|
259
283
|
ul = $('<p/>').html("This category is empty.");
|
260
|
-
$('#media').empty().append(ul);
|
284
|
+
$('#media').empty().append(ul);
|
261
285
|
if (that.refresh_unprocessed_images == true && processing)
|
262
|
-
setTimeout(function() { that.
|
286
|
+
setTimeout(function() { that.refresh_media(); }, 2000);
|
263
287
|
|
264
288
|
$.each(that.cat.media, function(i, m) {
|
265
289
|
$('li.media').draggable({
|
@@ -450,5 +474,82 @@ MediaController.prototype = {
|
|
450
474
|
}
|
451
475
|
});
|
452
476
|
},
|
477
|
+
|
478
|
+
media_with_id: function(media_id)
|
479
|
+
{
|
480
|
+
var that = this;
|
481
|
+
var m = false;
|
482
|
+
if (that.cat.media.length > 0)
|
483
|
+
{
|
484
|
+
$.each(that.cat.media, function(i, m2) {
|
485
|
+
if (parseInt(m2.id) == parseInt(media_id))
|
486
|
+
{
|
487
|
+
m = m2;
|
488
|
+
return false;
|
489
|
+
}
|
490
|
+
});
|
491
|
+
}
|
492
|
+
return m;
|
493
|
+
},
|
494
|
+
|
495
|
+
//============================================================================
|
496
|
+
// Aviary
|
497
|
+
//============================================================================
|
498
|
+
|
499
|
+
edit_image: function(media_id)
|
500
|
+
{
|
501
|
+
var that = this;
|
502
|
+
var m = that.media_with_id(media_id);
|
503
|
+
|
504
|
+
if (that.feather_editor != false)
|
505
|
+
{
|
506
|
+
that.edit_image_helper(m);
|
507
|
+
return;
|
508
|
+
}
|
509
|
+
that.feather_editor = new Aviary.Feather({
|
510
|
+
apiKey: '933414ee42934e8b81d8cd2226a5a13b',
|
511
|
+
theme: 'light',
|
512
|
+
enableCORS: false,
|
513
|
+
maxSize: 1600,
|
514
|
+
onSave: function(media_id, new_url) { return that.update_image(media_id, new_url); },
|
515
|
+
onLoad: function() { that.edit_image_helper(m); }
|
516
|
+
});
|
517
|
+
},
|
518
|
+
|
519
|
+
edit_image_helper: function(m)
|
520
|
+
{
|
521
|
+
console.log(m.image_urls.original_url);
|
522
|
+
var that = this;
|
523
|
+
that.feather_editor.launch({
|
524
|
+
image: 'image-' + m.id,
|
525
|
+
url: m.image_urls.original_url
|
526
|
+
});
|
527
|
+
},
|
528
|
+
|
529
|
+
update_image: function(image_id, new_url)
|
530
|
+
{
|
531
|
+
var that = this;
|
532
|
+
var media_id = parseInt(image_id.replace('image-', ''));
|
533
|
+
|
534
|
+
that.feather_editor.showWaitIndicator();
|
535
|
+
$.ajax({
|
536
|
+
url: '/admin/media/' + media_id,
|
537
|
+
type: 'put',
|
538
|
+
data: { image_url: new_url },
|
539
|
+
success: function(resp) {
|
540
|
+
if(resp.error) { alert("Error saving image:\n\n" + resp.error); }
|
541
|
+
if(resp.success) {
|
542
|
+
that.feather_editor.hideWaitIndicator();
|
543
|
+
var src = $('#image-' + media_id).attr('src').split('?')[0];
|
544
|
+
$('#image-' + media_id).attr('src', src + '?' + Date.now());
|
545
|
+
that.feather_editor.close();
|
546
|
+
that.refresh_media();
|
547
|
+
}
|
548
|
+
}
|
549
|
+
});
|
550
|
+
return false;
|
551
|
+
}
|
453
552
|
|
454
553
|
};
|
554
|
+
|
555
|
+
|
@@ -83,23 +83,40 @@
|
|
83
83
|
padding: 0;
|
84
84
|
display: inline-block;
|
85
85
|
width: 150px;
|
86
|
-
height:
|
86
|
+
height: 165px;
|
87
87
|
overflow: hidden;
|
88
88
|
background-color: #666;
|
89
89
|
background-position: center;
|
90
90
|
background-size: contain;
|
91
91
|
background-repeat: no-repeat;
|
92
92
|
border: #666 4px solid;
|
93
|
-
|
93
|
+
img {
|
94
|
+
max-height: 120px;
|
95
|
+
max-width: 90%;
|
96
|
+
}
|
94
97
|
span.name {
|
95
98
|
display: block;
|
96
99
|
position: absolute;
|
97
|
-
bottom:
|
100
|
+
bottom: 18px;
|
98
101
|
width: 150px;
|
99
102
|
text-align: center;
|
100
103
|
color: #fff;
|
101
104
|
text-decoration: none !important;
|
102
105
|
}
|
106
|
+
a {
|
107
|
+
text-decoration: underline;
|
108
|
+
cursor: pointer;
|
109
|
+
display: block;
|
110
|
+
font-size: 13px;
|
111
|
+
position: absolute;
|
112
|
+
bottom: 0;
|
113
|
+
text-align: center;
|
114
|
+
width: 100%;
|
115
|
+
color: #000;
|
116
|
+
&:hover {
|
117
|
+
color: blue;
|
118
|
+
}
|
119
|
+
}
|
103
120
|
&:hover {
|
104
121
|
background-color: #fff799;
|
105
122
|
border: #fff799 4px solid;
|
@@ -82,11 +82,51 @@ module Caboose
|
|
82
82
|
params.each do |name, value|
|
83
83
|
case name
|
84
84
|
when 'name' then m.name = value
|
85
|
-
when 'description' then m.description = value
|
85
|
+
when 'description' then m.description = value
|
86
|
+
when 'image_url' then
|
87
|
+
m.processed = false
|
88
|
+
m.delay.download_image_from_url(value)
|
86
89
|
end
|
87
90
|
end
|
91
|
+
|
92
|
+
m.save
|
93
|
+
resp.success = save
|
94
|
+
render :json => resp
|
95
|
+
end
|
96
|
+
|
97
|
+
# POST /admin/media/edit-image
|
98
|
+
#def admin_edit_image
|
99
|
+
# new_url = params[:new_url]
|
100
|
+
# media_id = params[:media_id]
|
101
|
+
# resp = StdClass.new({'attributes' => {}})
|
102
|
+
# if !new_url.blank? && !media_id.blank?
|
103
|
+
# m = Media.find(media_id.gsub("image-",""))
|
104
|
+
# m.image = new_url
|
105
|
+
# m.save
|
106
|
+
# resp.success = "Saved image!"
|
107
|
+
# else
|
108
|
+
# resp.error = "Couldn't save image"
|
109
|
+
# end
|
110
|
+
# render :json => resp
|
111
|
+
#end
|
88
112
|
|
89
|
-
|
113
|
+
# POST /admin/media/:id/image
|
114
|
+
def admin_update_image
|
115
|
+
return unless user_is_allowed('media', 'edit')
|
116
|
+
|
117
|
+
resp = StdClass.new
|
118
|
+
new_url = params[:new_url]
|
119
|
+
m = Media.where(:id => params[:id]).first
|
120
|
+
|
121
|
+
if m.nil?
|
122
|
+
resp.error = "Invalid media id."
|
123
|
+
elsif new_url.nil? || new_url.strip.length == 0
|
124
|
+
resp.error = "Invalid image URL."
|
125
|
+
else
|
126
|
+
m.image = URI.parse(new_url)
|
127
|
+
m.save
|
128
|
+
resp.success = "Image saved successfully."
|
129
|
+
end
|
90
130
|
render :json => resp
|
91
131
|
end
|
92
132
|
|
data/app/models/caboose/media.rb
CHANGED
@@ -35,6 +35,7 @@
|
|
35
35
|
<script type="text/javascript" src="/assets/plupload/jquery.ui.plupload/jquery.ui.plupload.js"></script>
|
36
36
|
-->
|
37
37
|
|
38
|
+
<script type="text/javascript" src="http://feather.aviary.com/imaging/v2/editor.js"></script>
|
38
39
|
<script type="text/javascript">
|
39
40
|
|
40
41
|
var controller = false;
|
@@ -46,9 +47,16 @@ $(document).ready(function() {
|
|
46
47
|
aws_access_key_id: '<%= raw @aws_access_key_id %>',
|
47
48
|
policy: '<%= raw @policy %>',
|
48
49
|
signature: '<%= raw @signature %>',
|
49
|
-
refresh_unprocessed_images:
|
50
|
-
|
50
|
+
refresh_unprocessed_images: true,
|
51
|
+
allow_edit: true
|
52
|
+
});
|
51
53
|
});
|
52
54
|
|
53
55
|
</script>
|
54
56
|
<% end %>
|
57
|
+
|
58
|
+
<%
|
59
|
+
# Adobe Image Editor SDK Credentials
|
60
|
+
# CLIENT SECRETf42be039-1af0-41d8-89bb-fdebdb557d3d
|
61
|
+
# CLIENT ID (DEVELOPMENT MODE)*933414ee42934e8b81d8cd2226a5a13b
|
62
|
+
%>
|
data/config/routes.rb
CHANGED
@@ -219,8 +219,9 @@ Caboose::Engine.routes.draw do
|
|
219
219
|
get "/admin/media/:id/description" => "media#admin_edit_description"
|
220
220
|
get "/admin/media/:id" => "media#admin_edit"
|
221
221
|
put "/admin/media/:id" => "media#admin_update"
|
222
|
-
post "/admin/media/:id/image" => "media#admin_update_image"
|
223
|
-
post "/admin/media"
|
222
|
+
post "/admin/media/:id/image" => "media#admin_update_image"
|
223
|
+
#post "/admin/media/edit-image" => "media#admin_edit_image"
|
224
|
+
post "/admin/media" => "media#admin_add"
|
224
225
|
delete "/admin/media/bulk" => "media#admin_bulk_delete"
|
225
226
|
delete "/admin/media/:id" => "media#admin_delete"
|
226
227
|
|
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.6.
|
4
|
+
version: 0.6.19
|
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-08-
|
11
|
+
date: 2015-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|