aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Borner2021-05-24 23:17:57 +0200
committerMarvin Borner2021-05-24 23:19:06 +0200
commitad663d667ddb9c1e5b6b729eb3840b0040c6ebf0 (patch)
tree33346c91cbc3012e1f3936cff396b6271f32402b
parent784fee375570197c8b07aa154b12c77f81aa607c (diff)
Fixed some QR-code issues
-rwxr-xr-xcli.js17
-rw-r--r--zeitung/parts/studenttemplate.tex3
2 files changed, 10 insertions, 10 deletions
diff --git a/cli.js b/cli.js
index fb24d08..90e451b 100755
--- a/cli.js
+++ b/cli.js
@@ -82,6 +82,9 @@ if ((idx = params.indexOf("-r")) > -1) {
)
.replace(/~/g, "$\\mathtt{\\sim}$");
+ // Quotes in QR codes destroy everything
+ const sanitizeQR = (text) => text.replace(/"/g, "").replace(/ /g, "\\ ");
+
let hay;
const answer = (needle) => {
const e = hay.find((e) => e.question === needle);
@@ -94,11 +97,9 @@ if ((idx = params.indexOf("-r")) > -1) {
// Be aware, I'm a longtime rhyme primer
db.dump().then(async (data) => {
await data.users.forEach(async (user) => {
- const curr = data.profile.filter((e) => e.user_id === user.id);
- const next = data.profile.filter((e) => e.user_id === user.id - 1);
+ hay = data.profile.filter((e) => e.user_id === user.id);
const comments = user.comments;
const chars = user.chars;
- hay = curr;
const obj = {
id: user.id,
name: `${user.name} ${user.middlename || ""} ${user.surname}`,
@@ -115,17 +116,15 @@ if ((idx = params.indexOf("-r")) > -1) {
obj.birthday = new Date(obj.birthday == "nichts" ? "1.1.2000" : obj.birthday).toLocaleDateString("de");
- // QR-Code.. DON'T ASK TODO: Fix for last student?
- hay = next;
- obj.qrcode = answer("QR-Code Text (z.B. Social Media Links, random Text, whatever)").replace(/ /g, "\\ ");
+ // QR-Code
+ obj.qrcode = sanitizeQR(answer("QR-Code Text (z.B. Social Media Links, random Text, whatever)"));
if (obj.qrcode === "nichts") obj.qrcode = "";
- hay = curr;
// 5head
let textex = "";
- Object.keys(obj).forEach((elem) => {
+ for (elem of Object.keys(obj)) {
textex += `\\def\\std${elem}{${obj[elem]}}`;
- });
+ }
textex += `\\student\\studentbackground{${obj.id}}{${obj.qrcode}}\n\n`;
diff --git a/zeitung/parts/studenttemplate.tex b/zeitung/parts/studenttemplate.tex
index 04eeaf3..08df0c0 100644
--- a/zeitung/parts/studenttemplate.tex
+++ b/zeitung/parts/studenttemplate.tex
@@ -61,8 +61,9 @@
\oddflip[keepaspectratio=true, width=\framewidth]{rahmen.png}
}
\put(\textwidth - \qrcodex, \framey - 25pt){
+ \def\stdqrcode{#2}
\ifdefempty{\stdqrcode}{}{
- \qrcode[nolink, height=0.7in]{\stdqrcode}
+ \qrcode[nolink, height=0.7in]{#2}
}
}
}