effective_assets 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -47,7 +47,7 @@ table {
47
47
  font-weight: bold;
48
48
  }
49
49
  .table thead th {
50
- vertical-align: bottom;
50
+ vertical-align: middle;
51
51
  }
52
52
  .table caption + thead tr:first-child th,
53
53
  .table caption + thead tr:first-child td,
@@ -4,20 +4,10 @@ body {
4
4
  padding: 10px;
5
5
  }
6
6
 
7
- .form-control.filter-attachments {
8
- display: inline;
9
- font-weight: normal;
10
- width: auto;
11
- min-width: 50%;
12
- margin-left: 10px;
13
- }
14
-
15
- .asset-box-input.dragin {
16
- border: 1px solid blue;
17
- border-radius: 4px;
18
- border-color: #66afe9;
19
- box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset, 0 0 8px rgba(102, 175, 233, 0.6);
20
- outline: 0 none;
7
+ .asset-box-input {
8
+ td.attachment-title {
9
+ max-width: 400px;
10
+ }
21
11
  }
22
12
 
23
13
  @import "effective_assets/iframe_bootstrap";
@@ -16,7 +16,7 @@ module Effective
16
16
  @aws_acl = 'public-read' # The CKEditor Insert Image functionality needs a public-read image here
17
17
  elsif params[:only] == 'nonimages'
18
18
  @assets = @assets.nonimages
19
- @file_types = [:pdf, :zip, :doc, :docx, :xls, :xlsx, :txt, :avi, :m4v, :m2v, :mov, :mp3, :mp4]
19
+ @file_types = [:pdf, :zip, :doc, :docx, :xls, :xlsx, :txt, :csv, :avi, :m4v, :m2v, :mov, :mp3, :mp4, :eml]
20
20
  end
21
21
 
22
22
  @user_uploads = UserUploads.new(@assets)
@@ -5,6 +5,7 @@ if defined?(EffectiveRegions)
5
5
  attribute :asset_id, Integer
6
6
  attribute :html_class, String
7
7
  attribute :link_title, String
8
+ attribute :private_url, Boolean
8
9
 
9
10
  def asset
10
11
  @asset ||= (Effective::Asset.where(:id => asset_id).first if asset_id)
@@ -14,6 +15,10 @@ if defined?(EffectiveRegions)
14
15
  :span
15
16
  end
16
17
 
18
+ def is_private?
19
+ private_url == true || (asset.try(:aws_acl) == 'authenticated-read')
20
+ end
21
+
17
22
  end
18
23
  end
19
24
  end
@@ -12,10 +12,16 @@ module Inputs
12
12
  def to_html
13
13
  output = ''
14
14
  output += header_html
15
- output += attachments_html
16
15
 
17
- output += dialog_html if @options[:dialog]
18
- output += uploader_html if @options[:uploader]
16
+ if @options[:uploader] == :top
17
+ output += uploader_html
18
+ output += attachments_html
19
+ output += dialog_html if @options[:dialog]
20
+ else
21
+ output += attachments_html
22
+ output += dialog_html if @options[:dialog]
23
+ output += uploader_html if @options[:uploader]
24
+ end
19
25
 
20
26
  output += footer_html
21
27
 
@@ -33,6 +39,7 @@ module Inputs
33
39
  data-attachable-type='#{@options[:attachable_type]}'
34
40
  data-attachable-object-name='#{@object_name}'
35
41
  data-attachment-style='#{@options[:attachment_style]}'
42
+ data-attachment-add-to='#{@options[:attachment_add_to]}'
36
43
  data-attachment-actions='#{@options[:attachment_actions].to_json()}'
37
44
  data-aws-acl='#{@options[:aws_acl]}'
38
45
  >".html_safe
@@ -44,10 +51,9 @@ module Inputs
44
51
  content_tag(:thead) do
45
52
  content_tag(:tr) do
46
53
  [
47
- content_tag(:th, 'Thumbnail'),
48
- content_tag(:th, 'Title'.html_safe + (@options[:table_filter_bar] ? filter_bar_html : '')),
49
- content_tag(:th, 'Size'),
50
- content_tag(:th)
54
+ content_tag(:th, ''),
55
+ content_tag(:th, ''),
56
+ content_tag(:th, (@options[:table_filter_bar] ? filter_bar_html : ''), :colspan => 2)
51
57
  ].join().html_safe
52
58
  end
53
59
  end + content_tag(:tbody, build_values_html, :class => 'attachments')
@@ -77,6 +83,7 @@ module Inputs
77
83
  :disabled => @options[:disabled],
78
84
  :file_types => @options[:file_types],
79
85
  :progress_bar_partial => @options[:progress_bar_partial],
86
+ :drop_files => @options[:uploader_drop_files],
80
87
  :aws_acl => @options[:aws_acl]
81
88
  }
82
89
  ).html_safe
@@ -129,9 +136,11 @@ module Inputs
129
136
 
130
137
  def initialize_options(method, opts)
131
138
  {
132
- :uploader => true,
139
+ :uploader => true, # :top, :bottom, true or false
140
+ :uploader_drop_files => false,
133
141
  :progress_bar_partial => 'asset_box_input/progress_bar_template',
134
142
  :attachment_style => :thumbnail, # :thumbnail, :table, or :list
143
+ :attachment_add_to => :bottom, # :bottom or :top (of attachments div)
135
144
  :attachment_actions => [:remove], # or :insert, :delete, :remove
136
145
  :table_filter_bar => false,
137
146
  :dialog => false,
@@ -20,10 +20,11 @@
20
20
 
21
21
  - if attachment_actions.include?('remove')
22
22
  %a.attachment-remove{:href => '#', :title => 'Remove'}
23
- %img{:src => asset_path('effective_assets/icon_close.png'), :alt => 'Remove'}
23
+ %i.glyphicon.glyphicon-remove
24
24
 
25
25
  - if attachment_actions.include?('delete')
26
- = link_to 'Delete', effective_assets.effective_asset_path(attachment.asset), :class => 'btn btn-danger attachment-delete', :data => {:method => :delete, :confirm => "Are you sure? This cannot be undone!"}
26
+ = link_to effective_assets.effective_asset_path(attachment.asset), :class => 'btn btn-danger attachment-delete', :data => {:method => :delete, :confirm => "Are you sure you want to delete this file? This cannot be undone!"} do
27
+ %i.glyphicon.glyphicon-trash
27
28
 
28
29
  - if attachment.persisted?
29
30
  = hidden_field_tag(attachable_object_name + "[attachments_attributes][#{uid}][id]", attachment.id)
@@ -1,11 +1,17 @@
1
1
  .uploads
2
- .asset-box-uploader{:id => "s3_#{uid}"}
2
+ .asset-box-uploader{:id => "s3_#{uid}", :class => ('drop-files' if drop_files) }
3
3
  = s3_uploader_fields(:aws_acl => aws_acl)
4
4
 
5
- - if limit > 1
6
- %input{:type => 'file', :name => 'file', :multiple => 'multiple', :disabled => disabled}
7
- - else
8
- %input{:type => 'file', :name => 'file', :disabled => disabled}
5
+ - if drop_files
6
+ %p Drop files here
7
+
8
+ %span.btn.btn-success.fileinput-button
9
+ %i.glyphicon.glyphicon-upload
10
+ %span Upload files...
11
+ - if limit > 1
12
+ %input{:type => 'file', :name => 'file', :multiple => 'multiple', :disabled => disabled}
13
+ - else
14
+ %input{:type => 'file', :name => 'file', :disabled => disabled}
9
15
 
10
16
  = render :partial => progress_bar_partial
11
17
 
@@ -14,4 +14,4 @@
14
14
 
15
15
  %body
16
16
  = simple_form_for @user_uploads, :url => '/' do |f|
17
- = f.input :uploads, :as => :asset_box, :label => false, :uploader => true, :attachment_style => :table, :table_filter_bar => true, :attachment_actions => [:insert, :delete], :file_types => (@file_types || :any), :aws_acl => (@aws_acl || 'public-read')
17
+ = f.input :uploads, :as => :asset_box, :label => false, :uploader => :top, :uploader_drop_files => true, :attachment_style => :table, :table_filter_bar => true, :attachment_actions => [:insert, :delete], :attachment_add_to => :top, :file_types => (@file_types || :any), :aws_acl => (@aws_acl || 'public-read')
@@ -1,4 +1,5 @@
1
1
  - asset = effective_asset.asset
2
+ - asset.aws_acl = 'authenticated-read' if effective_asset.is_private?
2
3
 
3
4
  - if asset.nil?
4
5
  %img{:src => '#'}
@@ -26,7 +26,7 @@ module EffectiveAssets
26
26
  end
27
27
 
28
28
  initializer "effective_assets.append_precompiled_assets" do |app|
29
- Rails.application.config.assets.precompile += ['effective_assets.js', 'effective_assets_iframe.js', 'effective_assets_iframe.css']
29
+ Rails.application.config.assets.precompile += ['effective_assets.js', 'effective_assets_iframe.js', 'effective_assets_iframe.css', 'spinner.gif']
30
30
  end
31
31
 
32
32
  # ActiveAdmin (optional)
@@ -1,3 +1,3 @@
1
1
  module EffectiveAssets
2
- VERSION = '1.1.2'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-20 00:00:00.000000000 Z
11
+ date: 2015-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails