fix(plugins/core): disable css optimization for extras_css (#756) [skip ci]

This commit is contained in:
Simon Lecoq
2022-01-09 19:54:29 +01:00
committed by GitHub
parent fa17bb48bd
commit 8d1f82963b
5 changed files with 10 additions and 6 deletions

View File

@@ -24,7 +24,8 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf,
//Initialization //Initialization
const pending = [] const pending = []
const {queries} = conf const {queries} = conf
const data = {q, animated:true, large:false, base:{}, config:{}, errors:[], plugins:{}, computed:{}} const extras = {css:(conf.settings.extras?.css ?? conf.settings.extras?.default ? q["extras.css"] ?? "" : "")}
const data = {q, animated:true, large:false, base:{}, config:{}, errors:[], plugins:{}, computed:{}, extras}
const imports = { const imports = {
plugins:Plugins, plugins:Plugins,
templates:Templates, templates:Templates,
@@ -153,7 +154,7 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf,
if (convert === "markdown-pdf") { if (convert === "markdown-pdf") {
return imports.svg.pdf(rendered, { return imports.svg.pdf(rendered, {
paddings:q["config.padding"] || conf.settings.padding, paddings:q["config.padding"] || conf.settings.padding,
style:(conf.settings.extras?.css ?? conf.settings.extras?.default ? q["extras.css"] ?? "" : ""), style:extras.css,
twemojis:q["config.twemoji"], twemojis:q["config.twemoji"],
gemojis:q["config.gemoji"], gemojis:q["config.gemoji"],
rest, rest,
@@ -164,7 +165,7 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf,
//Rendering //Rendering
console.debug(`metrics/compute/${login} > render`) console.debug(`metrics/compute/${login} > render`)
let rendered = await ejs.render(image, {...data, s:imports.s, f:imports.format, style:style + (conf.settings.extras?.css ?? conf.settings.extras?.default ? q["extras.css"] ?? "" : ""), fonts}, {views, async:true}) let rendered = await ejs.render(image, {...data, s:imports.s, f:imports.format, style, fonts}, {views, async:true})
//Additional transformations //Additional transformations
if (q["config.twemoji"]) if (q["config.twemoji"])

View File

@@ -59,6 +59,8 @@
columns: set.config.display === "columns", columns: set.config.display === "columns",
//Config //Config
config: set.config, config: set.config,
//Extras
extras:{css:options["extras.css"] ?? ""},
//Base elements //Base elements
base: set.plugins.enabled.base, base: set.plugins.enabled.base,
//Computed elements //Computed elements

View File

@@ -2,6 +2,7 @@
<defs><style><%= fonts %></style></defs> <defs><style><%= fonts %></style></defs>
<style data-optimizable="true"><%= style %></style> <style data-optimizable="true"><%= style %></style>
<style><%= extras.css %></style>
<foreignObject x="0" y="0" width="100%" height="100%"> <foreignObject x="0" y="0" width="100%" height="100%">
<div xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" class="items-wrapper"> <div xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" class="items-wrapper">

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -2,9 +2,8 @@
<defs><style><%= fonts %></style></defs> <defs><style><%= fonts %></style></defs>
<style data-optimizable="true"> <style data-optimizable="true"><%= style %></style>
<%= style %> <style><%= extras.css %></style>
</style>
<foreignObject x="0" y="0" width="100%" height="100%"> <foreignObject x="0" y="0" width="100%" height="100%">
<div xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink"> <div xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink">

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -28,6 +28,7 @@
<% } %> <% } %>
<% } %> <% } %>
</style> </style>
<style><%= extras.css %></style>
<foreignObject x="0" y="0" width="100%" height="100%"> <foreignObject x="0" y="0" width="100%" height="100%">
<div xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink"> <div xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink">

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB