no-style-please2-plugins 0.11.1 → 0.11.2
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/ext.rb +75 -1
- data/lib/version/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4019f862d9afa74d95a4bcacd0f2c401eaf5e6317f62104582838f65c9b39b7
|
4
|
+
data.tar.gz: e0fd447728fc26818fc8a78a12a99c4566ffb332cd05aa392aa5f61e75958854
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b61c348fa5d6269cf1a2563846a381dd7aebc1b0b73577a7f6b5f9779e7c1fb209ebec001c22f28a84a84f06ff554c0ac80828708266db59706def47c990db5a
|
7
|
+
data.tar.gz: 0edd0b4a9dbb59130998f7061de8f834645b0609dd4795e79609c9a311acc28533a2295c1522beafd95f996491195df7a33d8a18acace67df32245d89473559e
|
data/lib/ext.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "jekyll"
|
2
2
|
require "liquid"
|
3
3
|
require "fileutils"
|
4
|
-
|
4
|
+
require 'base64'
|
5
5
|
module Jekyll
|
6
6
|
class RenderTimeTag < Liquid::Tag
|
7
7
|
|
@@ -255,6 +255,78 @@ EOF
|
|
255
255
|
end
|
256
256
|
end
|
257
257
|
|
258
|
+
|
259
|
+
class FileBase64 < Liquid::Tag
|
260
|
+
Syntax = /\s*file\s*=\s*(\S+)/
|
261
|
+
|
262
|
+
|
263
|
+
def getPath(text,context)
|
264
|
+
rootPath = $g_config['code_root_path'] || 'static'
|
265
|
+
if text.start_with?("/")
|
266
|
+
filePath = "#{text}"[1..-1].strip()
|
267
|
+
filePath = File.expand_path(filePath)
|
268
|
+
elsif text.start_with?("@")
|
269
|
+
# _include/
|
270
|
+
filePath = "#{text}"[1..-1].strip()
|
271
|
+
|
272
|
+
|
273
|
+
site = context.registers[:site]
|
274
|
+
user_include_path = File.join(site.source, "_includes", filePath)
|
275
|
+
|
276
|
+
site = Jekyll.sites.first # 或你自己已有的 site
|
277
|
+
theme = site.theme
|
278
|
+
|
279
|
+
themeroot = theme.root # 就是当前主题的根目录
|
280
|
+
plugin_include_file = File.join(themeroot, "_includes/" + filePath)
|
281
|
+
|
282
|
+
if File.exist?(user_include_path)
|
283
|
+
filePath = user_include_path
|
284
|
+
elsif File.exist?(plugin_include_file)
|
285
|
+
filePath = plugin_include_file
|
286
|
+
else
|
287
|
+
filePath = user_include_path
|
288
|
+
end
|
289
|
+
|
290
|
+
|
291
|
+
else
|
292
|
+
filePath = "#{rootPath}/#{text}".strip()
|
293
|
+
filePath = File.expand_path(filePath)
|
294
|
+
end
|
295
|
+
return filePath
|
296
|
+
end
|
297
|
+
def initialize(tag_name, text, tokens)
|
298
|
+
|
299
|
+
@file = ""
|
300
|
+
@dynamicFile = ""
|
301
|
+
|
302
|
+
if text =~ Syntax
|
303
|
+
dynfile = Regexp.last_match(1)
|
304
|
+
@dynamicFile = dynfile.gsub(/^['"]|['"]$/, '')
|
305
|
+
else
|
306
|
+
@filename = text.gsub(/^['"]|['"]$/, '')
|
307
|
+
end
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
end
|
312
|
+
|
313
|
+
def render(context)
|
314
|
+
filePath = @filename
|
315
|
+
if @dynamicFile.length > 1
|
316
|
+
filePath = context[@dynamicFile]
|
317
|
+
end
|
318
|
+
filePath = getPath(filePath,context)
|
319
|
+
|
320
|
+
begin
|
321
|
+
file = File.open(filePath)
|
322
|
+
return Base64.strict_encode64 file.read()
|
323
|
+
rescue => exception
|
324
|
+
puts exception
|
325
|
+
return "Base64 file:#{filePath} failed #{@dynamicFile}"
|
326
|
+
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|
258
330
|
|
259
331
|
|
260
332
|
|
@@ -263,6 +335,8 @@ EOF
|
|
263
335
|
Liquid::Template.register_tag('asset_img', Jekyll::AssetImg)
|
264
336
|
Liquid::Template.register_tag('include_code', Jekyll::IncludeCode)
|
265
337
|
Liquid::Template.register_tag('include_raw', Jekyll::IncludeRaw)
|
338
|
+
Liquid::Template.register_tag('file_base64', Jekyll::FileBase64)
|
339
|
+
|
266
340
|
|
267
341
|
|
268
342
|
Liquid::Template.register_tag('post_link', Jekyll::PostLink)
|
data/lib/version/version.rb
CHANGED
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.11.
|
4
|
+
version: 0.11.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vitock
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|