caboose-cms 0.4.52 → 0.4.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/app/assets/javascripts/caboose/admin_page_edit_content.js +2 -2
- data/app/assets/javascripts/caboose/jquery.fileupload.js +1 -1
- data/app/assets/javascripts/caboose/jquery.iframe-transport.js +215 -1
- data/app/controllers/caboose/images_controller.rb +36 -9
- data/app/models/caboose/media_image.rb +8 -0
- data/app/views/caboose/images/admin_index.html.erb +89 -5
- data/app/views/caboose/images/admin_new.html.erb +53 -35
- data/app/views/caboose/images/admin_s3_result.html.erb +3 -0
- data/app/views/layouts/caboose/empty.html.erb +10 -0
- data/config/routes.rb +4 -2
- data/lib/caboose/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzhlMzNkYzE1YTRiM2FmY2RhZTBlODVjYTEyY2VjZTM4YWNiYWZjNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZGI2ZGYyNDJhZTEwNjU3ZDhjODM2NTQxMGFkOGNhZDllMzQ0NDg4Mw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZmQ2MWY0YThkYzA1YWJlNjI2MThiYjMyOTZkYjQ3NzcyYTY5ZTA5ZmE5YWRh
|
10
|
+
MDNmOGRiMzE2ZTBiNzIzODFiMTUzN2UwNmQ3MjZjZTI5ZjFmMDQ4M2RkYWI0
|
11
|
+
NTAwYmQ4MTFkZTU5OWEyZjI2MDQ3NWJmMDgzNDY4YzdlMGRlYzk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Nzk1ZTBhZWY1NTc4MzM5YmVjNDRkM2VjYjIxOWI1NzI4ZmMyNGVmM2IxOGNj
|
14
|
+
YWE0MGJhMWE0M2RlMjk3M2JiMDExZDNmYjQwOGIxYTkzNjZkOTY0OTUzY2Ji
|
15
|
+
OTFjOWVkN2M4YjhiMzMyN2ZmYWZjNTBkYmFjOGI5Njc1MDIzYzQ=
|
@@ -42,8 +42,8 @@ PageContentController.prototype = {
|
|
42
42
|
{
|
43
43
|
var ids = [];
|
44
44
|
$.each($(e.target).children(), function(i, el) {
|
45
|
-
var id = $(el).attr('id');
|
46
|
-
if (id.substr(0, 6) == 'block_') ids.push(id.substr(6));
|
45
|
+
var id = $(el).attr('id');
|
46
|
+
if (id && id.substr(0, 6) == 'block_') ids.push(id.substr(6));
|
47
47
|
});
|
48
48
|
|
49
49
|
$.ajax({
|
@@ -163,7 +163,7 @@
|
|
163
163
|
// value properties, a function returning such an array, a FormData
|
164
164
|
// object (for XHR file uploads), or a simple object.
|
165
165
|
// The form of the first fileInput is given as parameter to the function:
|
166
|
-
formData: function (form) {
|
166
|
+
formData: function (form) {
|
167
167
|
return form.serializeArray();
|
168
168
|
},
|
169
169
|
|
@@ -1 +1,215 @@
|
|
1
|
-
|
1
|
+
/*
|
2
|
+
* jQuery Iframe Transport Plugin 1.8.2
|
3
|
+
* https://github.com/blueimp/jQuery-File-Upload
|
4
|
+
*
|
5
|
+
* Copyright 2011, Sebastian Tschan
|
6
|
+
* https://blueimp.net
|
7
|
+
*
|
8
|
+
* Licensed under the MIT license:
|
9
|
+
* http://www.opensource.org/licenses/MIT
|
10
|
+
*/
|
11
|
+
|
12
|
+
/* global define, window, document */
|
13
|
+
|
14
|
+
(function (factory) {
|
15
|
+
'use strict';
|
16
|
+
if (typeof define === 'function' && define.amd) {
|
17
|
+
// Register as an anonymous AMD module:
|
18
|
+
define(['jquery'], factory);
|
19
|
+
} else {
|
20
|
+
// Browser globals:
|
21
|
+
factory(window.jQuery);
|
22
|
+
}
|
23
|
+
}(function ($) {
|
24
|
+
'use strict';
|
25
|
+
|
26
|
+
// Helper variable to create unique names for the transport iframes:
|
27
|
+
var counter = 0;
|
28
|
+
|
29
|
+
// The iframe transport accepts four additional options:
|
30
|
+
// options.fileInput: a jQuery collection of file input fields
|
31
|
+
// options.paramName: the parameter name for the file form data,
|
32
|
+
// overrides the name property of the file input field(s),
|
33
|
+
// can be a string or an array of strings.
|
34
|
+
// options.formData: an array of objects with name and value properties,
|
35
|
+
// equivalent to the return data of .serializeArray(), e.g.:
|
36
|
+
// [{name: 'a', value: 1}, {name: 'b', value: 2}]
|
37
|
+
// options.initialIframeSrc: the URL of the initial iframe src,
|
38
|
+
// by default set to "javascript:false;"
|
39
|
+
$.ajaxTransport('iframe', function (options) {
|
40
|
+
if (options.async) {
|
41
|
+
// javascript:false as initial iframe src
|
42
|
+
// prevents warning popups on HTTPS in IE6:
|
43
|
+
/*jshint scripturl: true */
|
44
|
+
var initialIframeSrc = options.initialIframeSrc || 'javascript:false;',
|
45
|
+
/*jshint scripturl: false */
|
46
|
+
form,
|
47
|
+
iframe,
|
48
|
+
addParamChar;
|
49
|
+
return {
|
50
|
+
send: function (_, completeCallback) {
|
51
|
+
form = $('<form style="display:block;"></form>');
|
52
|
+
form.attr('accept-charset', options.formAcceptCharset);
|
53
|
+
addParamChar = /\?/.test(options.url) ? '&' : '?';
|
54
|
+
// XDomainRequest only supports GET and POST:
|
55
|
+
if (options.type === 'DELETE') {
|
56
|
+
options.url = options.url + addParamChar + '_method=DELETE';
|
57
|
+
options.type = 'POST';
|
58
|
+
} else if (options.type === 'PUT') {
|
59
|
+
options.url = options.url + addParamChar + '_method=PUT';
|
60
|
+
options.type = 'POST';
|
61
|
+
} else if (options.type === 'PATCH') {
|
62
|
+
options.url = options.url + addParamChar + '_method=PATCH';
|
63
|
+
options.type = 'POST';
|
64
|
+
}
|
65
|
+
// IE versions below IE8 cannot set the name property of
|
66
|
+
// elements that have already been added to the DOM,
|
67
|
+
// so we set the name along with the iframe HTML markup:
|
68
|
+
counter += 1;
|
69
|
+
iframe = $(
|
70
|
+
'<iframe src="' + initialIframeSrc +
|
71
|
+
'" name="iframe-transport-' + counter + '" style="width: 1000px; height: 800px;"></iframe>'
|
72
|
+
).bind('load', function () {
|
73
|
+
var fileInputClones,
|
74
|
+
paramNames = $.isArray(options.paramName) ?
|
75
|
+
options.paramName : [options.paramName];
|
76
|
+
iframe
|
77
|
+
.unbind('load')
|
78
|
+
.bind('load', function () {
|
79
|
+
var response;
|
80
|
+
// Wrap in a try/catch block to catch exceptions thrown
|
81
|
+
// when trying to access cross-domain iframe contents:
|
82
|
+
try {
|
83
|
+
response = iframe.contents();
|
84
|
+
// Google Chrome and Firefox do not throw an
|
85
|
+
// exception when calling iframe.contents() on
|
86
|
+
// cross-domain requests, so we unify the response:
|
87
|
+
if (!response.length || !response[0].firstChild) {
|
88
|
+
throw new Error();
|
89
|
+
}
|
90
|
+
} catch (e) {
|
91
|
+
response = undefined;
|
92
|
+
}
|
93
|
+
// The complete callback returns the
|
94
|
+
// iframe content document as response object:
|
95
|
+
completeCallback(
|
96
|
+
200,
|
97
|
+
'success',
|
98
|
+
{'iframe': response}
|
99
|
+
);
|
100
|
+
// Fix for IE endless progress bar activity bug
|
101
|
+
// (happens on form submits to iframe targets):
|
102
|
+
$('<iframe src="' + initialIframeSrc + '"></iframe>')
|
103
|
+
.appendTo(form);
|
104
|
+
return;
|
105
|
+
window.setTimeout(function () {
|
106
|
+
// Removing the form in a setTimeout call
|
107
|
+
// allows Chrome's developer tools to display
|
108
|
+
// the response result
|
109
|
+
form.remove();
|
110
|
+
}, 0);
|
111
|
+
});
|
112
|
+
form
|
113
|
+
.prop('target', iframe.prop('name'))
|
114
|
+
.prop('action', options.url)
|
115
|
+
.prop('method', options.type);
|
116
|
+
if (options.formData) {
|
117
|
+
$.each(options.formData, function (index, field) {
|
118
|
+
$('<input type="hidden"/>')
|
119
|
+
.prop('name', field.name)
|
120
|
+
.val(field.value)
|
121
|
+
.appendTo(form);
|
122
|
+
});
|
123
|
+
}
|
124
|
+
if (options.fileInput && options.fileInput.length &&
|
125
|
+
options.type === 'POST') {
|
126
|
+
fileInputClones = options.fileInput.clone();
|
127
|
+
// Insert a clone for each file input field:
|
128
|
+
options.fileInput.after(function (index) {
|
129
|
+
return fileInputClones[index];
|
130
|
+
});
|
131
|
+
if (options.paramName) {
|
132
|
+
options.fileInput.each(function (index) {
|
133
|
+
$(this).prop(
|
134
|
+
'name',
|
135
|
+
paramNames[index] || options.paramName
|
136
|
+
);
|
137
|
+
});
|
138
|
+
}
|
139
|
+
// Appending the file input fields to the hidden form
|
140
|
+
// removes them from their original location:
|
141
|
+
form
|
142
|
+
.append(options.fileInput)
|
143
|
+
.prop('enctype', 'multipart/form-data')
|
144
|
+
// enctype must be set as encoding for IE:
|
145
|
+
.prop('encoding', 'multipart/form-data');
|
146
|
+
// Remove the HTML5 form attribute from the input(s):
|
147
|
+
options.fileInput.removeAttr('form');
|
148
|
+
}
|
149
|
+
form.submit();
|
150
|
+
// Insert the file input fields at their original location
|
151
|
+
// by replacing the clones with the originals:
|
152
|
+
if (fileInputClones && fileInputClones.length) {
|
153
|
+
options.fileInput.each(function (index, input) {
|
154
|
+
var clone = $(fileInputClones[index]);
|
155
|
+
// Restore the original name and form properties:
|
156
|
+
$(input)
|
157
|
+
.prop('name', clone.prop('name'))
|
158
|
+
.attr('form', clone.attr('form'));
|
159
|
+
clone.replaceWith(input);
|
160
|
+
});
|
161
|
+
}
|
162
|
+
});
|
163
|
+
form.append(iframe).appendTo(document.body);
|
164
|
+
},
|
165
|
+
abort: function () {
|
166
|
+
if (iframe) {
|
167
|
+
// javascript:false as iframe src aborts the request
|
168
|
+
// and prevents warning popups on HTTPS in IE6.
|
169
|
+
// concat is used to avoid the "Script URL" JSLint error:
|
170
|
+
iframe
|
171
|
+
.unbind('load')
|
172
|
+
.prop('src', initialIframeSrc);
|
173
|
+
}
|
174
|
+
if (form) {
|
175
|
+
form.remove();
|
176
|
+
}
|
177
|
+
}
|
178
|
+
};
|
179
|
+
}
|
180
|
+
});
|
181
|
+
|
182
|
+
// The iframe transport returns the iframe content document as response.
|
183
|
+
// The following adds converters from iframe to text, json, html, xml
|
184
|
+
// and script.
|
185
|
+
// Please note that the Content-Type for JSON responses has to be text/plain
|
186
|
+
// or text/html, if the browser doesn't include application/json in the
|
187
|
+
// Accept header, else IE will show a download dialog.
|
188
|
+
// The Content-Type for XML responses on the other hand has to be always
|
189
|
+
// application/xml or text/xml, so IE properly parses the XML response.
|
190
|
+
// See also
|
191
|
+
// https://github.com/blueimp/jQuery-File-Upload/wiki/Setup#content-type-negotiation
|
192
|
+
$.ajaxSetup({
|
193
|
+
converters: {
|
194
|
+
'iframe text': function (iframe) {
|
195
|
+
return iframe && $(iframe[0].body).text();
|
196
|
+
},
|
197
|
+
'iframe json': function (iframe) {
|
198
|
+
return iframe && $.parseJSON($(iframe[0].body).text());
|
199
|
+
},
|
200
|
+
'iframe html': function (iframe) {
|
201
|
+
return iframe && $(iframe[0].body).html();
|
202
|
+
},
|
203
|
+
'iframe xml': function (iframe) {
|
204
|
+
var xmlDoc = iframe && iframe[0];
|
205
|
+
return xmlDoc && $.isXMLDoc(xmlDoc) ? xmlDoc :
|
206
|
+
$.parseXML((xmlDoc.XMLDocument && xmlDoc.XMLDocument.xml) ||
|
207
|
+
$(xmlDoc.body).html());
|
208
|
+
},
|
209
|
+
'iframe script': function (iframe) {
|
210
|
+
return iframe && $.globalEval($(iframe[0].body).text());
|
211
|
+
}
|
212
|
+
}
|
213
|
+
});
|
214
|
+
|
215
|
+
}));
|
@@ -276,31 +276,58 @@ module Caboose
|
|
276
276
|
# GET /admin/images/sign-s3
|
277
277
|
def admin_sign_s3
|
278
278
|
|
279
|
+
name = params[:name]
|
280
|
+
mi = MediaImage.create(
|
281
|
+
:media_category_id => params[:media_category_id],
|
282
|
+
:name => params[:name]
|
283
|
+
)
|
284
|
+
key = "media-images/#{mi.id}#{File.extname(name)}".downcase
|
285
|
+
|
279
286
|
config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
|
280
287
|
access_key = config['access_key_id']
|
281
288
|
secret_key = config['secret_access_key']
|
282
289
|
bucket = config['bucket']
|
283
290
|
|
284
|
-
policy = {
|
291
|
+
policy = {
|
285
292
|
"expiration" => 10.seconds.from_now.utc.xmlschema,
|
286
293
|
"conditions" => [
|
287
|
-
{ "bucket" => 'cabooseit' },
|
294
|
+
{ "bucket" => 'cabooseit' },
|
295
|
+
["starts-with", "$key", key],
|
288
296
|
{ "acl" => "public-read" },
|
289
|
-
{ "success_action_status" => "200" }
|
297
|
+
{ "success_action_status" => "200" }
|
298
|
+
#{ "success_action_redirect" => "/admin/images/s3-result" }
|
290
299
|
]
|
291
300
|
}
|
292
301
|
policy = Base64.encode64(policy.to_json).gsub(/\n/,'')
|
293
302
|
signature = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), secret_key, policy)).gsub("\n","")
|
294
303
|
|
295
304
|
render :json => {
|
296
|
-
:
|
297
|
-
:
|
298
|
-
:
|
299
|
-
|
300
|
-
|
305
|
+
:media_image_id => mi.id,
|
306
|
+
:url => "https://#{bucket}.s3.amazonaws.com",
|
307
|
+
:fields => {
|
308
|
+
:key => key,
|
309
|
+
'AWSAccessKeyId' => access_key,
|
310
|
+
:acl => 'public-read',
|
311
|
+
:success_action_status => '200',
|
312
|
+
#:success_action_redirect => '/admin/images/s3-result',
|
313
|
+
:policy => policy,
|
314
|
+
:signature => signature
|
315
|
+
}
|
301
316
|
}
|
302
317
|
|
303
|
-
end
|
318
|
+
end
|
319
|
+
|
320
|
+
def admin_s3_result
|
321
|
+
render :layout => 'caboose/empty'
|
322
|
+
end
|
323
|
+
|
324
|
+
# GET /admin/images/:id/process
|
325
|
+
def admin_process
|
326
|
+
return if !user_is_allowed('images', 'edit')
|
327
|
+
mi = MediaImage.find(params[:id])
|
328
|
+
mi.delay.process
|
329
|
+
render :json => true
|
330
|
+
end
|
304
331
|
|
305
332
|
end
|
306
333
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
1
3
|
class Caboose::MediaImage < ActiveRecord::Base
|
2
4
|
|
3
5
|
self.table_name = "media_images"
|
@@ -13,4 +15,10 @@ class Caboose::MediaImage < ActiveRecord::Base
|
|
13
15
|
do_not_validate_attachment_file_type :image
|
14
16
|
attr_accessible :id, :media_category_id, :name, :description
|
15
17
|
|
18
|
+
def process
|
19
|
+
puts "http://#{Caboose::cdn_domain}/media-images/#{self.id}#{File.extname(self.name.downcase)}"
|
20
|
+
self.image = URI.parse("http://#{Caboose::cdn_domain}/media-images/#{self.id}#{File.extname(self.name.downcase)}")
|
21
|
+
self.save
|
22
|
+
end
|
23
|
+
|
16
24
|
end
|
@@ -1,9 +1,18 @@
|
|
1
1
|
<h1>Images</h1>
|
2
2
|
|
3
|
-
<% if @domain && @media_category %>
|
4
|
-
<
|
5
|
-
<
|
6
|
-
<
|
3
|
+
<% if @domain && @media_category %>
|
4
|
+
<form action='/admin/images/sign-s3' method='post' id='new_image_form' enctype='multipart/form-data'>
|
5
|
+
<input type='hidden' name='key' value='' />
|
6
|
+
<input type='hidden' name='AWSAccessKeyId' value='' />
|
7
|
+
<input type='hidden' name='acl' value='' />
|
8
|
+
<input type='hidden' name='success_action_status' value='' />
|
9
|
+
<!--<input type='hidden' name='success_action_redirect' value='' />-->
|
10
|
+
<input type='hidden' name='policy' value='' />
|
11
|
+
<input type='hidden' name='signature' value='' />
|
12
|
+
<input type="file" name="file" id="file" multiple='true' />
|
13
|
+
<div id='progress'><div id='bar'></div></div>
|
14
|
+
</form>
|
15
|
+
<p><a href='/admin/images/new-category?parent_id=<%= @media_category.id %>'>New Category</a></p>
|
7
16
|
</p>
|
8
17
|
<% if @media_category.children.count > 0 || @media_category.media_images.count > 0 %>
|
9
18
|
<ul class='media'>
|
@@ -11,7 +20,7 @@
|
|
11
20
|
<li class='category' id='cat<%= cat.id %>'><a href='/admin/images?media_category_id=<%= cat.id %>'><%= cat.name %></a></li>
|
12
21
|
<% end %>
|
13
22
|
<% @media_category.media_images.each do |mi| %>
|
14
|
-
<li class='image' id='image<%= mi.id %>'><a href='/admin/images/<%= mi.id %>'><img src='<%= mi.image.url(:thumb) %>' /><span><%=
|
23
|
+
<li class='image' id='image<%= mi.id %>'><a href='/admin/images/<%= mi.id %>'><img src='<%= mi.image.url(:thumb) %>' /><span><%= mi.name %></span></a></li>
|
15
24
|
<% end %>
|
16
25
|
</ul>
|
17
26
|
<% else %>
|
@@ -22,3 +31,78 @@
|
|
22
31
|
<% else %>
|
23
32
|
<p>It doesn't look like this site is configured for the current domain. Please <a href='/admin/sites'>configure your sites</a>.</p>
|
24
33
|
<% end %>
|
34
|
+
|
35
|
+
<% content_for :caboose_css do %>
|
36
|
+
<style type='text/css'>
|
37
|
+
ul.media li.image { list-style: none; margin: 0; padding: 0; float: left; }
|
38
|
+
ul.media li.image { list-style: none; margin: 0; padding: 0; float: left; }
|
39
|
+
ul.media li.image img {}
|
40
|
+
.progress { max-width: 600px; margin: 0.2em 0 0.2em 0; }
|
41
|
+
.progress .bar { height: 1.2em; padding: 0.2em; color: white; display: none; }
|
42
|
+
</style>
|
43
|
+
<% end %>
|
44
|
+
|
45
|
+
<% content_for :caboose_js do %>
|
46
|
+
<%= javascript_include_tag 'jquery.ui.widget' %>
|
47
|
+
<%= javascript_include_tag 'caboose/jquery.iframe-transport.js' %>
|
48
|
+
<%= javascript_include_tag 'caboose/jquery.fileupload.js' %>
|
49
|
+
<script type='text/javascript'>
|
50
|
+
|
51
|
+
var image_ids = [];
|
52
|
+
$(document).ready(function() {
|
53
|
+
$('#file').fileupload({
|
54
|
+
//forceIframeTransport: true,
|
55
|
+
autoUpload: true,
|
56
|
+
//replaceFileInput: true,
|
57
|
+
//singleFileUploads: false,
|
58
|
+
add: function(e, data) {
|
59
|
+
$.ajax({
|
60
|
+
url: '/admin/images/s3',
|
61
|
+
type: 'get',
|
62
|
+
data: {
|
63
|
+
name: data.files[0].name,
|
64
|
+
media_category_id: <%= @media_category.id %>
|
65
|
+
},
|
66
|
+
async: false,
|
67
|
+
success: function(resp) {
|
68
|
+
image_ids.push(resp.media_image_id);
|
69
|
+
var form = $('#new_image_form');
|
70
|
+
for (var i in resp.fields)
|
71
|
+
form.find("input[name=" + i + "]").val(resp.fields[i]);
|
72
|
+
form.attr('action', resp.url);
|
73
|
+
}
|
74
|
+
});
|
75
|
+
data.submit();
|
76
|
+
},
|
77
|
+
progressall: function (e, data) {
|
78
|
+
$('#bar').css('width', parseInt(data.loaded / data.total * 100, 10) + '%')
|
79
|
+
},
|
80
|
+
start: function (e) {
|
81
|
+
$('#file').hide();
|
82
|
+
$('#bar').css('background', 'green').css('display', 'block').css('width', '0%').html(" ");
|
83
|
+
},
|
84
|
+
done: function(e, data) {
|
85
|
+
console.log("Upload done.");
|
86
|
+
console.log(data);
|
87
|
+
setTimeout(function() {
|
88
|
+
$.each(image_ids, function(i, id) {
|
89
|
+
$.ajax({
|
90
|
+
url: '/admin/images/' + id + '/process',
|
91
|
+
type: 'get',
|
92
|
+
async: false,
|
93
|
+
success: function(resp) {}
|
94
|
+
});
|
95
|
+
});
|
96
|
+
window.location.reload(true);
|
97
|
+
}, 500);
|
98
|
+
},
|
99
|
+
fail: function(e, data) {
|
100
|
+
console.log("Upload failed.");
|
101
|
+
console.log(data);
|
102
|
+
$('#bar').css("background", "red").text("Failed");
|
103
|
+
}
|
104
|
+
});
|
105
|
+
});
|
106
|
+
|
107
|
+
</script>
|
108
|
+
<% end %>
|
@@ -1,10 +1,19 @@
|
|
1
|
-
|
1
|
+
<%
|
2
|
+
# https://github.com/blueimp/jQuery-File-Upload/wiki/Upload-directly-to-S3
|
3
|
+
%>
|
2
4
|
<h1>Upload Images</h1>
|
3
5
|
|
4
|
-
<form action='
|
5
|
-
<input type=
|
6
|
-
<
|
7
|
-
<
|
6
|
+
<form action='/admin/images/sign-s3' method='post' id='new_image_form' enctype='multipart/form-data'>
|
7
|
+
<input type='hidden' name='key' value='' />
|
8
|
+
<input type='hidden' name='AWSAccessKeyId' value='' />
|
9
|
+
<input type='hidden' name='acl' value='' />
|
10
|
+
<input type='hidden' name='success_action_status' value='' />
|
11
|
+
<!--<input type='hidden' name='success_action_redirect' value='' />-->
|
12
|
+
<input type='hidden' name='policy' value='' />
|
13
|
+
<input type='hidden' name='signature' value='' />
|
14
|
+
<input type="file" name="file" id="file" multiple='true' />
|
15
|
+
<div id='progress'><div id='bar'></div></div>
|
16
|
+
</form>
|
8
17
|
|
9
18
|
<% content_for :caboose_css do %>
|
10
19
|
<style type='text/css'>
|
@@ -14,48 +23,57 @@
|
|
14
23
|
<% end %>
|
15
24
|
|
16
25
|
<% content_for :caboose_js do %>
|
17
|
-
<%= javascript_include_tag 'jquery.ui.
|
26
|
+
<%= javascript_include_tag 'jquery.ui.widget' %>
|
18
27
|
<%= javascript_include_tag 'caboose/jquery.iframe-transport.js' %>
|
19
28
|
<%= javascript_include_tag 'caboose/jquery.fileupload.js' %>
|
20
29
|
<script type='text/javascript'>
|
21
30
|
|
22
|
-
$(document).ready(function() {
|
23
|
-
$('#
|
24
|
-
forceIframeTransport: true,
|
25
|
-
autoUpload: true,
|
26
|
-
|
27
|
-
//
|
28
|
-
|
29
|
-
type: 'POST',
|
30
|
-
//formData: pp.fields,
|
31
|
-
//paramName: 'file', // S3 does not like nested name fields i.e. name="user[avatar_url]"
|
32
|
-
//dataType: 'XML', // S3 returns XML if success_action_status is set to 201
|
33
|
-
replaceFileInput: false,
|
34
|
-
|
35
|
-
add: function(e, data) {
|
31
|
+
$(document).ready(function() {
|
32
|
+
$('#file').fileupload({
|
33
|
+
//forceIframeTransport: true,
|
34
|
+
autoUpload: true,
|
35
|
+
//replaceFileInput: true,
|
36
|
+
//singleFileUploads: false,
|
37
|
+
add: function(e, data) {
|
36
38
|
$.ajax({
|
37
|
-
url: '/admin/images/
|
39
|
+
url: '/admin/images/s3',
|
38
40
|
type: 'get',
|
39
41
|
data: {
|
40
|
-
name:
|
42
|
+
name: data.files[0].name,
|
41
43
|
media_category_id: <%= @media_category_id %>
|
42
44
|
},
|
43
45
|
async: false,
|
44
|
-
success: function(resp) {
|
45
|
-
|
46
|
-
var
|
47
|
-
|
48
|
-
|
49
|
-
//form.attr('action', pp.url);
|
46
|
+
success: function(resp) {
|
47
|
+
var form = $('#new_image_form');
|
48
|
+
for (var i in resp.fields)
|
49
|
+
form.find("input[name=" + i + "]").val(resp.fields[i]);
|
50
|
+
form.attr('action', resp.url);
|
50
51
|
}
|
51
|
-
});
|
52
|
-
|
52
|
+
});
|
53
|
+
data.submit();
|
53
54
|
},
|
54
|
-
progressall: function (e, data) {
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
progressall: function (e, data) {
|
56
|
+
$('#bar').css('width', parseInt(data.loaded / data.total * 100, 10) + '%')
|
57
|
+
},
|
58
|
+
start: function (e) {
|
59
|
+
$('#file').hide();
|
60
|
+
$('#bar').css('background', 'green').css('display', 'block').css('width', '0%').text("Uploading...");
|
61
|
+
},
|
62
|
+
done: function(e, data) {
|
63
|
+
console.log("Upload done.");
|
64
|
+
console.log(data);
|
65
|
+
$('#bar').text("Uploading done");
|
66
|
+
setTimeout(function() {
|
67
|
+
$('#file').val('').show();
|
68
|
+
$('#bar').css('background', 'transparent').empty();
|
69
|
+
}, 2000);
|
70
|
+
},
|
71
|
+
fail: function(e, data) {
|
72
|
+
console.log("Upload failed.");
|
73
|
+
console.log(data);
|
74
|
+
$('#bar').css("background", "red").text("Failed");
|
75
|
+
}
|
76
|
+
});
|
59
77
|
});
|
60
78
|
|
61
79
|
</script>
|
data/config/routes.rb
CHANGED
@@ -63,9 +63,11 @@ Caboose::Engine.routes.draw do
|
|
63
63
|
delete "admin/roles/:id/permissions/:permission_id" => "roles#remove_permission"
|
64
64
|
|
65
65
|
get "admin/images" => "images#admin_index"
|
66
|
-
get "admin/images/
|
66
|
+
get "admin/images/s3" => "images#admin_sign_s3"
|
67
|
+
get "admin/images/s3-result" => "images#admin_s3_result"
|
67
68
|
get "admin/images/new" => "images#admin_new"
|
68
|
-
get "admin/images/:id"
|
69
|
+
get "admin/images/:id/process" => "images#admin_process"
|
70
|
+
get "admin/images/:id" => "images#admin_edit"
|
69
71
|
put "admin/images/:id" => "images#admin_update"
|
70
72
|
post "admin/images/:id/image" => "images#admin_update_image"
|
71
73
|
post "admin/images" => "images#admin_add"
|
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.4.
|
4
|
+
version: 0.4.53
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -369,6 +369,7 @@ files:
|
|
369
369
|
- app/views/caboose/extras/error404.html.erb
|
370
370
|
- app/views/caboose/images/admin_index.html.erb
|
371
371
|
- app/views/caboose/images/admin_new.html.erb
|
372
|
+
- app/views/caboose/images/admin_s3_result.html.erb
|
372
373
|
- app/views/caboose/login/forgot_password_form.html.erb
|
373
374
|
- app/views/caboose/login/index.html.erb
|
374
375
|
- app/views/caboose/login/reset_password_form.html.erb
|
@@ -431,6 +432,7 @@ files:
|
|
431
432
|
- app/views/layouts/caboose/_top_nav.html.erb
|
432
433
|
- app/views/layouts/caboose/admin.html.erb
|
433
434
|
- app/views/layouts/caboose/application.html.erb
|
435
|
+
- app/views/layouts/caboose/empty.html.erb
|
434
436
|
- app/views/layouts/caboose/error404.html.erb
|
435
437
|
- app/views/layouts/caboose/modal.html.erb
|
436
438
|
- bin/caboose
|