-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: try to provide a share scoresheet link
- Loading branch information
Showing
9 changed files
with
690 additions
and
393 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {PdfRenderer} from "./PdfRenderer"; | ||
import pkg from "../../package.json"; | ||
|
||
function generatePdf(json) { | ||
let jsonString = JSON.stringify(json); | ||
console.info("Generate PDF"); | ||
console.info(json); | ||
let renderer = new PdfRenderer("BEER SCORESHEET", json.score); | ||
renderer.addMetdata(pkg.version, json.user.name, json.beer.entry, json.beer.category, jsonString); | ||
renderScoresheet(renderer, json); | ||
// let name = 'scoresheet-' + json.beer.tastingDate.toISOString().slice(0, 10).replace(/-/g, ""); | ||
let name = 'scoresheet-' + json.beer.tastingDate.replace(/-/g, ""); | ||
name += '-' + json.beer.entry.replace(/\W/g, '_'); | ||
name += '-' + json.beer.category.replace(/\W/g, '_'); | ||
name += '-' + json.user.name.replace(/\W/g, '_') + '.pdf'; | ||
console.info("Produce PDF " + name); | ||
return renderer.produce(name); | ||
} | ||
|
||
function renderScoresheet(renderer, json) { | ||
renderer.addVersion(pkg.version); | ||
json.user.render(renderer, json.beer.tastingDate); | ||
json.beer.render(renderer); | ||
json.aroma.render(renderer); | ||
json.appearance.render(renderer); | ||
json.flavor.render(renderer); | ||
json.mouthfeel.render(renderer); | ||
json.overall.render(renderer, json.score); | ||
} | ||
|
||
|
||
export {generatePdf} |
Oops, something went wrong.