From 28dc38196e813e30179df638d2759ed595317613 Mon Sep 17 00:00:00 2001 From: Max Value <greenwoodw50@gmail.com> Date: Thu, 23 Jan 2025 23:26:54 +0000 Subject: [PATCH] PDF manifest generation + added PDF manifest generation + added "crew notes" section in items.json = fixed visual bug on auth index "show data" drop down = minor visual changes to EPUB and MOBI layout - removed completed items off to-do list --- .gitignore | 5 ++++ auth/generate_docs.py | 66 +++++++++++++++++++++++++++++++++++++++---- auth/index.php | 9 +----- items.json | 9 ++++-- 4 files changed, 73 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index bd69528..3db8363 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,10 @@ item[0-9].html content.opf toc.ncx +*.toc *.epub *.mobi +*.tex +*.pdf +*.aux +*.log diff --git a/auth/generate_docs.py b/auth/generate_docs.py index aa9b76f..52b791a 100755 --- a/auth/generate_docs.py +++ b/auth/generate_docs.py @@ -1,5 +1,7 @@ #!.venv/bin/python +from pylatex import Command, Document, Section, Tabular, NewPage, NewLine +from pylatex.utils import NoEscape, bold import json import os @@ -21,9 +23,10 @@ for (i, item) in enumerate(items): <title>{item['code']}</title> </head> <body> - <h1>{item['code']}</h1> - <h2>{item['subtext']}</h2> - <p><b>Description:</b> {item['description']}</p> + <h2>{item['code']}</h2> + <p><em>{item['subtext']}</em></p> + <h4>Description</h4> + <p>{item['description']}</p> <table> <tr> <th>Rating</th> @@ -38,8 +41,10 @@ for (i, item) in enumerate(items): <td>{item['stockCount']}</td> </tr> </table> - <h3>Anchor notes:</h3> + <h4>Anchor notes:</h4> <p>{item['notes']}</p> + <h4>Crew notes:</h4> + <p>{item['crew_notes']}</p> </body> </html> """) @@ -153,6 +158,57 @@ with open("../docs/epub/toc.ncx", "w") as f: os.system(""" zip -X0 ../docs/item_manifest.epub ../docs/epub/mimetype && zip -Xur9D ../docs/item_manifest.epub ../docs/epub/* && - ebook-convert ../docs/item_manifest.epub ../docs/item_manifest.mobi + ebook-convert ../docs/item_manifest.epub ../docs/item_manifest.mobi & """) +os.system(f"pandoc -f html ../docs/epub/info_page.html -t latex -o ../docs/pdf/info.tex") +for i in range(len(items)): + os.system(f"pandoc -f html ../docs/epub/item{i}.html -t latex -o ../docs/pdf/item{i}.tex") + +geometry_options = { + "tmargin": "3cm", + "bmargin": "2cm", + "lmargin": "1.5cm", + "rmargin": "1.5cm" + } +doc = Document( + "XMDV Teleshopping item manifest", geometry_options=geometry_options, + textcomp = True + ) +doc.preamble.append(NoEscape(r"\usepackage{longtable}")) +doc.preamble.append(NoEscape(r"\usepackage{booktabs}")) +doc.preamble.append(NoEscape(r"\usepackage{hyperref}")) +doc.preamble.append(NoEscape(r"\usepackage{xcolor}")) + +doc.preamble.append(NoEscape(r"\def\tightlist{}")) + +doc.preamble.append(Command("title", "XMDV Teleshopping item manifest")) +doc.preamble.append(Command("author", "William Greenwood")) +doc.preamble.append(Command("date", NoEscape(r"\today"))) + +doc.append(NoEscape(r""" +\maketitle +\begin{center} +\textcolor{red}{\large{}Contains HIDDEN INFORMATION. NOT to be shared with anchor before shoot.} +\end{center} +\tableofcontents +\newpage + """)) + +with open(f"../docs/pdf/info.tex", "r") as f: + doc.append(NoEscape(f.read().encode('latin-1', 'ignore').decode('utf-8'))) + +doc.append(NoEscape(r""" + \vspace*{\fill} + \section{Items} + \newpage + """)) + +for i in range(len(items)): + with open(f"../docs/pdf/item{i}.tex", "r") as f: + doc.append(NoEscape(f.read().encode('latin-1', 'ignore').decode('utf-8'))) + + doc.append(NoEscape(r"\newpage")) + +doc.generate_tex("../docs/pdf/item_manifest") +doc.generate_pdf("../docs/item_manifest", silent=False) diff --git a/auth/index.php b/auth/index.php index af74f39..a5aa7e0 100644 --- a/auth/index.php +++ b/auth/index.php @@ -527,6 +527,7 @@ for ($i = 0; $i < 360; $i += $clockIncrement) { <br> <input style="vertical-align: top;" type="submit" name="update" value="Update"> <input style="vertical-align: top;" type="submit" name="generate_docs" value="Generate docs"> + <br> <details style="display: inline-block;"> <summary>Current data</summary> <?php echo "<pre>" . var_export($data, true) . "</pre>" ?> @@ -540,15 +541,7 @@ for ($i = 0; $i < 360; $i += $clockIncrement) { Still need to do plenty to both the GFX overlay and this page (and the actual clock): </p> <ul> - <li><s>Make this notes section a little better? it might actually be useful during the show. Although the arrow is quite difficult to click on</s></li> - <li><s>Add the controls for persentage sold and the relevant display on the GFX side of things</s></li> - <li><s>Add 2 more timers on both the controls and the GFX page</s></li> - <li><s>Add the timers and the % sold to the autocue so the presenter can atually see what theyre doing</s></li> - <li>Add a clock display to the GFX page and the autocue (could just be a gereric time?)</li> - <li><s>Make the top banner look better</s></li> - <li><s>Add some kind of rating into the item file and make it display</s></li> <li>add marquee of the current buyers of the product and figure out how to do this (potentially hard?)</li> - <li><s>Add producer notes to the interface and autocue</s></li> </ul> <p> and then still to do in the admin department: Talk to Joe about the GFX system, ask Ash about the lighting desk sAcn input and to setup things, makerspace the clock, text people about things, <s>arrange screentest with Jack</s>. diff --git a/items.json b/items.json index 4596c7a..4f2aeb9 100755 --- a/items.json +++ b/items.json @@ -6,7 +6,8 @@ "description":"Test item description", "origionalPrice":0, "stockCount":0, - "notes":"<p>[autocue] Showing: test product.<br>Commencing shortly.</p>" + "notes":"<p>[autocue] Showing: test product.<br>Commencing shortly.</p>", + "crew_notes":"testing" }, { "code":"Item 1", @@ -15,7 +16,8 @@ "description":"50m shiny gold <em>Stick-Strip</em>™! Origional beautiful formula! Cannot be broken! Too beautiful! Stuck!", "origionalPrice":500, "stockCount":100, - "notes":"<p>ITEM IS A REEL OF GOLDEN TAPE THAT CANNOT BE TORN</p><ul><li>EMPASIZE AS MUCH AS POSSIBLE HOW BEAUTIFUL IT IS</li></ul>" + "notes":"<p>ITEM IS A REEL OF GOLDEN TAPE THAT CANNOT BE TORN</p><ul><li>EMPASIZE AS MUCH AS POSSIBLE HOW BEAUTIFUL IT IS</li></ul>", + "crew_notes":"testing" }, { "code":"Item 2", @@ -24,6 +26,7 @@ "description":"Product 2 description. It's really long to see if the badge element moves down the page at all. I f**king hate CSS positioning. Oops family show.", "origionalPrice":170, "stockCount":200, - "notes":"Some more notes..." + "notes":"Some more notes...", + "crew_notes":"testing" } ] -- 2.39.2