kuppayam 0.1.12 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/image_uploader_helper.rb +40 -0
- data/app/models/image/base.rb +2 -0
- data/app/serializers/null_attribute_replacer.rb +7 -0
- data/app/uploaders/image_uploader.rb +3 -3
- data/config/initializers/active_support_time_with_zone.rb +11 -0
- data/config/locales/kuppayam/carrierwave.en.yml +14 -0
- data/lib/kuppayam/version.rb +1 -1
- metadata +11 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11fda69588abad8951771263514377d28cf05047
|
4
|
+
data.tar.gz: 291c146e6a4c6753316d693c094236b63307826c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 864bdbdb3928fe2f88d5cc8386b2c78442bce40aa4e2dfbf922d30c592b8f595ff877d3eaa74c790eb4c1b0ef0cf07f2c6b3b299f7055478799f026e2a472386
|
7
|
+
data.tar.gz: 1fb1142f4cba699e3d23e9f6890879cf2f63591aded4dc8dc27038ec42acfd2483d61b7daaab1b0aa3c7033073c89eb872cefceaa6fb94c513909997052abc3b
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module ImageUploaderHelper
|
2
|
+
|
3
|
+
#Reference: https://gist.github.com/ifightcrime/9291167a0a4367bb55a2
|
4
|
+
def image_params
|
5
|
+
params[:image_path] = parse_image_data(params[:image]) if params[:image]
|
6
|
+
params
|
7
|
+
end
|
8
|
+
|
9
|
+
def parse_image_data(base64_image)
|
10
|
+
filename = "upload-image"
|
11
|
+
in_content_type, encoding, string = base64_image.split(/[:;,]/)[1..3]
|
12
|
+
|
13
|
+
@tempfile = Tempfile.new(filename)
|
14
|
+
@tempfile.binmode
|
15
|
+
@tempfile.write Base64.decode64(string)
|
16
|
+
@tempfile.rewind
|
17
|
+
|
18
|
+
# for security we want the actual content type, not just what was passed in
|
19
|
+
content_type = `file --mime -b #{@tempfile.path}`.split(";")[0]
|
20
|
+
|
21
|
+
# we will also add the extension ourselves based on the above
|
22
|
+
# if it's not gif/jpeg/png, it will fail the validation in the upload model
|
23
|
+
extension = content_type.match(/gif|jpeg|png/).to_s
|
24
|
+
filename += ".#{extension}" if extension
|
25
|
+
|
26
|
+
ActionDispatch::Http::UploadedFile.new({
|
27
|
+
tempfile: @tempfile,
|
28
|
+
content_type: content_type,
|
29
|
+
filename: filename
|
30
|
+
})
|
31
|
+
end
|
32
|
+
|
33
|
+
def clean_tempfile
|
34
|
+
if @tempfile
|
35
|
+
@tempfile.close
|
36
|
+
@tempfile.unlink
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/app/models/image/base.rb
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
class ImageUploader < CarrierWave::Uploader::Base
|
4
4
|
|
5
5
|
# Include RMagick or MiniMagick support:
|
6
|
-
include CarrierWave::RMagick
|
7
|
-
|
6
|
+
# include CarrierWave::RMagick
|
7
|
+
include CarrierWave::MiniMagick
|
8
8
|
|
9
9
|
# Choose what kind of storage to use for this uploader:
|
10
|
-
|
10
|
+
storage Rails.env.production? ? :fog : :file
|
11
11
|
# storage :file
|
12
12
|
|
13
13
|
# Override the directory where uploaded files will be stored.
|
@@ -0,0 +1,14 @@
|
|
1
|
+
en:
|
2
|
+
errors:
|
3
|
+
messages:
|
4
|
+
carrierwave_processing_error: failed to be processed
|
5
|
+
carrierwave_integrity_error: is not of an allowed file type
|
6
|
+
carrierwave_download_error: could not be downloaded
|
7
|
+
extension_whitelist_error: "You are not allowed to upload %{extension} files, allowed types: %{allowed_types}"
|
8
|
+
extension_blacklist_error: "You are not allowed to upload %{extension} files, prohibited types: %{prohibited_types}"
|
9
|
+
content_type_whitelist_error: "You are not allowed to upload %{content_type} files"
|
10
|
+
content_type_blacklist_error: "You are not allowed to upload %{content_type} files"
|
11
|
+
rmagick_processing_error: "Failed to manipulate with rmagick, maybe it is not an image?"
|
12
|
+
mini_magick_processing_error: "Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: %{e}"
|
13
|
+
min_size_error: "File size should be greater than %{min_size}"
|
14
|
+
max_size_error: "File size should be less than %{max_size}"
|
data/lib/kuppayam/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kuppayam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kpvarma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -195,25 +195,25 @@ dependencies:
|
|
195
195
|
- !ruby/object:Gem::Version
|
196
196
|
version: 0.9.0
|
197
197
|
- !ruby/object:Gem::Dependency
|
198
|
-
name:
|
198
|
+
name: mini_magick
|
199
199
|
requirement: !ruby/object:Gem::Requirement
|
200
200
|
requirements:
|
201
201
|
- - "~>"
|
202
202
|
- !ruby/object:Gem::Version
|
203
|
-
version:
|
203
|
+
version: 4.8.0
|
204
204
|
- - ">="
|
205
205
|
- !ruby/object:Gem::Version
|
206
|
-
version:
|
206
|
+
version: 4.8.0
|
207
207
|
type: :development
|
208
208
|
prerelease: false
|
209
209
|
version_requirements: !ruby/object:Gem::Requirement
|
210
210
|
requirements:
|
211
211
|
- - "~>"
|
212
212
|
- !ruby/object:Gem::Version
|
213
|
-
version:
|
213
|
+
version: 4.8.0
|
214
214
|
- - ">="
|
215
215
|
- !ruby/object:Gem::Version
|
216
|
-
version:
|
216
|
+
version: 4.8.0
|
217
217
|
- !ruby/object:Gem::Dependency
|
218
218
|
name: rspec-rails
|
219
219
|
requirement: !ruby/object:Gem::Requirement
|
@@ -387,6 +387,7 @@ files:
|
|
387
387
|
- app/helpers/filter_helper.rb
|
388
388
|
- app/helpers/flash_helper.rb
|
389
389
|
- app/helpers/image_helper.rb
|
390
|
+
- app/helpers/image_uploader_helper.rb
|
390
391
|
- app/helpers/kuppayam_helper.rb
|
391
392
|
- app/helpers/meta_tags_helper.rb
|
392
393
|
- app/helpers/navigation_helper.rb
|
@@ -401,6 +402,7 @@ files:
|
|
401
402
|
- app/models/image/base.rb
|
402
403
|
- app/models/import_data.rb
|
403
404
|
- app/models/kuppayam/application_record.rb
|
405
|
+
- app/serializers/null_attribute_replacer.rb
|
404
406
|
- app/uploaders/document_uploader.rb
|
405
407
|
- app/uploaders/image_uploader.rb
|
406
408
|
- app/uploaders/import_data_uploader.rb
|
@@ -485,6 +487,7 @@ files:
|
|
485
487
|
- app/views/layouts/kuppayam/layout_horizontal_menu.html.erb
|
486
488
|
- app/views/layouts/kuppayam/print_a4.html.erb
|
487
489
|
- app/views/layouts/kuppayam/user.html.erb
|
490
|
+
- config/initializers/active_support_time_with_zone.rb
|
488
491
|
- config/initializers/config_center.rb
|
489
492
|
- config/initializers/importer.rb
|
490
493
|
- config/initializers/inflections.rb
|
@@ -493,6 +496,7 @@ files:
|
|
493
496
|
- config/locales/kuppayam/activerecord.en.yml
|
494
497
|
- config/locales/kuppayam/api.ar.yml
|
495
498
|
- config/locales/kuppayam/api.en.yml
|
499
|
+
- config/locales/kuppayam/carrierwave.en.yml
|
496
500
|
- config/locales/kuppayam/general.ar.yml
|
497
501
|
- config/locales/kuppayam/general.en.yml
|
498
502
|
- config/routes.rb
|