From 036eb5a860af2f328873068a4eb0715024cfb0af Mon Sep 17 00:00:00 2001 From: Justus Grunow Date: Sat, 25 Jan 2025 20:53:05 -0500 Subject: [PATCH] Now with 100% more templating! --- build.py | 65 +++++++++---- index.html | 203 ++++++++++++++++++++++++++++++++-------- menu.yaml | 76 +++++++++++---- recipes.html | 205 +++++++++++++++++++++++++++++++++++++++++ templates/base.html | 11 +++ templates/menu.html | 16 ++++ templates/recipes.html | 18 ++++ 7 files changed, 519 insertions(+), 75 deletions(-) create mode 100644 recipes.html create mode 100644 templates/base.html create mode 100644 templates/menu.html create mode 100644 templates/recipes.html diff --git a/build.py b/build.py index 8ea1fe2..1379602 100755 --- a/build.py +++ b/build.py @@ -1,39 +1,64 @@ #!/usr/bin/env python import yaml +import markdown +from jinja2 import Environment, PackageLoader, select_autoescape +env = Environment( + loader=PackageLoader("build"), + autoescape=select_autoescape() +) +menuOut = '' +recipesOut = '' -def writeLine(string): +def writeMenu(string): global menuOut menuOut += f"{string}\r\n" +def writeRec(string): + global recipesOut + recipesOut += f"{string}\r\n" + with open('menu.yaml', 'r') as file: menu = yaml.safe_load(file) +templateMenu = env.get_template("menu.html") +templateRecipes = env.get_template("recipes.html") -#print(menu['menu']) +with open('index.html', 'w') as file: + file.write(templateMenu.render(bevs = menu['menu'])) -menuOut = '''\ - - - -Cocktail Menu - - -''' +with open('recipes.html', 'w') as file: + file.write(templateRecipes.render(bevs = menu['menu'])) + +print(menu['menu']) for bev in menu['menu']: #print(bev) for name in bev: print(name) - writeLine(f'

{name}

') - writeLine('') + writeRec('

Directions

') + writeRec(markdown.markdown(bev[name]['directions'])) -menuOut += '''\ - - -''' +for ingredient in menu['out_of_stock']: + print(ingredient) -with open('index.html', 'w') as file: - file.write(menuOut) + + +testDict = { + 'First item': {'nest': 'dict'}, + 'Second item': 'Bywe', + 'Third item': 'Okay' + } + +print(testDict) + +for k, v in testDict.items(): + print(f"{k}: {v}") diff --git a/index.html b/index.html index 450c68a..1af2938 100644 --- a/index.html +++ b/index.html @@ -1,44 +1,173 @@ + Cocktail Menu -

Old Fashioned

- -

Boulevardier

- -

Sidecar

- -

Gin & Tonic

- -

Gimlet

- -

Bennet

- + + + +

Old Fashioned

+ + + + +

Boulevardier

+ + + + +

Black Manhattan

+ + + + +

MonteNegroni

+ + + + +

Sidecar

+ + + + +

Gin & Tonic

+ + + + +

Gimlet

+ + + + +

Bennet

+ + + + + - + \ No newline at end of file diff --git a/menu.yaml b/menu.yaml index c7d1c57..988288b 100644 --- a/menu.yaml +++ b/menu.yaml @@ -4,44 +4,84 @@ menu: base: Bourbon category: Ancestrals ingredients: - - Bourbon - - Maple syrup - - Angostura bitters + - Bourbon: 2 oz + - Maple syrup: 1tsp + - Angostura bitters: 2 dashes + directions: | + 1. Stir with ice. Strain into rocks glass over large cube. + 1. Garnish with orange twist. - Boulevardier: base: Bourbon category: Spirit-Forward ingredients: - - Bourbon - - Campari - - Sweet vermouth + - Bourbon: 1.5 oz + - Campari: 1 oz + - Sweet vermouth: 1 oz + directions: | + 1. Stir with ice. Strain into rocks glass over large cube. + 1. Garnish with orange twist. + - Black Manhattan: + base: Rye whiskey + category: Spirit-Forward + ingredients: + - Rye whiskey: 2 oz + - Amaro: 1 oz + - Angostura bitters: 1 dash + - Orange bitters: 1 dash + directions: | + 1. Stir with ice. Strain into chilled coupe. + 1. Garnish with orange twist. + - MonteNegroni: + base: Amaro Montenegro & Gin + category: + ingredients: + - Amaro Montenegro: 1 1/3 oz + - Gin: 2/3 oz + - Sweet vermouth: 2/3 oz + - Angostura bitters: 2 drops + directions: | + 1. Stir with ice. Strain into rocks glass over large cube. + 1. Garnish with orange twist. - Sidecar: base: Bourbon category: Sours ingredients: - - Bourbon - - Cointreau - - Lemon juice + - Bourbon: 2 oz + - Cointreau: 1 oz + - Lemon juice: 0.5 oz + directions: | + 1. Shake with ice. Double strain into chilled coupe. - "Gin & Tonic": base: Gin category: Highballs ingredients: - - Gin - - Tonic water + - Gin: 2 oz + - Tonic water: 4 oz + directions: | + 1. Pour gin and tonic over ice in short glass. + 1. Stir gently. + 1. Garnish with lime wheel. - Gimlet: base: Gin category: Sours ingredients: - - Gin - - Lime juice - - Simple syrup + - Gin: 2 oz + - Lime juice: 1 oz + - Simple syrup: 0.5 oz + directions: | + 1. Shake with ice. + 1. Double strain into chilled coupe. - Bennet: base: Gin category: Sours ingredients: - - Gin - - Lime juice - - Simple syrup - - Angostura bitters + - Gin: 2 oz + - Lime juice: 1 oz + - Simple syrup: 0.5 oz + - Angostura bitters: 1 dash + directions: | + 1. Shake with ice. + 1. Double strain into chilled coupe. out_of_stock: - Rye whiskey diff --git a/recipes.html b/recipes.html new file mode 100644 index 0000000..86c27cb --- /dev/null +++ b/recipes.html @@ -0,0 +1,205 @@ + + + + +Cocktail Menu + + + + + +

Old Fashioned

+ +

Directions!

+ 1. Stir with ice. Strain into rocks glass over large cube. +1. Garnish with orange twist. + + + + +

Boulevardier

+ +

Directions!

+ 1. Stir with ice. Strain into rocks glass over large cube. +1. Garnish with orange twist. + + + + +

Black Manhattan

+ +

Directions!

+ 1. Stir with ice. Strain into chilled coupe. +1. Garnish with orange twist. + + + + +

MonteNegroni

+ +

Directions!

+ 1. Stir with ice. Strain into rocks glass over large cube. +1. Garnish with orange twist. + + + + +

Sidecar

+ +

Directions!

+ 1. Shake with ice. Double strain into chilled coupe. + + + + +

Gin & Tonic

+ +

Directions!

+ 1. Pour gin and tonic over ice in short glass. +1. Stir gently. +1. Garnish with lime wheel. + + + + +

Gimlet

+ +

Directions!

+ 1. Shake with ice. +1. Double strain into chilled coupe. + + + + +

Bennet

+ +

Directions!

+ 1. Shake with ice. +1. Double strain into chilled coupe. + + + + + + + \ No newline at end of file diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..0aae118 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,11 @@ + + + + +{% block title %}{% endblock %} + + +{% block content %}{% endblock %} + + + diff --git a/templates/menu.html b/templates/menu.html new file mode 100644 index 0000000..925ef84 --- /dev/null +++ b/templates/menu.html @@ -0,0 +1,16 @@ +{% extends "base.html" %} +{% block title %}Cocktail Menu{% endblock %} +{% block content %} +{% for bev in bevs %} + {% for name, details in bev.items() %} +

{{ name }}

+ + {% endfor %} +{% endfor %} +{% endblock %} diff --git a/templates/recipes.html b/templates/recipes.html new file mode 100644 index 0000000..9b3fb4c --- /dev/null +++ b/templates/recipes.html @@ -0,0 +1,18 @@ +{% extends "base.html" %} +{% block title %}Cocktail Menu{% endblock %} +{% block content %} +{% for bev in bevs %} + {% for name, details in bev.items() %} +

{{ name }}

+ +

Directions!

+ {{ details['directions'] }} + {% endfor %} +{% endfor %} +{% endblock %}