Compare commits

..

3 Commits

Author SHA1 Message Date
e97e209746 Now laoding card subtitle from env
All checks were successful
continuous-integration/drone/push Build is passing
2021-04-22 17:41:36 +02:00
8f30d8933f Fixed typo in translation 2021-04-22 17:35:02 +02:00
f78037c0f1 Fixed barcode generation for runenrcard pdfs🐞 2021-04-22 17:32:36 +02:00
6 changed files with 13 additions and 10 deletions

View File

@ -157,7 +157,7 @@ export class PdfCreator {
let i, j; let i, j;
for (i = 0, j = cards.length; i < j; i += 10) { for (i = 0, j = cards.length; i < j; i += 10) {
let chunk = cards.slice(i, i + 10); let chunk = cards.slice(i, i + 10);
pdf_promises.push(this.generateRunnerCards(chunk, locale)); pdf_promises.push(this.generateRunnerCards(chunk, locale, codeformat));
} }
const pdfs = await Promise.all(pdf_promises); const pdfs = await Promise.all(pdf_promises);
return await this.mergePdfs(pdfs); return await this.mergePdfs(pdfs);
@ -166,7 +166,7 @@ export class PdfCreator {
await i18next.changeLanguage(locale); await i18next.changeLanguage(locale);
const template_source = fs.readFileSync(`${this.templateDir}/runner_card.html`, 'utf8'); const template_source = fs.readFileSync(`${this.templateDir}/runner_card.html`, 'utf8');
const template = Handlebars.compile(template_source); const template = Handlebars.compile(template_source);
let result = template({ cards, cards_swapped, eventname: config.eventname, codeformat: codeformat }) let result = template({ cards, cards_swapped, eventname: config.eventname, codeformat: codeformat, card_subtitle: config.card_subtitle })
result = await awaitAsyncHandlebarHelpers(result); result = await awaitAsyncHandlebarHelpers(result);
const pdf = await this.renderPdf(result, { format: "A4", landscape: false }); const pdf = await this.renderPdf(result, { format: "A4", landscape: false });
return pdf return pdf

View File

@ -15,6 +15,7 @@ export const config = {
disclaimer_text: process.env.DISCLAIMER_TEXT || "", disclaimer_text: process.env.DISCLAIMER_TEXT || "",
donations_footer_text: process.env.DONATIONS_FOOTER_TEXT || "", donations_footer_text: process.env.DONATIONS_FOOTER_TEXT || "",
contracts_per_runner: parseInt(process.env.CONTRACTS_PER_RUNNER) || 1, contracts_per_runner: parseInt(process.env.CONTRACTS_PER_RUNNER) || 1,
card_subtitle: process.env.CARD_SUBTITLE || ""
} }
let errors = 0 let errors = 0
if (typeof config.internal_port !== "number") { if (typeof config.internal_port !== "number") {

View File

@ -38,7 +38,7 @@ export class PdfController {
@Post('/cards') @Post('/cards')
@OpenAPI({ description: "Generate runner card pdfs from runner card objects.<br>You can choose your prefered locale by passing the 'locale' query-param." }) @OpenAPI({ description: "Generate runner card pdfs from runner card objects.<br>You can choose your prefered locale by passing the 'locale' query-param." })
async generateCards(@Body({ validate: true, options: { limit: "500mb" } }) cards: RunnerCard | RunnerCard[], @Res() res: any, @QueryParam("locale") locale: string, @QueryParam("download") download: boolean) { async generateCards(@Body({ validate: true, options: { limit: "500mb" } }) cards: RunnerCard | RunnerCard[], @Res() res: any, @QueryParam("locale") locale: string, @QueryParam("codeformat") codeformat: string, @QueryParam("download") download: boolean) {
if (!this.initialized) { if (!this.initialized) {
await this.pdf.init(); await this.pdf.init();
this.initialized = true; this.initialized = true;
@ -47,7 +47,7 @@ export class PdfController {
cards = [cards]; cards = [cards];
} }
cards = this.mapCardGroupNames(cards); cards = this.mapCardGroupNames(cards);
const contracts = await this.pdf.generateRunnerCards(cards, locale); const contracts = await this.pdf.generateRunnerCards(cards, locale, codeformat);
res.setHeader('content-type', 'application/pdf'); res.setHeader('content-type', 'application/pdf');
if (download) { if (download) {
res.setHeader('Content-Disposition', 'attachment; filename="cards.pdf"') res.setHeader('Content-Disposition', 'attachment; filename="cards.pdf"')

View File

@ -13,6 +13,7 @@
"id": "ID", "id": "ID",
"lastname": "Nachname", "lastname": "Nachname",
"location": "Ort", "location": "Ort",
"mit_unterstuetzung_von": "Mit Unterstützung von:",
"please_use_blockletters": "Bitte in DRUCKBUCHSTABEN schreiben", "please_use_blockletters": "Bitte in DRUCKBUCHSTABEN schreiben",
"postalcode": "Postleitzahl", "postalcode": "Postleitzahl",
"signature": "Unterschrift", "signature": "Unterschrift",

View File

@ -13,6 +13,7 @@
"id": "ID", "id": "ID",
"lastname": "Last name", "lastname": "Last name",
"location": "Location", "location": "Location",
"mit_unterstuetzung_von": "Supported by:",
"please_use_blockletters": "Please write in BLOCK LETTERS.", "please_use_blockletters": "Please write in BLOCK LETTERS.",
"postalcode": "Postal code", "postalcode": "Postal code",
"signature": "Signature", "signature": "Signature",

View File

@ -33,18 +33,18 @@
{{#each cards}} {{#each cards}}
<div class="column is-half runnercard"> <div class="column is-half runnercard">
<p class="title is-5" style="text-align: center; padding-bottom: 0; margin-top: -0.75rem;">{{../eventname}}</p> <p class="title is-5" style="text-align: center; padding-bottom: 0; margin-top: -0.75rem;">{{../eventname}}</p>
<p style="text-align: center; margin-top: -1.5rem; font-size: small;">lauf-fuer-kaya.de - am 01.01.2021</p> <p style="text-align: center; margin-top: -1.5rem; font-size: small;">{{../card_subtitle}}</p>
<p style="font-size: small;">Mit unterstützung von:</p> <p style="font-size: small;">{{__ "mit_unterstuetzung_von"}}</p>
<div class="columns" style="height: 6rem; overflow: hidden;"> <div class="columns" style="height: 6rem; overflow: hidden;">
<div class="column is-two-thirds"> <div class="column is-half">
<!--SPONSOR LOGO HERE--> <!--SPONSOR LOGO HERE-->
<img style="vertical-align: revert; margin-top: auto; object-fit: cover; max-height: 2cm;" <img style="vertical-align: revert; margin-top: auto; object-fit: cover; max-height: 2cm;"
src="{{--sponsor this.id}}" /> src="{{--sponsor this.id}}" />
</div> </div>
<div class="column is-one-third"> <div class="column is-half">
<!--BARCODE HERE--> <!--BARCODE HERE-->
<img style="vertical-align: revert; margin-top: auto; object-fit: cover; max-height: 2cm;" <img style="vertical-align: revert; margin-top: auto; object-fit: cover; max-height: 2cm;"
src="{{--bc this.id ../codeformat}}" /> src="{{--bc this.code ../codeformat}}" />
</div> </div>
</div> </div>
<p>{{this.runner.lastname}}, {{this.runner.firstname}} {{this.runner.middlename}}</p> <p>{{this.runner.lastname}}, {{this.runner.firstname}} {{this.runner.middlename}}</p>
@ -61,7 +61,7 @@
<div style="height: 2cm; padding: 0 0 2.25cm 0"> <div style="height: 2cm; padding: 0 0 2.25cm 0">
<img style="object-fit: cover; max-height: 2cm;" src="{{--sponsor this.id}}" /> <img style="object-fit: cover; max-height: 2cm;" src="{{--sponsor this.id}}" />
</div> </div>
<img style="object-fit: cover; max-height: 2.5cm; position: relative;" src="{{--bc this.id ../codeformat}}" /> <img style="object-fit: cover; max-height: 2.5cm; position: relative;" src="{{--bc this.code ../codeformat}}" />
</div> </div>
{{/each}} {{/each}}
</div> </div>