card-mod-carrierwave 0.18.1 → 0.19.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 +4 -4
- data/data/transform/20250204175412_fix_compound_self_sets.rb +13 -0
- data/lib/carrier_wave/card_mount/helper.rb +44 -0
- data/lib/carrier_wave/card_mount.rb +16 -26
- data/lib/carrier_wave/file_card_uploader/path.rb +4 -2
- data/lib/carrier_wave/file_card_uploader.rb +3 -1
- data/lib/carrier_wave/image_card_uploader.rb +2 -2
- data/set/abstract/attachment/00_upload_cache.rb +2 -1
- data/set/abstract/attachment/coded.rb +14 -3
- data/set/abstract/attachment/paths.rb +3 -3
- data/set/abstract/attachment.rb +24 -18
- data/set/all/file_utils.rb +4 -4
- data/set/self/favicon.rb +2 -2
- data/set/type/file.rb +1 -0
- metadata +12 -14
- data/data/files/mod_carrierwave_script_asset_output/file.js +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41e00279cb3fb0dfffc3135050fe876cfa14488a82b772574540826c75334b76
|
4
|
+
data.tar.gz: 6946ea1509d63ad54e59aa385a4ce8119b523a50ebe7faf4074ec8677f186608
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed8168b06078138a17aa2a085c374154849d7f2935e89300d520ab63772ebe6c91f3420ad06a692f6d14ff445aa25c1b8d1fa691c1256244b70acb103d19a5fb
|
7
|
+
data.tar.gz: f28efee9f686a1d84f21ce6b372514f53d834fdf29dbdda6a3b2d9693dd1e3022ddd05d1eeaced8f5a2c8a9b09280d89212c415a83d7ce0b3a22d56a6cf5324e
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
class FixCompoundSelfSets < Cardio::Migration::Transform
|
4
|
+
def up
|
5
|
+
Card.where("codename is not null and name is null").each do |card|
|
6
|
+
card.include_set_modules
|
7
|
+
card.update_column :codename, nil
|
8
|
+
next unless card.respond_to? :attachment
|
9
|
+
|
10
|
+
card.update_column :db_content, card.attachment.db_content
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module CarrierWave
|
2
|
+
module CardMount
|
3
|
+
# helper methods for mounted cards
|
4
|
+
module Helper
|
5
|
+
def read_uploader *args
|
6
|
+
read_attribute(*args)
|
7
|
+
end
|
8
|
+
|
9
|
+
def write_uploader *args
|
10
|
+
write_attribute(*args)
|
11
|
+
end
|
12
|
+
|
13
|
+
def reload *_args
|
14
|
+
@_mounters = nil
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
def serializable_hash opts=nil
|
19
|
+
except = serializable_hash_config opts, :except
|
20
|
+
only = serializable_hash_config opts, :only
|
21
|
+
|
22
|
+
self.class.uploaders.each_with_object(super(opts)) do |(column, _uploader), hash|
|
23
|
+
if add_column_to_serializable_hash? column.to_s, only, except
|
24
|
+
hash[column.to_s] = _mounter(column).uploader.serializable_hash
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def serializable_hash_config opts, key
|
32
|
+
opts&.dig(key) && Array.wrap(opts[:key]).map(&:to_s)
|
33
|
+
end
|
34
|
+
|
35
|
+
def add_column_to_serializable_hash? column, only, except
|
36
|
+
if only
|
37
|
+
only.include? column
|
38
|
+
elsif except
|
39
|
+
!except.include? column
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -7,6 +7,7 @@ module CarrierWave
|
|
7
7
|
# to card events.
|
8
8
|
module CardMount
|
9
9
|
include CarrierWave::Mount
|
10
|
+
# Helper # load helper module so it's available to mounted cards
|
10
11
|
|
11
12
|
def uploaders
|
12
13
|
Card.uploaders ||= {}
|
@@ -21,6 +22,12 @@ module CarrierWave
|
|
21
22
|
super
|
22
23
|
|
23
24
|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
25
|
+
include CarrierWave::CardMount::Helper
|
26
|
+
|
27
|
+
def attachment
|
28
|
+
#{column}
|
29
|
+
end
|
30
|
+
|
24
31
|
event :store_#{column}_event, :finalize, when: :store_#{column}_event? do
|
25
32
|
store_#{column}!
|
26
33
|
end
|
@@ -49,10 +56,6 @@ module CarrierWave
|
|
49
56
|
!coded? || ENV["STORE_CODED_FILES"]
|
50
57
|
end
|
51
58
|
|
52
|
-
def attachment
|
53
|
-
#{column}
|
54
|
-
end
|
55
|
-
|
56
59
|
def store_attachment!
|
57
60
|
set_specific.delete :#{column}
|
58
61
|
store_#{column}!
|
@@ -62,15 +65,20 @@ module CarrierWave
|
|
62
65
|
"#{column}".to_sym
|
63
66
|
end
|
64
67
|
|
65
|
-
def read_uploader *args; read_attribute *args; end
|
66
|
-
def write_uploader *args; write_attribute *args; end
|
67
|
-
|
68
68
|
def #{column}=(new_file)
|
69
|
-
return if new_file.blank?
|
69
|
+
return if new_file.blank? || identical_file?(new_file)
|
70
70
|
self.selected_action_id = Time.now.to_i unless history?
|
71
71
|
assign_file(new_file) { super }
|
72
72
|
end
|
73
73
|
|
74
|
+
def identical_file? new_file
|
75
|
+
return false if new?
|
76
|
+
|
77
|
+
::File.identical? #{column}.file.to_file, new_file
|
78
|
+
rescue StandardError
|
79
|
+
false
|
80
|
+
end
|
81
|
+
|
74
82
|
def remote_#{column}_url=(url)
|
75
83
|
assign_file(url) { super }
|
76
84
|
end
|
@@ -111,24 +119,6 @@ module CarrierWave
|
|
111
119
|
def #{column}_changed?
|
112
120
|
@#{column}_changed
|
113
121
|
end
|
114
|
-
|
115
|
-
def serializable_hash(opts=nil)
|
116
|
-
except = opts&.dig(:except) && Array.wrap(opts[:except]).map(&:to_s)
|
117
|
-
only = opts&.dig(:only) && Array.wrap(opts[:only]).map(&:to_s)
|
118
|
-
|
119
|
-
self.class.uploaders.each_with_object(super(opts)) do |(column, uploader), hash|
|
120
|
-
if (!only && !except) ||
|
121
|
-
(only && only.include?(column.to_s)) ||
|
122
|
-
(!only && except && !except.include?(column.to_s))
|
123
|
-
hash[column.to_s] = _mounter(column).uploader.serializable_hash
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
def reload(*)
|
129
|
-
@_mounters = nil
|
130
|
-
super
|
131
|
-
end
|
132
122
|
RUBY
|
133
123
|
end
|
134
124
|
end
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# extend core module from carrierwave gem
|
1
2
|
module CarrierWave
|
2
3
|
def self.tmp_path
|
3
4
|
@tmp_path ||= Card.paths["tmp"].existent.first
|
4
5
|
end
|
5
6
|
|
7
|
+
# custom uploader class for cards
|
6
8
|
class FileCardUploader
|
7
9
|
# path-related methods for uploader
|
8
10
|
module Path
|
@@ -20,7 +22,7 @@ module CarrierWave
|
|
20
22
|
end
|
21
23
|
|
22
24
|
def cache_dir
|
23
|
-
"#{@model.files_base_dir}/cache"
|
25
|
+
"#{@model.files_base_dir 'tmp'}/cache"
|
24
26
|
end
|
25
27
|
|
26
28
|
# Carrierwave calls store_path without argument when it stores the file
|
@@ -41,7 +43,7 @@ module CarrierWave
|
|
41
43
|
end
|
42
44
|
|
43
45
|
def tmp_path
|
44
|
-
Dir.
|
46
|
+
Dir.mkdir_p model.tmp_upload_dir
|
45
47
|
File.join model.tmp_upload_dir, filename
|
46
48
|
end
|
47
49
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# extend the carrierwave gem modules/classes
|
1
2
|
module CarrierWave
|
2
3
|
# Takes care of the file upload for cards with attached files.
|
3
4
|
# Most of the upload behaviour depends on the card itself.
|
@@ -235,6 +236,7 @@ module CarrierWave
|
|
235
236
|
end
|
236
237
|
end
|
237
238
|
|
239
|
+
# alterations to Carrierwave methods
|
238
240
|
class SanitizedFile
|
239
241
|
def content_type
|
240
242
|
# the original content_type method doesn't seem to be very reliable
|
@@ -270,7 +272,7 @@ module CarrierWave
|
|
270
272
|
|
271
273
|
# put version at the end of the filename
|
272
274
|
def full_filename for_file
|
273
|
-
name = super
|
275
|
+
name = super
|
274
276
|
return unless name.present?
|
275
277
|
|
276
278
|
parts = name.split "."
|
@@ -42,12 +42,12 @@ module CarrierWave
|
|
42
42
|
# end
|
43
43
|
|
44
44
|
def identifier
|
45
|
-
full_filename(super
|
45
|
+
full_filename(super)
|
46
46
|
end
|
47
47
|
|
48
48
|
# add 'original' if no version is given
|
49
49
|
def full_filename for_file
|
50
|
-
name = super
|
50
|
+
name = super
|
51
51
|
if name.blank? || version_name
|
52
52
|
name
|
53
53
|
else
|
@@ -58,6 +58,7 @@ end
|
|
58
58
|
|
59
59
|
# at some point uploaded files of canceled file card creation
|
60
60
|
# should be deleted. We do this when ever an new file is created.
|
61
|
+
# FIXME: move to cron job
|
61
62
|
event :clear_draft_files, :integrate_with_delay, priority: 100, on: :create do
|
62
63
|
Card.delete_tmp_files_of_cached_uploads
|
63
64
|
end
|
@@ -86,5 +87,5 @@ end
|
|
86
87
|
|
87
88
|
# place for files if card doesn't have an id yet
|
88
89
|
def tmp_upload_dir _action_id=nil
|
89
|
-
"#{files_base_dir}/#{upload_cache_card.id}"
|
90
|
+
"#{files_base_dir 'tmp'}/#{upload_cache_card.id}"
|
90
91
|
end
|
@@ -6,7 +6,7 @@ end
|
|
6
6
|
|
7
7
|
event :validate_coded_storage_type, :validate, on: :save, when: :coded? do
|
8
8
|
storage_type_error :mod_argument_needed_to_save unless mod
|
9
|
-
storage_type_error :codename_needed_for_storage
|
9
|
+
storage_type_error :codename_needed_for_storage unless coded_ok?
|
10
10
|
end
|
11
11
|
|
12
12
|
def mod= value
|
@@ -19,6 +19,10 @@ end
|
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
|
+
def coded_ok?
|
23
|
+
!codename_parts.find(&:blank?)
|
24
|
+
end
|
25
|
+
|
22
26
|
def uncode?
|
23
27
|
(@explicit_storage_type != :coded) && !set_specific[:mod].present? && current.coded?
|
24
28
|
# (@explicit_storage_type != :coded) && !mod && current.coded?
|
@@ -37,16 +41,23 @@ def mod_from_content
|
|
37
41
|
end
|
38
42
|
|
39
43
|
def mod_name_match cont
|
40
|
-
cont&.match %r{^:[
|
44
|
+
cont&.match %r{^:[:\w/+]+/([^./]+)\.}
|
41
45
|
end
|
42
46
|
|
43
47
|
# place for files of mod file cards
|
44
48
|
def coded_dir new_mod=nil
|
45
|
-
|
49
|
+
dir_parts = [mod_dir(new_mod), MOD_FILE_DIR] + codename_parts
|
50
|
+
dir = File.join(*dir_parts)
|
46
51
|
FileUtils.mkdir_p(dir) unless File.directory?(dir)
|
47
52
|
dir
|
48
53
|
end
|
49
54
|
|
55
|
+
def codename_parts
|
56
|
+
return [codename.to_s] if name.simple?
|
57
|
+
|
58
|
+
@codename_parts ||= name.parts.map { |p| p.codename&.to_s }
|
59
|
+
end
|
60
|
+
|
50
61
|
def mod_dir new_mod=nil
|
51
62
|
mod_name = new_mod || mod
|
52
63
|
dir = Cardio::Mod.dirs.path(mod_name) || (mod_name.to_sym == :test && "test")
|
@@ -11,8 +11,8 @@ def upload_dir
|
|
11
11
|
id ? "#{files_base_dir}/#{id}" : tmp_upload_dir
|
12
12
|
end
|
13
13
|
|
14
|
-
def files_base_dir
|
15
|
-
dir = bucket ? bucket_config[:subdirectory] : Card.paths[
|
14
|
+
def files_base_dir type="files"
|
15
|
+
dir = bucket ? bucket_config[:subdirectory] : Card.paths[type].existent.first
|
16
16
|
dir || files_base_dir_configuration_error
|
17
17
|
end
|
18
18
|
|
@@ -24,7 +24,7 @@ end
|
|
24
24
|
# used in the identifier
|
25
25
|
def file_dir
|
26
26
|
if coded?
|
27
|
-
":#{
|
27
|
+
codename_parts.map { |c| ":#{c}" }.join Name.joint
|
28
28
|
elsif cloud?
|
29
29
|
"(#{bucket})/#{file_id}"
|
30
30
|
else
|
data/set/abstract/attachment.rb
CHANGED
@@ -12,10 +12,7 @@ end
|
|
12
12
|
|
13
13
|
# we need a card id for the path so we have to update db_content when we have
|
14
14
|
# an id
|
15
|
-
event :correct_identifier, :finalize, on: :save, when:
|
16
|
-
correct_id = attachment.db_content
|
17
|
-
return if db_content == correct_id
|
18
|
-
|
15
|
+
event :correct_identifier, :finalize, on: :save, when: :incorrect_identifier? do
|
19
16
|
update_column :db_content, attachment.db_content
|
20
17
|
expire
|
21
18
|
end
|
@@ -36,10 +33,21 @@ event :validate_file_exist, :validate, on: :create, skip: :allowed do
|
|
36
33
|
end
|
37
34
|
end
|
38
35
|
|
39
|
-
event :write_identifier, after: :save_original_filename, when:
|
36
|
+
event :write_identifier, after: :save_original_filename, when: :write_identifier? do
|
40
37
|
self.content = attachment.db_content
|
41
38
|
end
|
42
39
|
|
40
|
+
def incorrect_identifier?
|
41
|
+
return false if web?
|
42
|
+
|
43
|
+
correct_id = attachment.db_content
|
44
|
+
correct_id.present? && db_content != correct_id
|
45
|
+
end
|
46
|
+
|
47
|
+
def write_identifier?
|
48
|
+
!web?
|
49
|
+
end
|
50
|
+
|
43
51
|
def file_ready_to_save?
|
44
52
|
attachment.file.present? &&
|
45
53
|
!preliminary_upload? &&
|
@@ -99,8 +107,6 @@ def duplicate?
|
|
99
107
|
(old = attachment.file) &&
|
100
108
|
(new = set_specific[attachment_name]) &&
|
101
109
|
old.size == new.size
|
102
|
-
# rescue Card::Error
|
103
|
-
# false
|
104
110
|
end
|
105
111
|
|
106
112
|
def delete_files_for_action action
|
@@ -112,7 +118,7 @@ def delete_files_for_action action
|
|
112
118
|
end
|
113
119
|
end
|
114
120
|
|
115
|
-
def revision action, before_action
|
121
|
+
def revision action, before_action: false
|
116
122
|
return unless (result = super)
|
117
123
|
|
118
124
|
result[:empty_ok] = true
|
@@ -127,6 +133,10 @@ def attachment_format ext
|
|
127
133
|
end
|
128
134
|
end
|
129
135
|
|
136
|
+
def original_extension
|
137
|
+
@original_extension ||= attachment&.extension&.sub(/^\./, "")
|
138
|
+
end
|
139
|
+
|
130
140
|
def rescuing_extension_issues
|
131
141
|
yield
|
132
142
|
rescue StandardError => e
|
@@ -134,6 +144,12 @@ rescue StandardError => e
|
|
134
144
|
nil
|
135
145
|
end
|
136
146
|
|
147
|
+
def confirm_original_extension ext
|
148
|
+
return unless ["file", original_extension].member? ext
|
149
|
+
|
150
|
+
original_extension
|
151
|
+
end
|
152
|
+
|
137
153
|
def detect_extension ext
|
138
154
|
return unless (mime_types = MIME::Types[attachment.content_type])
|
139
155
|
|
@@ -143,13 +159,3 @@ end
|
|
143
159
|
def recognized_extension? mime_types, ext
|
144
160
|
mime_types.find { |mt| mt.extensions.member? ext }
|
145
161
|
end
|
146
|
-
|
147
|
-
def confirm_original_extension ext
|
148
|
-
return unless ["file", original_extension].member? ext
|
149
|
-
|
150
|
-
original_extension
|
151
|
-
end
|
152
|
-
|
153
|
-
def original_extension
|
154
|
-
@original_extension ||= attachment&.extension&.sub(/^\./, "")
|
155
|
-
end
|
data/set/all/file_utils.rb
CHANGED
@@ -30,10 +30,10 @@ module ClassMethods
|
|
30
30
|
|
31
31
|
def draft_actions_with_attachment
|
32
32
|
Card::Action.find_by_sql(
|
33
|
-
"SELECT * FROM card_actions "\
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
"SELECT * FROM card_actions " \
|
34
|
+
"INNER JOIN cards ON card_actions.card_id = cards.id " \
|
35
|
+
"WHERE cards.type_id IN (#{Card::FileID}, #{Card::ImageID}) " \
|
36
|
+
"AND card_actions.draft = true"
|
37
37
|
)
|
38
38
|
end
|
39
39
|
|
data/set/self/favicon.rb
CHANGED
@@ -11,7 +11,7 @@ format :html do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def raw_help_text
|
14
|
-
"A favicon (or shortcut icon) is a small image used by browsers to help identify "\
|
15
|
-
|
14
|
+
"A favicon (or shortcut icon) is a small image used by browsers to help identify " \
|
15
|
+
"your website. [[http://www.decko.org/favicon|How to customize your favicon]]"
|
16
16
|
end
|
17
17
|
end
|
data/set/type/file.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: card-mod-carrierwave
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan McCutchen
|
8
8
|
- Philipp Kühl
|
9
9
|
- Gerry Gleason
|
10
|
-
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: card
|
@@ -18,14 +17,14 @@ dependencies:
|
|
18
17
|
requirements:
|
19
18
|
- - '='
|
20
19
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
20
|
+
version: 1.109.1
|
22
21
|
type: :runtime
|
23
22
|
prerelease: false
|
24
23
|
version_requirements: !ruby/object:Gem::Requirement
|
25
24
|
requirements:
|
26
25
|
- - '='
|
27
26
|
- !ruby/object:Gem::Version
|
28
|
-
version: 1.
|
27
|
+
version: 1.109.1
|
29
28
|
- !ruby/object:Gem::Dependency
|
30
29
|
name: carrierwave
|
31
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,28 +87,28 @@ dependencies:
|
|
88
87
|
requirements:
|
89
88
|
- - '='
|
90
89
|
- !ruby/object:Gem::Version
|
91
|
-
version: 0.
|
90
|
+
version: 0.19.1
|
92
91
|
type: :runtime
|
93
92
|
prerelease: false
|
94
93
|
version_requirements: !ruby/object:Gem::Requirement
|
95
94
|
requirements:
|
96
95
|
- - '='
|
97
96
|
- !ruby/object:Gem::Version
|
98
|
-
version: 0.
|
97
|
+
version: 0.19.1
|
99
98
|
- !ruby/object:Gem::Dependency
|
100
99
|
name: card-mod-permissions
|
101
100
|
requirement: !ruby/object:Gem::Requirement
|
102
101
|
requirements:
|
103
102
|
- - '='
|
104
103
|
- !ruby/object:Gem::Version
|
105
|
-
version: 0.
|
104
|
+
version: 0.19.1
|
106
105
|
type: :runtime
|
107
106
|
prerelease: false
|
108
107
|
version_requirements: !ruby/object:Gem::Requirement
|
109
108
|
requirements:
|
110
109
|
- - '='
|
111
110
|
- !ruby/object:Gem::Version
|
112
|
-
version: 0.
|
111
|
+
version: 0.19.1
|
113
112
|
description: ''
|
114
113
|
email:
|
115
114
|
- info@decko.org
|
@@ -139,12 +138,13 @@ files:
|
|
139
138
|
- data/files/logo.svg
|
140
139
|
- data/files/logo/image-original.svg
|
141
140
|
- data/files/mao2.jpg
|
142
|
-
- data/files/mod_carrierwave_script_asset_output/file.js
|
143
141
|
- data/files/rails.gif
|
144
142
|
- data/real.yml
|
145
143
|
- data/transform/20230130141025_move_favicon.rb
|
144
|
+
- data/transform/20250204175412_fix_compound_self_sets.rb
|
146
145
|
- lib/card/mod/carrierwave.rb
|
147
146
|
- lib/carrier_wave/card_mount.rb
|
147
|
+
- lib/carrier_wave/card_mount/helper.rb
|
148
148
|
- lib/carrier_wave/file_card_uploader.rb
|
149
149
|
- lib/carrier_wave/file_card_uploader/path.rb
|
150
150
|
- lib/carrier_wave/image_card_uploader.rb
|
@@ -180,7 +180,6 @@ metadata:
|
|
180
180
|
documentation_url: http://docs.decko.org/
|
181
181
|
card-mod: carrierwave
|
182
182
|
card-mod-group: gem-defaults
|
183
|
-
post_install_message:
|
184
183
|
rdoc_options: []
|
185
184
|
require_paths:
|
186
185
|
- lib
|
@@ -188,15 +187,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
188
187
|
requirements:
|
189
188
|
- - ">="
|
190
189
|
- !ruby/object:Gem::Version
|
191
|
-
version: '3.
|
190
|
+
version: '3.2'
|
192
191
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
192
|
requirements:
|
194
193
|
- - ">="
|
195
194
|
- !ruby/object:Gem::Version
|
196
195
|
version: '0'
|
197
196
|
requirements: []
|
198
|
-
rubygems_version: 3.
|
199
|
-
signing_key:
|
197
|
+
rubygems_version: 3.6.8
|
200
198
|
specification_version: 4
|
201
199
|
summary: File and Image handling
|
202
200
|
test_files: []
|
@@ -1,2 +0,0 @@
|
|
1
|
-
// upload.js.coffee
|
2
|
-
(function(){var e;decko.editors.init[".file-upload"]=function(){return decko.upload_file(this)},$.extend(decko,{upload_file:function(e){var t;return $(e).on("fileuploadsubmit",function(e,t){var r,i,a;return i=(r=$(this)).siblings(".attachment_card_name:first").attr("name"),a=r.siblings("#attachment_type_id").val(),t.formData={"card[type_id]":a,attachment_upload:i}}),t=$(e).closest("form").attr("action").indexOf("update")>-1?"card/update/"+$(e).siblings("#file_card_name").val():"card/create",$(e).fileupload({url:decko.path(t),dataType:"html",done:decko.doneFile,add:decko.chooseFile,progressall:decko.progressallFile})},chooseFile:function(e,t){var r;return t.form.find("button[type=submit]").attr("disabled",!0),r=$(this).closest(".card-editor"),$("#progress").show(),r.append('<input type="hidden" class="extra_upload_param" value="true" name="attachment_upload">'),r.append('<input type="hidden" class="extra_upload_param" value="preview_editor" name="view">'),t.submit(),r.find(".choose-file").hide(),r.find(".extra_upload_param").remove()},progressallFile:function(e,t){var r;return r=parseInt(t.loaded/t.total*100,10),$("#progress .progress-bar").css("width",r+"%")},doneFile:function(e,t){return $(this).closest(".card-editor").find(".chosen-file").replaceWith(t.result),t.form.find("button[type=submit]").attr("disabled",!1)}}),$(window).ready(function(){return $("body").on("click",".cancel-upload",function(){var e;return(e=$(this).closest(".card-editor")).find(".choose-file").show(),e.find(".chosen-file").empty(),e.find(".progress").show(),e.find("#progress .progress-bar").css("width","0%"),e.find("#progress").hide()}),$("body").on("submit","form",function(){return e(this,!0)}),$("body").on("ajax:complete","form",function(){return e(this,!1)})}),e=function(e,t){var r;if((r=$(e).find(".file-upload[type=file]"))[0])return r.prop("disabled",t)}}).call(this);
|