Now with 100% more templating!

This commit is contained in:
Justus Grunow 2025-01-25 20:53:23 -05:00
commit 48638e65cb
7 changed files with 492 additions and 79 deletions

View File

@ -1,39 +1,33 @@
#!/usr/bin/env python
import yaml
def writeLine(string):
global menuOut
menuOut += f"{string}\r\n"
import markdown
from jinja2 import Environment, PackageLoader, select_autoescape
env = Environment(
loader=PackageLoader("build"),
autoescape=select_autoescape()
)
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 = '''\
<html>
<head>
<link rel="stylesheet" href="style.css">
<title>Cocktail Menu</title>
</head>
<body>
'''
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'<h2>{name}</h2>')
writeLine('<ul>')
for ingredient in bev[name]['ingredients']:
writeLine(f'<li>{ingredient}</li>')
writeLine('</ul>')
print(f'<li>{ingredient[list(ingredient)[0]]} {list(ingredient)[0]}</li>')
print(markdown.markdown(bev[name]['directions']))
menuOut += '''\
</body>
</html>
'''
with open('index.html', 'w') as file:
file.write(menuOut)
for ingredient in menu['out_of_stock']:
print(ingredient)

View File

@ -1,44 +1,173 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<title>Cocktail Menu</title>
</head>
<body>
<h2>Old Fashioned</h2>
<ul>
<li>Bourbon</li>
<li>Maple syrup</li>
<li>Angostura bitters</li>
</ul>
<h2>Boulevardier</h2>
<ul>
<li>Bourbon</li>
<li>Campari</li>
<li>Sweet vermouth</li>
</ul>
<h2>Black Manhattan</h2>
<ul>
<li>Rye whiskey</li>
<li>Amaro</li>
<li>Angostura bitters</li>
<li>Orange bitters</li>
</ul>
<h2>MonteNegroni</h2>
<ul>
<li>Amaro Montenegro</li>
<li>Gin</li>
<li>Sweet vermouth</li>
<li>Angostura bitters</li>
</ul>
<h2>Sidecar</h2>
<ul>
<li>Bourbon</li>
<li>Cointreau</li>
<li>Lemon juice</li>
</ul>
<h2>Gin & Tonic</h2>
<h2>Gin &amp; Tonic</h2>
<ul>
<li>Gin</li>
<li>Tonic water</li>
</ul>
<h2>Gimlet</h2>
<ul>
<li>Gin</li>
<li>Lime juice</li>
<li>Simple syrup</li>
</ul>
<h2>Bennet</h2>
<ul>
<li>Gin</li>
<li>Lime juice</li>
<li>Simple syrup</li>
<li>Angostura bitters</li>
</ul>
</body>
</html>

View File

@ -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

205
recipes.html Normal file
View File

@ -0,0 +1,205 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<title>Cocktail Menu</title>
</head>
<body>
<h2>Old Fashioned</h2>
<ul>
<li>2 oz Bourbon</li>
<li>1tsp Maple syrup</li>
<li>2 dashes Angostura bitters</li>
</ul>
<h3>Directions!</h3>
1. Stir with ice. Strain into rocks glass over large cube.
1. Garnish with orange twist.
<h2>Boulevardier</h2>
<ul>
<li>1.5 oz Bourbon</li>
<li>1 oz Campari</li>
<li>1 oz Sweet vermouth</li>
</ul>
<h3>Directions!</h3>
1. Stir with ice. Strain into rocks glass over large cube.
1. Garnish with orange twist.
<h2>Black Manhattan</h2>
<ul>
<li>2 oz Rye whiskey</li>
<li>1 oz Amaro</li>
<li>1 dash Angostura bitters</li>
<li>1 dash Orange bitters</li>
</ul>
<h3>Directions!</h3>
1. Stir with ice. Strain into chilled coupe.
1. Garnish with orange twist.
<h2>MonteNegroni</h2>
<ul>
<li>1 1/3 oz Amaro Montenegro</li>
<li>2/3 oz Gin</li>
<li>2/3 oz Sweet vermouth</li>
<li>2 drops Angostura bitters</li>
</ul>
<h3>Directions!</h3>
1. Stir with ice. Strain into rocks glass over large cube.
1. Garnish with orange twist.
<h2>Sidecar</h2>
<ul>
<li>2 oz Bourbon</li>
<li>1 oz Cointreau</li>
<li>0.5 oz Lemon juice</li>
</ul>
<h3>Directions!</h3>
1. Shake with ice. Double strain into chilled coupe.
<h2>Gin &amp; Tonic</h2>
<ul>
<li>2 oz Gin</li>
<li>4 oz Tonic water</li>
</ul>
<h3>Directions!</h3>
1. Pour gin and tonic over ice in short glass.
1. Stir gently.
1. Garnish with lime wheel.
<h2>Gimlet</h2>
<ul>
<li>2 oz Gin</li>
<li>1 oz Lime juice</li>
<li>0.5 oz Simple syrup</li>
</ul>
<h3>Directions!</h3>
1. Shake with ice.
1. Double strain into chilled coupe.
<h2>Bennet</h2>
<ul>
<li>2 oz Gin</li>
<li>1 oz Lime juice</li>
<li>0.5 oz Simple syrup</li>
<li>1 dash Angostura bitters</li>
</ul>
<h3>Directions!</h3>
1. Shake with ice.
1. Double strain into chilled coupe.
</body>
</html>

11
templates/base.html Normal file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<title>{% block title %}{% endblock %}</title>
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>

16
templates/menu.html Normal file
View File

@ -0,0 +1,16 @@
{% extends "base.html" %}
{% block title %}Cocktail Menu{% endblock %}
{% block content %}
{% for bev in bevs %}
{% for name, details in bev.items() %}
<h2>{{ name }}</h2>
<ul>
{% for ingredient in details['ingredients'] %}
{% for name, amount in ingredient.items() %}
<li>{{ name }}</li>
{% endfor %}
{% endfor %}
</ul>
{% endfor %}
{% endfor %}
{% endblock %}

18
templates/recipes.html Normal file
View File

@ -0,0 +1,18 @@
{% extends "base.html" %}
{% block title %}Cocktail Menu{% endblock %}
{% block content %}
{% for bev in bevs %}
{% for name, details in bev.items() %}
<h2>{{ name }}</h2>
<ul>
{% for ingredient in details['ingredients'] %}
{% for name, amount in ingredient.items() %}
<li>{{ amount }} {{ name }}</li>
{% endfor %}
{% endfor %}
</ul>
<h3>Directions!</h3>
{{ details['directions'] }}
{% endfor %}
{% endfor %}
{% endblock %}