attache_rails 0.2.3 → 0.2.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c05f1c9700fcff236abe554ee5bff029d799dff
|
4
|
+
data.tar.gz: 688d2432bdb57cfa15cedafe56d0dec0deb461b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48a55b14c595316bd139959a225f6d5e9d93b5da87ca5fd95089c7b1b144f482af0143b6ff995e32d88fb4a30c2974b7f446c3845a783e25a080cbebf807eca6
|
7
|
+
data.tar.gz: 81d5d5005af6e89b301852a0af93a1aa3315d6f733ae64aa7bc6c7da323d8bb95dc5b894ef78799ef7da0b90ff44c87a0bc0e7491448022eb11e0b4360ad98b5
|
@@ -113,8 +113,9 @@ var AttacheFileInput = React.createClass({displayName: "AttacheFileInput",
|
|
113
113
|
result.src = that.props['data-downloadurl'] + '/' + parts.join('/');
|
114
114
|
result.filename = result.src.split('/').pop().split(/[#?]/).shift();
|
115
115
|
}
|
116
|
+
var previewKey = "preview" + key;
|
116
117
|
previews.push(
|
117
|
-
React.createElement("div", {className: "attache-file-input"},
|
118
|
+
React.createElement("div", {key: previewKey, className: "attache-file-input"},
|
118
119
|
React.createElement("input", {type: "hidden", name: that.props.name, value: json, readOnly: "true"}),
|
119
120
|
React.createElement(Preview, React.__spread({}, result, {key: key, onRemove: that.onRemove.bind(that, key)}))
|
120
121
|
)
|
@@ -124,14 +125,15 @@ var AttacheFileInput = React.createClass({displayName: "AttacheFileInput",
|
|
124
125
|
var placeholders = [];
|
125
126
|
if (previews.length == 0 && that.props['data-placeholder']) $.each(JSON.parse(that.props['data-placeholder']), function(uid, src) {
|
126
127
|
placeholders.push(
|
127
|
-
React.createElement(Placeholder, React.__spread({},
|
128
|
+
React.createElement(Placeholder, React.__spread({key: "placeholder"}, that.props, {src: src}))
|
128
129
|
);
|
129
130
|
});
|
130
131
|
|
131
132
|
var discards = [];
|
132
133
|
$.each(that.state.attaches_discarded, function(index, discard) {
|
134
|
+
var discardKey = "discard" + discard.path;
|
133
135
|
discards.push(
|
134
|
-
React.createElement("input", {type: "hidden", name: discard.fieldname, value: discard.path})
|
136
|
+
React.createElement("input", {key: discardKey, type: "hidden", name: discard.fieldname, value: discard.path})
|
135
137
|
);
|
136
138
|
});
|
137
139
|
|
@@ -113,8 +113,9 @@ var AttacheFileInput = React.createClass({
|
|
113
113
|
result.src = that.props['data-downloadurl'] + '/' + parts.join('/');
|
114
114
|
result.filename = result.src.split('/').pop().split(/[#?]/).shift();
|
115
115
|
}
|
116
|
+
var previewKey = "preview" + key;
|
116
117
|
previews.push(
|
117
|
-
<div className="attache-file-input">
|
118
|
+
<div key={previewKey} className="attache-file-input">
|
118
119
|
<input type="hidden" name={that.props.name} value={json} readOnly="true" />
|
119
120
|
<Preview {...result} key={key} onRemove={that.onRemove.bind(that, key)}/>
|
120
121
|
</div>
|
@@ -124,14 +125,15 @@ var AttacheFileInput = React.createClass({
|
|
124
125
|
var placeholders = [];
|
125
126
|
if (previews.length == 0 && that.props['data-placeholder']) $.each(JSON.parse(that.props['data-placeholder']), function(uid, src) {
|
126
127
|
placeholders.push(
|
127
|
-
<Placeholder
|
128
|
+
<Placeholder key="placeholder" {...that.props} src={src} />
|
128
129
|
);
|
129
130
|
});
|
130
131
|
|
131
132
|
var discards = [];
|
132
133
|
$.each(that.state.attaches_discarded, function(index, discard) {
|
134
|
+
var discardKey = "discard" + discard.path;
|
133
135
|
discards.push(
|
134
|
-
<input type="hidden" name={discard.fieldname} value={discard.path} />
|
136
|
+
<input key={discardKey} type="hidden" name={discard.fieldname} value={discard.path} />
|
135
137
|
);
|
136
138
|
});
|
137
139
|
|
data/lib/attache_rails/model.rb
CHANGED
@@ -21,7 +21,10 @@ module AttacheRails
|
|
21
21
|
|
22
22
|
def attache_upload_and_get_json(readable)
|
23
23
|
uri = URI.parse(ATTACHE_UPLOAD_URL)
|
24
|
-
|
24
|
+
original_filename = readable.try(:original_filename) ||
|
25
|
+
readable.try(:path) && File.basename(readable.try(:path)) ||
|
26
|
+
'noname'
|
27
|
+
uri.query = { file: original_filename, **attache_auth_options }.collect {|k,v|
|
25
28
|
CGI.escape(k.to_s) + "=" + CGI.escape(v.to_s)
|
26
29
|
}.join('&')
|
27
30
|
attache_retry_doing(3) { HTTPClient.post(uri, readable, {'Content-Type' => 'binary/octet-stream'}).body }
|
@@ -30,7 +33,7 @@ module AttacheRails
|
|
30
33
|
def attache_url_for(json_string, geometry)
|
31
34
|
JSON.parse(json_string).tap do |attrs|
|
32
35
|
prefix, basename = File.split(attrs['path'])
|
33
|
-
attrs['url'] = [ATTACHE_DOWNLOAD_URL, prefix, CGI.escape(geometry), basename].join('/')
|
36
|
+
attrs['url'] = [ATTACHE_DOWNLOAD_URL, prefix, CGI.escape(geometry), CGI.escape(basename)].join('/')
|
34
37
|
end
|
35
38
|
end
|
36
39
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attache_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- choonkeat
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|