html-pipeline-gitlab 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a04526910d21f11a1ed3fb6454963fa945d735b
|
4
|
+
data.tar.gz: aa1094422047dd9abc6f21f256db333d5bd822b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4534b8f0a609dc402022277731c89c79eb5f6092c1ef262539872db562691c32d01cde63f9d1d90af2d2aaa5e3ad838859b047f96f794e81f68f21dfca36d89b
|
7
|
+
data.tar.gz: 7fff5f62c408bb0fe8a39961ee60800642d25c9652c274bf66148e0a941f334d105566b816ec798ffe2e37a29af67a813194bfd6cdd75a8fc865e5c8b95098e2
|
@@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_runtime_dependency 'gitlab_emoji', '~> 0.0.1'
|
27
27
|
spec.add_runtime_dependency 'sanitize', '~> 2.1'
|
28
28
|
spec.add_runtime_dependency 'actionpack', '~> 4'
|
29
|
-
spec.add_runtime_dependency '
|
29
|
+
spec.add_runtime_dependency 'mime-types'
|
30
30
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'base64'
|
2
|
-
require '
|
2
|
+
require 'mime-types'
|
3
3
|
require 'html/pipeline/filter'
|
4
4
|
require 'uri'
|
5
5
|
|
@@ -28,19 +28,13 @@ module HTML
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def base64_encode_image(file_path)
|
31
|
-
|
32
|
-
|
33
|
-
img.strip!
|
34
|
-
if img.filesize > 100_000
|
35
|
-
img.format = 'JPG'
|
36
|
-
# Resize it to be maximum 600px * 600px.
|
37
|
-
img.resize_to_fit!(600, 600)
|
38
|
-
encoded_image = Base64.encode64(img.to_blob { self.quality = 60 })
|
39
|
-
else
|
40
|
-
encoded_image = Base64.encode64(img.to_blob)
|
41
|
-
end
|
31
|
+
mime_type = MIME::Types.type_for(file_path).first
|
32
|
+
return nil if mime_type.nil?
|
42
33
|
|
43
|
-
|
34
|
+
content_type = mime_type.content_type
|
35
|
+
img = File.read(file_path)
|
36
|
+
encoded_image = Base64.encode64(img)
|
37
|
+
"data:#{content_type};base64,#{encoded_image}"
|
44
38
|
end
|
45
39
|
|
46
40
|
def get_file_path(url, upload_path, base_url)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html-pipeline-gitlab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Schilling
|
@@ -110,7 +110,7 @@ dependencies:
|
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '4'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
|
-
name:
|
113
|
+
name: mime-types
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
116
|
- - ">="
|