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

Include colors and theme when sharing timetable #3467

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
22 changes: 10 additions & 12 deletions export/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,32 @@
},
"dependencies": {
"@sentry/node": "5.30.0",
"@sparticuz/chromium": "92.0.0",
"axios": "0.21.2",
"bunyan": "1.8.15",
"chrome-aws-lambda": "~6.0.0",
"fs-extra": "9.1.0",
"http-graceful-shutdown": "2.3.2",
"koa": "2.13.1",
"koa-router": "10.0.0",
"koa-views": "6.3.1",
"lodash": "4.17.21",
"nodemon": "2.0.9",
"nodemon": "2.0.22",
"pug": "3.0.2",
"puppeteer-core": "5.5.0"
"puppeteer-core": "10.4.0"
},
"devDependencies": {
"@types/fs-extra": "9.0.6",
"@types/fs-extra": "9.0.13",
"@types/koa": "2.13.8",
"@types/koa-router": "7.4.1",
"@types/koa-router": "7.4.4",
"@types/koa-views": "2.0.4",
"@types/lodash": "4.14.170",
"@types/node": "18.16.19",
"@types/pug": "2.0.4",
"@types/puppeteer": "^5.4.7",
"@vercel/node": "1.9.0",
"@types/lodash": "4.14.196",
"@types/node": "18.17.3",
"@types/pug": "2.0.6",
"@vercel/node": "1.15.4",
"cross-env": "7.0.3",
"dotenv": "8.2.0",
"dotenv": "8.6.0",
"npm-run-all": "4.1.5",
"prettier": "2.8.8",
"puppeteer": "~6.0.0",
"typescript": "5.1.6"
}
}
2 changes: 1 addition & 1 deletion export/src/handler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Sentry from '@sentry/node';
import type { NowApiHandler, NowRequest, NowResponse } from '@vercel/node';
import type { Page } from 'puppeteer';
import type { Page } from 'puppeteer-core';

import * as render from './render-serverless';
import config from './config';
Expand Down
8 changes: 4 additions & 4 deletions export/src/render-serverless.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import chromium from 'chrome-aws-lambda';
import type { Page } from 'puppeteer';
import chromium from '@sparticuz/chromium';
import puppeteer, { Page } from 'puppeteer-core';

import { getModules } from './data';
import config from './config';
Expand All @@ -23,7 +23,7 @@ async function setViewport(page: Page, options: ViewportOptions = {}) {
}

export async function open(url: string) {
const browser = await chromium.puppeteer.launch({
const browser = await puppeteer.launch({
// devtools: !!process.env.DEVTOOLS, // TODO: Query string && NODE_ENV === 'development'?
args: chromium.args,
defaultViewport: chromium.defaultViewport,
Expand Down Expand Up @@ -72,7 +72,7 @@ export async function pdf(page: Page, data: PageData) {

return await page.pdf({
printBackground: true,
format: 'A4',
format: 'a4',
landscape: data.theme.timetableOrientation === 'HORIZONTAL',
});
}
4 changes: 2 additions & 2 deletions export/src/render.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs-extra';
import puppeteer, { Page } from 'puppeteer';
import puppeteer, { Page } from 'puppeteer-core';
import type { Middleware } from 'koa';

import { getModules } from './data';
Expand Down Expand Up @@ -106,7 +106,7 @@ export async function pdf(page: Page, data: PageData) {

return await page.pdf({
printBackground: true,
format: 'A4',
format: 'a4',
landscape: data.theme.timetableOrientation === 'HORIZONTAL',
});
}
2 changes: 1 addition & 1 deletion export/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Page } from 'puppeteer';
import type { Page } from 'puppeteer-core';

export type TimetableOrientation = 'HORIZONTAL' | 'VERTICAL';

Expand Down
Loading