no-style-please2-plugins 0.4.2 → 0.5.0

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
  SHA256:
3
- metadata.gz: 05d235704b099fe3023235fb4797174a87f9e1d49e51c82d397ac9d697d68f17
4
- data.tar.gz: 4b48165a07d9f74543611812d132a49ee125e82dfd989b4b370f7d2f9625b0f9
3
+ metadata.gz: 6ce217454acd101d7d2885044d9675b60e5bc7404a454a622d2b1210b22be12a
4
+ data.tar.gz: babeb067c289bdd08b650639d50973ea111b92b202fd979a0e2b79d5470dba02
5
5
  SHA512:
6
- metadata.gz: 921f81bc1fa1760118cd40a5f713f53e4fae917a7692b0fe23606c534c1ec0e9e45ff61c7a42b915fed5f4ee711a1808e806d8591f930081cbec5c45af54a706
7
- data.tar.gz: b9dd3ccbb742348847eafd97a134b26f8982f4c2da4c0cc935ee0fdf8ce1e74025b2af9e34c2fcd25dda9e9fcb80ed712be1ea1e8d8eed5257770f5c2b632e00
6
+ metadata.gz: 8ea12bce7eee576a03595b149a526f8a3286677099ad8778d00e81ed9a71e68e83128d1fe44449114ead0dcc64fff13625b932d78b793d959514f4d1f437ef23
7
+ data.tar.gz: a5e75cc87025cdc350bf6b3184271bd55636d25cd0d3e2c6a7c418b3fbcff39408696600acd7cb2095a4a6c5b6554e9a56d6802f3bf4d3665f7dfc9ae5842cfa
data/README.md CHANGED
@@ -1,8 +1,13 @@
1
- # No::Style::Please2::Plugins
2
1
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/no/style/please2/plugins`. To experiment with that code, run `bin/console` for an interactive prompt.
2
+ this is jekyll plugin for no-style-please2 theme
4
3
 
5
- TODO: Delete this and the text above, and describe your gem
4
+ ## Feature
5
+ + tag support, this plugin will create tag page if you add tags in your post
6
+ + liquid tags
7
+ + post_link ,link to post via title
8
+ + img_link ,link to a image
9
+ + asset_img insert a picture into the post content
10
+ + encryption support. encrypt the post content. you can set password for tag, or set a password in the post front matter. password will be encrypted by ECC cryption.
6
11
 
7
12
  ## Installation
8
13
 
@@ -16,7 +21,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
16
21
 
17
22
  ## Usage
18
23
 
19
- TODO: Write usage instructions here
24
+ see this [demo](https://vitock.ink/no-style-please-demo/)
20
25
 
21
26
  ## Development
22
27
 
@@ -26,4 +31,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
26
31
 
27
32
  ## Contributing
28
33
 
29
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/no-style-please2-plugins.
34
+ Bug reports and pull requests are welcome on GitHub at https://github.com/vitock/no-style-please2-plugins.
data/gem.gemspec CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
 
35
35
  spec.add_dependency "jekyll", "~>4.0"
36
36
  spec.add_dependency "ltec", "~> 0.1.2"
37
- spec.add_dependency "salsa20", "~> 0.1.3"
37
+ # spec.add_dependency "salsa20", "~> 0.1.3"
38
38
  spec.add_dependency "digest"
39
39
  # Uncomment to register a new dependency of your gem
40
40
  # spec.add_dependency "example-gem", "~> 1.0"
data/lib/enc.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'openssl'
2
2
  require 'base64'
3
- require 'salsa20'
4
3
  require 'digest'
5
4
  require 'ltec'
6
5
  require "jekyll"
@@ -58,6 +57,25 @@ module Jekyll
58
57
  end
59
58
  end
60
59
  module EncFilter
60
+
61
+ def genKey(password)
62
+ salt = 'this is a salt string 20221019'
63
+ iter = 12345
64
+ key_len = 32
65
+ key = OpenSSL::KDF.pbkdf2_hmac(password, salt: salt, iterations: iter,
66
+ length: key_len, hash: "sha256")
67
+ return key
68
+ end
69
+
70
+ def encrypt(msg,password)
71
+ cipher = OpenSSL::Cipher::AES.new(256, :GCM).encrypt
72
+ iv = cipher.random_iv
73
+ cipher.iv = iv
74
+ cipher.key = genKey password
75
+ encrypted = cipher.update(msg) + cipher.final
76
+ return 'E1.' + Base64.strict_encode64(iv + encrypted + cipher.auth_tag)
77
+
78
+ end
61
79
  def get_encrypt_id(content,page)
62
80
  key = EncFilterTool.getKey(content,page)
63
81
  if key != nil && key.length > 0
@@ -68,15 +86,9 @@ module Jekyll
68
86
  end
69
87
 
70
88
  def encrypt_content(content,page,prefix)
71
- keyOri = EncFilterTool.getKey(content,page)
72
- keyOri = prefix + keyOri + prefix
73
- key = Digest::MD5.hexdigest(keyOri).downcase()
74
- iv = Digest::MD5.hexdigest(content).downcase()
75
- ivHex = iv[0...16]
76
- iv = ivHex.scan(/../).map { |x| x.hex.chr }.join
77
- encryptor = Salsa20.new(key, iv)
78
- encrypted_text = encryptor.encrypt(content)
79
- return ivHex + ":" + Base64.strict_encode64(encrypted_text)
89
+ psw = EncFilterTool.getKey(content,page)
90
+ psw = prefix + psw + prefix
91
+ return encrypt content,psw
80
92
  end
81
93
 
82
94
 
data/lib/ext.rb CHANGED
@@ -27,7 +27,12 @@ module Jekyll
27
27
 
28
28
 
29
29
  def initialize(tag_name, text, tokens)
30
- @img_name = text.strip
30
+ arr = text.strip.split(" ")
31
+ @img_name = arr[0]
32
+ @img_width = nil
33
+ if arr.count > 1
34
+ @img_width = arr[1]
35
+ end
31
36
  end
32
37
 
33
38
  def render(context)
@@ -43,7 +48,14 @@ module Jekyll
43
48
  if base && base.length
44
49
  link = "#{base}/pics/#{dirPath}/#{@img_name}"
45
50
  end
46
- return "![](#{link})"
51
+
52
+ if @img_width != nil
53
+ return "<img src='#{link}' style='width:#{@img_width}px'>"
54
+ else
55
+ return "![](#{link})"
56
+ end
57
+
58
+
47
59
  end
48
60
  end
49
61
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NoStylePlease2
4
- VERSION = "0.4.2"
4
+ VERSION = "0.5.0"
5
5
  end
data/test.rb CHANGED
@@ -1,9 +1,54 @@
1
1
  #!/usr/bin/env ruby
2
- # require "ltec"
3
- # require "nostyleplease2plugins"
4
-
5
- # Jekyll::test
6
-
7
- a = '12-3'
8
- b = a.split(' ',2)
9
- print b
2
+
3
+ require 'openssl'
4
+ require 'base64'
5
+ def genKey(password)
6
+ salt = 'this is a salt string 20221019'
7
+ iter = 12345
8
+ key_len = 32
9
+ key = OpenSSL::KDF.pbkdf2_hmac(password, salt: salt, iterations: iter,
10
+ length: key_len, hash: "sha256")
11
+ return key
12
+ end
13
+
14
+ def encrypt(msg,password)
15
+
16
+ cipher = OpenSSL::Cipher::AES.new(256, :GCM).encrypt
17
+ iv = cipher.random_iv
18
+ cipher.iv = iv
19
+ cipher.key = genKey password
20
+ encrypted = cipher.update(msg) + cipher.final
21
+ return 'E1.' + Base64.strict_encode64(iv + encrypted + cipher.auth_tag)
22
+
23
+ end
24
+
25
+
26
+ def decrypt(enstring,password)
27
+ b64 = enstring[3..-1]
28
+ data = Base64.strict_decode64 b64
29
+
30
+ len = data.bytesize
31
+ iv = data[0...12]
32
+ auth_tag = data[0...16] #data[len-16..-1]
33
+ encdata = data[12...len-16]
34
+
35
+
36
+ cipher = OpenSSL::Cipher::AES.new(256, :GCM).decrypt
37
+ cipher.iv = iv
38
+ cipher.key = genKey password
39
+ # cipher.auth_tag = '1234567890123456'
40
+
41
+ result = cipher.update(encdata)
42
+ return result
43
+
44
+ end
45
+
46
+
47
+ msg = '我的 12a23007'
48
+ z = encrypt msg,'123'
49
+ puts z
50
+
51
+ puts z[3..-1]
52
+
53
+ m = decrypt z ,'123'
54
+ puts m
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: no-style-please2-plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vitock
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-30 00:00:00.000000000 Z
11
+ date: 2022-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.1.2
41
- - !ruby/object:Gem::Dependency
42
- name: salsa20
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 0.1.3
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 0.1.3
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: digest
57
43
  requirement: !ruby/object:Gem::Requirement