]> OzVa Git service - bread/commitdiff
Added full recipe book
authorMax Value <greenwoodw50@gmail.com>
Sat, 17 May 2025 02:36:07 +0000 (03:36 +0100)
committerMax Value <greenwoodw50@gmail.com>
Sat, 17 May 2025 02:36:07 +0000 (03:36 +0100)
+ pdf title and author to all compiled documents
+ added pdf to gitignore

.gitignore
sous.py
templates/index.html
templates/index.tex [deleted file]
templates/main.tex [new file with mode: 0644]
templates/template.tex

index d1c201314c82f309468e49481c5173291264b74d..bc95d3eefc4051d52758d212b574d32cb0c6e954 100644 (file)
@@ -1,3 +1,4 @@
 build/*
 recipes/*
 /index.html
+*.pdf
diff --git a/sous.py b/sous.py
index 0770aeefbc45917b8ed73ebc8cdc6a1d59f4baf6..37f8df9eae2f632b74c9f2bde76fbbacadc4ac19 100755 (executable)
--- a/sous.py
+++ b/sous.py
@@ -56,6 +56,14 @@ class RecipeBook:
                for recipe in tqdm(self.recipes):
                        recipe.render_latex(self.latex_environment)
 
+               print("Generating full document...")
+               template = self.latex_environment.get_template("main.tex")
+               with open("build/main.tex", "w") as f:
+                       f.write(template.render(recipes = self.recipes))
+
+               system(f"pdflatex -interaction='nonstopmode' -output-directory='build' 'build/main.tex' > /dev/zero")
+               system(f"mv build/main.pdf bread.pdf")
+
 class Recipe:
        def __init__(self, filename: str):
                with open(path.join("src", filename), "rb") as f:
index f0d52e62ef108c8673921fe25a51c06efe28a0fc..dd1a9d334dc3aaaf65eedaab54575e01f7573ec9 100644 (file)
@@ -9,6 +9,7 @@
                <main>
                <img src="banner.png" />
                <h1>Bread</h1>
+               <p><a href="bread.pdf">All recipes [PDF]</a></p>
                <p>
                        Collection of recipes with <a href="pages/percentage.html">bakers percentage</a> and example weights. Recipes are stored in TOML format and periodically compiled to this website and the accompanying printouts. This is done with a <a href="https://git.ozva.co.uk/?p=bread">tool I built</a>. <a href="pages/temperature.html">Temperatures</a> are listed in celceus and should be assumed to be with fan when refering to baking.
                </p>
diff --git a/templates/index.tex b/templates/index.tex
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/templates/main.tex b/templates/main.tex
new file mode 100644 (file)
index 0000000..20e3ddc
--- /dev/null
@@ -0,0 +1,89 @@
+\documentclass{article}
+
+\usepackage[margin=2cm]{geometry}
+\usepackage[scaled]{helvet}
+\usepackage[T1]{fontenc}
+\usepackage{graphicx}
+\graphicspath{{../}}
+\renewcommand\familydefault{\sfdefault}
+
+\usepackage{hyperref}
+\hypersetup{
+       colorlinks=true,
+       linkcolor=blue,
+       urlcolor=blue,
+       pdftitle={Bread Book},
+       pdfauthor={William Greenwood}
+       }
+
+\begin{document}
+
+\pagenumbering{gobble}
+
+\noindent\includegraphics[width=\textwidth]{banner}
+
+\vspace{4mm}
+
+{\noindent\large{}\textbf{William Greenwood}}
+
+\vspace{4mm}
+
+Collection of recipes with bakers percentage and example weights. Recipes are stored in TOML format and periodically compiled to the website (\url{https://bread.ozva.co.uk}) and the accompanying printouts. This is done with a tool I built. Temperatures are listed in celceus and should be assumed to be with fan when refering to baking. Currently |~ recipes|length ~| recipes at last compilation (\today{}).
+
+\vspace{4mm}
+
+\begin{enumerate}
+       \itemsep0em
+       |% for recipe in recipes %|
+               \item \textbf{|~ recipe.recipe.information.title ~|}. |~ recipe.recipe.information.description ~|
+       |% endfor %|
+\end{enumerate}
+
+\newpage
+
+|% for recipe in recipes %|
+
+       |% set recipe = recipe.recipe %|
+
+       \section{|~ recipe.information.title ~|}
+
+       |~ recipe.information.description ~|
+
+       \subsection*{Notes}
+
+       |~ recipe.information.notes|replace("\n", "\n\n")|replace("%", "\%")|replace("#", "\#") ~|
+
+       \subsection*{Ingredients}
+
+       \renewcommand{\arraystretch}{1.2}
+       \begin{tabular}{lllllll}
+               & \textbf{Bakers \%} & \textbf{500g total} & \textbf{1kg total} & \textbf{2kg total} & \textbf{3kg total} & \textbf{4kg total} \\
+               \hline
+               |% for name, weight in recipe.ingredients.items() %|
+                       |~ name|replace("-", " ")|title ~| &
+                       |~ weight ~|\% &
+
+                               |% macro weighted(multiplier) %|
+                                       |% set rounded = (weight * recipe.kg * multiplier)|round|int %|
+                                       |% set real = (weight * recipe.kg * multiplier)|round(2) %|
+                                       |% set error = (real - rounded)|abs %|
+                                       |% if error < real * 0.05 %|
+                                               |~ rounded ~|
+                                       |% else %|
+                                               |~ real ~|
+                                       |% endif %|
+                               |% endmacro %|
+
+                               |~ weighted(0.5) ~| &
+                               |~ weighted(1) ~| &
+                               |~ weighted(2) ~| &
+                               |~ weighted(3) ~| &
+                               |~ weighted(4) ~| \\
+               |% endfor %|
+       \end{tabular}
+
+       \newpage
+
+|% endfor %|
+
+\end{document}
index 95ec1132b2af6769fab8c14bfc14ca26a58cafc3..90c8080457b344d0de47d00df6327a0b74d7eb36 100644 (file)
@@ -5,6 +5,15 @@
 \usepackage[T1]{fontenc}
 \renewcommand\familydefault{\sfdefault}
 
+\usepackage{hyperref}
+\hypersetup{
+       colorlinks=true,
+       linkcolor=blue,
+       urlcolor=blue,
+       pdftitle={|~ recipe.information.title ~|},
+       pdfauthor={William Greenwood}
+       }
+
 \begin{document}
 
 \section*{|~ recipe.information.title ~|}
@@ -13,7 +22,7 @@
 
 \subsection*{Notes}
 
-|~ recipe.information.notes|replace("\n", "\n\n")|replace("%", "\%") ~|
+|~ recipe.information.notes|replace("\n", "\n\n")|replace("%", "\%")|replace("#", "\#") ~|
 
 \subsection*{Ingredients}