Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
77086a6e
Unverified
Commit
77086a6e
authored
Jun 19, 2020
by
Regev Brody
Committed by
GitHub
Jun 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: optional kroki/plantuml svg caching (#2047)
* feat: Caching kroki svgs #2020
parent
e03a80dc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
3 deletions
+41
-3
renderer.js
server/modules/rendering/html-core/renderer.js
+1
-1
definition.yml
server/modules/rendering/html-image-prefetch/definition.yml
+8
-0
renderer.js
server/modules/rendering/html-image-prefetch/renderer.js
+30
-0
renderer.js
server/modules/rendering/markdown-kroki/renderer.js
+1
-1
renderer.js
server/modules/rendering/markdown-plantuml/renderer.js
+1
-1
No files found.
server/modules/rendering/html-core/renderer.js
View file @
77086a6e
...
...
@@ -24,7 +24,7 @@ module.exports = {
for
(
let
child
of
_
.
reject
(
this
.
children
,
[
'step'
,
'post'
]))
{
const
renderer
=
require
(
`../
${
_
.
kebabCase
(
child
.
key
)}
/renderer.js`
)
renderer
.
init
(
$
,
child
.
config
)
await
renderer
.
init
(
$
,
child
.
config
)
}
// --------------------------------
...
...
server/modules/rendering/html-image-prefetch/definition.yml
0 → 100644
View file @
77086a6e
key
:
htmlImagePrefetch
title
:
Image Prefetch
description
:
Prefetch remotely rendered images (korki/plantuml)
author
:
requarks.io
icon
:
mdi-cloud-download-outline
enabledDefault
:
false
dependsOn
:
htmlCore
props
:
{}
server/modules/rendering/html-image-prefetch/renderer.js
0 → 100644
View file @
77086a6e
const
request
=
require
(
'request-promise'
)
const
prefetch
=
async
(
element
)
=>
{
const
url
=
element
.
attr
(
`src`
)
let
response
try
{
response
=
await
request
({
method
:
`GET`
,
url
,
resolveWithFullResponse
:
true
})
}
catch
(
err
)
{
WIKI
.
logger
.
warn
(
`Failed to prefetch
${
url
}
`
)
WIKI
.
logger
.
warn
(
err
)
return
}
const
contentType
=
response
.
headers
[
`content-type`
]
const
image
=
Buffer
.
from
(
response
.
body
).
toString
(
'base64'
)
element
.
attr
(
'src'
,
`data:
${
contentType
}
;base64,
${
image
}
`
)
element
.
removeClass
(
'prefetch-candidate'
);
}
module
.
exports
=
{
async
init
(
$
)
{
const
promises
=
$
(
'img.prefetch-candidate'
).
map
((
index
,
element
)
=>
{
return
prefetch
(
$
(
element
))
}).
toArray
()
await
Promise
.
all
(
promises
)
}
}
server/modules/rendering/markdown-kroki/renderer.js
View file @
77086a6e
...
...
@@ -120,7 +120,7 @@ module.exports = {
token
=
state
.
push
(
'kroki'
,
'img'
,
0
)
// alt is constructed from children. No point in populating it here.
token
.
attrs
=
[
[
'src'
,
`
${
server
}
/
${
diagramType
}
/svg/
${
result
}
`
],
[
'alt'
,
''
],
[
'class'
,
'uml-diagram'
]
]
token
.
attrs
=
[
[
'src'
,
`
${
server
}
/
${
diagramType
}
/svg/
${
result
}
`
],
[
'alt'
,
''
],
[
'class'
,
'uml-diagram
prefetch-candidate
'
]
]
token
.
block
=
true
token
.
children
=
altToken
token
.
info
=
params
...
...
server/modules/rendering/markdown-plantuml/renderer.js
View file @
77086a6e
...
...
@@ -116,7 +116,7 @@ module.exports = {
token
=
state
.
push
(
'uml_diagram'
,
'img'
,
0
)
// alt is constructed from children. No point in populating it here.
token
.
attrs
=
[
[
'src'
,
`
${
server
}
/
${
imageFormat
}
/
${
zippedCode
}
`
],
[
'alt'
,
''
],
[
'class'
,
'uml-diagram'
]
]
token
.
attrs
=
[
[
'src'
,
`
${
server
}
/
${
imageFormat
}
/
${
zippedCode
}
`
],
[
'alt'
,
''
],
[
'class'
,
'uml-diagram
prefetch-candidate
'
]
]
token
.
block
=
true
token
.
children
=
altToken
token
.
info
=
params
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment