middleman-mdocs 0.1.6 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +35 -33
- data/lib/middleman-mdocs/file_renderer_cache.rb +1 -1
- data/lib/middleman-mdocs/resource.rb +65 -18
- data/lib/middleman-mdocs/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbfbd40e49f58b11ba5a574c16976c4c13d74bffbc931a9600470ec8ea54cbe9
|
4
|
+
data.tar.gz: 409e96bc9d7e9023f15fc23b2d79bb7870387018bec1d2ec96142010a1bc266f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2547991a43fea03ad9c614548926bfe060d4bc46cc6908dbba07180238b9e97b64ac84184f8f841b346b0ab792fddd18d9262d2f12a6f625ef86a853e4013d07
|
7
|
+
data.tar.gz: 937f5865c60c4155ea4be1f7702a3bd44d1c8177ebd9ee35adfefaf9462f7283e4829f4f5a94f5db65268389bca155272de56807b25fe949e6cf668939d52443
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
middleman-mdocs (0.1.
|
4
|
+
middleman-mdocs (0.1.8)
|
5
5
|
activesupport
|
6
6
|
awesome_print
|
7
7
|
kramdown
|
@@ -18,43 +18,44 @@ PATH
|
|
18
18
|
GEM
|
19
19
|
remote: https://rubygems.org/
|
20
20
|
specs:
|
21
|
-
activesupport (5.2.
|
21
|
+
activesupport (5.2.8.1)
|
22
22
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
23
23
|
i18n (>= 0.7, < 2)
|
24
24
|
minitest (~> 5.1)
|
25
25
|
tzinfo (~> 1.1)
|
26
|
-
addressable (2.8.
|
27
|
-
public_suffix (>= 2.0.2, <
|
26
|
+
addressable (2.8.1)
|
27
|
+
public_suffix (>= 2.0.2, < 6.0)
|
28
28
|
ansi (1.5.0)
|
29
|
-
asciidoctor (2.0.
|
30
|
-
asciidoctor-plantuml (0.0.
|
31
|
-
asciidoctor (>=
|
29
|
+
asciidoctor (2.0.18)
|
30
|
+
asciidoctor-plantuml (0.0.16)
|
31
|
+
asciidoctor (>= 2.0.17, < 3.0.0)
|
32
32
|
ast (2.4.2)
|
33
33
|
awesome_print (1.9.2)
|
34
|
-
backports (3.
|
34
|
+
backports (3.23.0)
|
35
35
|
coffee-script (2.4.1)
|
36
36
|
coffee-script-source
|
37
37
|
execjs
|
38
38
|
coffee-script-source (1.12.2)
|
39
|
-
concurrent-ruby (1.1.
|
39
|
+
concurrent-ruby (1.1.10)
|
40
40
|
contracts (0.13.0)
|
41
41
|
diff-lcs (1.4.4)
|
42
42
|
docile (1.4.0)
|
43
|
-
dotenv (2.
|
43
|
+
dotenv (2.8.1)
|
44
44
|
erubis (2.7.0)
|
45
45
|
execjs (2.8.1)
|
46
|
-
exifr (1.3.
|
46
|
+
exifr (1.3.10)
|
47
47
|
fast_blank (1.0.1)
|
48
|
-
fastimage (2.2.
|
49
|
-
ffi (1.15.
|
48
|
+
fastimage (2.2.6)
|
49
|
+
ffi (1.15.5)
|
50
50
|
fspath (3.1.2)
|
51
|
-
gitlab_kramdown (0.
|
52
|
-
asciidoctor-plantuml (= 0.0.
|
53
|
-
kramdown (~> 2.
|
54
|
-
nokogiri (~> 1.
|
55
|
-
rouge (~>
|
56
|
-
haml (
|
57
|
-
temple (>= 0.8.
|
51
|
+
gitlab_kramdown (0.22.0)
|
52
|
+
asciidoctor-plantuml (= 0.0.16)
|
53
|
+
kramdown (~> 2.4.0)
|
54
|
+
nokogiri (~> 1.13.0)
|
55
|
+
rouge (~> 4.0.0)
|
56
|
+
haml (6.0.10)
|
57
|
+
temple (>= 0.8.2)
|
58
|
+
thor
|
58
59
|
tilt
|
59
60
|
hamster (3.0.0)
|
60
61
|
concurrent-ruby (~> 1.0)
|
@@ -71,14 +72,14 @@ GEM
|
|
71
72
|
fspath (>= 2.1, < 4)
|
72
73
|
image_optim (~> 0.19)
|
73
74
|
image_size (1.5.0)
|
74
|
-
in_threads (1.
|
75
|
-
kramdown (2.
|
75
|
+
in_threads (1.6.0)
|
76
|
+
kramdown (2.4.0)
|
76
77
|
rexml
|
77
78
|
libv8 (3.16.14.19-x86_64-linux)
|
78
79
|
listen (3.0.8)
|
79
80
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
80
81
|
rb-inotify (~> 0.9, >= 0.9.7)
|
81
|
-
mdocs_kramdown (0.1.
|
82
|
+
mdocs_kramdown (0.1.2.70482)
|
82
83
|
gitlab_kramdown (~> 0)
|
83
84
|
memoist (0.16.2)
|
84
85
|
middleman (4.3.11)
|
@@ -121,8 +122,8 @@ GEM
|
|
121
122
|
middleman-core (>= 3.2)
|
122
123
|
nokogiri (~> 1.6)
|
123
124
|
therubyracer (~> 0.12.2)
|
124
|
-
minitest (5.
|
125
|
-
nokogiri (1.
|
125
|
+
minitest (5.16.3)
|
126
|
+
nokogiri (1.13.9-x86_64-linux)
|
126
127
|
racc (~> 1.4)
|
127
128
|
padrino-helpers (0.13.3.4)
|
128
129
|
i18n (~> 0.6, >= 0.6.7)
|
@@ -134,19 +135,19 @@ GEM
|
|
134
135
|
parser (3.0.2.0)
|
135
136
|
ast (~> 2.4.1)
|
136
137
|
progress (3.6.0)
|
137
|
-
public_suffix (
|
138
|
-
racc (1.
|
139
|
-
rack (2.2.
|
138
|
+
public_suffix (5.0.0)
|
139
|
+
racc (1.6.0)
|
140
|
+
rack (2.2.4)
|
140
141
|
rainbow (3.0.0)
|
141
142
|
rake (13.0.6)
|
142
|
-
rb-fsevent (0.11.
|
143
|
+
rb-fsevent (0.11.2)
|
143
144
|
rb-inotify (0.10.1)
|
144
145
|
ffi (~> 1.0)
|
145
146
|
redcarpet (3.5.1)
|
146
147
|
ref (2.0.0)
|
147
148
|
regexp_parser (2.1.1)
|
148
149
|
rexml (3.2.5)
|
149
|
-
rouge (
|
150
|
+
rouge (4.0.0)
|
150
151
|
rspec (3.10.0)
|
151
152
|
rspec-core (~> 3.10.0)
|
152
153
|
rspec-expectations (~> 3.10.0)
|
@@ -199,16 +200,17 @@ GEM
|
|
199
200
|
therubyracer (0.12.3)
|
200
201
|
libv8 (~> 3.16.14.15)
|
201
202
|
ref
|
202
|
-
thor (1.1
|
203
|
+
thor (1.2.1)
|
203
204
|
thread_safe (0.3.6)
|
204
|
-
tilt (2.0.
|
205
|
-
tzinfo (1.2.
|
205
|
+
tilt (2.0.11)
|
206
|
+
tzinfo (1.2.10)
|
206
207
|
thread_safe (~> 0.1)
|
207
208
|
uglifier (3.2.0)
|
208
209
|
execjs (>= 0.3.0, < 3)
|
209
210
|
unicode-display_width (2.1.0)
|
210
211
|
|
211
212
|
PLATFORMS
|
213
|
+
ruby
|
212
214
|
x86_64-linux
|
213
215
|
|
214
216
|
DEPENDENCIES
|
@@ -7,7 +7,7 @@ module ::Middleman
|
|
7
7
|
ORIGINAL_RENDER = Engine.fetch_from(self).decorated_methods_for(:instance_methods, :render)[0].method.instance_variable_get('@method')
|
8
8
|
|
9
9
|
def render(locs, opts, context, &block)
|
10
|
-
return ORIGINAL_RENDER.bind(self).call(locs, opts, context, &block) if locs[:rack]
|
10
|
+
return ORIGINAL_RENDER.bind(self).call(locs, opts, context, &block) # if locs[:rack]
|
11
11
|
|
12
12
|
cache_key = Digest::MD5.hexdigest("#{locs.to_h.to_json}_#{opts.to_h.to_json}")
|
13
13
|
|
@@ -21,11 +21,25 @@ module MiddlemanMdocs
|
|
21
21
|
def html?
|
22
22
|
@html ||= destination_path.end_with?('.html')
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def ready?
|
26
26
|
mdocs.ready?
|
27
27
|
end
|
28
28
|
|
29
|
+
def touch
|
30
|
+
@updated = SecureRandom.hex
|
31
|
+
end
|
32
|
+
|
33
|
+
def data
|
34
|
+
$data_cache ||= {}
|
35
|
+
$data_cache[page_id] ||= super
|
36
|
+
end
|
37
|
+
|
38
|
+
def metadata
|
39
|
+
$metadata_cache ||= {}
|
40
|
+
$metadata_cache[destination_path] ||= super
|
41
|
+
end
|
42
|
+
|
29
43
|
def copy_from(other)
|
30
44
|
resource = self
|
31
45
|
unless @patched
|
@@ -70,12 +84,8 @@ module MiddlemanMdocs
|
|
70
84
|
(mdocs.dependencies(self).map(&:timestamp) + [File.mtime(File.realdirpath(source_file)), File.mtime(source_file)]).max
|
71
85
|
end
|
72
86
|
|
73
|
-
def cache_key
|
74
|
-
"#{page_id}/#{timestamp}/"
|
75
|
-
end
|
76
|
-
|
77
87
|
def title
|
78
|
-
with_cache(:title
|
88
|
+
with_cache(:title) do
|
79
89
|
data[:title] || metadata[:title] || toc&.children&.first&.raw_text
|
80
90
|
end
|
81
91
|
end
|
@@ -87,11 +97,11 @@ module MiddlemanMdocs
|
|
87
97
|
end
|
88
98
|
|
89
99
|
def text
|
90
|
-
force_render if !metadata[:ignore] && html?
|
100
|
+
force_render(:text) if !metadata[:ignore] && html?
|
91
101
|
end
|
92
102
|
|
93
103
|
def tags
|
94
|
-
with_cache(:tags
|
104
|
+
with_cache(:tags) do
|
95
105
|
guard_recursive('tags', page_id, []) do |_key|
|
96
106
|
text
|
97
107
|
end
|
@@ -101,14 +111,14 @@ module MiddlemanMdocs
|
|
101
111
|
end
|
102
112
|
|
103
113
|
def keywords
|
104
|
-
with_cache(:keywords
|
114
|
+
with_cache(:keywords) do
|
105
115
|
options[:keywords] =
|
106
116
|
::MiddlemanMdocs::Resource.normalize_keywords(tags, options[:keywords], data[:keywords], metadata[:keywords])
|
107
117
|
end
|
108
118
|
end
|
109
119
|
|
110
120
|
def toc
|
111
|
-
with_cache(:toc
|
121
|
+
with_cache(:toc) do
|
112
122
|
if metadata[:ignore] || !html?
|
113
123
|
nil
|
114
124
|
else
|
@@ -131,7 +141,7 @@ module MiddlemanMdocs
|
|
131
141
|
added = ::MiddlemanMdocs::Resource.normalize_tags(args)
|
132
142
|
return if (added - (options[:tags] || [])).empty?
|
133
143
|
|
134
|
-
|
144
|
+
cache_reset(:tags)
|
135
145
|
options[:tags] = ::MiddlemanMdocs::Resource.normalize_tags(options[:tags], data[:tags], metadata[:tags], added)
|
136
146
|
end
|
137
147
|
|
@@ -141,7 +151,7 @@ module MiddlemanMdocs
|
|
141
151
|
added = ::MiddlemanMdocs::Resource.normalize_keywords(args)
|
142
152
|
return if (added - (options[:keywords] || [])).empty?
|
143
153
|
|
144
|
-
|
154
|
+
cache_reset(:keywords)
|
145
155
|
options[:keywords] =
|
146
156
|
::MiddlemanMdocs::Resource.normalize_keywords(options[:tags], options[:keywords], data[:keywords], metadata[:keywords],
|
147
157
|
added)
|
@@ -167,29 +177,66 @@ module MiddlemanMdocs
|
|
167
177
|
super.force_encoding(Encoding.default_external)
|
168
178
|
end
|
169
179
|
|
170
|
-
def force_render
|
171
|
-
render({ layout: false }, { current_path: path, force_current_page: self })
|
180
|
+
def force_render key = :force
|
181
|
+
render({ layout: false, key: key}, { current_path: path, force_current_page: self })
|
172
182
|
end
|
173
183
|
|
174
184
|
def render(opts = {}, locs = {})
|
175
185
|
return super if nocache? || locs.has_key?('rack') || locs.has_key?(:rack)
|
176
|
-
|
186
|
+
|
177
187
|
with_cache(Digest::MD5.hexdigest(opts.to_json + locs.to_json) + 'render') do
|
178
188
|
# puts "REFRESH: #{binary?} #{page_id}: #{opts.to_json + locs.to_json}"
|
179
189
|
super
|
180
190
|
end
|
181
191
|
end
|
182
192
|
|
193
|
+
def cache_key(*key)
|
194
|
+
"#{page_id}/#{timestamp}/#{key.map(&:to_s).sort.join('_')}"
|
195
|
+
end
|
196
|
+
|
183
197
|
private
|
184
198
|
|
199
|
+
PARTIAL_RX = ['partial', 'include', 'render', 'merge'].map do |token|
|
200
|
+
/\b#{token}\b/
|
201
|
+
end
|
202
|
+
|
185
203
|
def nocache?
|
186
|
-
|
204
|
+
tmpl = with_cache(:noacahe, expires_in: 1.minute) do
|
205
|
+
file_descriptor.try(:read).then do |content|
|
206
|
+
false if content.nil?
|
207
|
+
PARTIAL_RX.any? do |rx|
|
208
|
+
content.match(rx)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
#r = binary? || metadata[:ignore] || metadata[:nocache] || data[:nocache] || tmpl
|
214
|
+
r = binary? || metadata[:nocache] || data[:nocache] || tmpl
|
215
|
+
|
216
|
+
# if r
|
217
|
+
# puts "NOCACHE#{page_id}: #{r}"
|
218
|
+
# puts "b:#{binary?}"
|
219
|
+
# #puts "i:#{metadata[:ignore]}"
|
220
|
+
# puts "c:#{metadata[:nocache]}"
|
221
|
+
# puts "d:#{data[:nocache]}"
|
222
|
+
# puts "t:#{tmpl}"
|
223
|
+
# end
|
224
|
+
|
225
|
+
r
|
226
|
+
end
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
def cache_reset(*key)
|
231
|
+
extension.cache.delete([cache_key(key)])
|
187
232
|
end
|
188
233
|
|
189
|
-
def with_cache(*key, &block)
|
190
|
-
extension.cache.fetch([cache_key
|
234
|
+
def with_cache(*key, **opts, &block)
|
235
|
+
extension.cache.fetch([cache_key(key)], **opts, &block)
|
191
236
|
end
|
192
237
|
|
238
|
+
|
239
|
+
|
193
240
|
def custom_deep_merge!(left, right)
|
194
241
|
left.merge!(right) do |_key, this_val, other_val|
|
195
242
|
if this_val.is_a?(Hash) && other_val.is_a?(Hash)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-mdocs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samoylenko Yuri
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-11-
|
12
|
+
date: 2022-11-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
222
|
- !ruby/object:Gem::Version
|
223
223
|
version: '0'
|
224
224
|
requirements: []
|
225
|
-
rubygems_version: 3.
|
225
|
+
rubygems_version: 3.1.4
|
226
226
|
signing_key:
|
227
227
|
specification_version: 4
|
228
228
|
summary: Extension for Middleman
|