kuppayam 0.1.12 → 0.1.13

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: 24abab3e7660af35334f396237441417a64e825f
4
- data.tar.gz: 64e55c1fadbce666f2e2d5c5de97af770b10a063
3
+ metadata.gz: 11fda69588abad8951771263514377d28cf05047
4
+ data.tar.gz: 291c146e6a4c6753316d693c094236b63307826c
5
5
  SHA512:
6
- metadata.gz: 3ab29b837994d1eae4c3537223bd57e39829a10f9fb009bfc67afdd512d922184e02e1f94f7b0441b30a85abdb9ebccd4df2ebe36f4c8cc830534de0c0748a40
7
- data.tar.gz: 16eba03d23005b6e36029e05bd9e7a55bb46f82c716db60c52bf132dcfb4f0b582487db5b02a1de260ac995cf0c443f1b04722cafe0a78176802c75f8b7ae9b9
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
@@ -1,3 +1,5 @@
1
+ require 'filesize'
2
+
1
3
  class Image::Base < Kuppayam::ApplicationRecord
2
4
 
3
5
  # Constants
@@ -0,0 +1,7 @@
1
+ module NullAttributeReplacer
2
+ def serializable_hash(adapter_options = nil, options = {}, adapter_instance = self.class.serialization_adapter_instance)
3
+ hash = super
4
+ hash.each { |key, value| hash[key] = "" if value.nil? }
5
+ hash
6
+ end
7
+ end
@@ -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
- # include CarrierWave::MiniMagick
6
+ # include CarrierWave::RMagick
7
+ include CarrierWave::MiniMagick
8
8
 
9
9
  # Choose what kind of storage to use for this uploader:
10
- # storage Rails.env.production? ? :fog : :file
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,11 @@
1
+ class ActiveSupport::TimeWithZone
2
+ def as_json(options = {})
3
+ strftime('%d-%m-%Y %H:%M:%S')
4
+ end
5
+ end
6
+
7
+ class Date
8
+ def as_json(options = nil) #:nodoc:
9
+ strftime("%d-%m-%Y")
10
+ end
11
+ end
@@ -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}"
@@ -1,3 +1,3 @@
1
1
  module Kuppayam
2
- VERSION = '0.1.12'
2
+ VERSION = '0.1.13'
3
3
  end
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.12
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-18 00:00:00.000000000 Z
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: rmagick
198
+ name: mini_magick
199
199
  requirement: !ruby/object:Gem::Requirement
200
200
  requirements:
201
201
  - - "~>"
202
202
  - !ruby/object:Gem::Version
203
- version: 2.13.3
203
+ version: 4.8.0
204
204
  - - ">="
205
205
  - !ruby/object:Gem::Version
206
- version: 2.13.2
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: 2.13.3
213
+ version: 4.8.0
214
214
  - - ">="
215
215
  - !ruby/object:Gem::Version
216
- version: 2.13.2
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