Merge pull request 'Alpha Release 0.4.0' (#38) from dev into main
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/tag Build is failing

Reviewed-on: #38
Reviewed-by: Philipp Dormann <philipp@philippdormann.de>
This commit is contained in:
Nicolai Ort 2021-03-14 15:51:53 +00:00
commit 8d3cc34395
7 changed files with 69 additions and 21 deletions

View File

@ -1,6 +1,27 @@
---
kind: secret
name: docker_username
get:
path: odit-registry-builder
name: username
---
kind: secret
name: docker_password
get:
path: odit-registry-builder
name: password
---
kind: secret
name: git_ssh
get:
path: odit-git-bot
name: sshkey
--- ---
kind: pipeline kind: pipeline
type: docker type: kubernetes
name: build:dev name: build:dev
clone: clone:
disable: true disable: true
@ -16,9 +37,9 @@ steps:
depends_on: [clone] depends_on: [clone]
settings: settings:
username: username:
from_secret: DOCKER_REGISTRY_USER from_secret: docker_username
password: password:
from_secret: DOCKER_REGISTRY_PASSWORD from_secret: docker_password
repo: registry.odit.services/lfk/document-server repo: registry.odit.services/lfk/document-server
tags: tags:
- dev - dev
@ -38,7 +59,7 @@ steps:
author_email: bot@odit.services author_email: bot@odit.services
remote: git@git.odit.services:lfk/document-server.git remote: git@git.odit.services:lfk/document-server.git
ssh_key: ssh_key:
from_secret: GITLAB_SSHKEY from_secret: git_ssh
- name: run full license export - name: run full license export
depends_on: ["clone"] depends_on: ["clone"]
image: node:14.15.1-alpine3.12 image: node:14.15.1-alpine3.12
@ -56,7 +77,7 @@ steps:
remote: git@git.odit.services:lfk/document-server.git remote: git@git.odit.services:lfk/document-server.git
skip_verify: true skip_verify: true
ssh_key: ssh_key:
from_secret: GITLAB_SSHKEY from_secret: git_ssh
trigger: trigger:
branch: branch:
@ -66,7 +87,7 @@ trigger:
--- ---
kind: pipeline kind: pipeline
type: docker type: kubernetes
name: build:latest name: build:latest
clone: clone:
disable: true disable: true
@ -84,9 +105,9 @@ steps:
image: plugins/docker image: plugins/docker
settings: settings:
username: username:
from_secret: DOCKER_REGISTRY_USER from_secret: docker_username
password: password:
from_secret: DOCKER_REGISTRY_PASSWORD from_secret: docker_password
repo: registry.odit.services/lfk/document-server repo: registry.odit.services/lfk/document-server
tags: tags:
- latest - latest
@ -99,7 +120,7 @@ steps:
commit: false commit: false
remote: git@git.odit.services:lfk/document-server.git remote: git@git.odit.services:lfk/document-server.git
ssh_key: ssh_key:
from_secret: GITLAB_SSHKEY from_secret: git_ssh
trigger: trigger:
branch: branch:
@ -109,7 +130,7 @@ trigger:
--- ---
kind: pipeline kind: pipeline
type: docker type: kubernetes
name: build:tags name: build:tags
steps: steps:
@ -118,9 +139,9 @@ steps:
depends_on: [clone] depends_on: [clone]
settings: settings:
username: username:
from_secret: DOCKER_REGISTRY_USER from_secret: docker_username
password: password:
from_secret: DOCKER_REGISTRY_PASSWORD from_secret: docker_password
repo: registry.odit.services/lfk/document-server repo: registry.odit.services/lfk/document-server
tags: tags:
- '${DRONE_TAG}' - '${DRONE_TAG}'

View File

@ -2,12 +2,26 @@
All notable changes to this project will be documented in this file. Dates are displayed in UTC. All notable changes to this project will be documented in this file. Dates are displayed in UTC.
#### [v0.3.3](https://git.odit.services/lfk/document-server/compare/v0.3.3...v0.3.3)
- Merge pull request 'Configurable sponsoring disclaimer feature/33-disclaimer' (#34) from feature/33-disclaimer into dev [`e9d3574`](https://git.odit.services/lfk/document-server/commit/e9d35745997a9e948509ea67b59f5a7658f9d652)
- Updated styleing [`03ed6d5`](https://git.odit.services/lfk/document-server/commit/03ed6d5bc18c5b26edd7b1d698c9de936e008f32)
- Added disclaimer to template [`4e1e124`](https://git.odit.services/lfk/document-server/commit/4e1e124d0dc08f96aeb05dd1c975064fe785b80f)
- MAde disclaimer configurable via env [`5e4d6f4`](https://git.odit.services/lfk/document-server/commit/5e4d6f44dab581483135594432bd8c8d65ba74ef)
- MAde disclaimer configurable via env [`885765a`](https://git.odit.services/lfk/document-server/commit/885765ac71b6a65c869ee841c383667f4947dcde)
- 🧾New changelog file version [CI SKIP] [skip ci] [`19fbf50`](https://git.odit.services/lfk/document-server/commit/19fbf50f6f6057c5321a999b6551d05db32b5fd8)
- Added reamde entry for the new env var [`9dd62ce`](https://git.odit.services/lfk/document-server/commit/9dd62cefa94bf3f0bf8e77fd25e7ca1ec4b30e2b)
#### [v0.3.3](https://git.odit.services/lfk/document-server/compare/v0.3.2...v0.3.3) #### [v0.3.3](https://git.odit.services/lfk/document-server/compare/v0.3.2...v0.3.3)
> 19 February 2021
- Merge pull request 'Alpha Release 0.3.3 - Download options' (#32) from dev into main [`21b5e04`](https://git.odit.services/lfk/document-server/commit/21b5e048ed5ed72f88304e5c737639c54cc71483)
- 🧾New changelog file version [CI SKIP] [skip ci] [`d1a29c1`](https://git.odit.services/lfk/document-server/commit/d1a29c1cbb8845a1adf8a414d158ebcabd48dc04) - 🧾New changelog file version [CI SKIP] [skip ci] [`d1a29c1`](https://git.odit.services/lfk/document-server/commit/d1a29c1cbb8845a1adf8a414d158ebcabd48dc04)
- 🧾New changelog file version [CI SKIP] [skip ci] [`fd8b7e5`](https://git.odit.services/lfk/document-server/commit/fd8b7e56da4a1601141f63627e3990660c521ea6) - 🧾New changelog file version [CI SKIP] [skip ci] [`fd8b7e5`](https://git.odit.services/lfk/document-server/commit/fd8b7e56da4a1601141f63627e3990660c521ea6)
- Added download option to cards [`1ca5d3e`](https://git.odit.services/lfk/document-server/commit/1ca5d3ea078ef51818657e2b3c9f114c67bff86d) - Added download option to cards [`1ca5d3e`](https://git.odit.services/lfk/document-server/commit/1ca5d3ea078ef51818657e2b3c9f114c67bff86d)
- Added download header [`55877de`](https://git.odit.services/lfk/document-server/commit/55877de2aa46583f30d033467037e0454d1236be) - Added download header [`55877de`](https://git.odit.services/lfk/document-server/commit/55877de2aa46583f30d033467037e0454d1236be)
- 🧾New changelog file version [CI SKIP] [skip ci] [`c012b49`](https://git.odit.services/lfk/document-server/commit/c012b4943d96ee3a9442c65389c4dcea08642109)
- 🚀Bumped version to v0.3.3 [`ba566bc`](https://git.odit.services/lfk/document-server/commit/ba566bcc33ed920324cd9977b3f293a2c629f92c) - 🚀Bumped version to v0.3.3 [`ba566bc`](https://git.odit.services/lfk/document-server/commit/ba566bcc33ed920324cd9977b3f293a2c629f92c)
- 🧾New changelog file version [CI SKIP] [skip ci] [`a386c5b`](https://git.odit.services/lfk/document-server/commit/a386c5bef88da29e4447399d4edca0234b674ed5) - 🧾New changelog file version [CI SKIP] [skip ci] [`a386c5b`](https://git.odit.services/lfk/document-server/commit/a386c5bef88da29e4447399d4edca0234b674ed5)

View File

@ -36,6 +36,8 @@ The basic generation mechanism makes the templates and routes interchangeable (i
| SPONSORING_RECEIPT_MINIMUM_AMOUNT | String | "10" | The mimimum total donation amount a sponsor has to donate to be able to receive a donation receipt - used to generate pdf text. | SPONSORING_RECEIPT_MINIMUM_AMOUNT | String | "10" | The mimimum total donation amount a sponsor has to donate to be able to receive a donation receipt - used to generate pdf text.
| SPONOR_LOGOS | Array<String> | Empty png | The sponsor images you want to loop through. You can provide them via http url, local file or base64-encoded image. | SPONOR_LOGOS | Array<String> | Empty png | The sponsor images you want to loop through. You can provide them via http url, local file or base64-encoded image.
| API_KEY | String(min length: 64) | Random generated string | The api key you want to use for auth (query-param `key`), has to be at least 64 chars long. | API_KEY | String(min length: 64) | Random generated string | The api key you want to use for auth (query-param `key`), has to be at least 64 chars long.
| DISCLAIMER_TEXT | String | N/A | A disclaimer that will get displayed on the bottom of each sponsoring contract. R/N You can only provide the disclaimer for one language.
| CONTRACTS_PER_RUNNER | Number | 1 | The amount of contracts that get created per runner (per request).
## Templates ## Templates
> The document server uses html templates to generate various pdf documents. > The document server uses html templates to generate various pdf documents.

View File

@ -1,6 +1,6 @@
{ {
"name": "@odit/lfk-document-server", "name": "@odit/lfk-document-server",
"version": "0.3.3", "version": "0.4.0",
"description": "The document generation server for the LfK! runner system. This generates certificates, sponsoring aggreements and more", "description": "The document generation server for the LfK! runner system. This generates certificates, sponsoring aggreements and more",
"main": "src/app.ts", "main": "src/app.ts",
"scripts": { "scripts": {

View File

@ -22,6 +22,7 @@ export class PdfCreator {
private templateDir = path.join(__dirname, '/templates'); private templateDir = path.join(__dirname, '/templates');
private browser; private browser;
private static interpolations = { eventname: config.eventname, sponsoring_receipt_minimum_amount: config.sponsoring_receipt_minimum_amount, currency_symbol: config.currency_symbol } private static interpolations = { eventname: config.eventname, sponsoring_receipt_minimum_amount: config.sponsoring_receipt_minimum_amount, currency_symbol: config.currency_symbol }
private static contractsPerRunner = config.contracts_per_runner;
/** /**
* Main constructor. * Main constructor.
@ -108,6 +109,11 @@ export class PdfCreator {
if (runners.length == 1 && Object.keys(runners[0]).length == 0) { if (runners.length == 1 && Object.keys(runners[0]).length == 0) {
runners[0] = this.generateEmptyRunner(); runners[0] = this.generateEmptyRunner();
} }
for (var i = 1; i < PdfCreator.contractsPerRunner; i++) {
runners = runners.reduce(function (res, current, index, array) {
return res.concat([current, current]);
}, []);
}
if (runners.length > 50) { if (runners.length > 50) {
let pdf_promises = new Array<Promise<Buffer>>(); let pdf_promises = new Array<Promise<Buffer>>();
let i, j; let i, j;
@ -121,7 +127,7 @@ export class PdfCreator {
await i18next.changeLanguage(locale); await i18next.changeLanguage(locale);
const template_source = fs.readFileSync(`${this.templateDir}/sponsoring_contract.html`, 'utf8'); const template_source = fs.readFileSync(`${this.templateDir}/sponsoring_contract.html`, 'utf8');
const template = Handlebars.compile(template_source); const template = Handlebars.compile(template_source);
let result = template({ runners, codeformat }); let result = template({ runners, codeformat, disclaimer: config.disclaimer_text });
result = await awaitAsyncHandlebarHelpers(result); result = await awaitAsyncHandlebarHelpers(result);
const pdf = await this.renderPdf(result, { format: "A5", landscape: true }); const pdf = await this.renderPdf(result, { format: "A5", landscape: true });
return pdf return pdf

View File

@ -12,11 +12,16 @@ export const config = {
codeformat: process.env.CODEFORMAT || "qrcode", codeformat: process.env.CODEFORMAT || "qrcode",
sponor_logos: getSponsorLogos(), sponor_logos: getSponsorLogos(),
api_key: getApiKey(), api_key: getApiKey(),
disclaimer_text: process.env.DISCLAIMER_TEXT || "",
contracts_per_runner: process.env.CONTRACTS_PER_RUNNER || 1,
} }
let errors = 0 let errors = 0
if (typeof config.internal_port !== "number") { if (typeof config.internal_port !== "number") {
errors++ errors++
} }
if (typeof config.contracts_per_runner !== "number") {
errors++
}
if (typeof config.development !== "boolean") { if (typeof config.development !== "boolean") {
errors++ errors++
} }

View File

@ -68,8 +68,8 @@
<p style="font-size: x-small; display: block;">{{__ "group"}}</p> <p style="font-size: x-small; display: block;">{{__ "group"}}</p>
</div> </div>
</div> </div>
<p>{{__ "sponsoring_amount_per_distance"}}</p> <p style="margin-top: -0.5rem">{{__ "sponsoring_amount_per_distance"}}</p>
<div class="columns"> <div class="columns" style="margin-top: -1rem;">
<div class="column is-6"> <div class="column is-6">
<span style="border-bottom: 1px solid; width: 100%; display: block;"></span> <span style="border-bottom: 1px solid; width: 100%; display: block;"></span>
<p style="font-size: x-small; display: block;">{{__ "lastname"}}</p> <p style="font-size: x-small; display: block;">{{__ "lastname"}}</p>
@ -79,9 +79,9 @@
<p style="font-size: x-small; display: block;">{{__ "firstname"}}</p> <p style="font-size: x-small; display: block;">{{__ "firstname"}}</p>
</div> </div>
</div> </div>
<p style="font-size: medium;">{{__ "address"}} ({{__ "sponsor"}})</p> <p style="font-size: medium; margin-top: -0.5rem;">{{__ "address"}} ({{__ "sponsor"}})</p>
<p style="font-size: x-small;">({{__ "sponsoring_address_condition"}})</p> <p style="font-size: x-small;">({{__ "sponsoring_address_condition"}})</p>
<div class="columns"> <div class="columns" style="margin-top: -1rem;">
<div class="column is-8"> <div class="column is-8">
<span style="border-bottom: 1px solid; width: 100%; display: block;"></span> <span style="border-bottom: 1px solid; width: 100%; display: block;"></span>
<p style="font-size: x-small; display: block;">{{__ "street"}}</p> <p style="font-size: x-small; display: block;">{{__ "street"}}</p>
@ -91,7 +91,7 @@
<p style="font-size: x-small; display: block;">{{__ "house_number"}}</p> <p style="font-size: x-small; display: block;">{{__ "house_number"}}</p>
</div> </div>
</div> </div>
<div class="columns"> <div class="columns" style="margin-top: -1rem;">
<div class="column is-4"> <div class="column is-4">
<span style="border-bottom: 1px solid; width: 100%; display: block;"></span> <span style="border-bottom: 1px solid; width: 100%; display: block;"></span>
<p style="font-size: x-small; display: block;">{{__ "postalcode"}}</p> <p style="font-size: x-small; display: block;">{{__ "postalcode"}}</p>
@ -101,8 +101,7 @@
<p style="font-size: x-small; display: block;">{{__ "city"}}</p> <p style="font-size: x-small; display: block;">{{__ "city"}}</p>
</div> </div>
</div> </div>
<br> <div class="columns" style="margin-top: -1rem;">
<div class="columns">
<div class="column is-7"> <div class="column is-7">
<span style="border-bottom: 1px solid; width: 100%; display: block;"></span> <span style="border-bottom: 1px solid; width: 100%; display: block;"></span>
<p style="font-size: x-small; display: block;">{{__ "location"}}, {{__ "date"}}</p> <p style="font-size: x-small; display: block;">{{__ "location"}}, {{__ "date"}}</p>
@ -112,6 +111,7 @@
<p style="font-size: x-small; display: block;">{{__ "signature"}}</p> <p style="font-size: x-small; display: block;">{{__ "signature"}}</p>
</div> </div>
</div> </div>
<p style="font-size: xx-small; overflow: hidden; height: 4rem; text-align: center;">{{../disclaimer}}</p>
</div> </div>
</div> </div>
{{/each}} {{/each}}