Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Fix page breaks in pdf #700

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.16.0
12.18.4
8 changes: 4 additions & 4 deletions createLessonPdfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ const convertUrl = async (browser, lesson) => {
page = idlePages.pop();
} else {
page = await browser.newPage();
page.setDefaultNavigationTimeout(60000); // Increase from 30s to 60s
page.on('console', consoleMsg => {
console.log(`[Puppeteer console] ${consoleMsg.type()}: ${consoleMsg.text()} [[${page.url()}]]`);
});
page.setDefaultNavigationTimeout(120000); // Increase from 30s to 120s
// page.on('console', consoleMsg => {
// console.log(`[Puppeteer console] ${consoleMsg.type()}: ${consoleMsg.text()} [[${page.url()}]]`);
// });
page.on('error', (err) => {
console.log(`[Puppeteer error] Page crashed: ${err} [[${page.url()}]]`);
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build": "webpack --mode=development --progress",
"build:prod": "webpack --mode=production -p --progress --env.BUILD_PDF",
"build:analyse": "webpack --mode=production --progress --profile --json > stats.json",
"build:travis": "webpack --mode=production -p",
"build:travis": "webpack --mode=production -p --env.BUILD_PDF",
"serve": "node server.js",
"test": "mocha \"test/**/*@(.js|.jsx)\"",
"test:links": "node test-links.js",
Expand Down
3 changes: 1 addition & 2 deletions src/components/LessonPage/Content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ $checkbox-blue: #abdbea;
opacity: 0;
}
li {
break-inside: avoid;
list-style: none;
padding-top: 10px;
padding-bottom: 10px;
margin-left: 45px;
}
li::before {
Expand Down
22 changes: 12 additions & 10 deletions src/components/LessonPage/PdfButton.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
/* eslint-env node */

import React from 'react';
import PropTypes from 'prop-types';
import {useSelector} from 'react-redux';
import useStyles from 'isomorphic-style-loader/useStyles';
import styles from './PdfButton.scss';
import {getTranslator} from '../../selectors/translate';
import Button from 'react-bootstrap/lib/Button';
import Glyphicon from 'react-bootstrap/lib/Glyphicon';
import {getLessonPath} from '../../resources/lessonFrontmatter';

const PdfButton = () => {
const PdfButton = ({course, lesson, language, isReadme}) => {
useStyles(styles);

const t = useSelector(state => getTranslator(state));

const handleClick = () => {
const result = window.confirm(t('lessons.pdfstyling'));
if (result) {
window.print();
}
};

const path = getLessonPath(course, lesson, language, isReadme);
const options = {
onClick: handleClick,
href: `${process.env.PUBLICPATH}${path.slice(1)}.pdf`,
bsStyle: 'pdf',
bsSize: 'small',
className: styles.container,
Expand All @@ -36,4 +31,11 @@ const PdfButton = () => {
);
};

PdfButton.propTypes = {
course: PropTypes.string.isRequired,
lesson: PropTypes.string.isRequired,
language: PropTypes.string.isRequired,
isReadme: PropTypes.bool.isRequired,
};

export default PdfButton;
2 changes: 0 additions & 2 deletions src/constants/captions_en.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ export default {
translatedby: 'Translated by:',
course: 'Course:',
pdf: 'Download PDF',
pdfstyling: 'Select Save as PDF. Then you can select More settings and check ' +
'Background graphics to get more colors.',
print: 'Print',
toteacherinstruction: 'To Teacher Instructions',
tolesson: 'To Lesson',
Expand Down
2 changes: 0 additions & 2 deletions src/constants/captions_is.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ export default {
translatedby: 'Þýðandi:',
course: 'Námskeið:',
pdf: 'Sækja PDF',
pdfstyling: 'Veldu Vista sem PDF. Síðan er hægt að velja Fleiri stillingar og athuga ' +
'Bakgrunnsgrafík til að fá fleiri liti.',
print: 'Prenta',
toteacherinstruction: 'Leiðbeiningar fyrir kennara',
tolesson: 'Til verkefnis',
Expand Down
2 changes: 0 additions & 2 deletions src/constants/captions_nb.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ export default {
translatedby: 'Oversatt av:',
course: 'Kurs:',
pdf: 'Last ned PDF',
pdfstyling: 'Velg Lagre som PDF. Så kan man velge ' +
'Flere innstillinger og huke av Bakgrunnsgrafikk for å få med flere farger',
print: 'Skriv ut',
toteacherinstruction: 'Til lærerveiledning',
tolesson: 'Til oppgave',
Expand Down
2 changes: 0 additions & 2 deletions src/constants/captions_nn.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ export default {
translatedby: 'Omsett av:',
course: 'Kurs:',
pdf: 'Last ned PDF',
pdfstyling: 'Velg Lagre som PDF. Så kan man velge ' +
'Flere innstillinger og huke av Bakgrunnsgrafikk for å få med flere farger',
print: 'Skriv ut',
toteacherinstruction: 'Til lærarrettleiing',
tolesson: 'Til oppgåve',
Expand Down
65 changes: 47 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2007,6 +2007,11 @@ buffer-alloc@^1.1.0, buffer-alloc@^1.2.0:
buffer-alloc-unsafe "^1.1.0"
buffer-fill "^1.0.0"

buffer-crc32@~0.2.3:
version "0.2.13"
resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242"
integrity sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=

[email protected]:
version "0.0.1"
resolved "https://registry.yarnpkg.com/buffer-equal/-/buffer-equal-0.0.1.tgz#91bc74b11ea405bc916bc6aa908faafa5b4aac4b"
Expand Down Expand Up @@ -2654,7 +2659,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=

concat-stream@1.6.2, concat-stream@^1.5.0:
concat-stream@^1.5.0, concat-stream@^1.6.2:
version "1.6.2"
resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34"
dependencies:
Expand Down Expand Up @@ -2989,19 +2994,26 @@ date-now@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b"

[email protected], debug@^2.1.2, debug@^2.2.0, debug@^2.3.3:
[email protected], debug@^2.1.2, debug@^2.2.0, debug@^2.3.3, debug@^2.6.9:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
dependencies:
ms "2.0.0"

[email protected], debug@^3.1.0, debug@^3.2.5:
[email protected], debug@^3.2.5:
version "3.2.6"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b"
integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==
dependencies:
ms "^2.1.1"

debug@^3.1.0:
version "3.2.7"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a"
integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==
dependencies:
ms "^2.1.1"

debug@^4.0.1, debug@^4.1.0, debug@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791"
Expand Down Expand Up @@ -3906,13 +3918,14 @@ extract-text-webpack-plugin@^4.0.0-beta.0:
webpack-sources "^1.1.0"

extract-zip@^1.6.6:
version "1.6.7"
resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.7.tgz#a840b4b8af6403264c8db57f4f1a74333ef81fe9"
version "1.7.0"
resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.7.0.tgz#556cc3ae9df7f452c493a0cfb51cc30277940927"
integrity sha512-xoh5G1W/PB0/27lXgMQyIhP5DSY/LhoCsOyZgb+6iMmRtCwVBo55uKaMoEYrDCKQhWvqEip5ZPKAc6eFNyf/MA==
dependencies:
concat-stream "1.6.2"
debug "2.6.9"
mkdirp "0.5.1"
yauzl "2.4.1"
concat-stream "^1.6.2"
debug "^2.6.9"
mkdirp "^0.5.4"
yauzl "^2.10.0"

[email protected]:
version "1.0.2"
Expand Down Expand Up @@ -4014,9 +4027,10 @@ fbjs@^0.8.9:
setimmediate "^1.0.5"
ua-parser-js "^0.7.9"

fd-slicer@~1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.0.1.tgz#8b5bcbd9ec327c5041bf9ab023fd6750f1177e65"
fd-slicer@~1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.1.0.tgz#25c7c89cb1f9077f8891bbe61d8f390eae256f1e"
integrity sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=
dependencies:
pend "~1.2.0"

Expand Down Expand Up @@ -6414,8 +6428,9 @@ [email protected], mime@^1.2.9, mime@^1.3.4:
integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==

mime@^2.0.3:
version "2.3.1"
resolved "https://registry.yarnpkg.com/mime/-/mime-2.3.1.tgz#b1621c54d63b97c47d3cfe7f7215f7d64517c369"
version "2.4.7"
resolved "https://registry.yarnpkg.com/mime/-/mime-2.4.7.tgz#962aed9be0ed19c91fd7dc2ece5d7f4e89a90d74"
integrity sha512-dhNd1uA2u397uQk3Nv5LM4lm93WYDUXFn3Fu291FJerns4jyTudqhIWe4W04YLy7Uk1tm1Ore04NpjRvQp/NPA==

mime@^2.4.4:
version "2.4.4"
Expand Down Expand Up @@ -6486,6 +6501,11 @@ minimist@^1.1.3, minimist@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"

minimist@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==

minipass@^2.2.1, minipass@^2.3.3:
version "2.3.3"
resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.3.3.tgz#a7dcc8b7b833f5d368759cce544dccb55f50f233"
Expand Down Expand Up @@ -6551,6 +6571,13 @@ [email protected], [email protected], "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1:
dependencies:
minimist "0.0.8"

mkdirp@^0.5.4:
version "0.5.5"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def"
integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==
dependencies:
minimist "^1.2.5"

mocha@^6.2.1:
version "6.2.1"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-6.2.1.tgz#da941c99437da9bac412097859ff99543969f94c"
Expand Down Expand Up @@ -10731,11 +10758,13 @@ yargs@^7.0.0:
y18n "^3.2.1"
yargs-parser "^5.0.0"

[email protected]:
version "2.4.1"
resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.4.1.tgz#9528f442dab1b2284e58b4379bb194e22e0c4005"
yauzl@^2.10.0:
version "2.10.0"
resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9"
integrity sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=
dependencies:
fd-slicer "~1.0.1"
buffer-crc32 "~0.2.3"
fd-slicer "~1.1.0"

yml-loader@^2.1.0:
version "2.1.0"
Expand Down