fix pdf generation 2

remotes/1693055039339581669/master
Igor Laborie 5 years ago
parent 78944ae641
commit e31acad1e0
  1. 3
      .gitlab-ci.yml
  2. 2
      themes/devfest-theme-hugo
  3. 31
      tools/minify.js

@ -11,12 +11,12 @@ before_script:
sandbox: sandbox:
script: script:
- hugo --quiet
- node tools/pdf.js - node tools/pdf.js
- hugo -F - hugo -F
- node tools/minify.js - node tools/minify.js
- firebase use default - firebase use default
- firebase deploy --token "$FIREBASE_SANDBOX_TOKEN" - firebase deploy --token "$FIREBASE_SANDBOX_TOKEN"
- ls public/schedule/
artifacts: artifacts:
paths: paths:
- public - public
@ -27,6 +27,7 @@ prod:
variables: variables:
HUGO_ENV: production HUGO_ENV: production
script: script:
- hugo --quiet
- node tools/pdf.js - node tools/pdf.js
- hugo --baseURL https://2019.devfesttoulouse.fr/ - hugo --baseURL https://2019.devfesttoulouse.fr/
- node tools/minify.js - node tools/minify.js

@ -1 +1 @@
Subproject commit defa281b712030049b17f57741fba6ebc2984e83 Subproject commit 6a8d7c8af563c5fa71e36e31fe6425ce85702f36

@ -1,20 +1,27 @@
const {readFileSync, writeFileSync} = require('fs'); const {readFileSync, writeFileSync} = require('fs');
const {sync: glob} = require('glob'); const {sync: glob} = require('glob');
const {minify} = require('html-minifier'); const {minify} = require('html-minifier');
const {Logger} = require('plop-logger'); const {Logger, LogLevel} = require('plop-logger');
const {colorEmojiConfig} = require('plop-logger/lib/extra/colorEmojiConfig'); const {colorEmojiConfig} = require('plop-logger/lib/extra/colorEmojiConfig');
Logger.config = colorEmojiConfig; Logger.config = colorEmojiConfig;
const logger = Logger.getLogger('minifier'); const logger = Logger.getLogger('minifier');
logger.level = LogLevel.All;
glob(`public/**/*.html`) const htmlFiles = `public/**/*.html`;
.forEach(file => { logger.info('Compress HTML files', htmlFiles);
const html = readFileSync(file, 'utf8');
const minified = minify(html, {}); const totalGain = glob(htmlFiles)
const gain = html.length - minified.length; .map(file => {
if (gain > 0) { const html = readFileSync(file, 'utf8');
const percent = (gain / html.length) * 100; const minified = minify(html, {});
logger.info(file, () => ['gain', percent.toFixed(2), '%'].join(" ")); const gain = html.length - minified.length;
writeFileSync(file, minified, {flag: 'w'}); if (gain > 0) {
} const percent = (gain / html.length) * 100;
}); logger.debug(file, () => ['gain', percent.toFixed(2), '%'].join(" "));
writeFileSync(file, minified, {flag: 'w'});
}
return gain;
}).reduce((acc, elt) => acc + elt, 0);
logger.info('Total gain', '' + totalGain);

Loading…
Cancel
Save