camaleon_media_paperclip 0.1.0 → 0.1.1

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea27a35608e4611b0d94a3e09a8ecd18fc9166e6
4
- data.tar.gz: 01f7d4be1784e3e0382927f143ed5b99a5f31eca
3
+ metadata.gz: 17e7ae58967a55f394616132a19a63e325b902b9
4
+ data.tar.gz: 8173ed1c7a66faac93fd030fd908b65d62ba69f1
5
5
  SHA512:
6
- metadata.gz: 0ac7c29e30adad6dd3bc788f9203d7fa242beec5888dff30b70875b2394fe2cec91bcbcaffe68a878c056918cab0a9fab7df9c7cf3d7f54f0ec33fa147305e5f
7
- data.tar.gz: 18eed33fcb5839bc558d4f292d1be66013d7ede59956ead098839d8f362694659fdf42820f9a9b762d9ba5fa76fe089db9ea4e0cb1daee236b58cb19abd3a7f4
6
+ metadata.gz: 8272acb389f307e9ecb248e0ae4b9b39b0aa002fc425c1253c87d73f8fc4d96eded0da0bce2372dd518306b9bc63a0bde458f5d1ed7302a15422012210d1d7fd
7
+ data.tar.gz: 4abcf77ea761ae6e8ea615ebd2437d2b50d85e218f89eee0fb6e2744059519c30472bdf6948dd824edcecd80002c121a28bb9b6ba0f32dc93001bd52e26eae97
@@ -1,3 +1,3 @@
1
1
  module CamaleonMediaPaperclip
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: camaleon_media_paperclip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - QuintEvents
@@ -79,9 +79,6 @@ files:
79
79
  - app/assets/javascripts/admin/elfinder/upload_elfinder.js
80
80
  - app/controllers/plugins/camaleon_media_paperclip/admin_controller.rb
81
81
  - app/helpers/plugins/camaleon_media_paperclip/helper.rb
82
- - app/models/plugins/camaleon_media_paperclip.rb
83
- - app/models/plugins/camaleon_media_paperclip/file.rb
84
- - app/models/plugins/camaleon_media_paperclip/folder.rb
85
82
  - app/views/plugins/camaleon_media_paperclip/admin/settings.html.erb
86
83
  - config/camaleon_plugin.json
87
84
  - config/routes.rb
@@ -1,5 +0,0 @@
1
- module Plugins::CamaleonMediaPaperclip
2
- def self.table_name_prefix
3
- 'plugins_camaleon_media_paperclip_'
4
- end
5
- end
@@ -1,33 +0,0 @@
1
- class Plugins::CamaleonMediaPaperclip::File < ActiveRecord::Base
2
- belongs_to :folder
3
-
4
- has_attached_file :content
5
-
6
- before_save :set_dimensions, if: :image?
7
-
8
- def self.find_by_pathname(pathname)
9
- dirname, basename = Pathname.new(pathname).cleanpath.split
10
- find_by(dirname: dirname, basename: basename)
11
- end
12
-
13
- def image?
14
- # This regex comes from paperclip wiki, there is probably a better way
15
- content_content_type =~ %r{^(image|(x-)?application)/(bmp|gif|jpeg|jpg|pjpeg|png|x-png)$}
16
- end
17
-
18
- def dimensions
19
- image? && "#{width}x#{height}"
20
- end
21
-
22
- private
23
-
24
- def set_dimensions
25
- return unless image?
26
- tempfile = content.queued_for_write[:original]
27
- unless tempfile.nil?
28
- geometry = Paperclip::Geometry.from_file(tempfile)
29
- self.width = geometry.width.to_i
30
- self.height = geometry.height.to_i
31
- end
32
- end
33
- end
@@ -1,54 +0,0 @@
1
- module Plugins::CamaleonMediaPaperclip
2
- CMP = self
3
-
4
- class Folder < ActiveRecord::Base
5
- include CamaleonMediaPaperclip::HashUtils
6
-
7
- has_many :files
8
- has_many :folders
9
- belongs_to :folder
10
-
11
- def children
12
- files = CMP::File.where(folder_id: id).
13
- select(CMP::File.arel_table[:filename].as('pathname')).
14
- arel
15
- folders = CMP::Folder.where(folder_id: id).
16
- select(CMP::Folder.arel_table[:path].as('pathname')).
17
- arel
18
-
19
- union = Arel::Nodes::Union.new(files, folders)
20
- query = Arel::Nodes::TableAlias.new(union, 'query')
21
-
22
- CMP::Folder.from(query.to_sql).pluck(:pathname)
23
- end
24
-
25
- def name
26
- ::Pathname.new(path.to_s).basename.to_s
27
- end
28
-
29
- def mtime
30
- updated_at.try(:tv_sec).to_i
31
- end
32
-
33
- def cwd
34
- entry = {
35
- name: name,
36
- hash: "v0_#{to_base64url(path.to_s)}",
37
- mime: 'directory',
38
- ts: mtime,
39
- size: 0,
40
- dirs: self.class.exists?(folder_id: id),
41
- read: 1,
42
- write: 1,
43
- locked: 0
44
- }
45
- entry[:volumeid] = 'v0_' unless id
46
- entry[:phash] = "v0_#{to_base64url(folder.path.to_s)}" if id
47
- entry
48
- end
49
-
50
- def file_entries(include_tree)
51
- []
52
- end
53
- end
54
- end