assetable 0.1.2 → 0.1.3

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
- MDE0MDczY2NjOGI4Njk3MTZjNDMxMjAwNzFjMDhjYmQxNDUxY2JjMQ==
4
+ MjZiYTU5Zjc1OTk0NTE2MzFhZWRlMjdlYzVmZmMyOTMzYWNmMzM1Mg==
5
5
  data.tar.gz: !binary |-
6
- ZWU0OTBhNzFkNTJjOTczNzEyN2I3OTMwYjkxNWU2MmNhNDNjYmI5YQ==
6
+ ZDIxMWU0MjMyYTdhZDQ5NTM2NzJmOTViY2ViYTdmMTNhM2E5NjExOQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YWNlOGVmMzU3M2NiZjhmOGIxMzg4N2Y5ZjYwYjNmOWIyYWFjNWU5ZjBlMmVm
10
- NzUwZTNlMzkzNjI4MTRkMTVlMjljOWQ3YTI5ODkwYjk3ZmVlZDk2ZDg0MmM5
11
- OWRmNzJiMTFhYzI4NDRiNjFmZjc3MDkxYTFkMmM1MjNkODFmYjA=
9
+ YmIwNWJjOGE2ZTNmMzhlMjdhNGU5ZmE0MTIyMjM1NzIwOTI2OGQ4YzIwZDhj
10
+ ZmE3OTRmY2FjYmY2YjFhY2FhNjMyOGM2MzRhNzc1MWYzNzUyZGM4ZWY4YWRh
11
+ NmJmMTU2NTliNDMyMWViMDE3YTgwMTYxMTU1MThjZGUxNmU4ODk=
12
12
  data.tar.gz: !binary |-
13
- ODc2NTJjNjM3YzczYjY4ZDQ3M2Y1YTkwODdkMjhmNDM4YjhhYjg3MjU3N2U3
14
- Y2E1ZDgzNWFmYWM0NDJmMWM4ZTg1ZGNhNTM4YzBlMWE0YjQzZjY1ZWQ1Y2Jk
15
- NGY4NWE3MmI1ZWJhYzM3OWZlNTk4Mjk0ZWUxOTdjNjBiZGYyODQ=
13
+ OTAxYjQ3ZWUwMDA2MWE4ZmM2ZmRhZjUyOWYxNzY4NDcyZWQ5OTcyYmE3NzY2
14
+ YjhjNTgwMTQ2NWM4MTA2YTJkNjc0NTEwZGVkZmRkOWM0YjU3NTYwNzkxMWNk
15
+ MTAyNzMwZWFmNDU2MWY3MmIyZDZkOGUyNGVhN2JhYmZiNGZjYzA=
@@ -214,6 +214,7 @@ input[type="checkbox"],
214
214
  cursor: not-allowed
215
215
 
216
216
 
217
- input.input-fluid
217
+ input.input-fluid,
218
+ textarea.input-fluid
218
219
  +box-sizing(border-box)
219
220
  width: 100%
@@ -28,8 +28,11 @@ class Assetable::ExternalServicesController < ActionController::Base
28
28
  def permitted_params
29
29
  params.require(:external_service).permit(
30
30
  :name,
31
+ :filename,
31
32
  :body,
32
- :content_type
33
+ :content_type,
34
+ :width,
35
+ :height
33
36
  )
34
37
  end
35
38
 
data/app/models/asset.rb CHANGED
@@ -1,3 +1,19 @@
1
+ # Base Asset Class
2
+ # ---------------------------------------
3
+ # Available Attributes:
4
+ # :type
5
+ # :name
6
+ # :body
7
+ # :filename
8
+ # :checksum
9
+ # :path
10
+ # :content_type
11
+ # :file_size
12
+ # :width
13
+ # :height
14
+ # :duration
15
+ # :bit_rate
16
+
1
17
  class Asset < ActiveRecord::Base
2
18
 
3
19
  has_many :asset_attachments, :as => :assetable, :dependent => :destroy
@@ -2,7 +2,6 @@ class ExternalService < Asset
2
2
 
3
3
  validates_presence_of :name, :body
4
4
 
5
- # G
6
5
  def self.possible_content_types
7
6
  if user_defined_document_types = Assetable.external_document_types
8
7
  return user_defined_document_types
@@ -11,4 +10,13 @@ class ExternalService < Asset
11
10
  end
12
11
  end
13
12
 
13
+ def has_icon?
14
+ available_icons = Assetable.external_document_icons.collect{|k, v| k}
15
+ available_icons.include? self.content_type.to_sym if self.content_type.present?
16
+ end
17
+
18
+ def icon
19
+ Assetable.external_document_icons[self.content_type.to_sym].to_s if self.has_icon?
20
+ end
21
+
14
22
  end
@@ -8,7 +8,10 @@
8
8
  - elsif asset.video?
9
9
  = image_tag "assetable/icons/icon-mp4.png", class: "uploader-preview"
10
10
  - elsif asset.external_service?
11
- = image_tag "assetable/icons/icon-document.png", class: "uploader-preview"
11
+ - if asset.has_icon?
12
+ = image_tag "assetable/icons/#{asset.icon}", class: "uploader-preview"
13
+ - else
14
+ = image_tag "assetable/icons/icon-document.png", class: "uploader-preview"
12
15
 
13
16
  %span.uploader-name= asset.name
14
17
  .uploader-size-and-actions
@@ -11,10 +11,13 @@
11
11
 
12
12
  .form-group
13
13
  = f.label :name
14
- = f.text_field :name, class: "form-control inpu-fluid", required: true
14
+ = f.text_field :name, class: "form-control input-fluid", required: true
15
15
  .form-group
16
16
  = f.label :content_type
17
17
  = f.select :content_type, ExternalService.possible_content_types
18
+ .form-group
19
+ = f.label :filename
20
+ = f.text_field :filename, class: "form-control input-fluid"
18
21
  .form-group
19
22
  = f.label :body
20
23
  = f.text_area :body, class: "form-control input-fluid", required: true
@@ -52,7 +52,11 @@ class ActionView::Helpers::FormBuilder
52
52
  elsif asset.video?
53
53
  preview_image_tag = image_tag(ActionController::Base.helpers.asset_path("assetable/icons/icon-mp4.png"), class: "uploader-preview")
54
54
  elsif asset.external_service?
55
- preview_image_tag = image_tag(ActionController::Base.helpers.asset_path("assetable/icons/icon-document.png"), class: "uploader-preview")
55
+ if asset.has_icon?
56
+ preview_image_tag = image_tag(ActionController::Base.helpers.asset_path("assetable/icons/#{asset.icon}"), class: "uploader-preview")
57
+ else
58
+ preview_image_tag = image_tag(ActionController::Base.helpers.asset_path("assetable/icons/icon-document.png"), class: "uploader-preview")
59
+ end
56
60
  end
57
61
 
58
62
  return link_to preview_image_tag, asset.filename.to_s, target: "_blank"
@@ -3,7 +3,8 @@ module Assetable
3
3
 
4
4
  VALID_OPTION_KEYS = [
5
5
  :storage,
6
- :external_document_types
6
+ :external_document_types,
7
+ :external_document_icons
7
8
  ]
8
9
 
9
10
  attr_accessor *VALID_OPTION_KEYS
@@ -1,3 +1,3 @@
1
1
  module Assetable
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
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.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Koht
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-12 00:00:00.000000000 Z
11
+ date: 2013-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails