caboose-cms 0.5.221 → 0.5.222
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 +401 -0
- data/app/assets/javascripts/caboose/jquery-ui.drag-multiple.min.js +4 -0
- data/app/assets/javascripts/plupload/Moxie.swf +0 -0
- data/app/assets/javascripts/plupload/Moxie.xap +0 -0
- data/app/assets/javascripts/plupload/i18n/ar.js +2 -0
- data/app/assets/javascripts/plupload/i18n/az.js +2 -0
- data/app/assets/javascripts/plupload/i18n/bg.js +2 -0
- data/app/assets/javascripts/plupload/i18n/bs.js +2 -0
- data/app/assets/javascripts/plupload/i18n/ca.js +2 -0
- data/app/assets/javascripts/plupload/i18n/cs.js +2 -0
- data/app/assets/javascripts/plupload/i18n/cy.js +2 -0
- data/app/assets/javascripts/plupload/i18n/da.js +2 -0
- data/app/assets/javascripts/plupload/i18n/de.js +2 -0
- data/app/assets/javascripts/plupload/i18n/el.js +2 -0
- data/app/assets/javascripts/plupload/i18n/en.js +2 -0
- data/app/assets/javascripts/plupload/i18n/es.js +2 -0
- data/app/assets/javascripts/plupload/i18n/et.js +2 -0
- data/app/assets/javascripts/plupload/i18n/fa.js +2 -0
- data/app/assets/javascripts/plupload/i18n/fi.js +2 -0
- data/app/assets/javascripts/plupload/i18n/fr.js +2 -0
- data/app/assets/javascripts/plupload/i18n/he.js +2 -0
- data/app/assets/javascripts/plupload/i18n/hr.js +2 -0
- data/app/assets/javascripts/plupload/i18n/hu.js +2 -0
- data/app/assets/javascripts/plupload/i18n/hy.js +2 -0
- data/app/assets/javascripts/plupload/i18n/id.js +2 -0
- data/app/assets/javascripts/plupload/i18n/it.js +2 -0
- data/app/assets/javascripts/plupload/i18n/ja.js +2 -0
- data/app/assets/javascripts/plupload/i18n/ka.js +2 -0
- data/app/assets/javascripts/plupload/i18n/kk.js +2 -0
- data/app/assets/javascripts/plupload/i18n/km.js +2 -0
- data/app/assets/javascripts/plupload/i18n/ko.js +2 -0
- data/app/assets/javascripts/plupload/i18n/ku_IQ.js +2 -0
- data/app/assets/javascripts/plupload/i18n/lt.js +2 -0
- data/app/assets/javascripts/plupload/i18n/lv.js +2 -0
- data/app/assets/javascripts/plupload/i18n/mn.js +2 -0
- data/app/assets/javascripts/plupload/i18n/ms.js +2 -0
- data/app/assets/javascripts/plupload/i18n/nl.js +2 -0
- data/app/assets/javascripts/plupload/i18n/pl.js +2 -0
- data/app/assets/javascripts/plupload/i18n/pt_BR.js +2 -0
- data/app/assets/javascripts/plupload/i18n/ro.js +2 -0
- data/app/assets/javascripts/plupload/i18n/ru.js +2 -0
- data/app/assets/javascripts/plupload/i18n/sk.js +2 -0
- data/app/assets/javascripts/plupload/i18n/sq.js +2 -0
- data/app/assets/javascripts/plupload/i18n/sr.js +2 -0
- data/app/assets/javascripts/plupload/i18n/sr_RS.js +2 -0
- data/app/assets/javascripts/plupload/i18n/sv.js +2 -0
- data/app/assets/javascripts/plupload/i18n/th_TH.js +2 -0
- data/app/assets/javascripts/plupload/i18n/tr.js +2 -0
- data/app/assets/javascripts/plupload/i18n/uk_UA.js +2 -0
- data/app/assets/javascripts/plupload/i18n/vi.js +2 -0
- data/app/assets/javascripts/plupload/i18n/zh_CN.js +2 -0
- data/app/assets/javascripts/plupload/i18n/zh_TW.js +2 -0
- data/app/assets/javascripts/plupload/jquery.plupload.queue/css/jquery.plupload.queue.css +185 -0
- data/app/assets/javascripts/plupload/jquery.plupload.queue/img/backgrounds.gif +0 -0
- data/app/assets/javascripts/plupload/jquery.plupload.queue/img/buttons-disabled.png +0 -0
- data/app/assets/javascripts/plupload/jquery.plupload.queue/img/buttons.png +0 -0
- data/app/assets/javascripts/plupload/jquery.plupload.queue/img/delete.gif +0 -0
- data/app/assets/javascripts/plupload/jquery.plupload.queue/img/done.gif +0 -0
- data/app/assets/javascripts/plupload/jquery.plupload.queue/img/error.gif +0 -0
- data/app/assets/javascripts/plupload/jquery.plupload.queue/img/throbber.gif +0 -0
- data/app/assets/javascripts/plupload/jquery.plupload.queue/img/transp50.png +0 -0
- data/app/assets/javascripts/plupload/jquery.plupload.queue/jquery.plupload.queue.js +428 -0
- data/app/assets/javascripts/plupload/jquery.plupload.queue/jquery.plupload.queue.min.js +1 -0
- data/app/assets/javascripts/plupload/jquery.ui.plupload/css/jquery.ui.plupload.css +370 -0
- data/app/assets/javascripts/plupload/jquery.ui.plupload/img/loading.gif +0 -0
- data/app/assets/javascripts/plupload/jquery.ui.plupload/img/plupload.png +0 -0
- data/app/assets/javascripts/plupload/jquery.ui.plupload/jquery.ui.plupload.js +1323 -0
- data/app/assets/javascripts/plupload/jquery.ui.plupload/jquery.ui.plupload.min.js +1 -0
- data/app/assets/javascripts/plupload/moxie.js +10726 -0
- data/app/assets/javascripts/plupload/moxie.min.js +15 -0
- data/app/assets/javascripts/plupload/plupload.dev.js +2315 -0
- data/app/assets/javascripts/plupload/plupload.full.min.js +28 -0
- data/app/assets/javascripts/plupload/plupload.min.js +13 -0
- data/app/assets/stylesheets/caboose/admin_media_index.css.scss +115 -0
- data/app/controllers/caboose/application_controller.rb +1 -1
- data/app/controllers/caboose/cart_controller.rb +1 -1
- data/app/controllers/caboose/media_categories_controller.rb +44 -8
- data/app/controllers/caboose/media_controller.rb +116 -0
- data/app/controllers/caboose/posts_controller.rb +1 -1
- data/app/controllers/caboose/sns_controller.rb +60 -0
- data/app/models/caboose/block.rb +4 -2
- data/app/models/caboose/media.rb +94 -0
- data/app/models/caboose/media_category.rb +55 -15
- data/app/models/caboose/schema.rb +6 -9
- data/app/models/caboose/tax_calculator.rb +1 -1
- data/app/views/caboose/{images → media}/admin_edit.html.erb +0 -0
- data/app/views/caboose/media/admin_index.html.erb +49 -0
- data/app/views/caboose/posts/admin_edit_general.html.erb +3 -1
- data/config/routes.rb +30 -17
- data/lib/caboose.rb +6 -0
- data/lib/caboose/version.rb +1 -1
- metadata +81 -11
- data/app/assets/javascripts/caboose/admin_images_index.js +0 -171
- data/app/assets/stylesheets/caboose/admin_images_index.css.scss +0 -53
- data/app/controllers/caboose/images_controller.rb +0 -149
- data/app/models/caboose/media_file.rb +0 -18
- data/app/models/caboose/media_image.rb +0 -43
- data/app/views/caboose/images/admin_index.html.erb +0 -59
- data/app/views/caboose/images/admin_new.html.erb +0 -80
- data/app/views/caboose/images/admin_s3_result.html.erb +0 -3
@@ -1,171 +0,0 @@
|
|
1
|
-
|
2
|
-
var ImagesController = function(params) { this.init(params); };
|
3
|
-
|
4
|
-
ImagesController.prototype = {
|
5
|
-
|
6
|
-
cat_id: false,
|
7
|
-
cat: false,
|
8
|
-
|
9
|
-
init: function(params) {
|
10
|
-
var that = this;
|
11
|
-
for (var i in params)
|
12
|
-
this[i] = params[i];
|
13
|
-
|
14
|
-
$('#new_cat_link').click(function(e) {
|
15
|
-
e.preventDefault();
|
16
|
-
that.add_category(that.cat_id);
|
17
|
-
});
|
18
|
-
|
19
|
-
this.print_images();
|
20
|
-
},
|
21
|
-
|
22
|
-
// Gets updated image info from server and prints out categories and images.
|
23
|
-
print_images: function() {
|
24
|
-
var that = this;
|
25
|
-
$('#message').html("<p class='loading'>Refreshing images...</p>");
|
26
|
-
$.ajax({
|
27
|
-
url: '/admin/images/json',
|
28
|
-
type: 'get',
|
29
|
-
async: false,
|
30
|
-
data: { media_category_id: this.cat_id },
|
31
|
-
success: function(resp) {
|
32
|
-
that.cat = resp;
|
33
|
-
}
|
34
|
-
});
|
35
|
-
$('#message').empty();
|
36
|
-
var ul = $('<ul/>');
|
37
|
-
if (this.cat.children.length > 0 || this.cat.images.count > 0)
|
38
|
-
{
|
39
|
-
$.each(this.cat.children, function(i, cat2) {
|
40
|
-
ul.append($('<li/>').addClass('category').attr('id', 'cat' + cat2.id)
|
41
|
-
.append($('<a/>').attr('href', '/admin/images?media_category_id=' + cat2.id)
|
42
|
-
.append($('<span/>').addClass('icon icon-folder2'))
|
43
|
-
.append($('<span/>').addClass('name').html(cat2.name))
|
44
|
-
)
|
45
|
-
);
|
46
|
-
});
|
47
|
-
$.each(this.cat.images, function(i, mi) {
|
48
|
-
ul.append($('<li/>').addClass('image').attr('id', 'image' + mi.id)
|
49
|
-
.append($('<a/>')
|
50
|
-
.attr('href', '/admin/images/' + mi.id)
|
51
|
-
.css('background-image', mi.tiny_url)
|
52
|
-
.append($('<span/>').addClass('name').html(mi.name))
|
53
|
-
)
|
54
|
-
);
|
55
|
-
});
|
56
|
-
}
|
57
|
-
else
|
58
|
-
ul = $('<p/>').html("This category is empty.");
|
59
|
-
$('#media').empty().append(ul);
|
60
|
-
},
|
61
|
-
|
62
|
-
// Adds a new media category
|
63
|
-
add_category: function(parent_id, name)
|
64
|
-
{
|
65
|
-
var that = this;
|
66
|
-
if (!name)
|
67
|
-
{
|
68
|
-
var div = $('<p/>').addClass('note warning')
|
69
|
-
.append('New Category Name: ')
|
70
|
-
.append($('<input/>').attr('type', 'text').attr('id', 'new_cat_name')).append(" ")
|
71
|
-
.append($('<input/>').attr('type', 'button').val('Add').click(function() { that.add_category(parent_id, $('#new_cat_name').val()); })).append(" ")
|
72
|
-
.append($('<input/>').attr('type', 'button').val('Cancel').click(function() { $('#new_cat_message').empty(); }));
|
73
|
-
$('#new_cat_message').empty().append(div);
|
74
|
-
return;
|
75
|
-
}
|
76
|
-
$('#new_cat_message').empty().html("<p class='loading'>Adding category...</p>");
|
77
|
-
$.ajax({
|
78
|
-
url: '/admin/media-categories',
|
79
|
-
type: 'post',
|
80
|
-
data: {
|
81
|
-
parent_id: parent_id,
|
82
|
-
name: name
|
83
|
-
},
|
84
|
-
success: function(resp) {
|
85
|
-
if (resp.error) $('#new_cat_message').empty().html("<p class='note error'>" + resp.error + "</p>");
|
86
|
-
if (resp.refresh) window.location.reload(true);
|
87
|
-
}
|
88
|
-
});
|
89
|
-
},
|
90
|
-
|
91
|
-
// Lets a single image poll the server to see if it has been processed.
|
92
|
-
wait_for_image_processing: function(image_id, i)
|
93
|
-
{
|
94
|
-
if (!i) i = 1;
|
95
|
-
var is_finished = false;
|
96
|
-
$.ajax({
|
97
|
-
url: '/admin/images/' + image_id + '/finished',
|
98
|
-
type: 'get',
|
99
|
-
async: false,
|
100
|
-
success: function(resp) {
|
101
|
-
if (resp.error) alert("Error processing image: \n" + resp.error);
|
102
|
-
if (resp.is_finished)
|
103
|
-
{
|
104
|
-
is_finished = true;
|
105
|
-
$('#image' + mi.id + ' a').css('background-image', resp.tiny_url);
|
106
|
-
}
|
107
|
-
}
|
108
|
-
});
|
109
|
-
if (!is_finished)
|
110
|
-
setTimeout(function() { that.wait_for_image_processing(image_id, i+1); }, 500);
|
111
|
-
},
|
112
|
-
|
113
|
-
upload_form: function()
|
114
|
-
{
|
115
|
-
var that = this;
|
116
|
-
$('#file').fileupload({
|
117
|
-
//forceIframeTransport: true,
|
118
|
-
autoUpload: true,
|
119
|
-
//replaceFileInput: true,
|
120
|
-
//singleFileUploads: false,
|
121
|
-
add: function(e, data) {
|
122
|
-
$.ajax({
|
123
|
-
url: '/admin/images/s3',
|
124
|
-
type: 'get',
|
125
|
-
data: {
|
126
|
-
name: data.files[0].name,
|
127
|
-
media_category_id: that.cat_id
|
128
|
-
},
|
129
|
-
async: false,
|
130
|
-
success: function(resp) {
|
131
|
-
image_ids.push(resp.media_image_id);
|
132
|
-
var form = $('#new_image_form');
|
133
|
-
for (var i in resp.fields)
|
134
|
-
form.find("input[name=" + i + "]").val(resp.fields[i]);
|
135
|
-
form.attr('action', resp.url);
|
136
|
-
}
|
137
|
-
});
|
138
|
-
data.submit();
|
139
|
-
},
|
140
|
-
progressall: function (e, data) {
|
141
|
-
$('#bar').css('width', parseInt(data.loaded / data.total * 100, 10) + '%')
|
142
|
-
},
|
143
|
-
start: function (e) {
|
144
|
-
$('#file').hide();
|
145
|
-
$('#bar').css('background', 'green').css('display', 'block').css('width', '0%').html(" ");
|
146
|
-
},
|
147
|
-
done: function(e, data) {
|
148
|
-
console.log("Upload done.");
|
149
|
-
console.log(data);
|
150
|
-
setTimeout(function() {
|
151
|
-
$.each(image_ids, function(i, id) {
|
152
|
-
$.ajax({
|
153
|
-
url: '/admin/images/' + id + '/process',
|
154
|
-
type: 'get',
|
155
|
-
async: false,
|
156
|
-
success: function(resp) {}
|
157
|
-
});
|
158
|
-
});
|
159
|
-
$('#progress').empty().html("<p class='loading'>Upload complete. Processing images...</p>");
|
160
|
-
that.wait_for_image_processing(id);
|
161
|
-
|
162
|
-
}, 500);
|
163
|
-
},
|
164
|
-
fail: function(e, data) {
|
165
|
-
console.log("Upload failed.");
|
166
|
-
console.log(data);
|
167
|
-
$('#bar').css("background", "red").text("Failed");
|
168
|
-
}
|
169
|
-
});
|
170
|
-
}
|
171
|
-
};
|
@@ -1,53 +0,0 @@
|
|
1
|
-
|
2
|
-
#media {
|
3
|
-
ul {
|
4
|
-
list-style: none; margin: 0; padding: 0;
|
5
|
-
|
6
|
-
li {
|
7
|
-
list-style: none; margin: 4px; padding: 0; float: left;
|
8
|
-
a {
|
9
|
-
display: block;
|
10
|
-
width: 150px;
|
11
|
-
height: 150px;
|
12
|
-
overflow: hidden;
|
13
|
-
border: #666 4px solid;
|
14
|
-
background-size: contain;
|
15
|
-
background-repeat: no-repeat;
|
16
|
-
background-position: center;
|
17
|
-
background-color: #666;
|
18
|
-
position: relative;
|
19
|
-
text-align: center;
|
20
|
-
|
21
|
-
span { color: #fff; text-decoration: none; }
|
22
|
-
span.name { display: block; background: #666; color: #fff; text-decoration: none !important; border: 0; }
|
23
|
-
|
24
|
-
&:hover {
|
25
|
-
background-color: #fff69f;
|
26
|
-
border-color: #fff69f;
|
27
|
-
|
28
|
-
span { background: #efefef; color: #000; }
|
29
|
-
span.name { background: #fff69f; color: #000; }
|
30
|
-
}
|
31
|
-
|
32
|
-
&.selected span,
|
33
|
-
&.selected:hover span { background: #fff69f; color: #000; border: #fff69f 1px solid; }
|
34
|
-
}
|
35
|
-
&.category {
|
36
|
-
a span.icon { display: block; padding: 10px 20px; font-size: 24pt; color: #fff; }
|
37
|
-
a:hover span.icon { background: #fff69f; color: #000; }
|
38
|
-
}
|
39
|
-
}
|
40
|
-
}
|
41
|
-
}
|
42
|
-
|
43
|
-
.progress {
|
44
|
-
max-width: 600px;
|
45
|
-
margin: 0.2em 0 0.2em 0;
|
46
|
-
.bar {
|
47
|
-
height: 1.2em;
|
48
|
-
padding: 0.2em;
|
49
|
-
color: white;
|
50
|
-
display: none;
|
51
|
-
}
|
52
|
-
}
|
53
|
-
|
@@ -1,149 +0,0 @@
|
|
1
|
-
|
2
|
-
module Caboose
|
3
|
-
class ImagesController < ApplicationController
|
4
|
-
|
5
|
-
helper :application
|
6
|
-
|
7
|
-
def before_action
|
8
|
-
@page = Page.page_with_uri(request.host_with_port, '/admin')
|
9
|
-
end
|
10
|
-
|
11
|
-
# GET /admin/images
|
12
|
-
def admin_index
|
13
|
-
return if !user_is_allowed('images', 'view')
|
14
|
-
render :file => 'caboose/extras/error_invalid_site' and return if @site.nil?
|
15
|
-
|
16
|
-
id = params[:media_category_id]
|
17
|
-
@media_category = id ? MediaCategory.find(id) : MediaCategory.top_image_category(@site.id)
|
18
|
-
render :layout => 'caboose/admin'
|
19
|
-
end
|
20
|
-
|
21
|
-
# GET /admin/images/json
|
22
|
-
def admin_json
|
23
|
-
return if !user_is_allowed('images', 'view')
|
24
|
-
render :json => false and return if @site.nil?
|
25
|
-
|
26
|
-
id = params[:media_category_id]
|
27
|
-
cat = id ? MediaCategory.find(id) : MediaCategory.top_image_category(@site.id)
|
28
|
-
render :json => cat.api_hash
|
29
|
-
end
|
30
|
-
|
31
|
-
# GET /admin/images/new
|
32
|
-
def admin_new
|
33
|
-
return unless user_is_allowed('images', 'add')
|
34
|
-
@media_category_id = params[:media_category_id]
|
35
|
-
render :layout => 'caboose/admin'
|
36
|
-
end
|
37
|
-
|
38
|
-
# GET /admin/images/:id
|
39
|
-
def admin_edit
|
40
|
-
return unless user_is_allowed('images', 'edit')
|
41
|
-
@media_image = MediaImage.find(params[:id])
|
42
|
-
render :layout => 'caboose/admin'
|
43
|
-
end
|
44
|
-
|
45
|
-
# PUT /admin/images/:id
|
46
|
-
def admin_update
|
47
|
-
return unless user_is_allowed('images', 'edit')
|
48
|
-
|
49
|
-
resp = StdClass.new({'attributes' => {}})
|
50
|
-
image = MediaImage.find(params[:id])
|
51
|
-
|
52
|
-
save = true
|
53
|
-
params.each do |name, value|
|
54
|
-
case name
|
55
|
-
when 'name' then image.name = value
|
56
|
-
when 'description' then image.description = value
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
resp.success = save && image.save
|
61
|
-
render :json => resp
|
62
|
-
end
|
63
|
-
|
64
|
-
# DELETE /admin/images/:id
|
65
|
-
def admin_delete
|
66
|
-
return unless user_is_allowed('images', 'delete')
|
67
|
-
img = MediaImage.find(params[:id])
|
68
|
-
resp = StdClass.new({
|
69
|
-
'redirect' => "/admin/images?media_category_id=#{img.media_category_id}"
|
70
|
-
})
|
71
|
-
img.destroy
|
72
|
-
render :json => resp
|
73
|
-
end
|
74
|
-
|
75
|
-
# GET /admin/images/sign-s3
|
76
|
-
def admin_sign_s3
|
77
|
-
|
78
|
-
name = params[:name]
|
79
|
-
mi = MediaImage.create(
|
80
|
-
:media_category_id => params[:media_category_id],
|
81
|
-
:name => params[:name]
|
82
|
-
)
|
83
|
-
key = "media-images/#{mi.id}#{File.extname(name)}".downcase
|
84
|
-
|
85
|
-
config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
|
86
|
-
access_key = config['access_key_id']
|
87
|
-
secret_key = config['secret_access_key']
|
88
|
-
bucket = config['bucket']
|
89
|
-
|
90
|
-
policy = {
|
91
|
-
"expiration" => 10.seconds.from_now.utc.xmlschema,
|
92
|
-
"conditions" => [
|
93
|
-
{ "bucket" => bucket },
|
94
|
-
["starts-with", "$key", key],
|
95
|
-
{ "acl" => "public-read" },
|
96
|
-
{ "success_action_status" => "200" }
|
97
|
-
#{ "success_action_redirect" => "/admin/images/s3-result" }
|
98
|
-
]
|
99
|
-
}
|
100
|
-
policy = Base64.encode64(policy.to_json).gsub(/\n/,'')
|
101
|
-
signature = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), secret_key, policy)).gsub("\n","")
|
102
|
-
|
103
|
-
render :json => {
|
104
|
-
:media_image_id => mi.id,
|
105
|
-
:url => "https://#{bucket}.s3.amazonaws.com",
|
106
|
-
:fields => {
|
107
|
-
:key => key,
|
108
|
-
'AWSAccessKeyId' => access_key,
|
109
|
-
:acl => 'public-read',
|
110
|
-
:success_action_status => '200',
|
111
|
-
#:success_action_redirect => '/admin/images/s3-result',
|
112
|
-
:policy => policy,
|
113
|
-
:signature => signature
|
114
|
-
}
|
115
|
-
}
|
116
|
-
|
117
|
-
end
|
118
|
-
|
119
|
-
def admin_s3_result
|
120
|
-
render :layout => 'caboose/empty'
|
121
|
-
end
|
122
|
-
|
123
|
-
# GET /admin/images/:id/process
|
124
|
-
def admin_process
|
125
|
-
return if !user_is_allowed('images', 'edit')
|
126
|
-
mi = MediaImage.find(params[:id])
|
127
|
-
mi.delay.process
|
128
|
-
render :json => true
|
129
|
-
end
|
130
|
-
|
131
|
-
## GET /admin/images/:id/finished
|
132
|
-
def admin_process_finished
|
133
|
-
return if !user_is_allowed('images', 'edit')
|
134
|
-
mi = MediaImage.find(params[:id])
|
135
|
-
resp = StdClass.new
|
136
|
-
if mi.image_file_name && mi.image_file_name.strip.length > 0
|
137
|
-
resp.is_finished = true
|
138
|
-
resp.tiny_url = mi.image.url(:tiny)
|
139
|
-
resp.thumb_url = mi.image.url(:thumb)
|
140
|
-
resp.large_url = mi.image.url(:large)
|
141
|
-
resp.original_url = mi.image.url(:original)
|
142
|
-
else
|
143
|
-
resp.is_finished = false
|
144
|
-
end
|
145
|
-
render :json => resp
|
146
|
-
end
|
147
|
-
|
148
|
-
end
|
149
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
class Caboose::MediaFile < ActiveRecord::Base
|
2
|
-
|
3
|
-
self.table_name = "media_files"
|
4
|
-
belongs_to :media_category
|
5
|
-
has_attached_file :file, :path => ':path_prefixmedia-files/:id.:extension'
|
6
|
-
do_not_validate_attachment_file_type :file
|
7
|
-
attr_accessible :id, :media_category_id, :name, :description
|
8
|
-
|
9
|
-
def api_hash
|
10
|
-
{
|
11
|
-
:id => self.id,
|
12
|
-
:name => self.name,
|
13
|
-
:description => self.description,
|
14
|
-
:url => self.file.url
|
15
|
-
}
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'uri'
|
2
|
-
require 'httparty'
|
3
|
-
|
4
|
-
class Caboose::MediaImage < ActiveRecord::Base
|
5
|
-
|
6
|
-
self.table_name = "media_images"
|
7
|
-
belongs_to :media_category
|
8
|
-
has_attached_file :image,
|
9
|
-
:path => ':path_prefixmedia-images/:id_:style.:extension',
|
10
|
-
:default_url => 'http://placehold.it/300x300',
|
11
|
-
:styles => {
|
12
|
-
:tiny => '150x200>',
|
13
|
-
:thumb => '300x400>',
|
14
|
-
:large => '600x800>'
|
15
|
-
}
|
16
|
-
do_not_validate_attachment_file_type :image
|
17
|
-
attr_accessible :id, :media_category_id, :name, :description
|
18
|
-
|
19
|
-
def process
|
20
|
-
|
21
|
-
config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
|
22
|
-
bucket = config['bucket']
|
23
|
-
|
24
|
-
uri = "http://#{bucket}.s3.amazonaws.com/media-images/#{self.id}#{File.extname(self.name.downcase)}"
|
25
|
-
puts "Processing #{uri}..."
|
26
|
-
|
27
|
-
self.image = URI.parse(uri)
|
28
|
-
self.save
|
29
|
-
end
|
30
|
-
|
31
|
-
def api_hash
|
32
|
-
{
|
33
|
-
:id => self.id,
|
34
|
-
:name => self.name,
|
35
|
-
:description => self.description,
|
36
|
-
:tiny_url => self.image.url(:tiny),
|
37
|
-
:thumb_url => self.image.url(:thumb),
|
38
|
-
:large_url => self.image.url(:large),
|
39
|
-
:original_url => self.image.url(:original)
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
<h1>Images</h1>
|
2
|
-
|
3
|
-
<% if @site && @media_category %>
|
4
|
-
<%
|
5
|
-
arr = []
|
6
|
-
cat = @media_category
|
7
|
-
arr << cat
|
8
|
-
while cat.parent_id
|
9
|
-
cat = cat.parent
|
10
|
-
arr << cat
|
11
|
-
end
|
12
|
-
crumb_trail = arr.collect{ |cat| "<a href='/admin/images?media_category_id=#{cat.id}'>#{cat.name}</a>" }.reverse.join(" > ")
|
13
|
-
%>
|
14
|
-
<p id='crumb_trail'><%= raw crumb_trail %></p>
|
15
|
-
|
16
|
-
<form action='/admin/images/sign-s3' method='post' id='new_image_form' enctype='multipart/form-data'>
|
17
|
-
<input type='hidden' name='key' value='' />
|
18
|
-
<input type='hidden' name='AWSAccessKeyId' value='' />
|
19
|
-
<input type='hidden' name='acl' value='' />
|
20
|
-
<input type='hidden' name='success_action_status' value='' />
|
21
|
-
<input type='hidden' name='policy' value='' />
|
22
|
-
<input type='hidden' name='signature' value='' />
|
23
|
-
<input type="file" name="file" id="file" multiple='true' style='display: none;' />
|
24
|
-
<p>
|
25
|
-
<a href='#' id='new_cat_link'>New Category</a> |
|
26
|
-
<a href='#' onclick="$('#file').click();">Upload Files</a>
|
27
|
-
</p>
|
28
|
-
<div id='progress'><div id='bar'></div></div>
|
29
|
-
</form>
|
30
|
-
<div id='new_cat_message'></div>
|
31
|
-
</p>
|
32
|
-
<div id='media'></div>
|
33
|
-
<% elsif @site && @media_category.nil? %>
|
34
|
-
<p>Invalid media category.</p>
|
35
|
-
<% else %>
|
36
|
-
<p>It doesn't look like this site is configured for the current domain. Please <a href='/admin/sites'>configure your sites</a>.</p>
|
37
|
-
<% end %>
|
38
|
-
|
39
|
-
<% content_for :caboose_css do %>
|
40
|
-
<%= stylesheet_link_tag 'caboose/icomoon_fonts' %>
|
41
|
-
<%= stylesheet_link_tag 'caboose/admin_images_index' %>
|
42
|
-
<% end %>
|
43
|
-
|
44
|
-
<% content_for :caboose_js do %>
|
45
|
-
<%= javascript_include_tag 'jquery.ui.widget' %>
|
46
|
-
<%= javascript_include_tag 'caboose/jquery.iframe-transport.js' %>
|
47
|
-
<%= javascript_include_tag 'caboose/jquery.fileupload.js' %>
|
48
|
-
<%= javascript_include_tag 'caboose/admin_images_index.js' %>
|
49
|
-
<script type='text/javascript'>
|
50
|
-
|
51
|
-
var controller = false;
|
52
|
-
$(document).ready(function() {
|
53
|
-
controller = new ImagesController({
|
54
|
-
cat_id: <%= @media_category.id %>
|
55
|
-
});
|
56
|
-
});
|
57
|
-
|
58
|
-
</script>
|
59
|
-
<% end %>
|