From: Max Value Date: Sat, 17 May 2025 02:36:07 +0000 (+0100) Subject: Added full recipe book X-Git-Url: https://git.ozva.co.uk/?a=commitdiff_plain;h=dd2190d748c18edb2cf65e70e4361a39681b0019;p=bread Added full recipe book + pdf title and author to all compiled documents + added pdf to gitignore --- diff --git a/.gitignore b/.gitignore index d1c2013..bc95d3e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build/* recipes/* /index.html +*.pdf diff --git a/sous.py b/sous.py index 0770aee..37f8df9 100755 --- 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: diff --git a/templates/index.html b/templates/index.html index f0d52e6..dd1a9d3 100644 --- a/templates/index.html +++ b/templates/index.html @@ -9,6 +9,7 @@

Bread

+

All recipes [PDF]

Collection of recipes with bakers percentage and example weights. Recipes are stored in TOML format and periodically compiled to this website 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.

diff --git a/templates/index.tex b/templates/index.tex deleted file mode 100644 index e69de29..0000000 diff --git a/templates/main.tex b/templates/main.tex new file mode 100644 index 0000000..20e3ddc --- /dev/null +++ b/templates/main.tex @@ -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} diff --git a/templates/template.tex b/templates/template.tex index 95ec113..90c8080 100644 --- a/templates/template.tex +++ b/templates/template.tex @@ -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}