assetable 0.2.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjdkNGY5ZTA4YjM5ZTYzN2M0MWJmYWIzOWYyNjk0OWU1NDczNWRlZg==
4
+ Mjg5N2ViZDI4NDNjYjA1YWIxYWI0MTczN2IyMGU5OTdiNmI5MmNjMw==
5
5
  data.tar.gz: !binary |-
6
- NDMxMWI4MDQwMDE1MDcxNDM1NGM5ZDk5YjFlYjlmMTJkNmFhYWNiZA==
6
+ ZDZjYmQzY2RhNjgyNDVhY2Y2OGEyNTU3MmIyOTFjMjRlMzQwN2Y0YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjY2NzE3ZjhiYTE5OGZlODMyNDA1YTZkYjBjZTNhN2U4ZmNjOThjODRkNzVi
10
- MTViZTU5YTJhMTc5YWJjZmNmM2E0YjA1OWVlNjM0ZmNhMWU4MTcxODBlNmY1
11
- MjZjYWI4MjU1NzJjM2IyOTJlYWZmOTkzYTk5YjkyMDFmNjc1ZTA=
9
+ ODIxZTgwNWZiYjQzZTQzY2Q4MjFlMGQzNjQ1M2Y5MTBkYmMyYjA2ZjM4ODJj
10
+ MGFiMTlhOTk4ODU2MmVlMzVmNWZiOGVkOWQ2ZDg1MmYyNjM3NWI1NGQwOWY0
11
+ YzRmZjdmZTEzZjhiZjZlOTRiNTAwMzdiOTQzMzQyNjFjZjQ1MTk=
12
12
  data.tar.gz: !binary |-
13
- Njg5NWI1NzBmNzJiYWI4YTYwYTBjMDBlMmY5ZTNjY2E4YzIwZDlhNGYzOWQ0
14
- M2MyNGEyZDk2Mzg1Njk1ZGE2MDRlODBlZGVhNjE3NjZkODI3MDAwZjYyMTYw
15
- OWU5MzZhYmNhMzU3NWIyZWY4NDhiMDRjZGI2MjdlZDFkY2ZhMDI=
13
+ YzVjYTBkNzVlYmNkNWRjZDNlYzE5YjVkYjNkNzYwZTgyY2EyODg1MTkyNDA3
14
+ MTVkZjZkNTZhNDE0NTA3ZDBkNTcyM2I2OGE1OWFlNGEwNTQ5ZjU1MWQ2MmVl
15
+ NDI4ZDJiMTFkYjc3NmM0ZjdlYjBkNzFjOGU3YTMwMGJlNzNlMGI=
@@ -3,7 +3,7 @@ class Assetable::AssetsController < ActionController::Base
3
3
  respond_to :html, :js
4
4
 
5
5
  def index
6
- @assets = Asset.page(params[:page]).per(20)
6
+ @assets = Assetabler::Asset.page(params[:page]).per(20)
7
7
  @fieldname = params[:fieldname]
8
8
  @uploader_id = params[:uploader_id]
9
9
  end
@@ -12,7 +12,7 @@ class Assetable::AssetsController < ActionController::Base
12
12
  def insert
13
13
  @fieldname = params[:fieldname]
14
14
  @uploader_id = params[:uploader_id]
15
- @assets = Asset.find(params[:asset_ids])
15
+ @assets = Assetabler::Asset.find(params[:asset_ids])
16
16
  end
17
17
 
18
18
  # Create a new asset
@@ -23,11 +23,11 @@ class Assetable::AssetsController < ActionController::Base
23
23
 
24
24
  # Create the appropriate model
25
25
  if content_type.split("/").first == "image"
26
- @asset = Image.new(asset_params)
26
+ @asset = Assetabler::Image.new(asset_params)
27
27
  elsif content_type.split("/").first == "video"
28
- @asset = Video.new(asset_params)
28
+ @asset = Assetabler::Video.new(asset_params)
29
29
  elsif content_type.split("/").first == "application"
30
- @asset = Document.new(asset_params)
30
+ @asset = Assetabler::Document.new(asset_params)
31
31
  end
32
32
 
33
33
  # Return
@@ -42,12 +42,12 @@ class Assetable::AssetsController < ActionController::Base
42
42
 
43
43
  # Edit an asset will return the edit form
44
44
  def edit
45
- @asset = Asset.find(params[:id])
45
+ @asset = Assetabler::Asset.find(params[:id])
46
46
  end
47
47
 
48
48
  # Update an asset
49
49
  def update
50
- @asset = Asset.find(params[:id])
50
+ @asset = Assetabler::Asset.find(params[:id])
51
51
  @asset.update_attributes(permitted_params)
52
52
  end
53
53
 
@@ -9,14 +9,14 @@ class Assetable::ExternalServicesController < ActionController::Base
9
9
 
10
10
  # New template
11
11
  def new
12
- @external_service = ExternalService.new
12
+ @external_service = Assetabler::ExternalService.new
13
13
  @fieldname = params[:fieldname]
14
14
  @uploader_id = params[:uploader_id]
15
15
  end
16
16
 
17
17
  # Create a new external service asset
18
18
  def create
19
- @external_service = ExternalService.new(permitted_params)
19
+ @external_service = Assetabler::ExternalService.new(permitted_params)
20
20
 
21
21
  if @external_service.errors.empty? and @external_service.save
22
22
  @fieldname = params[:fieldname]
@@ -1,7 +1,7 @@
1
1
  module Assetable::AssetHelper
2
2
 
3
3
  def asset_preview asset
4
- render partial: "assetable/shared/asset_preview", locals: { asset: asset }
4
+ render_to_string partial: "assetable/shared/asset_preview", locals: { asset: asset }
5
5
  end
6
6
 
7
7
  end
@@ -21,7 +21,8 @@ class GalleryInput < SimpleForm::Inputs::FileInput
21
21
  uploader_html = template.content_tag(:div, (gallery_hidden_input + preview), class: "uploader-assets-wrapper")
22
22
 
23
23
  # Create and return the uploader html
24
- uploader_wrapper = template.content_tag :div, (uploader_html + hidden_input + directions_html.html_safe), class: "gallery-uploader"
24
+ directions = options[:directions]
25
+ uploader_wrapper = template.content_tag :div, (uploader_html + hidden_input + directions_html(directions, attribute_name).html_safe), class: "gallery-uploader"
25
26
  return uploader_wrapper
26
27
  end
27
28
 
@@ -3,6 +3,7 @@ class UploaderInput < SimpleForm::Inputs::FileInput
3
3
  include Assetable::Uploaders
4
4
 
5
5
  def input
6
+
6
7
  # Create the hidden input as fields_for
7
8
  fieldname = "#{object_name}[#{attribute_name}_association_attributes][asset_id]"
8
9
 
@@ -18,7 +19,7 @@ class UploaderInput < SimpleForm::Inputs::FileInput
18
19
 
19
20
  # Create and return the uploader html
20
21
  directions = options[:directions]
21
- uploader_wrapper = template.content_tag :div, (uploader_html + directions_html(directions).html_safe), class: "assetable-uploader"
22
+ uploader_wrapper = template.content_tag :div, (uploader_html + directions_html(directions, attribute_name).html_safe), class: "assetable-uploader"
22
23
  return uploader_wrapper
23
24
  end
24
25
 
@@ -0,0 +1,5 @@
1
+ module Assetabler
2
+ def self.table_name_prefix
3
+ 'assetable_'
4
+ end
5
+ end
@@ -0,0 +1,55 @@
1
+ module Assetabler
2
+ class Asset < ActiveRecord::Base
3
+
4
+ has_many :asset_attachments, :as => :assetable, :dependent => :destroy
5
+ has_many :assetable, :through => :asset_attachments
6
+
7
+ before_save :update_asset_attributes
8
+
9
+
10
+
11
+ # File Type Helpers
12
+ # ---------------------------------------------------------------------
13
+
14
+ # Is the asset a image?
15
+ def image?
16
+ self.type == "Assetabler::Image"
17
+ end
18
+
19
+ # Is the asset a document?
20
+ def document?
21
+ self.type == "Assetabler::Document"
22
+ end
23
+
24
+ # Is the asset a video?
25
+ def video?
26
+ self.type == "Assetabler::Video"
27
+ end
28
+
29
+ def external_service?
30
+ self.type == "Assetabler::ExternalService"
31
+ end
32
+
33
+
34
+ # File meta and helpers
35
+ # ---------------------------------------------------------------------
36
+
37
+ # Get the file type extension from the filename
38
+ def extension
39
+ filename = File.extname(self.filename.to_s)
40
+ filename[0] = '' # remove the dot, i.e. (.docx or .pptx)
41
+ filename
42
+ end
43
+
44
+ # Add some custom attributes to the asset
45
+ def update_asset_attributes
46
+ if !self.external_service? and self.present? and self.changed?
47
+ self.content_type = self.filename.file.content_type
48
+ self.file_size = self.filename.file.size
49
+ self.width, self.height = `identify -format "%wx%h" #{self.filename.file.path}`.split(/x/) unless self.document? or self.width? or self.height?
50
+ self.ratio = self.width.to_f / self.height.to_f if self.width.present? and self.height.present?
51
+ end
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,33 @@
1
+ module Assetabler
2
+ class AssetAttachment < ActiveRecord::Base
3
+
4
+ belongs_to :asset
5
+ belongs_to :assetable, polymorphic: true
6
+
7
+ before_validation :ensure_name_is_not_blank
8
+ before_save :set_sort_order
9
+
10
+ # Is the asset_attachment attached to a gallery?
11
+ def gallery?
12
+ assetable_type.downcase == "gallery"
13
+ end
14
+
15
+ def gallery
16
+ assetable
17
+ end
18
+
19
+
20
+ private
21
+
22
+ # Ensure the name is not blank to avoid unique indexes on the name
23
+ # If it's blank, let's set it to nil
24
+ def ensure_name_is_not_blank
25
+ name = nil if name.blank?
26
+ end
27
+
28
+ def set_sort_order
29
+ sort_order = assetable.asset_attachments.size if gallery? and sort_order.blank?
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,7 @@
1
+ module Assetabler
2
+ class Document < Asset
3
+
4
+ mount_uploader :filename, DocumentUploader
5
+
6
+ end
7
+ end
@@ -0,0 +1,24 @@
1
+ module Assetabler
2
+ class ExternalService < Asset
3
+
4
+ validates_presence_of :name, :body
5
+
6
+ def self.possible_content_types
7
+ if user_defined_document_types = Assetable.external_document_types
8
+ return user_defined_document_types
9
+ else
10
+ return ["iFrame", "Third Party API"]
11
+ end
12
+ end
13
+
14
+ def has_icon?
15
+ available_icons = Assetable.external_document_icons.collect{|k, v| k}
16
+ available_icons.include? self.content_type.to_sym if self.content_type.present?
17
+ end
18
+
19
+ def icon
20
+ Assetable.external_document_icons[self.content_type.to_sym].to_s if self.has_icon?
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,13 @@
1
+ module Assetabler
2
+ class Gallery < ActiveRecord::Base
3
+
4
+ belongs_to :galleryable, polymorphic: true
5
+ has_many :asset_attachments, -> { order('sort_order asc') }, as: :assetable, dependent: :destroy
6
+ has_many :assets, through: :asset_attachments
7
+
8
+ accepts_nested_attributes_for :asset_attachments, allow_destroy: true
9
+
10
+
11
+
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ module Assetabler
2
+ class Image < Asset
3
+
4
+ mount_uploader :filename, ImageUploader
5
+
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Assetabler
2
+ class Video < Asset
3
+
4
+ mount_uploader :filename, VideoUploader
5
+
6
+ end
7
+ end
@@ -1,6 +1,6 @@
1
1
  class CreateAssets < ActiveRecord::Migration
2
2
  def change
3
- create_table :assets do |t|
3
+ create_table :assetable_assets do |t|
4
4
  t.string :type
5
5
  t.string :name
6
6
  t.text :body
@@ -1,15 +1,15 @@
1
1
  class CreateAssetAttachments < ActiveRecord::Migration
2
2
  def change
3
- create_table :asset_attachments do |t|
3
+ create_table :assetable_asset_attachments do |t|
4
4
  t.references :asset
5
5
  t.references :assetable, :polymorphic => true
6
6
  t.string :name
7
7
  t.timestamps
8
8
  end
9
9
 
10
- add_index :asset_attachments, :asset_id
11
- add_index :asset_attachments, [:assetable_type, :assetable_id]
12
- add_index :asset_attachments, [:assetable_type, :assetable_id, :name], unique: true, name: "named_asset"
13
- add_index :asset_attachments, :assetable_id
10
+ add_index :assetable_asset_attachments, :asset_id
11
+ add_index :assetable_asset_attachments, [:assetable_type, :assetable_id], name: "poly_asset"
12
+ add_index :assetable_asset_attachments, [:assetable_type, :assetable_id, :name], unique: true, name: "named_asset"
13
+ add_index :assetable_asset_attachments, :assetable_id
14
14
  end
15
15
  end
@@ -1,14 +1,14 @@
1
1
  class CreateGalleries < ActiveRecord::Migration
2
2
  def change
3
- create_table :galleries do |t|
3
+ create_table :assetable_galleries do |t|
4
4
  t.references :galleryable, :polymorphic => true
5
5
  t.string :name
6
6
  t.timestamps
7
7
  end
8
8
 
9
- add_index :galleries, [:galleryable_type, :galleryable_id]
10
- add_index :galleries, [:galleryable_type, :galleryable_id, :name], unique: true, name: "named_gallery"
9
+ add_index :assetable_galleries, [:galleryable_type, :galleryable_id], name: "poly_asset"
10
+ add_index :assetable_galleries, [:galleryable_type, :galleryable_id, :name], unique: true, name: "named_gallery"
11
11
 
12
- add_index :galleries, :galleryable_id
12
+ add_index :assetable_galleries, :galleryable_id
13
13
  end
14
14
  end
@@ -1,5 +1,5 @@
1
1
  class AddRatioToAssets < ActiveRecord::Migration
2
2
  def change
3
- add_column :assets, :ratio, :float, precision: 5, scale: 4
3
+ add_column :assetable_assets, :ratio, :float, precision: 5, scale: 4
4
4
  end
5
5
  end
@@ -1,10 +1,11 @@
1
1
  class AddSortOrderToAssetAttachments < ActiveRecord::Migration
2
2
  def change
3
- add_column :asset_attachments, :sort_order, :integer, default: 0
3
+ add_column :assetable_asset_attachments, :sort_order, :integer, default: 0
4
4
 
5
- AssetAttachment.reset_column_information
5
+ Assetabler::AssetAttachment.reset_column_information
6
+ Assetabler::Gallery.reset_column_information
6
7
 
7
- Gallery.all.each do |gallery|
8
+ Assetabler::Gallery.all.each do |gallery|
8
9
  if gallery.asset_attachments.present?
9
10
  gallery.asset_attachments.each_with_index do |attachment, index|
10
11
  attachment.update_attribute(:sort_order, index)
@@ -9,24 +9,32 @@ module Assetable
9
9
  def assetable *args
10
10
  if args.present?
11
11
  args.each do |arg|
12
- has_one :"#{arg}_association", -> { where(name: arg) }, class_name: "AssetAttachment", as: :assetable
13
- has_one arg, through: :"#{arg}_association", source: :asset
12
+ has_one :"#{arg}_association", -> { where(name: arg) }, class_name: "Assetabler::AssetAttachment", as: :assetable
13
+ has_one arg, through: :"#{arg}_association", :source => :asset
14
14
  accepts_nested_attributes_for :"#{arg}_association", allow_destroy: true
15
+ # Hack to fix the has_one accessor from not correctly guessing namespace of source association
16
+ class_eval %Q"
17
+ def #{arg}
18
+ #{arg}_association.try(:asset) || super
19
+ end
20
+ "
21
+
15
22
  end
16
23
  end
24
+
17
25
  end
18
26
 
19
27
  # Galleries
20
28
  def galleryable *args
21
29
  # By default, let's include a gallery.
22
30
  unless args.include? :gallery
23
- has_one :gallery, as: :galleryable, dependent: :destroy
31
+ has_one :gallery, class_name: "Assetabler::Gallery", as: :galleryable, dependent: :destroy
24
32
  accepts_nested_attributes_for :gallery
25
33
  end
26
34
 
27
35
  if args.present?
28
36
  args.each do |arg|
29
- has_one arg, -> { where(name: arg) }, class_name: "Gallery", as: :galleryable
37
+ has_one arg, -> { where(name: arg) }, class_name: "Assetabler::Gallery", as: :galleryable
30
38
  accepts_nested_attributes_for arg
31
39
  end
32
40
  end
@@ -3,6 +3,11 @@ module Assetable
3
3
  config.generators.integration_tool :rspec
4
4
  config.generators.test_framework :rspec
5
5
 
6
+
7
+ initializer :assets do |config|
8
+ Rails.application.config.assets.precompile += %w( Moxie.swf Moxie.xap )
9
+ end
10
+
6
11
  # Run the engine migrations with the main app rake task
7
12
  initializer :append_migrations do |app|
8
13
  unless app.root.to_s.match root.to_s
@@ -9,7 +9,7 @@ module Assetable::Uploaders
9
9
  # modal_gallery.assets.each do |asset|
10
10
  modal_gallery.asset_attachments.each_with_index do |asset_attachment, index|
11
11
  # gallery += asset_preview(asset, :gallery, fieldname)
12
- gallery += ActionController::Base.new.send(:render_to_string, partial: "assetable/shared/templates/gallery_item", locals: { asset: asset_attachment.asset, asset_attachment: asset_attachment, fieldname: fieldname, index: index })
12
+ gallery += ac.send(:render_to_string, partial: "assetable/shared/templates/gallery_item", locals: { asset: asset_attachment.asset, asset_attachment: asset_attachment, fieldname: fieldname, index: index })
13
13
  end
14
14
 
15
15
  gallery
@@ -17,11 +17,18 @@ module Assetable::Uploaders
17
17
  end
18
18
 
19
19
  def asset_preview asset, type=:asset, fieldname=nil
20
- ActionController::Base.new.send(:render_to_string, partial: "assetable/shared/templates/#{type.downcase.to_s}_item", locals: { asset: asset, fieldname: fieldname })
20
+ ac.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 directions=nil
24
- ActionController::Base.new.send(:render_to_string, partial: 'assetable/assets/directions', locals: {directions: directions})
23
+ def directions_html(directions, fieldname=nil)
24
+ ac.send(:render_to_string, :partial => 'assetable/assets/directions', locals: {directions: directions, fieldname: fieldname})
25
+ end
26
+
27
+ def ac
28
+ return @c if @c.present?
29
+ @c = ActionController::Base.new
30
+ @c.request = OpenStruct.new()
31
+ @c
25
32
  end
26
33
 
27
34
  end
@@ -1,3 +1,3 @@
1
1
  module Assetable
2
- VERSION = "0.2.4"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assetable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Koht
@@ -14,14 +14,14 @@ dependencies:
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - ! '>'
18
18
  - !ruby/object:Gem::Version
19
19
  version: 4.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - ! '>'
25
25
  - !ruby/object:Gem::Version
26
26
  version: 4.0.0
27
27
  - !ruby/object:Gem::Dependency
@@ -335,13 +335,14 @@ files:
335
335
  - app/helpers/assetable/asset_helper.rb
336
336
  - app/inputs/gallery_input.rb
337
337
  - app/inputs/uploader_input.rb
338
- - app/models/asset.rb
339
- - app/models/asset_attachment.rb
340
- - app/models/document.rb
341
- - app/models/external_service.rb
342
- - app/models/gallery.rb
343
- - app/models/image.rb
344
- - app/models/video.rb
338
+ - app/models/assetabler.rb
339
+ - app/models/assetabler/asset.rb
340
+ - app/models/assetabler/asset_attachment.rb
341
+ - app/models/assetabler/document.rb
342
+ - app/models/assetabler/external_service.rb
343
+ - app/models/assetabler/gallery.rb
344
+ - app/models/assetabler/image.rb
345
+ - app/models/assetabler/video.rb
345
346
  - app/uploaders/asset_uploader.rb
346
347
  - app/uploaders/document_uploader.rb
347
348
  - app/uploaders/image_uploader.rb
@@ -1,70 +0,0 @@
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
-
17
- class Asset < ActiveRecord::Base
18
-
19
- has_many :asset_attachments, :as => :assetable, :dependent => :destroy
20
- has_many :assetable, :through => :asset_attachments
21
-
22
- before_validation :update_asset_attributes
23
-
24
- validates_uniqueness_of :checksum, message: "File has already been uploaded." if Assetable.unique_assets
25
-
26
-
27
- # File Type Helpers
28
- # ---------------------------------------------------------------------
29
-
30
- # Is the asset a image?
31
- def image?
32
- self.type == "Image"
33
- end
34
-
35
- # Is the asset a document?
36
- def document?
37
- self.type == "Document"
38
- end
39
-
40
- # Is the asset a video?
41
- def video?
42
- self.type == "Video"
43
- end
44
-
45
- def external_service?
46
- self.type == "ExternalService"
47
- end
48
-
49
-
50
- # File meta and helpers
51
- # ---------------------------------------------------------------------
52
-
53
- # Get the file type extension from the filename
54
- def extension
55
- filename = File.extname(self.filename.to_s)
56
- filename[0] = '' # remove the dot, i.e. (.docx or .pptx)
57
- filename
58
- end
59
-
60
- # Add some custom attributes to the asset
61
- def update_asset_attributes
62
- if !self.external_service? and self.present? and self.changed?
63
- self.content_type = self.filename.file.content_type
64
- self.file_size = self.filename.file.size
65
- self.width, self.height = `identify -format "%wx%h" #{self.filename.file.path}`.split(/x/) unless self.document? or self.width? or self.height?
66
- self.ratio = self.width.to_f / self.height.to_f if self.width.present? and self.height.present?
67
- end
68
- end
69
-
70
- end
@@ -1,31 +0,0 @@
1
- class AssetAttachment < ActiveRecord::Base
2
-
3
- belongs_to :asset
4
- belongs_to :assetable, polymorphic: true
5
-
6
- before_validation :ensure_name_is_not_blank
7
- before_save :set_sort_order
8
-
9
- # Is the asset_attachment attached to a gallery?
10
- def gallery?
11
- assetable_type.downcase == "gallery"
12
- end
13
-
14
- def gallery
15
- assetable
16
- end
17
-
18
-
19
- private
20
-
21
- # Ensure the name is not blank to avoid unique indexes on the name
22
- # If it's blank, let's set it to nil
23
- def ensure_name_is_not_blank
24
- name = nil if name.blank?
25
- end
26
-
27
- def set_sort_order
28
- sort_order = assetable.asset_attachments.size if gallery? and sort_order.blank?
29
- end
30
-
31
- end
@@ -1,5 +0,0 @@
1
- class Document < Asset
2
-
3
- mount_uploader :filename, DocumentUploader
4
-
5
- end
@@ -1,22 +0,0 @@
1
- class ExternalService < Asset
2
-
3
- validates_presence_of :name, :body
4
-
5
- def self.possible_content_types
6
- if user_defined_document_types = Assetable.external_document_types
7
- return user_defined_document_types
8
- else
9
- return ["iFrame", "Third Party API"]
10
- end
11
- end
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
-
22
- end
@@ -1,9 +0,0 @@
1
- class Gallery < ActiveRecord::Base
2
-
3
- belongs_to :galleryable, polymorphic: true
4
- has_many :asset_attachments, -> { order('sort_order asc') }, as: :assetable, dependent: :destroy
5
- has_many :assets, through: :asset_attachments
6
-
7
- accepts_nested_attributes_for :asset_attachments, allow_destroy: true
8
-
9
- end
@@ -1,5 +0,0 @@
1
- class Image < Asset
2
-
3
- mount_uploader :filename, ImageUploader
4
-
5
- end
@@ -1,5 +0,0 @@
1
- class Video < Asset
2
-
3
- mount_uploader :filename, VideoUploader
4
-
5
- end