Merge branch 'develop' into 'master'

Develop

See merge request devfest-toulouse/site-devfest-2019!87
master
Igor Laborie 5 years ago
commit b339ce5dbc
  1. 6
      .gitlab-ci.yml
  2. 2
      content/schedule/_index.fr.md
  3. 2
      content/schedule/_index.md
  4. 3573
      static/api/site.json
  5. 38
      tools/pdf.js

@ -11,9 +11,8 @@ before_script:
sandbox:
script:
- hugo --quiet
- node tools/pdf.js
- hugo -F
- node tools/pdf.js
- node tools/minify.js
- firebase use default
- firebase deploy --token "$FIREBASE_SANDBOX_TOKEN"
@ -27,9 +26,8 @@ prod:
variables:
HUGO_ENV: production
script:
- hugo --quiet
- node tools/pdf.js
- hugo --baseURL https://2019.devfesttoulouse.fr/
- node tools/pdf.js
- node tools/minify.js
- firebase use prod
- firebase deploy --token "$FIREBASE_PROD_TOKEN"

@ -15,7 +15,7 @@ horizontal: false
<svg class="icon icon-calendar"><use xlink:href="#calendar"></use></svg> ICal
</a>
<a class="btn primary btn-lg" href="/schedule/schedule.pdf">
<a class="btn primary btn-lg" href="/schedule/schedule-fr.pdf">
<svg class="icon icon-pdf"><use xlink:href="#pdf"></use></svg> PDF
</a>

@ -14,7 +14,7 @@ horizontal: false
<svg class="icon icon-calendar"><use xlink:href="#calendar"></use></svg> ICal
</a>
<a class="btn primary btn-lg" href="/schedule/schedule.pdf">
<a class="btn primary btn-lg" href="/schedule/schedule-en.pdf">
<svg class="icon icon-pdf"><use xlink:href="#pdf"></use></svg> PDF
</a>

File diff suppressed because one or more lines are too long

@ -9,7 +9,10 @@ Logger.config.defaultLevel = LogLevel.Debug;
const logger = Logger.getLogger('pdf');
// Configuration
const output = 'static/schedule/schedule.pdf';
const outputs = {
'schedule/index.html': 'public/schedule/schedule-en.pdf',
'fr/schedule/index.html': 'public/schedule/schedule-fr.pdf',
};
const serverConf = {
port: 8765,
options: {
@ -70,13 +73,28 @@ async function cleanupBeforePrint(page) {
await page.$$eval(toHide.join(','), elts =>
elts.forEach(elt =>
elt.parentNode.removeChild(elt)));
elt && elt.parentNode ? elt.parentNode.removeChild(elt) : elt));
await page.addStyleTag({
content: '@page { size: auto; }',
});
}
async function renderPdf(page, file, output) {
const url = `http://localhost:${serverConf.port}/${file}`;
logger.info("go to", url);
const pageResponse = await page.goto(url, {waitUntil: 'networkidle2'});
logger.debug("done", pageResponse.statusText());
await cleanupBeforePrint(page);
logger.info('export pdf', output);
const format = 'A3';
const scale = .4;
const printBackground = true;
return page.pdf({path: output, format, scale, printBackground});
}
(async () => {
const server = await startServer(serverConf);
@ -87,18 +105,10 @@ async function cleanupBeforePrint(page) {
const page = await browser.newPage();
logger.debug("opened new page");
const file = 'fr/schedule/index.html';
const url = `http://localhost:${serverConf.port}/${file}`;
logger.info("go to", url);
const pageResponse = await page.goto(url, {waitUntil: 'networkidle2'});
logger.debug("done", pageResponse.statusText());
await cleanupBeforePrint(page);
logger.info('export pdf', output);
const format = 'A3';
const scale = .4;
const printBackground = true;
await page.pdf({path:output, format, scale, printBackground});
for (let [file, output] of Object.entries(outputs)) {
await renderPdf(page, file, output);
}
logger.debug("pdf done");
} catch (e) {

Loading…
Cancel
Save