Compare commits
No commits in common. "e8124964c6c3c8226dbdb6a932944e8872466fe6" and "a3e8e89160a9c641c149bb4ffeac158d76f4ea90" have entirely different histories.
e8124964c6
...
a3e8e89160
@ -6,8 +6,8 @@ HTML.
|
||||
|
||||
I used these scripts to create my [recipes
|
||||
site](https://tilde.town/~gamerdonkey/recipes/) here on town. Fun fact: you can
|
||||
replace the `html` in the URLs with `json` to get my recipes in their raw JSON
|
||||
format!
|
||||
replace the `html` with `json` in the URLs to get my recipes in their raw JSON
|
||||
format.
|
||||
|
||||
## Requirements
|
||||
|
||||
@ -54,8 +54,8 @@ JSON YOU DID NOT CREATE YOURSELF!**
|
||||
|
||||
This script takes an argument pointing to a directory of recipe JSON files, in
|
||||
the format created by the `create_recipe_json.py` script. It then does a
|
||||
recursive depth-first search on each tree in each file to generate HTML files
|
||||
with a traditional recipe and a tabular-style recipe card. You may also pass
|
||||
recursive depth-first search on each tree in that file to generate an HTML
|
||||
file with a traditional recipe and a tabular-style recipe card. It also takes
|
||||
an optional argument pointing to a file and, if given, the contents of that
|
||||
file will be inserted into the header section of the generated `index.html`.
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import json
|
||||
import re
|
||||
|
||||
from anytree import Node, RenderTree
|
||||
from anytree.exporter import DictExporter
|
||||
@ -65,18 +64,10 @@ prep_time = input("Prep time: ")
|
||||
cook_time = input("Cook time: ")
|
||||
|
||||
recipe = Recipe(name, description, servings, prep_time, cook_time)
|
||||
for _, node in nodes.items():
|
||||
recipe.add_sub_recipe(node)
|
||||
|
||||
root_keys = nodes.keys()
|
||||
if len(root_keys) > 1:
|
||||
print_nodes()
|
||||
order = input("Multiple tree roots detected, please specify order (comma-separated): ")
|
||||
root_keys = [int(key.strip()) for key in order.split(",")]
|
||||
|
||||
for key in root_keys:
|
||||
recipe.add_sub_recipe(nodes[key])
|
||||
|
||||
filename = re.sub(r"[ -]", "_", name.strip()).lower()
|
||||
filename = f"{re.sub(r'[^a-z_]', '', filename)}.json"
|
||||
filename = f"{name.replace(' ', '_').lower()}.json"
|
||||
|
||||
print(f"Writing to {filename}...")
|
||||
with open(filename, 'w') as f:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user