From 087a18deb845442f0d3dd340678919616a837a1d Mon Sep 17 00:00:00 2001 From: Max Value Date: Sat, 7 Jun 2025 14:50:25 +0100 Subject: [PATCH] Started adding GMI --- index.gmi | 95 ++++++++++++++++++++++++++++++++++++++++++ index.html | 3 +- sous.py | 36 +++++++++++++++- templates/index.gmi | 32 ++++++++++++++ templates/template.gmi | 48 +++++++++++++++++++++ 5 files changed, 212 insertions(+), 2 deletions(-) create mode 100644 index.gmi create mode 100644 templates/index.gmi create mode 100644 templates/template.gmi diff --git a/index.gmi b/index.gmi new file mode 100644 index 0000000..ae414d0 --- /dev/null +++ b/index.gmi @@ -0,0 +1,95 @@ +# Bread + +=> gemini://bread.ozva.co.uk/bread.pdf 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 Celsius and should be assumed to be with fan when referring to baking. + +=> https://bread.ozva.co.uk/pages/percentage.html Bakers percentage [WWW] +=> https://git.ozva.co.uk/?p=bread Git repo [WWW] +=> https://bread.ozva.co.uk/pages/temperature.html Temperature guide [WWW] +=> https://bread.ozva.co.uk/pages/national-loaf.html A new national loaf [WWW] + +In many of these recipes, the salt measurement is a constant 1.5%. This is personal taste and although the presence of salt does affect the formation of the crust (and the taste) salt could be totally removed from all recipes. + +## Recipes + +### All recipes + +=> gemini://bread.ozva.co.uk/recipes/calvel-pain-au-levain.gmi Pain Au Levain (Pain Au Levain recipe from 'Taste of Bread'.) +=> gemini://bread.ozva.co.uk/recipes/kaiser-rolls-vegan.gmi Kaiser rolls (vegan) (Under development.) +=> gemini://bread.ozva.co.uk/recipes/kaiser-rolls.gmi Kaiser rolls (Chainbaker kaiser rolls.) +=> gemini://bread.ozva.co.uk/recipes/polish-white-v4.gmi White yeasted with polish pre-ferment v4 (Less acidic flavor than the v4 sourdough.) +=> gemini://bread.ozva.co.uk/recipes/sourdough-white-v4.gmi Sourdough white v4 (Sourdough sandwich loaf, similar to french bread.) +=> gemini://bread.ozva.co.uk/recipes/challah.gmi Challah (Jewish sweet-bread.) +=> gemini://bread.ozva.co.uk/recipes/challah-polish.gmi Challah with pre-ferment (Jewish sweet-bread with polish.) +=> gemini://bread.ozva.co.uk/recipes/panettone.gmi Panettone (Panettone.) +=> gemini://bread.ozva.co.uk/recipes/calvel-polish.gmi Polish pre-ferment (Recommended polish recipe from 'Taste of Bread'.) +=> gemini://bread.ozva.co.uk/recipes/seeded-rye.gmi Seeded Sourdough Rye (Sourdough rye with seeds. Can be used as a guide for other seeded breads.) +=> gemini://bread.ozva.co.uk/recipes/straight-white-v4.gmi Straight white yeasted v4 (Regular white yeasted bread.) +=> gemini://bread.ozva.co.uk/recipes/ciabatta-polish.gmi Ciabatta with pre-ferment (Light Italian bread with polish.) +=> gemini://bread.ozva.co.uk/recipes/ciabatta.gmi Ciabatta (Light Italian bread.) + + +### Keywords + +sourdough + +=> gemini://bread.ozva.co.uk/recipes/calvel-pain-au-levain.gmi Pain Au Levain (Pain Au Levain recipe from 'Taste of Bread'.) +=> gemini://bread.ozva.co.uk/recipes/sourdough-white-v4.gmi Sourdough white v4 (Sourdough sandwich loaf, similar to french bread.) +=> gemini://bread.ozva.co.uk/recipes/panettone.gmi Panettone (Panettone.) +=> gemini://bread.ozva.co.uk/recipes/seeded-rye.gmi Seeded Sourdough Rye (Sourdough rye with seeds. Can be used as a guide for other seeded breads.) + +white + +=> gemini://bread.ozva.co.uk/recipes/calvel-pain-au-levain.gmi Pain Au Levain (Pain Au Levain recipe from 'Taste of Bread'.) +=> gemini://bread.ozva.co.uk/recipes/kaiser-rolls-vegan.gmi Kaiser rolls (vegan) (Under development.) +=> gemini://bread.ozva.co.uk/recipes/kaiser-rolls.gmi Kaiser rolls (Chainbaker kaiser rolls.) +=> gemini://bread.ozva.co.uk/recipes/polish-white-v4.gmi White yeasted with polish pre-ferment v4 (Less acidic flavor than the v4 sourdough.) +=> gemini://bread.ozva.co.uk/recipes/sourdough-white-v4.gmi Sourdough white v4 (Sourdough sandwich loaf, similar to french bread.) +=> gemini://bread.ozva.co.uk/recipes/challah.gmi Challah (Jewish sweet-bread.) +=> gemini://bread.ozva.co.uk/recipes/challah-polish.gmi Challah with pre-ferment (Jewish sweet-bread with polish.) +=> gemini://bread.ozva.co.uk/recipes/panettone.gmi Panettone (Panettone.) +=> gemini://bread.ozva.co.uk/recipes/straight-white-v4.gmi Straight white yeasted v4 (Regular white yeasted bread.) +=> gemini://bread.ozva.co.uk/recipes/ciabatta-polish.gmi Ciabatta with pre-ferment (Light Italian bread with polish.) +=> gemini://bread.ozva.co.uk/recipes/ciabatta.gmi Ciabatta (Light Italian bread.) + +vegan + +=> gemini://bread.ozva.co.uk/recipes/calvel-pain-au-levain.gmi Pain Au Levain (Pain Au Levain recipe from 'Taste of Bread'.) +=> gemini://bread.ozva.co.uk/recipes/kaiser-rolls-vegan.gmi Kaiser rolls (vegan) (Under development.) +=> gemini://bread.ozva.co.uk/recipes/polish-white-v4.gmi White yeasted with polish pre-ferment v4 (Less acidic flavor than the v4 sourdough.) +=> gemini://bread.ozva.co.uk/recipes/sourdough-white-v4.gmi Sourdough white v4 (Sourdough sandwich loaf, similar to french bread.) +=> gemini://bread.ozva.co.uk/recipes/straight-white-v4.gmi Straight white yeasted v4 (Regular white yeasted bread.) +=> gemini://bread.ozva.co.uk/recipes/ciabatta-polish.gmi Ciabatta with pre-ferment (Light Italian bread with polish.) +=> gemini://bread.ozva.co.uk/recipes/ciabatta.gmi Ciabatta (Light Italian bread.) + +yeasted + +=> gemini://bread.ozva.co.uk/recipes/kaiser-rolls-vegan.gmi Kaiser rolls (vegan) (Under development.) +=> gemini://bread.ozva.co.uk/recipes/kaiser-rolls.gmi Kaiser rolls (Chainbaker kaiser rolls.) +=> gemini://bread.ozva.co.uk/recipes/challah.gmi Challah (Jewish sweet-bread.) +=> gemini://bread.ozva.co.uk/recipes/challah-polish.gmi Challah with pre-ferment (Jewish sweet-bread with polish.) +=> gemini://bread.ozva.co.uk/recipes/seeded-rye.gmi Seeded Sourdough Rye (Sourdough rye with seeds. Can be used as a guide for other seeded breads.) +=> gemini://bread.ozva.co.uk/recipes/straight-white-v4.gmi Straight white yeasted v4 (Regular white yeasted bread.) +=> gemini://bread.ozva.co.uk/recipes/ciabatta-polish.gmi Ciabatta with pre-ferment (Light Italian bread with polish.) +=> gemini://bread.ozva.co.uk/recipes/ciabatta.gmi Ciabatta (Light Italian bread.) + +brioche + +=> gemini://bread.ozva.co.uk/recipes/kaiser-rolls-vegan.gmi Kaiser rolls (vegan) (Under development.) +=> gemini://bread.ozva.co.uk/recipes/kaiser-rolls.gmi Kaiser rolls (Chainbaker kaiser rolls.) + +pre-ferment + +=> gemini://bread.ozva.co.uk/recipes/polish-white-v4.gmi White yeasted with polish pre-ferment v4 (Less acidic flavor than the v4 sourdough.) +=> gemini://bread.ozva.co.uk/recipes/challah-polish.gmi Challah with pre-ferment (Jewish sweet-bread with polish.) +=> gemini://bread.ozva.co.uk/recipes/calvel-polish.gmi Polish pre-ferment (Recommended polish recipe from 'Taste of Bread'.) +=> gemini://bread.ozva.co.uk/recipes/ciabatta-polish.gmi Ciabatta with pre-ferment (Light Italian bread with polish.) + +rye + +=> gemini://bread.ozva.co.uk/recipes/seeded-rye.gmi Seeded Sourdough Rye (Sourdough rye with seeds. Can be used as a guide for other seeded breads.) + + + +=> https://git.ozva.co.uk/?p=bread;a=commit;h=HEAD Last compiled at 2025-06-07 14:47:26.884327 [WWW] \ No newline at end of file diff --git a/index.html b/index.html index f6575c3..6aef956 100644 --- a/index.html +++ b/index.html @@ -3,6 +3,7 @@ + Bread @@ -169,7 +170,7 @@
  • Add rye and other ancient grain breads
  • -

    Last compiled at 2025-06-06 13:45:53.278224

    +

    Last compiled at 2025-06-07 14:47:26.899342

    \ No newline at end of file diff --git a/sous.py b/sous.py index fdef8a7..53fca61 100755 --- a/sous.py +++ b/sous.py @@ -65,6 +65,32 @@ class RecipeBook: system(f"pdflatex -interaction='nonstopmode' -output-directory='build' 'build/main.tex' > /dev/zero") system(f"mv build/main.pdf bread.pdf") + def render_gemtext(self): + keywords = {} + + print("Generating gemtext documents...") + for recipe in tqdm(self.recipes): + recipe.render_gemtext(self.html_environment) + + for word in recipe.recipe["information"]["keywords"]: + if word in keywords: + keywords[word].append(( + recipe.recipe["gmi"], + recipe.recipe["information"]["title"], + recipe.recipe["information"]["description"] + )) + else: + keywords |= { word: [( + recipe.recipe["gmi"], + recipe.recipe["information"]["title"], + recipe.recipe["information"]["description"] + )]} + + print("Generating gmi homepage...") + template = self.html_environment.get_template("index.gmi") + with open("index.gmi", "w") as f: + f.write(template.render(recipes = self.recipes, keywords = keywords, time = datetime.now())) + class Recipe: def __init__(self, filename: str): with open(path.join("src", filename), "rb") as f: @@ -76,6 +102,7 @@ class Recipe: self.recipe.update(filename = filename) self.recipe.update(html = filename[:-5] + ".html") self.recipe.update(tex = filename[:-5] + ".tex") + self.recipe.update(gmi = filename[:-5] + ".gmi") self.recipe.update(pdf = filename[:-5] + ".pdf") self.recipe.update(image = path.isfile(f"media/{filename[:-5]}.png")) @@ -100,11 +127,18 @@ class Recipe: system(f"pdflatex -interaction='nonstopmode' -output-directory='build' 'build/{self.recipe['tex']}' > /dev/zero") system(f"mv build/{self.recipe['pdf']} recipes") + def render_gemtext(self, environment: Environment): + template = environment.get_template("template.gmi") + + with open(path.join("recipes", self.recipe["gmi"]), "w") as f: + f.write(template.render(recipe = self.recipe, time = datetime.now())) + # main recipe_book = RecipeBook() -recipe_book.render_html() recipe_book.render_latex() +recipe_book.render_gemtext() +recipe_book.render_html() print("Happy baking!") diff --git a/templates/index.gmi b/templates/index.gmi new file mode 100644 index 0000000..1f2774a --- /dev/null +++ b/templates/index.gmi @@ -0,0 +1,32 @@ +# Bread + +=> gemini://bread.ozva.co.uk/bread.pdf 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 Celsius and should be assumed to be with fan when referring to baking. + +=> https://bread.ozva.co.uk/pages/percentage.html Bakers percentage [WWW] +=> https://git.ozva.co.uk/?p=bread Git repo [WWW] +=> https://bread.ozva.co.uk/pages/temperature.html Temperature guide [WWW] +=> https://bread.ozva.co.uk/pages/national-loaf.html A new national loaf [WWW] + +In many of these recipes, the salt measurement is a constant 1.5%. This is personal taste and although the presence of salt does affect the formation of the crust (and the taste) salt could be totally removed from all recipes. + +## Recipes + +### All recipes + +{% for recipe in recipes -%} +=> gemini://bread.ozva.co.uk/recipes/{{ recipe.recipe.gmi }} {{ recipe.recipe.information.title }} ({{ recipe.recipe.information.description }}) +{% endfor %} + +### Keywords + +{% for word, list in keywords.items() -%} +{{ word }} + +{% for item in list -%} +=> gemini://bread.ozva.co.uk/recipes/{{ item.0 }} {{ item.1 }} ({{ item.2 }}) +{% endfor %} +{% endfor %} + +=> https://git.ozva.co.uk/?p=bread;a=commit;h=HEAD Last compiled at {{ time }} [WWW] diff --git a/templates/template.gmi b/templates/template.gmi new file mode 100644 index 0000000..608f226 --- /dev/null +++ b/templates/template.gmi @@ -0,0 +1,48 @@ +=> gemini://bread.ozva.co.uk Back to main page + +# {{ recipe.information.title }} + +{{ recipe.information.description }} + +=> https://git.ozva.co.uk/?p=bread;a=history;f=src/{{ recipe.filename }};">[History] History [WWW] +=> https://bread.ozva.co.uk/{{ recipe.pdf }} Print-out [PDF] + +## Notes + +{{ recipe.information.notes|replace("\n", "\n\n") }} + +## Ingredients + +### Bakers Percentage + +{% for name, weight in recipe.ingredients.items() -%} +* {{ name|replace("-", " ")|title }} - {{ weight }}% +{% endfor -%} + +{% for multiplier in [0.5,1,2,3,4]%} +### Total weight {{multiplier}}kg +{% for name, weight in recipe.ingredients.items() -%} +{%- 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 %} +* {{ name|replace("-", " ")|title }} - {{ rounded }} +{%- else -%} +* {{ name|replace("-", " ")|title }} - {{ real }} +{%- endif -%} + +{% endfor %} +{% endfor %} + +Percentage total: {{ recipe.total }}% +Values have been rounded where the error would not be significant (p > 0.05). + +{% if recipe.information.links is defined %} +## Links + +{% for link in recipe.information.links -%} +=> {{link}} {{link}} [WWW] +{%- endfor %} +{%- endif %} + +=> https://git.ozva.co.uk/?p=bread;a=commit;h=HEAD" Last compiled at {{ time }} [WWW] -- 2.39.2