tb_media 1.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Rakefile +9 -0
- data/Readme.markdown +12 -12
- data/app/assets/javascripts/{spud/admin → admin}/media/application.js +21 -11
- data/app/assets/javascripts/{spud/admin → admin}/media/picker.js +3 -3
- data/app/assets/javascripts/{spud/admin → admin}/media/plugin.js +2 -2
- data/app/assets/libs/jcrop/css/jquery.Jcrop.css +1 -1
- data/app/assets/stylesheets/{spud/admin/media/application.css → admin/media/application.css.scss} +9 -10
- data/app/controllers/{spud/admin → admin}/media_controller.rb +12 -18
- data/app/controllers/{spud/admin → admin}/media_picker_controller.rb +1 -1
- data/app/models/spud_media.rb +15 -13
- data/app/views/{spud/admin → admin}/media/edit.html.erb +3 -5
- data/app/views/admin/media/index.html.erb +37 -0
- data/app/views/{spud/admin → admin}/media/new.html.erb +3 -2
- data/app/views/{spud/admin → admin}/media_picker/_media.html.erb +1 -1
- data/config/routes.rb +6 -7
- data/lib/spud_media/engine.rb +4 -3
- data/lib/spud_media/version.rb +1 -1
- metadata +59 -33
- data/app/helpers/spud/admin/users_helper.rb +0 -2
- data/app/helpers/spud/user_sessions_helper.rb +0 -2
- data/app/views/spud/admin/media/index.html.erb +0 -37
- /data/app/assets/images/{spud/admin → admin}/files_thumbs/dat_thumb.png +0 -0
- /data/app/assets/images/{spud/admin → admin}/files_thumbs/doc_thumb.png +0 -0
- /data/app/assets/images/{spud/admin → admin}/files_thumbs/jpg_thumb.png +0 -0
- /data/app/assets/images/{spud/admin → admin}/files_thumbs/mp3_thumb.png +0 -0
- /data/app/assets/images/{spud/admin → admin}/files_thumbs/pdf_thumb.png +0 -0
- /data/app/assets/images/{spud/admin → admin}/files_thumbs/png_thumb.png +0 -0
- /data/app/assets/images/{spud/admin → admin}/files_thumbs/ppt_thumb.png +0 -0
- /data/app/assets/images/{spud/admin → admin}/files_thumbs/txt_thumb.png +0 -0
- /data/app/assets/images/{spud/admin → admin}/files_thumbs/xls_thumb.png +0 -0
- /data/app/assets/images/{spud/admin → admin}/files_thumbs/zip_thumb.png +0 -0
- /data/app/assets/images/{spud/admin → admin}/media/checkers.jpg +0 -0
- /data/app/assets/images/{spud/admin → admin}/media_thumb.png +0 -0
- /data/app/assets/images/{spud/admin → admin}/media_thumb@2x.png +0 -0
- /data/app/assets/images/{spud/admin → admin}/media_tiny.png +0 -0
- /data/app/assets/stylesheets/{spud/admin → admin}/media/plugin.css +0 -0
- /data/app/views/{spud/admin → admin}/media_picker/create.html.erb +0 -0
- /data/app/views/{spud/admin → admin}/media_picker/create.js.erb +0 -0
- /data/app/views/{spud/admin → admin}/media_picker/index.html.erb +0 -0
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjQxMzBlNGVlYTQ2YTA0Y2JhZGRkOGNkOWFkNDU1YTM4MGFmNzU3Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmM2ZWMyMGNiNmQ3MjIyYTRkOWM4NDRmNjcyYTgxNzVmNTBkMTgyYQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDg1Yjk0YTJlOWE4NGE2YzMyNDkwOTE4OTJlM2RjNWZhZGE4YmUxMWUxYzk5
|
10
|
+
Zjg5YWQ0N2E3N2FjOGY3NGFiOGFiM2M1Njg2OTVkZmViNDVhNTVjNDMwNGVk
|
11
|
+
ZDY5NWVmMmI5NTkzZjlhZGY1ZDZlZmYwZmY1Nzg2YzYwNTk1NTQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Nzc5M2ZhZmIyZTA2MGNlMGMyNDBmNjNkNmZjYjIyNzQ5ZjRjNTc5Y2FjNzk5
|
14
|
+
ODk1ODdmOWIxZDRhMWI1NzUxMmQyZTI1OWQwODI5Y2I4OWZmYzQyNTEzYWFl
|
15
|
+
YTYzZWU5MzhmNGI0N2RmODE4ZDA3YTA1ZmYxMDJkMjU0NzFmMTc=
|
data/Rakefile
CHANGED
@@ -26,3 +26,12 @@ load 'rails/tasks/engine.rake'
|
|
26
26
|
Bundler::GemHelper.install_tasks
|
27
27
|
|
28
28
|
require 'rake'
|
29
|
+
|
30
|
+
begin
|
31
|
+
require 'jasmine'
|
32
|
+
load 'jasmine/tasks/jasmine.rake'
|
33
|
+
rescue LoadError
|
34
|
+
task :jasmine do
|
35
|
+
abort "Jasmine is not available. In order to run jasmine, you must: (sudo) gem install jasmine"
|
36
|
+
end
|
37
|
+
end
|
data/Readme.markdown
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
#
|
1
|
+
# TB Media
|
2
2
|
|
3
|
-
|
3
|
+
TB Media is an engine for managing documents and other miscellaneous media files, designed for use with [Twice Baked][1].
|
4
4
|
|
5
5
|
## Installation/Usage
|
6
6
|
|
7
7
|
1. In your Gemfile add the following
|
8
8
|
|
9
|
-
gem '
|
9
|
+
gem 'tb_media'
|
10
10
|
|
11
11
|
2. Run bundle install
|
12
12
|
3. Copy in database migrations to your new rails project
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
bundle exec rake railties:install:migrations
|
15
|
+
rake db:migrate
|
16
16
|
|
17
|
-
4. Run a rails server instance and point your browser to
|
17
|
+
4. Run a rails server instance and point your browser to `/admin`
|
18
18
|
|
19
19
|
## Configuration
|
20
20
|
|
21
|
-
|
21
|
+
TB Media accepts the following configuration options:
|
22
22
|
|
23
23
|
Spud::Media.configure do |config|
|
24
24
|
|
@@ -26,7 +26,7 @@ Spud Photos accepts the following configuration options:
|
|
26
26
|
config.paperclip_storage = :s3
|
27
27
|
config.s3_credentials = "#{Rails.root}/config/s3.yml"
|
28
28
|
|
29
|
-
|
29
|
+
# see below for notes on 'storage_path_protected'
|
30
30
|
config.storage_path = "public/system/spud_media/:id/:style/:basename.:extension"
|
31
31
|
config.storage_path_protected = "public/system/spud_media_protected/:id/:style/:basename.:extension"
|
32
32
|
config.storage_url = "/system/spud_media/:id/:style/:basename.:extension"
|
@@ -50,12 +50,10 @@ Files marked as unprotected will be uploaded to Amazon using the `public_read` A
|
|
50
50
|
|
51
51
|
Files marked as protected are uploaded using the `private` ACL. In this case, calling `@media.attachment_url` will return a local URL that hits the show action of our `ProtectedMedia` controller. Once we have verified the user is logged in we generate a secure URL and redirect the user to it. The generated URL is good for 10 minutes.
|
52
52
|
|
53
|
-
[1]:https://github.com/davydotcom/spud_core_admin
|
54
|
-
|
55
53
|
Testing
|
56
54
|
-----------------
|
57
55
|
|
58
|
-
|
56
|
+
TB uses RSpec for testing. Get the tests running with a few short commands:
|
59
57
|
|
60
58
|
1. Create and migrate the databases:
|
61
59
|
|
@@ -70,4 +68,6 @@ Spud uses RSpec for testing. Get the tests running with a few short commands:
|
|
70
68
|
|
71
69
|
rspec spec
|
72
70
|
|
73
|
-
After the tests have completed the current code coverage stats is available by opening ```/coverage/index.html``` in a browser.
|
71
|
+
After the tests have completed the current code coverage stats is available by opening ```/coverage/index.html``` in a browser.
|
72
|
+
|
73
|
+
[1]:https://bitbucket.org/westlakedesign/tb_core
|
@@ -1,6 +1,6 @@
|
|
1
1
|
//= require jcrop/js/jquery.Jcrop
|
2
|
-
//= require
|
3
|
-
//= require
|
2
|
+
//= require admin/media/plugin
|
3
|
+
//= require admin/media/picker
|
4
4
|
//= require_self
|
5
5
|
|
6
6
|
spud.admin.media = new function(){
|
@@ -19,15 +19,7 @@ spud.admin.media = new function(){
|
|
19
19
|
|
20
20
|
this.edit = function(){
|
21
21
|
cropimage = $('#spud_media_cropper_image');
|
22
|
-
|
23
|
-
setTimeout(function(){
|
24
|
-
if(cropimage[0].complete){
|
25
|
-
self.initializeEditor();
|
26
|
-
}
|
27
|
-
else{
|
28
|
-
self.edit();
|
29
|
-
}
|
30
|
-
}, 50);
|
22
|
+
self.initializeEditor();
|
31
23
|
};
|
32
24
|
|
33
25
|
this.initializeEditor = function(){
|
@@ -172,4 +164,22 @@ spud.admin.media = new function(){
|
|
172
164
|
return false;
|
173
165
|
}
|
174
166
|
};
|
167
|
+
/* parseIntOrDefault
|
168
|
+
* @params
|
169
|
+
* val {required} = value to be parsed
|
170
|
+
* defVal {required} = default return value if parsing fails
|
171
|
+
* radix {optional} = base
|
172
|
+
*/
|
173
|
+
this.parseIntOrDefault = function(params) {
|
174
|
+
var radix = params.radix || 10;
|
175
|
+
var val = params.val;
|
176
|
+
var result = parseInt(val, radix);
|
177
|
+
if(isNaN(result)) {
|
178
|
+
result = 0;
|
179
|
+
if(params.hasOwnProperty('defVal')) {
|
180
|
+
result = params.defVal;
|
181
|
+
}
|
182
|
+
}
|
183
|
+
return result;
|
184
|
+
};
|
175
185
|
};
|
@@ -116,7 +116,7 @@ spud.admin.mediapicker = new function(){
|
|
116
116
|
$('.spud_media_picker_list').prepend(html);
|
117
117
|
$('.spud_media_picker_item').first().click();
|
118
118
|
self.goToTab('#spud_media_picker_tab_choose');
|
119
|
-
self.
|
119
|
+
self.resetUploadForm();
|
120
120
|
};
|
121
121
|
|
122
122
|
this.resetUploadForm = function(){
|
@@ -190,8 +190,8 @@ spud.admin.mediapicker = new function(){
|
|
190
190
|
e.preventDefault();
|
191
191
|
if(selectedFile.type == 'img'){
|
192
192
|
selectedFile.title = $('input[name="spud_media_picker_option_title"]').val();
|
193
|
-
selectedFile.width =
|
194
|
-
selectedFile.height =
|
193
|
+
selectedFile.width = spud.admin.media.parseIntOrDefault({value: $('input[name="spud_media_picker_option_dimension_w"]').val(), defVal: ""});
|
194
|
+
selectedFile.height = spud.admin.media.parseIntOrDefault({value: $('input[name="spud_media_picker_option_dimension_h"]').val(), defVal: ""});
|
195
195
|
var float = $('select[name="spud_media_picker_option_float"]').val();
|
196
196
|
var style = "";
|
197
197
|
if(float){
|
@@ -28,7 +28,7 @@
|
|
28
28
|
ed.addCommand('spudMediaShowPicker', function(){
|
29
29
|
ed.windowManager.open({
|
30
30
|
title: 'Spud Media Picker',
|
31
|
-
file: '/
|
31
|
+
file: '/admin/media_picker',
|
32
32
|
width: 450 + parseInt(ed.getLang('example.delta_width', 0), 10),
|
33
33
|
height: 300 + parseInt(ed.getLang('example.delta_height', 0), 10),
|
34
34
|
inline: 1,
|
@@ -43,7 +43,7 @@
|
|
43
43
|
ed.addButton('spud_media_picker', {
|
44
44
|
title: 'Insert Spud Media',
|
45
45
|
cmd: 'spudMediaShowPicker',
|
46
|
-
image: '/assets/
|
46
|
+
image: '/assets/admin/media_tiny.png'
|
47
47
|
});
|
48
48
|
|
49
49
|
ed.addCommand('spudMediaInsertSelected', function(ui, data){
|
data/app/assets/stylesheets/{spud/admin/media/application.css → admin/media/application.css.scss}
RENAMED
@@ -1,7 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
*= require spud/admin/media/plugin
|
4
|
-
*/
|
1
|
+
//= require jcrop/css/jquery.Jcrop
|
2
|
+
//= require admin/media/plugin
|
5
3
|
|
6
4
|
img.size-50-thumb {
|
7
5
|
width:50px;
|
@@ -24,24 +22,25 @@ img.size-50-thumb {
|
|
24
22
|
border-top: none;
|
25
23
|
}
|
26
24
|
#spud_media_cropper{
|
27
|
-
position: relative;
|
28
|
-
overflow: hidden;
|
29
|
-
width: 900px;
|
30
25
|
/*height: 800px;*/
|
31
|
-
background:url('
|
32
|
-
margin:auto;
|
26
|
+
background: image-url('admin/media/checkers.jpg');
|
33
27
|
}
|
34
28
|
#spud_media_cropper_container{
|
35
29
|
|
36
30
|
}
|
37
31
|
#spud_media_cropper_jcrop_container{
|
38
|
-
position:
|
32
|
+
position: relative;
|
39
33
|
}
|
40
34
|
#spud_media_cropper_target{
|
41
35
|
position: absolute;
|
42
36
|
}
|
43
37
|
#spud_media_cropper_image{
|
44
38
|
position: absolute;
|
39
|
+
max-width: none;
|
40
|
+
display:none;
|
41
|
+
}
|
42
|
+
#spud_media_cropper img {
|
43
|
+
max-width: none !important;
|
45
44
|
}
|
46
45
|
|
47
46
|
/* Crop toolbar
|
@@ -1,6 +1,6 @@
|
|
1
|
-
class
|
2
|
-
layout '
|
3
|
-
add_breadcrumb "Media", :
|
1
|
+
class Admin::MediaController < Admin::ApplicationController
|
2
|
+
layout 'admin/detail'
|
3
|
+
add_breadcrumb "Media", :admin_media_path
|
4
4
|
belongs_to_spud_app :media
|
5
5
|
before_filter :load_media,:only => [:edit,:update,:show,:destroy,:set_private,:set_access]
|
6
6
|
|
@@ -11,35 +11,29 @@ class Spud::Admin::MediaController < Spud::Admin::ApplicationController
|
|
11
11
|
|
12
12
|
def new
|
13
13
|
@page_name = "New Media"
|
14
|
-
add_breadcrumb "New", :
|
14
|
+
add_breadcrumb "New", :new_admin_medium_path
|
15
15
|
@media = SpudMedia.new
|
16
16
|
respond_with @media
|
17
17
|
end
|
18
18
|
|
19
19
|
def create
|
20
20
|
@page_name = "New Media"
|
21
|
-
add_breadcrumb "New", :
|
21
|
+
add_breadcrumb "New", :new_admin_medium_path
|
22
22
|
@media = SpudMedia.new(params[:spud_media])
|
23
|
-
location =
|
23
|
+
location = admin_media_path
|
24
24
|
if @media.save
|
25
25
|
flash[:notice] = "File uploaded successfully"
|
26
26
|
if @media.is_image?
|
27
|
-
location =
|
27
|
+
location = edit_admin_medium_path(@media.id)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
respond_with @media, :location => location
|
31
31
|
end
|
32
32
|
|
33
|
-
def show
|
34
|
-
@page_name = "Media: #{@media.attachment_file_name}"
|
35
|
-
add_breadcrumb @media.attachment_file_name, :new_spud_admin_media_path
|
36
|
-
respond_with @media
|
37
|
-
end
|
38
|
-
|
39
33
|
def edit
|
40
34
|
if !@media.is_image?
|
41
35
|
flash[:error] = "Unable to edit #{@media.attachment_file_name}"
|
42
|
-
redirect_to
|
36
|
+
redirect_to admin_media_path
|
43
37
|
end
|
44
38
|
end
|
45
39
|
|
@@ -47,18 +41,18 @@ class Spud::Admin::MediaController < Spud::Admin::ApplicationController
|
|
47
41
|
if @media.update_attributes(params[:spud_media])
|
48
42
|
@media.attachment.reprocess!
|
49
43
|
end
|
50
|
-
respond_with @media, :location =>
|
44
|
+
respond_with @media, :location => admin_media_path
|
51
45
|
end
|
52
46
|
|
53
47
|
def destroy
|
54
48
|
flash[:notice] = "File successfully destroyed" if @media.destroy
|
55
|
-
respond_with @media, :location =>
|
49
|
+
respond_with @media, :location => admin_media_path
|
56
50
|
end
|
57
51
|
|
58
52
|
def set_access
|
59
53
|
is_protected = params[:protected] || false
|
60
54
|
@media.update_attribute(:is_protected, is_protected)
|
61
|
-
respond_with @media, :location =>
|
55
|
+
respond_with @media, :location => admin_media_path
|
62
56
|
end
|
63
57
|
|
64
58
|
private
|
@@ -66,7 +60,7 @@ private
|
|
66
60
|
@media = SpudMedia.where(:id => params[:id]).first
|
67
61
|
if @media.blank?
|
68
62
|
flash[:error] = "Media Asset not found!"
|
69
|
-
redirect_to
|
63
|
+
redirect_to admin_media_path() and return
|
70
64
|
end
|
71
65
|
|
72
66
|
end
|
data/app/models/spud_media.rb
CHANGED
@@ -16,6 +16,8 @@ class SpudMedia < ActiveRecord::Base
|
|
16
16
|
|
17
17
|
validates_numericality_of :crop_x, :crop_y, :crop_w, :crop_h, :crop_s, :allow_nil => true
|
18
18
|
|
19
|
+
validates_attachment :attachment, :presence => true
|
20
|
+
|
19
21
|
before_create :rename_file
|
20
22
|
#after_create :validate_permissions
|
21
23
|
before_update :validate_permissions
|
@@ -29,41 +31,41 @@ class SpudMedia < ActiveRecord::Base
|
|
29
31
|
|
30
32
|
def image_from_type
|
31
33
|
|
32
|
-
if self.is_image?
|
34
|
+
if self.is_image?
|
33
35
|
return self.attachment_url(:small)
|
34
36
|
|
35
37
|
elsif self.attachment_content_type.blank?
|
36
|
-
return "
|
38
|
+
return "admin/files_thumbs/dat_thumb.png"
|
37
39
|
|
38
40
|
elsif self.attachment_content_type.match(/jpeg|jpg/)
|
39
|
-
return "
|
41
|
+
return "admin/files_thumbs/jpg_thumb.png"
|
40
42
|
|
41
43
|
elsif self.attachment_content_type.match(/png/)
|
42
|
-
return "
|
44
|
+
return "admin/files_thumbs/png_thumb.png"
|
43
45
|
|
44
46
|
elsif self.attachment_content_type.match(/zip|tar|tar\.gz|gz/)
|
45
|
-
return "
|
47
|
+
return "admin/files_thumbs/zip_thumb.png"
|
46
48
|
|
47
49
|
elsif self.attachment_content_type.match(/xls|xlsx/)
|
48
|
-
return "
|
50
|
+
return "admin/files_thumbs/xls_thumb.png"
|
49
51
|
|
50
52
|
elsif self.attachment_content_type.match(/doc|docx/)
|
51
|
-
return "
|
53
|
+
return "admin/files_thumbs/doc_thumb.png"
|
52
54
|
|
53
55
|
elsif self.attachment_content_type.match(/ppt|pptx/)
|
54
|
-
return "
|
56
|
+
return "admin/files_thumbs/ppt_thumb.png"
|
55
57
|
|
56
58
|
elsif self.attachment_content_type.match(/txt|text/)
|
57
|
-
return "
|
59
|
+
return "admin/files_thumbs/txt_thumb.png"
|
58
60
|
|
59
61
|
elsif self.attachment_content_type.match(/pdf|ps/)
|
60
|
-
return "
|
62
|
+
return "admin/files_thumbs/pdf_thumb.png"
|
61
63
|
|
62
64
|
elsif self.attachment_content_type.match(/mp3|wav|aac/)
|
63
|
-
return "
|
65
|
+
return "admin/files_thumbs/mp3_thumb.png"
|
64
66
|
end
|
65
67
|
|
66
|
-
return "
|
68
|
+
return "admin/files_thumbs/dat_thumb.png"
|
67
69
|
end
|
68
70
|
|
69
71
|
def is_image?
|
@@ -88,7 +90,7 @@ class SpudMedia < ActiveRecord::Base
|
|
88
90
|
|
89
91
|
def dynamic_styles
|
90
92
|
styles = {}
|
91
|
-
if is_image?
|
93
|
+
if is_image? #|| is_pdf?
|
92
94
|
styles[:small] = '50'
|
93
95
|
if has_custom_crop?
|
94
96
|
styles[:cropped] = {:geometry => '', :convert_options => "-resize #{crop_s}% -crop #{crop_w}x#{crop_h}+#{crop_x}+#{crop_y}"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%= error_messages_for(@media) %>
|
2
2
|
|
3
3
|
<div id="spud_media_cropper_toolbar">
|
4
|
-
<%= form_for @media, :url =>
|
4
|
+
<%= form_for @media, :url => admin_medium_path(@media) do |f| %>
|
5
5
|
|
6
6
|
<div class="spud_media_cropper_toolbar_item">
|
7
7
|
<%= label_tag :x %>
|
@@ -32,16 +32,14 @@
|
|
32
32
|
|
33
33
|
<div id="spud_media_cropper_toolbar_actions">
|
34
34
|
<%= f.submit 'Crop', :id => 'spud_media_cropper_submit', :class => 'btn btn-mini btn-primary' %>
|
35
|
-
<%= link_to "Don't Crop",
|
35
|
+
<%= link_to "Don't Crop", admin_media_path, :class => 'btn btn-mini' %>
|
36
36
|
</div>
|
37
37
|
<% end %>
|
38
38
|
</div>
|
39
39
|
|
40
40
|
<div id="spud_media_cropper_outer">
|
41
|
-
<div id="spud_media_cropper">
|
42
|
-
<div id="spud_media_cropper_jcrop_container">
|
41
|
+
<div id="spud_media_cropper" align="center">
|
43
42
|
<img src="<%= @media.attachment_url(:original) %>" id="spud_media_cropper_image" />
|
44
|
-
</div>
|
45
43
|
</div>
|
46
44
|
</div>
|
47
45
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<%=content_for :data_controls do%>
|
2
|
+
<%=link_to "Upload File",new_admin_medium_path(),:class => "btn btn-primary",:title => "Upload File"%>
|
3
|
+
<%end%>
|
4
|
+
<%=content_for :detail do%>
|
5
|
+
<div class="page_list">
|
6
|
+
<%@media.each do |media|%>
|
7
|
+
<div class="page_row">
|
8
|
+
|
9
|
+
<span class="row_meta">
|
10
|
+
<% if media.is_protected && media.is_image? %>
|
11
|
+
<img src="<%= media.image_from_type %>" class="size-50-thumb" />
|
12
|
+
<% else %>
|
13
|
+
<%= image_tag(media.image_from_type, :class => "size-50-thumb") %>
|
14
|
+
<% end %>
|
15
|
+
<%= link_to media.attachment_file_name, media.attachment_url %>
|
16
|
+
</span>
|
17
|
+
|
18
|
+
<span class="edit_controls">
|
19
|
+
<% if media.is_image? %>
|
20
|
+
<%= link_to 'Crop', edit_admin_medium_path(media.id), :class => 'btn' %>
|
21
|
+
<% end %>
|
22
|
+
<% if media.is_protected %>
|
23
|
+
<%= link_to raw('<i class="icon-lock"></i> Protected'), set_access_admin_medium_path(media.id, :protected => false), :method => :put, :class => 'btn' %>
|
24
|
+
<% else %>
|
25
|
+
<%= link_to 'Public', set_access_admin_medium_path(media.id, :protected => true), :method => :put, :class => 'btn' %>
|
26
|
+
<% end %>
|
27
|
+
<%=link_to "Remove", admin_medium_path(:id => media.id),:method => :delete,:class => 'btn btn-danger',:confirm => "Are you sure you want to remove this file?"%>
|
28
|
+
</span>
|
29
|
+
|
30
|
+
<br style="clear:both;"/>
|
31
|
+
</div>
|
32
|
+
<%end%>
|
33
|
+
<%=will_paginate @media%>
|
34
|
+
|
35
|
+
</div>
|
36
|
+
|
37
|
+
<%end%>
|
@@ -1,7 +1,8 @@
|
|
1
1
|
|
2
2
|
|
3
3
|
|
4
|
-
<%=form_for @media,:url =>
|
4
|
+
<%=form_for @media,:url => admin_media_path(),:html=>{:class=>"form-horizontal", :multipart => true} do |f|%>
|
5
|
+
<%= tb_form_errors(@media) %>
|
5
6
|
<fieldset>
|
6
7
|
<legend>Upload Media</legend>
|
7
8
|
|
@@ -20,7 +21,7 @@
|
|
20
21
|
</div>
|
21
22
|
|
22
23
|
<div class="form-actions">
|
23
|
-
<%=f.submit "Upload", :class=>"btn btn-primary","data-loading-text"=>"Uploading..."%> or <%=link_to "cancel",
|
24
|
+
<%=f.submit "Upload", :class=>"btn btn-primary","data-loading-text"=>"Uploading..."%> or <%=link_to "cancel",admin_media_path,:class => "btn"%>
|
24
25
|
</div>
|
25
26
|
<%end%>
|
26
27
|
|
@@ -7,7 +7,7 @@
|
|
7
7
|
'data-lastmod' => media.attachment_updated_at.blank? == false ? media.attachment_updated_at.strftime("%l:%M %p, %D") : '',
|
8
8
|
'data-protected' => (media.is_protected ? 'Yes' : 'No') do %>
|
9
9
|
<span class="spud_media_picker_item_thumb">
|
10
|
-
<% if media.is_protected &&
|
10
|
+
<% if media.is_protected && media.is_image? %>
|
11
11
|
<img src="<%= media.image_from_type %>"/>
|
12
12
|
<% else %>
|
13
13
|
<%= image_tag(media.image_from_type) %>
|
data/config/routes.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
2
|
+
|
3
|
+
namespace :admin do
|
4
|
+
resources :media do
|
5
|
+
put 'set_access', :on => :member
|
6
|
+
end
|
7
|
+
resources :media_picker, :only => [:index, :create]
|
9
8
|
end
|
10
9
|
|
11
10
|
#get '/media/protected/:id/:style/:filename' => 'ProtectedMedia#show', :as => 'protected_media'
|
data/lib/spud_media/engine.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
require 'tb_core'
|
2
2
|
require 'paperclip'
|
3
|
+
|
3
4
|
module Spud
|
4
5
|
module Media
|
5
6
|
class Engine < Rails::Engine
|
6
7
|
engine_name :tb_media
|
7
8
|
initializer :admin do
|
8
|
-
Spud::Core.append_admin_javascripts('
|
9
|
-
Spud::Core.append_admin_stylesheets('
|
9
|
+
Spud::Core.append_admin_javascripts('admin/media/application')
|
10
|
+
Spud::Core.append_admin_stylesheets('admin/media/application')
|
10
11
|
Spud::Core.configure do |config|
|
11
|
-
config.admin_applications += [{:name => "Media"
|
12
|
+
config.admin_applications += [{:name => "Media", :thumbnail => "admin/media_thumb.png", :url => "/admin/media", :order => 3, :retina => true}]
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
data/lib/spud_media/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tb_media
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Woods
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -164,6 +164,34 @@ dependencies:
|
|
164
164
|
- - ~>
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: 0.6.4
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: capybara
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - '='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 2.0.1
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - '='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 2.0.1
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: jasmine
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ! '>='
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ! '>='
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
167
195
|
description: Spud Media allows you to upload files to your site and manage them in
|
168
196
|
the spud administrative panel. It also uses paperclip and supports s3 storage
|
169
197
|
email:
|
@@ -172,23 +200,23 @@ executables: []
|
|
172
200
|
extensions: []
|
173
201
|
extra_rdoc_files: []
|
174
202
|
files:
|
175
|
-
- app/assets/images/
|
176
|
-
- app/assets/images/
|
177
|
-
- app/assets/images/
|
178
|
-
- app/assets/images/
|
179
|
-
- app/assets/images/
|
180
|
-
- app/assets/images/
|
181
|
-
- app/assets/images/
|
182
|
-
- app/assets/images/
|
183
|
-
- app/assets/images/
|
184
|
-
- app/assets/images/
|
185
|
-
- app/assets/images/
|
186
|
-
- app/assets/images/
|
187
|
-
- app/assets/images/
|
188
|
-
- app/assets/images/
|
189
|
-
- app/assets/javascripts/
|
190
|
-
- app/assets/javascripts/
|
191
|
-
- app/assets/javascripts/
|
203
|
+
- app/assets/images/admin/files_thumbs/dat_thumb.png
|
204
|
+
- app/assets/images/admin/files_thumbs/doc_thumb.png
|
205
|
+
- app/assets/images/admin/files_thumbs/jpg_thumb.png
|
206
|
+
- app/assets/images/admin/files_thumbs/mp3_thumb.png
|
207
|
+
- app/assets/images/admin/files_thumbs/pdf_thumb.png
|
208
|
+
- app/assets/images/admin/files_thumbs/png_thumb.png
|
209
|
+
- app/assets/images/admin/files_thumbs/ppt_thumb.png
|
210
|
+
- app/assets/images/admin/files_thumbs/txt_thumb.png
|
211
|
+
- app/assets/images/admin/files_thumbs/xls_thumb.png
|
212
|
+
- app/assets/images/admin/files_thumbs/zip_thumb.png
|
213
|
+
- app/assets/images/admin/media/checkers.jpg
|
214
|
+
- app/assets/images/admin/media_thumb.png
|
215
|
+
- app/assets/images/admin/media_thumb@2x.png
|
216
|
+
- app/assets/images/admin/media_tiny.png
|
217
|
+
- app/assets/javascripts/admin/media/application.js
|
218
|
+
- app/assets/javascripts/admin/media/picker.js
|
219
|
+
- app/assets/javascripts/admin/media/plugin.js
|
192
220
|
- app/assets/libs/jcrop/css/Jcrop.gif
|
193
221
|
- app/assets/libs/jcrop/css/jquery.Jcrop.css
|
194
222
|
- app/assets/libs/jcrop/css/jquery.Jcrop.min.css
|
@@ -203,22 +231,20 @@ files:
|
|
203
231
|
- app/assets/libs/tiny_mce/plugins/spud_media/js/template.js
|
204
232
|
- app/assets/libs/tiny_mce/plugins/spud_media/langs/en_dlg.js
|
205
233
|
- app/assets/libs/tiny_mce/plugins/spud_media/template.htm
|
206
|
-
- app/assets/stylesheets/
|
207
|
-
- app/assets/stylesheets/
|
234
|
+
- app/assets/stylesheets/admin/media/application.css.scss
|
235
|
+
- app/assets/stylesheets/admin/media/plugin.css
|
236
|
+
- app/controllers/admin/media_controller.rb
|
237
|
+
- app/controllers/admin/media_picker_controller.rb
|
208
238
|
- app/controllers/protected_media_controller.rb
|
209
|
-
- app/controllers/spud/admin/media_controller.rb
|
210
|
-
- app/controllers/spud/admin/media_picker_controller.rb
|
211
239
|
- app/helpers/protected_media_helper.rb
|
212
|
-
- app/helpers/spud/admin/users_helper.rb
|
213
|
-
- app/helpers/spud/user_sessions_helper.rb
|
214
240
|
- app/models/spud_media.rb
|
215
|
-
- app/views/
|
216
|
-
- app/views/
|
217
|
-
- app/views/
|
218
|
-
- app/views/
|
219
|
-
- app/views/
|
220
|
-
- app/views/
|
221
|
-
- app/views/
|
241
|
+
- app/views/admin/media/edit.html.erb
|
242
|
+
- app/views/admin/media/index.html.erb
|
243
|
+
- app/views/admin/media/new.html.erb
|
244
|
+
- app/views/admin/media_picker/_media.html.erb
|
245
|
+
- app/views/admin/media_picker/create.html.erb
|
246
|
+
- app/views/admin/media_picker/create.js.erb
|
247
|
+
- app/views/admin/media_picker/index.html.erb
|
222
248
|
- config/routes.rb
|
223
249
|
- db/migrate/20120101194256_create_spud_media.rb
|
224
250
|
- db/migrate/20120501203325_add_protected_to_spud_media.rb
|
@@ -250,7 +276,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
250
276
|
version: '0'
|
251
277
|
requirements: []
|
252
278
|
rubyforge_project:
|
253
|
-
rubygems_version: 2.0.
|
279
|
+
rubygems_version: 2.0.7
|
254
280
|
signing_key:
|
255
281
|
specification_version: 4
|
256
282
|
summary: Spud File upload/management module
|
@@ -1,37 +0,0 @@
|
|
1
|
-
<%=content_for :data_controls do%>
|
2
|
-
<%=link_to "Upload File",new_spud_admin_medium_path(),:class => "btn btn-primary",:title => "Upload File"%>
|
3
|
-
<%end%>
|
4
|
-
<%=content_for :detail do%>
|
5
|
-
<div class="page_list">
|
6
|
-
<%@media.each do |media|%>
|
7
|
-
<div class="page_row">
|
8
|
-
|
9
|
-
<span class="row_meta">
|
10
|
-
<% if media.is_protected && (media.is_image? || media.is_pdf?) %>
|
11
|
-
<img src="<%= media.image_from_type %>" class="size-50-thumb" />
|
12
|
-
<% else %>
|
13
|
-
<%= image_tag(media.image_from_type, :class => "size-50-thumb") %>
|
14
|
-
<% end %>
|
15
|
-
<%= link_to media.attachment.url.split("/").last, media.attachment_url %>
|
16
|
-
</span>
|
17
|
-
|
18
|
-
<span class="edit_controls">
|
19
|
-
<% if media.is_image? %>
|
20
|
-
<%= link_to 'Crop', edit_spud_admin_medium_path(media.id), :class => 'btn' %>
|
21
|
-
<% end %>
|
22
|
-
<% if media.is_protected %>
|
23
|
-
<%= link_to raw('<i class="icon-lock"></i> Protected'), set_access_spud_admin_medium_path(media.id, :protected => false), :method => :put, :class => 'btn' %>
|
24
|
-
<% else %>
|
25
|
-
<%= link_to 'Public', set_access_spud_admin_medium_path(media.id, :protected => true), :method => :put, :class => 'btn' %>
|
26
|
-
<% end %>
|
27
|
-
<%=link_to "Remove", spud_admin_medium_path(:id => media.id),:method => :delete,:class => 'btn btn-danger',:confirm => "Are you sure you want to remove this file?"%>
|
28
|
-
</span>
|
29
|
-
|
30
|
-
<br style="clear:both;"/>
|
31
|
-
</div>
|
32
|
-
<%end%>
|
33
|
-
<%=will_paginate @media%>
|
34
|
-
|
35
|
-
</div>
|
36
|
-
|
37
|
-
<%end%>
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|