no-style-please2-plugins 0.10.0 → 0.11.1
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 +61 -17
- 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: afe6e6995a5c47069cd2b21d4e48a1cf29afab98905f355f227e1241cb30ee4b
|
4
|
+
data.tar.gz: 2c09e5836ff991484ad4ed9bd62e3c3b48e1be398bd77c66f17687bcdc854f13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: faa96fe0004c5b9a525f5feb106aaf68ad788e2659a0aaea1d3662ac3b0b177a957215e6e37adab275f2e532f9f7b53eef05be249d92ef83a2c9cefd8ae1ee44
|
7
|
+
data.tar.gz: 29a9c97558cce0c387fda8a94163ffe5cb75e9d171e65424e7dcf74c25d6df2d90593e09613ab24a5d0749187141cd0a764609990b51ca12a3cddac9801d699a
|
data/lib/ext.rb
CHANGED
@@ -127,7 +127,7 @@ module Jekyll
|
|
127
127
|
|
128
128
|
def initialize(tag_name, text, tokens)
|
129
129
|
rootPath0 = $g_config['include_file_path'] || 'assets'
|
130
|
-
filePath0 = "#{rootPath0}/#{text}".strip
|
130
|
+
filePath0 = "#{rootPath0}/#{text}".strip()
|
131
131
|
begin
|
132
132
|
file = File.open(filePath0)
|
133
133
|
@filecontent = file.read()
|
@@ -152,9 +152,9 @@ module Jekyll
|
|
152
152
|
|
153
153
|
rootPath = $g_config['code_root_path'] || 'static'
|
154
154
|
if text.start_with?("/")
|
155
|
-
filePath = "#{text}"[1..-1].strip
|
155
|
+
filePath = "#{text}"[1..-1].strip()
|
156
156
|
else
|
157
|
-
filePath = "#{rootPath}/#{text}".strip
|
157
|
+
filePath = "#{rootPath}/#{text}".strip()
|
158
158
|
end
|
159
159
|
filePath = File.expand_path(filePath)
|
160
160
|
puts "--------- include code: #{filePath}"
|
@@ -183,31 +183,75 @@ EOF
|
|
183
183
|
|
184
184
|
|
185
185
|
class IncludeRaw < Liquid::Tag
|
186
|
-
|
187
|
-
|
188
|
-
|
186
|
+
Syntax = /\s*file\s*=\s*(\S+)/
|
187
|
+
|
188
|
+
|
189
|
+
def getPath(text,context)
|
189
190
|
rootPath = $g_config['code_root_path'] || 'static'
|
190
191
|
if text.start_with?("/")
|
191
|
-
filePath = "#{text}"[1..-1].strip
|
192
|
+
filePath = "#{text}"[1..-1].strip()
|
193
|
+
filePath = File.expand_path(filePath)
|
194
|
+
elsif text.start_with?("@")
|
195
|
+
# _include/
|
196
|
+
filePath = "#{text}"[1..-1].strip()
|
197
|
+
|
198
|
+
|
199
|
+
site = context.registers[:site]
|
200
|
+
user_include_path = File.join(site.source, "_includes", filePath)
|
201
|
+
|
202
|
+
site = Jekyll.sites.first # 或你自己已有的 site
|
203
|
+
theme = site.theme
|
204
|
+
|
205
|
+
themeroot = theme.root # 就是当前主题的根目录
|
206
|
+
plugin_include_file = File.join(themeroot, "_includes/" + filePath)
|
207
|
+
|
208
|
+
if File.exist?(user_include_path)
|
209
|
+
filePath = user_include_path
|
210
|
+
elsif File.exist?(plugin_include_file)
|
211
|
+
filePath = plugin_include_file
|
212
|
+
else
|
213
|
+
filePath = user_include_path
|
214
|
+
end
|
215
|
+
|
216
|
+
|
192
217
|
else
|
193
|
-
filePath = "#{rootPath}/#{text}".strip
|
218
|
+
filePath = "#{rootPath}/#{text}".strip()
|
219
|
+
filePath = File.expand_path(filePath)
|
194
220
|
end
|
195
|
-
|
196
|
-
|
221
|
+
return filePath
|
222
|
+
end
|
223
|
+
def initialize(tag_name, text, tokens)
|
224
|
+
|
225
|
+
@file = ""
|
226
|
+
@dynamicFile = ""
|
227
|
+
|
228
|
+
if text =~ Syntax
|
229
|
+
dynfile = Regexp.last_match(1)
|
230
|
+
@dynamicFile = dynfile.gsub(/^['"]|['"]$/, '')
|
231
|
+
else
|
232
|
+
@filename = text.gsub(/^['"]|['"]$/, '')
|
233
|
+
end
|
234
|
+
|
235
|
+
|
197
236
|
|
237
|
+
end
|
238
|
+
|
239
|
+
def render(context)
|
240
|
+
filePath = @filename
|
241
|
+
if @dynamicFile.length > 1
|
242
|
+
filePath = context[@dynamicFile]
|
243
|
+
end
|
244
|
+
filePath = getPath(filePath,context)
|
245
|
+
|
246
|
+
puts "include_raw :#{filePath} failed #{@dynamicFile}"
|
198
247
|
begin
|
199
248
|
file = File.open(filePath)
|
200
|
-
|
249
|
+
return file.read()
|
201
250
|
rescue => exception
|
202
251
|
puts exception
|
203
|
-
|
252
|
+
return "Load file:#{filePath} failed #{@dynamicFile}"
|
204
253
|
|
205
254
|
end
|
206
|
-
|
207
|
-
end
|
208
|
-
|
209
|
-
def render(context)
|
210
|
-
return @filecontent
|
211
255
|
end
|
212
256
|
end
|
213
257
|
|
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.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vitock
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-04-
|
11
|
+
date: 2025-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|