assetable 0.2.2 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDMxNzlhNTkyNjhiZWU1M2E2ZjA4OTVhMTE2OGM4NzUzYzQ3YmFjNQ==
4
+ NjdkNGY5ZTA4YjM5ZTYzN2M0MWJmYWIzOWYyNjk0OWU1NDczNWRlZg==
5
5
  data.tar.gz: !binary |-
6
- ZTIzN2MxZDFmNWY1ZTI0OTgyZDNhY2UxM2NkNDUyMmE3Yjg2NzE0Yg==
7
- !binary "U0hBNTEy":
6
+ NDMxMWI4MDQwMDE1MDcxNDM1NGM5ZDk5YjFlYjlmMTJkNmFhYWNiZA==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- YjExMTViODM1ZDAxZDA5MmYwYWFlNjZlZWU4MzljN2QyNzEzNDhhZTA4YzE1
10
- OTRlOTc0OThhYjY2OWJhY2VmYzczZWZjMmQ2ZjgyYmZmNDdhY2I1YWU0NDhl
11
- NGQzYzZkMzU0NDY3YzRiYmY0NTVlYzVmZDgxYmE0ZTAxZjRiYjU=
9
+ MjY2NzE3ZjhiYTE5OGZlODMyNDA1YTZkYjBjZTNhN2U4ZmNjOThjODRkNzVi
10
+ MTViZTU5YTJhMTc5YWJjZmNmM2E0YjA1OWVlNjM0ZmNhMWU4MTcxODBlNmY1
11
+ MjZjYWI4MjU1NzJjM2IyOTJlYWZmOTkzYTk5YjkyMDFmNjc1ZTA=
12
12
  data.tar.gz: !binary |-
13
- ODZiODNjN2Y2ZjkyZDkyZGU2MWVmMzIxOTRjOWI2ZWUwMzExOTk3MTNkZmRi
14
- NDE0MjU1NzlmMDZmMTI3MGYxYWMzZGE1YjBjZjgxMmNjY2UwOTE2NDg4NmRl
15
- NTc3YmM1OTQ1Nzc0OWRhOWIyZTMzYzU5NzMxZjI3MjJiNDgxZDk=
13
+ Njg5NWI1NzBmNzJiYWI4YTYwYTBjMDBlMmY5ZTNjY2E4YzIwZDlhNGYzOWQ0
14
+ M2MyNGEyZDk2Mzg1Njk1ZGE2MDRlODBlZGVhNjE3NjZkODI3MDAwZjYyMTYw
15
+ OWU5MzZhYmNhMzU3NWIyZWY4NDhiMDRjZGI2MjdlZDFkY2ZhMDI=
@@ -83,7 +83,7 @@
83
83
  extensions: "zip"
84
84
  ,
85
85
  title: "Documents"
86
- extensions: "pdf, doc, docx, xls, xlsx"
86
+ extensions: "pdf,doc,docx,xls,xlsx"
87
87
  ]
88
88
  max_file_size: assetable_uploader.options.max_file_size
89
89
  prevent_duplicates: true
@@ -134,6 +134,7 @@
134
134
  $(this).removeClass "droppable" if $(this).hasClass("droppable")
135
135
 
136
136
  $(draggable_selector).on "drop", ->
137
+ $(this).find('.alert').remove()
137
138
  $(this).removeClass "droppable" if $(this).hasClass("droppable")
138
139
 
139
140
 
@@ -9,7 +9,7 @@ bind_uploaders = ->
9
9
  $this.assetable_uploader
10
10
  multi_selection: false
11
11
  url: "/assetable/assets.js"
12
- # directions: $this.attr('data-uploader-directions')
12
+ directions: $this.attr('data-uploader-directions')
13
13
  # max_file_size: $this.attr("data-max-file-size")
14
14
  authenticity_token: $("meta[name=\"csrf-token\"]").attr("content")
15
15
  fileRemoved: (item, button) ->
@@ -31,9 +31,9 @@ class Assetable::AssetsController < ActionController::Base
31
31
  end
32
32
 
33
33
  # Return
34
+ @fieldname = params[:fieldname]
35
+ @uploader_id = params[:uploader_id]
34
36
  if @asset.errors.empty? and @asset.save
35
- @fieldname = params[:fieldname]
36
- @uploader_id = params[:uploader_id]
37
37
  render :create
38
38
  else
39
39
  render :error
@@ -17,7 +17,8 @@ class UploaderInput < SimpleForm::Inputs::FileInput
17
17
  uploader_html = template.content_tag(:div, (hidden_field + preview.html_safe), class: "uploader-assets-wrapper")
18
18
 
19
19
  # Create and return the uploader html
20
- uploader_wrapper = template.content_tag :div, (uploader_html + directions_html.html_safe), class: "assetable-uploader"
20
+ directions = options[:directions]
21
+ uploader_wrapper = template.content_tag :div, (uploader_html + directions_html(directions).html_safe), class: "assetable-uploader"
21
22
  return uploader_wrapper
22
23
  end
23
24
 
@@ -19,8 +19,9 @@ class Asset < ActiveRecord::Base
19
19
  has_many :asset_attachments, :as => :assetable, :dependent => :destroy
20
20
  has_many :assetable, :through => :asset_attachments
21
21
 
22
- before_save :update_asset_attributes
22
+ before_validation :update_asset_attributes
23
23
 
24
+ validates_uniqueness_of :checksum, message: "File has already been uploaded." if Assetable.unique_assets
24
25
 
25
26
 
26
27
  # File Type Helpers
@@ -3,7 +3,10 @@
3
3
  .uploader-directions-copy
4
4
  = link_to "select file", "#", class: "browse-btn"
5
5
  or
6
- = link_to "add a third party service", Rails.application.routes.url_helpers.new_assetable_external_service_path, class: "btn-third-party", remote: true
6
+ - if directions.present?
7
+ = directions
8
+ - else
9
+ = link_to "add a third party service", Rails.application.routes.url_helpers.new_assetable_external_service_path, class: "btn-third-party", remote: true
7
10
 
8
11
  / or
9
12
  / = link_to "select from gallery", Rails.application.routes.url_helpers.assetable_assets_path(fieldname: fieldname, uploader_id: id), remote: true
@@ -0,0 +1,3 @@
1
+ var uploader = $('#<%= @uploader_id %>');
2
+
3
+ $('#<%= @uploader_id %>').append('<%= j render partial: "assetable/shared/templates/asset_error", locals: { asset: @asset, fieldname: @fieldname } %>');
@@ -0,0 +1,2 @@
1
+ .alert.alert-danger
2
+ = asset.errors.full_messages.join(", ")
@@ -0,0 +1,6 @@
1
+ # Default configs
2
+ Assetable.configure do |config|
3
+ config.storage = :fog
4
+ config.max_file_size = "10MB"
5
+ config.unique_assets = true
6
+ end
@@ -4,6 +4,7 @@ module Assetable
4
4
  VALID_OPTION_KEYS = [
5
5
  :storage,
6
6
  :max_file_size,
7
+ :unique_assets,
7
8
  :external_document_types,
8
9
  :external_document_icons
9
10
  ]
@@ -20,8 +20,8 @@ module Assetable::Uploaders
20
20
  ActionController::Base.new.send(:render_to_string, partial: "assetable/shared/templates/#{type.downcase.to_s}_item", locals: { asset: asset, fieldname: fieldname })
21
21
  end
22
22
 
23
- def directions_html
24
- ActionController::Base.new.send(:render_to_string, :partial => 'assetable/assets/directions')
23
+ def directions_html directions=nil
24
+ ActionController::Base.new.send(:render_to_string, partial: 'assetable/assets/directions', locals: {directions: directions})
25
25
  end
26
26
 
27
27
  end
@@ -1,3 +1,3 @@
1
1
  module Assetable
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assetable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Koht
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-16 00:00:00.000000000 Z
11
+ date: 2014-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -283,6 +283,9 @@ executables: []
283
283
  extensions: []
284
284
  extra_rdoc_files: []
285
285
  files:
286
+ - MIT-LICENSE
287
+ - README.rdoc
288
+ - Rakefile
286
289
  - app/assets/images/assetable/icon-upload.png
287
290
  - app/assets/images/assetable/icons/icon-ai.png
288
291
  - app/assets/images/assetable/icons/icon-css.png
@@ -350,6 +353,7 @@ files:
350
353
  - app/views/assetable/assets/_table.html.haml
351
354
  - app/views/assetable/assets/create.js.erb
352
355
  - app/views/assetable/assets/edit.js.erb
356
+ - app/views/assetable/assets/error.js.erb
353
357
  - app/views/assetable/assets/index.js.erb
354
358
  - app/views/assetable/assets/insert.js.erb
355
359
  - app/views/assetable/assets/update.js.erb
@@ -357,8 +361,10 @@ files:
357
361
  - app/views/assetable/external_services/create.js.erb
358
362
  - app/views/assetable/external_services/new.js.erb
359
363
  - app/views/assetable/shared/_asset_preview.html.haml
364
+ - app/views/assetable/shared/templates/_asset_error.html.haml
360
365
  - app/views/assetable/shared/templates/_asset_item.html.haml
361
366
  - app/views/assetable/shared/templates/_gallery_item.html.haml
367
+ - config/initializers/assetable.rb
362
368
  - config/initializers/carrierwave.rb
363
369
  - config/initializers/gallery_input.rb
364
370
  - config/initializers/uploader_input.rb
@@ -368,16 +374,13 @@ files:
368
374
  - db/migrate/20131125200943_create_galleries.rb
369
375
  - db/migrate/20140121173312_add_ratio_to_assets.rb
370
376
  - db/migrate/20140220053656_add_sort_order_to_asset_attachments.rb
377
+ - lib/assetable.rb
371
378
  - lib/assetable/active_record/base.rb
372
379
  - lib/assetable/config.rb
373
380
  - lib/assetable/engine.rb
374
381
  - lib/assetable/inputs/uploaders.rb
375
382
  - lib/assetable/version.rb
376
- - lib/assetable.rb
377
383
  - lib/tasks/assetable_tasks.rake
378
- - MIT-LICENSE
379
- - Rakefile
380
- - README.rdoc
381
384
  - test/fixtures/asset_attachments.yml
382
385
  - test/fixtures/assets.yml
383
386
  - test/fixtures/images.yml
@@ -405,7 +408,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
405
408
  version: '0'
406
409
  requirements: []
407
410
  rubyforge_project:
408
- rubygems_version: 2.0.7
411
+ rubygems_version: 2.2.2
409
412
  signing_key:
410
413
  specification_version: 4
411
414
  summary: Dead simple asset uploader attachments for your active record models
@@ -418,4 +421,3 @@ test_files:
418
421
  - test/models/asset_test.rb
419
422
  - test/models/image_test.rb
420
423
  - test/models/video_test.rb
421
- has_rdoc: