ufujs-rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +63 -0
- data/lib/assets/javascripts/jquery_ufujs.coffee +11 -0
- data/lib/ufujs-rails/version.rb +5 -0
- data/lib/ufujs-rails.rb +6 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7ef345d3307eb01f8d1d9adf799012b00d9e13f4
|
4
|
+
data.tar.gz: 1f28e5ca4005a65f52ceb2be69de784a75655a35
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7f6cd9a9ac4502f8628320834e898ab3c8b87aa6e5195d29715b6ab992ed9676c7be76695d9eeec2a5be475ca90ff9f1393a83c537b45a287e29166d9ccd31d8
|
7
|
+
data.tar.gz: 466212cd8c15cabd51a043d185060fe086043adad63e713f10122db317a29b79d6210574bce4554e8aa62102e7c98998b40e5cb22ea18a58b5226465fe212515
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
Unobtrusive File Upload adapter for jQuery UJS and Rails
|
2
|
+
-
|
3
|
+
|
4
|
+
This gem takes care about file uploads for remote form.
|
5
|
+
It is a simple alternative for [remotipart](https://github.com/JangoSteve/remotipart) gem for rails.
|
6
|
+
But instead of using iframe for file uploads this gem uses the base64 encoding to send the file to the server.
|
7
|
+
|
8
|
+
Installing
|
9
|
+
-
|
10
|
+
|
11
|
+
Add it to your Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'ufujs-rails'
|
15
|
+
gem 'carrierwave-base64'
|
16
|
+
```
|
17
|
+
|
18
|
+
Then run `bundle install` to update your application's bundle.
|
19
|
+
|
20
|
+
And in `application.js` under the `jquery_ujs`:
|
21
|
+
|
22
|
+
```javascript
|
23
|
+
//= require jquery_ufujs
|
24
|
+
```
|
25
|
+
|
26
|
+
Usage
|
27
|
+
-
|
28
|
+
|
29
|
+
This gem encode the base64 string on the client side.
|
30
|
+
Use [carrierwave-base64](https://github.com/lebedev-yury/carrierwave-base64) to handle the decoding on the server side.
|
31
|
+
|
32
|
+
Active Record
|
33
|
+
=
|
34
|
+
|
35
|
+
Mount the uploader: `mount_base64_uploader :image, ImageUploader`
|
36
|
+
|
37
|
+
Filter Parameters
|
38
|
+
=
|
39
|
+
To keep your logs clean you can add the filter with name of you attribute to `config/initializers/filter_paremeter_logging.rb`:
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
config.filter_parameters += [:image]
|
43
|
+
```
|
44
|
+
|
45
|
+
Browser Compatibility
|
46
|
+
-
|
47
|
+
|
48
|
+
IE10 +
|
49
|
+
Chrome
|
50
|
+
Firefox
|
51
|
+
Opera
|
52
|
+
Safari
|
53
|
+
|
54
|
+
If you care about IE9 and lower, don't worry I am sure that you will have the white line in your life soon.
|
55
|
+
|
56
|
+
For IE9 and lower form will be submited as `HTML`.
|
57
|
+
You just have to add the `authenticity_token` option to your form
|
58
|
+
|
59
|
+
```slim
|
60
|
+
= form_for @record, remote: true, authenticity_token: true do
|
61
|
+
```
|
62
|
+
|
63
|
+
Copyright© Alex Galushka
|
@@ -0,0 +1,11 @@
|
|
1
|
+
$(document).on 'ajax:aborted:file', 'form', (e, inputs) ->
|
2
|
+
j = 1
|
3
|
+
form = $(@)
|
4
|
+
$.map inputs, (input, i) ->
|
5
|
+
fr = new FileReader()
|
6
|
+
fr.readAsDataURL(input.files[0])
|
7
|
+
fr.onload = ->
|
8
|
+
form.append("<input type='hidden' name='#{input.name}' value='#{fr.result}' />")
|
9
|
+
$.rails.handleRemote(form) if (inputs.length == j)
|
10
|
+
j++
|
11
|
+
return false
|
data/lib/ufujs-rails.rb
ADDED
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ufujs-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Galushka
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jquery-rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Unobtrusive File Upload adapter for jQuery UJS and Rails.
|
28
|
+
email:
|
29
|
+
- galulex@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- README.md
|
35
|
+
- lib/assets/javascripts/jquery_ufujs.coffee
|
36
|
+
- lib/ufujs-rails.rb
|
37
|
+
- lib/ufujs-rails/version.rb
|
38
|
+
homepage: https://github.com/active-bridge/ufujs-rails
|
39
|
+
licenses: []
|
40
|
+
metadata: {}
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 2.4.5
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: Dead simple remove file uploader for Rails
|
61
|
+
test_files: []
|