no-style-please2-plugins 0.11.2 → 0.11.3
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 +4 -4
- data/lib/enc.rb +5 -0
- data/lib/ext.rb +45 -0
- data/lib/version/version.rb +1 -1
- data/test.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6a7bd011e093cf19ae22dc2851898347f1afd2f247eb8c81274e2fd03e5f474
|
4
|
+
data.tar.gz: 693b524f338b58300871fa5db936802e527205d80aa7e04f59bd068de67128e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9aa78868e4f312f3006b7a7664485279ebe4b3e4eea7e7ca05a75d5f03e5041458db7a3a5c5f8f0f5178addeab690390b51e55be8c352c144973289abddaf0ce
|
7
|
+
data.tar.gz: 76e836b48a804ef7acf37a95614f363b8ab91eb334848f5eecb52223750fba431c64b484cc1d74ab03cad1b0521ca40ab1a897796ee7fe19492035600603268e
|
data/lib/enc.rb
CHANGED
data/lib/ext.rb
CHANGED
@@ -2,6 +2,7 @@ require "jekyll"
|
|
2
2
|
require "liquid"
|
3
3
|
require "fileutils"
|
4
4
|
require 'base64'
|
5
|
+
require 'enc'
|
5
6
|
module Jekyll
|
6
7
|
class RenderTimeTag < Liquid::Tag
|
7
8
|
|
@@ -35,6 +36,24 @@ module Jekyll
|
|
35
36
|
@img_width = arr[1]
|
36
37
|
end
|
37
38
|
end
|
39
|
+
|
40
|
+
def guess_image_mime_by_base64(base64_str)
|
41
|
+
prefix = base64_str[0, 15] # 取前 15 个字符足够判断
|
42
|
+
|
43
|
+
case
|
44
|
+
when prefix.start_with?('/9j/')
|
45
|
+
'image/jpeg'
|
46
|
+
when prefix.start_with?('iVBOR')
|
47
|
+
'image/png'
|
48
|
+
when prefix.start_with?('R0lGODdh', 'R0lGODlh')
|
49
|
+
'image/gif'
|
50
|
+
when prefix.start_with?('UklGR')
|
51
|
+
'image/webp'
|
52
|
+
else
|
53
|
+
'image/png'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
38
57
|
|
39
58
|
def render(context)
|
40
59
|
path = context['page']['path']
|
@@ -50,6 +69,32 @@ module Jekyll
|
|
50
69
|
link = "#{base}/pics/#{dirPath}/#{@img_name}"
|
51
70
|
end
|
52
71
|
|
72
|
+
enc = EncFilterClass.new
|
73
|
+
encid = enc.get_encrypt_id('',context['page'])
|
74
|
+
if !encid.nil? && encid.length > 0
|
75
|
+
begin
|
76
|
+
file = File.open(File.expand_path("pics/#{dirPath}/#{@img_name}"))
|
77
|
+
b64 = Base64.strict_encode64 file.read()
|
78
|
+
link = "data:image/#{guess_image_mime_by_base64(b64)};base64," + b64
|
79
|
+
puts "Encrypt img #{"pics/#{dirPath}/#{@img_name}"}"
|
80
|
+
rescue => exception
|
81
|
+
puts "\n----------------------------"
|
82
|
+
puts exception
|
83
|
+
|
84
|
+
puts "\nEncrypt img #{"pics/#{dirPath}/#{@img_name}"} Fail"
|
85
|
+
puts "----------------------------"
|
86
|
+
|
87
|
+
link = 'ERROR '
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
else
|
95
|
+
end
|
96
|
+
|
97
|
+
|
53
98
|
if @img_width != nil
|
54
99
|
return "<img src='#{link}' style='width:#{@img_width}px'>"
|
55
100
|
else
|
data/lib/version/version.rb
CHANGED
data/test.rb
CHANGED