diff options
author | Marvin Borner | 2021-02-08 15:26:19 +0100 |
---|---|---|
committer | Marvin Borner | 2021-02-08 15:26:34 +0100 |
commit | 817f18cf40371128740270e8d71de523cf72316c (patch) | |
tree | 34c744bebc0903079ebc297f43b4f5e948541897 | |
parent | 4a87c860681ee2c872aa3f40c024d6d66f8d087c (diff) |
beautiful code
-rwxr-xr-x | cli.js | 22 | ||||
-rw-r--r-- | db.js | 6 | ||||
-rw-r--r-- | zeitung/main.tex | 1 | ||||
-rw-r--r-- | zeitung/parts/imprint.tex | 15 | ||||
-rw-r--r-- | zeitung/parts/studenttemplate.tex | 10 |
5 files changed, 50 insertions, 4 deletions
@@ -67,16 +67,23 @@ if ((idx = params.indexOf("-r")) > -1) { // TODO: Erkennungsmerkmale, Wohnort?? // WARNING: UGLY! + const sanitize = (text) => + text + .replace(/(\r\n|\n|\r)/gm, "") + .replace(/\\/g, "\\\\") + .replace(/&/g, "\\&"); + let hay; const answer = (needle) => { const e = hay.find((e) => e.question === needle); - if (e && e.answer && e.answer.length > 1) return e.answer; + if (e && e.answer && e.answer.length > 1) return sanitize(e.answer); else return "nichts"; }; db.dump().then((data) => { data.users.forEach((user) => { hay = data.profile.filter((e) => e.user_id === user.id); + const comments = user.comments; const obj = { id: user.id - 1, // Why tf tho name: `${user.name} ${user.middlename || ""} ${user.surname}`, @@ -98,7 +105,18 @@ if ((idx = params.indexOf("-r")) > -1) { }); textex += "\\student"; - textex = textex.replace(/(\r\n|\n|\r)/gm, "").replace(/&/g, "\\&"); + // Ugly inline comments + if (comments && comments.length > 0) { + textex += + "\n\n\\renewcommand{\\arraystretch}{1.5}\\hspace*{\\commentsx}\\begin{tabularx}{\\commentswidth}{*{2}{>{\\RaggedRight\\arraybackslash}X}}"; + for (let i = 0; i < comments.length; i += 2) { + const first = comments[i].comment; + const second = comments[i + 1] ? comments[i + 1].comment : " "; + textex += `${sanitize(first)} & ${sanitize(second)} \\\\`; + } + textex += "\\end{tabularx}\\renewcommand{\\arraystretch}{1}"; + } + fs.writeFile( __dirname + "/zeitung/parts/students/" + user.class + "/" + user.username + ".tex", textex, @@ -240,6 +240,12 @@ class DB { const profile = await this.query( "SELECT q.question, a.answer, a.user_id FROM profile_questions q INNER JOIN profile_answers a ON a.question_id = q.id", ); + + for (const user of users) { + user.comments = await this.query("SELECT comment from profile_comments where profile_id=" + user.id); + //user["comments"].forEach((comment) => console.log("Kommentar: " + comment.comment)); + } + return { users, profile }; } diff --git a/zeitung/main.tex b/zeitung/main.tex index 3afc3b2..7d2dd98 100644 --- a/zeitung/main.tex +++ b/zeitung/main.tex @@ -15,6 +15,7 @@ \usepackage{fancyhdr} \usepackage{background} \usepackage{changepage} +\usepackage{tabularx} % Font \setmainfont{"[tierra-nueva.otf]"}[BoldFont="[tierra-nueva-bold.otf]"] diff --git a/zeitung/parts/imprint.tex b/zeitung/parts/imprint.tex index 124dc43..cee13b1 100644 --- a/zeitung/parts/imprint.tex +++ b/zeitung/parts/imprint.tex @@ -1,2 +1,15 @@ \title{Impressum} -\lipsum[1-2] + +% TODO: Druckerei, Auflage, Verfasser (PFLICHT) +% Alle Rechte vorbehalten + +\begin{tabular}{ l l } + \textbf{V.i.S.d.P} & RBS TG13 \\ % Verantwortlich im Sinne des Presserechts + \textbf{\LaTeX} & Marvin Borner, Lars Krönner \\ + \textbf{Web-Plattform} & Lars Krönner, Marvin Borner \\ + \textbf{Web-Hosting} & Marvin Borner \\ + \textbf{Design} & Leia Saumweber, Tomislav Strazanac \\ + \textbf{Finanzierung \& Werbung} & Lars Mayer \\ + \textbf{Planung \& Organisation} & Mathias Schmiegel, Sebastian Sutor \\ + \textbf{Open-Source Code} & \url{https://github.com/marvinborner/abitur2021} +\end{tabular} diff --git a/zeitung/parts/studenttemplate.tex b/zeitung/parts/studenttemplate.tex index 0fb3dfc..db7daf4 100644 --- a/zeitung/parts/studenttemplate.tex +++ b/zeitung/parts/studenttemplate.tex @@ -64,7 +64,7 @@ \fi \def\tablewidth{0.6\linewidth} -\hspace*{\tablex}\Large\begin{minipage}{\tablewidth} +\hspace*{\tablex}\large\begin{minipage}{\tablewidth} \begin{tabular}{@{}ll@{}} \textbf{Name:} & \stdname \\ \textbf{Geburtstag:} & \multicolumn{1}{p{\tablewidth}}{\RaggedRight\stdbirthday} \\ @@ -83,3 +83,11 @@ \begin{figure}[H] \hspace*{-2.5cm}\includegraphics[keepaspectratio=true, width=\paperwidth]{mittelwelle.png} \end{figure} + +% Comments +\def\commentswidth{0.7\linewidth} +\ifoddpage + \def\commentsx{-1cm} +\else + \def\commentsx{\framewidth} +\fi |