logo

Grimgrains

[mirror] Plant-based cooking website <https://grimgrains.com/>
commit: e83b439503b5ee852ce9f1d19bedf1f6d684a9b6
parent d24f8b0cc9a2a6fab00d1e434159ce3126f65507
Author: microlith57 <microlith57@gmail.com>
Date:   Mon, 24 Jun 2019 21:21:34 +1200

Add a fancy service panel for debugging

Signed-off-by: microlith57 <microlith57@gmail.com>

Diffstat:

Mindex.html1+
Amedia/ingredients/lentils.png0
Amedia/ingredients/peas.png0
Mriven.html1+
Mscripts/database/ingredients.ndtl21++++++++++++++++-----
Mscripts/database/recipes.ndtl12++++++------
Mscripts/graph.js5+++--
Ascripts/templates/service.js143+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 170 insertions(+), 13 deletions(-)

diff --git a/index.html b/index.html @@ -40,6 +40,7 @@ <script src="scripts/templates/page.js"></script> <script src="scripts/templates/home.js"></script> <script src="scripts/templates/search.js"></script> + <script src="scripts/templates/service.js"></script> <link rel="stylesheet" type="text/css" href="links/reset.css"/> <link rel="stylesheet" type="text/css" href="links/main.css"/> diff --git a/media/ingredients/lentils.png b/media/ingredients/lentils.png Binary files differ. diff --git a/media/ingredients/peas.png b/media/ingredients/peas.png Binary files differ. diff --git a/riven.html b/riven.html @@ -25,6 +25,7 @@ <script src="scripts/templates/recipe.js"></script> <script src="scripts/templates/ingredient.js"></script> <script src="scripts/templates/page.js"></script> + <script src="scripts/templates/service.js"></script> <link rel="stylesheet" type="text/css" href="links/reset.css"/> <link rel="stylesheet" type="text/css" href="links/riven.fonts.css"/> diff --git a/scripts/database/ingredients.ndtl b/scripts/database/ingredients.ndtl @@ -161,7 +161,7 @@ Chia seeds ~ ROOT VEGETABLES Nagaimo -Carrot +Carrots BREF : Overconsumming carrots can cause what is reffered to as "Carotenosis", a condition in which the skin turns orange. Heirloom Carrots Ginger @@ -290,19 +290,22 @@ Persimmon Dates BREF : Date palms have been around for at least 50 million years! Deglet Noor Dates + PARENT : Dates +Date caramel + PARENT : Dates + BREF : Date caramel is used to make {{salted caramel carob chip cookies}}, and has a recipe there. Pamplemousse Rhubarb Apricot Jam Starfruit Mixed fruits Coconut -Date Plums Pineapple ~ SPICES -Aonori +Ao nori Kanten powder BREF : A seaweed-based gelling agent derived from tengusa, a specific type of red seaweed. Kanten confections don't dissolve at room temperature, unlike gelatin. Turmeric @@ -423,9 +426,13 @@ Einkorn Flour Spelt Spelt Flour PARENT : Flour +Gluten Flour + PARENT : Flour Corn Cornmeal + PARENT : Corn Corn Semolina + PARENT : Corn ~ GRAINS @@ -438,6 +445,8 @@ Basmati Rice PARENT : Rice White Rice PARENT : Rice +Short Grain White Rice + PARENT : White Rice, Rice Black Rice PARENT : Rice Puffed Rice @@ -482,7 +491,6 @@ Red Miso ~ Tell me (microlith57) if this color needs changing. White Miso COLOR : #955C19 -~ #FFD800 mayo? Tofu COLOR : #EFEFEF BREF : The word {_bean curds_} for tofu has been used in the US since 1840. See also: {{silken tofu}}, {{burmese tofu}}. @@ -492,6 +500,9 @@ Silken Tofu Burmese Tofu PARENT : Tofu COLOR : #EFEFEF +Tofu Mayo + PARENT : Tofu + COLOR : #FFD800 Nutolene Soy protein @@ -518,7 +529,7 @@ Cornstarch Active dry yeast Baking soda BREF : Since sodium bicarbonate can cause alkalosis, it's sometimes used to treat aspirin overdoses. -Agar agar +Agar agar powder BREF : Agar is used to make impression material in dentistry. Arrowroot starch diff --git a/scripts/database/recipes.ndtl b/scripts/database/recipes.ndtl @@ -65,10 +65,10 @@ SWEET AND SOUR LENTILS Main Brown lentils : 1/2 cup Vegetable bouillon : 1 1/2 cups - carrot : 1, cubed - daikon : 2", cubed - chives : 3 stalks - salt : 1/4 tsp + Carrots : 1, cubed + Daikon : 2", cubed + Chives : 3 stalks + Salt : 1/4 tsp Sauce Soy sauce : 2 tbsp Rice vinegar : 2 tbsp @@ -1460,7 +1460,7 @@ CARROT KINPIRA ONIGIRAZU & The concept of this rice sandwich, is perfect when you don't have the right type of rice available for onigiri. You can use just about any type, i tested it out a few different kinds. & The rice was seasoned with miso for added flavour, and was filled with carrot kinpira. Kinpira means "sauteed" (sually with a mixture of mirin soy sauce and chili peppers.) It's a sweet, and spicy dish that is often served in bentos. I knew I wanted this as a filling for my onigirazu, to satisfy my sudden craving for Japanese food. This would have been amazing with gobo, but finding the root here in Montreal is no easy task. % recipes/carrot.kinpira.onigirazu.2.jpg - & You should try and make your own version of onigirazu at home! As i said, it's no-fail. I may not live near a 24h kombini, with readily available onigiri anymore, but i know i can make some at home easily, and quickly. + & You should try and make your own version of onigirazu at home! As I said, it's no-fail. I may not live near a 24h kombini, with readily available onigiri anymore, but I know I can make some at home easily, and quickly. INST Kinpira carrot @@ -1651,7 +1651,7 @@ SALTED CARAMEL CAROB CHIP COOKIES Cooking batter Vegan butter : 1/4 cup, earth balance Coconut sugar : 3/4 cup - Dates caramel : 1/4 cup, see above + Date caramel : 1/4 cup, see above Flax seeds : 1 tbsp Einkorn flour : 1 cup + 3 tbsp Baking soda : 3/4 tsp diff --git a/scripts/graph.js b/scripts/graph.js @@ -16,7 +16,8 @@ function graph () { Ø('search').create({ x: 5, y: 14 }, SearchTemplate), Ø('home').create({ x: 2, y: 14 }, HomeTemplate), Ø('recipe').create({ x: 5, y: 8 }, RecipeTemplate), - Ø('ingredient').create({ x: 8, y: 8 }, IngredientTemplate) + Ø('ingredient').create({ x: 8, y: 8 }, IngredientTemplate), + Ø('service').create({ x: 8, y: 14 }, ServiceTemplate) ]) Ø('client').mesh({ x: 32, y: 0 }, [ @@ -44,7 +45,7 @@ function graph () { // Assoc Ø('template').syphon(['recipe', 'ingredient', 'page']) - Ø('page').syphon(['home', 'search']) + Ø('page').syphon(['home', 'search', 'service']) Ø('template').connect(['view', 'document']) Ø('view').bind(['header', 'core', 'footer']) diff --git a/scripts/templates/service.js b/scripts/templates/service.js @@ -0,0 +1,143 @@ +function ServiceTemplate (id, rect) { + Node.call(this, id, rect) + + this.glyph = NODE_GLYPHS.render + + this.answer = function (q) { + let recipe_ingredients = find_ingredients(q.tables.recipes) + + let html = ` + ${make_pageless(recipe_ingredients, q.tables.ingredients)} + ${make_unused(recipe_ingredients, q.tables.ingredients)} + ` + return { + title: `GrimGrains — Service Panel`, + view: { + core: { + content: html, + related: '' + } + } + } + } + + function find_ingredients (recipes) { + let h = [] + for (id in recipes) { + let recipe = recipes[id] + for (id in recipe.INGR) { + let category = recipe.INGR[id] + for (name in category) { + if (!h.includes(name.toLowerCase())) {h.push(name.toLowerCase())} + } + } + } + return h + } + + function make_pageless (used, pages) { + let pageless = find_pageless(used, pages) + let html = "" + for (id in pageless) { + html += ` + <li class='ingredient missing'> + <a href='#${pageless[id].to_url()}' onclick="Ø('query').bang('${pageless[id]}')"> + <img src='media/ingredients/${pageless[id].to_path()}.png'/> + </a> + <t class='name'>${pageless[id].capitalize()}</t> + </li>` + } + if (html == "") {return `<h2>No Ingredients Without Pages!</h2>`} + return `<h2>Ingredients Without Pages</h2><ul class='ingredients'>${html}</ul>` + } + + function find_pageless (used, pages) { + let pageless = [] + + for (id in used) { + let name = used[id].toUpperCase() + if (!pages[name]) {pageless.push(name)} + } + + return pageless + } + + function make_unused (used, pages) { + let unused = find_unused(used, pages) + let html = "" + + for (id in unused) { + html += ` + <li class='ingredient'> + <a href='#${unused[id].to_url()}' onclick="Ø('query').bang('${unused[id]}')"> + <img src='media/ingredients/${unused[id].to_path()}.png'/> + </a> + <t class='name'>${unused[id].capitalize()}</t> + </li>` + } + if (html == "") {return `<h2>No Unused Ingredients!</h2>`} + return `<h2>Unused Ingredients</h2><ul class='ingredients'>${html}</ul>` + } + + function find_unused (used, pages) { + let unused = [] + + for (name in pages) { + if (!used.includes(name.toLowerCase())) {unused.push(name)} + } + + return unused + } + + function make_ingredients (ingredients, table) { + let html = '' + for (id in ingredients) { + let name = ingredients[id][0] + html += ` + <li class='ingredient${!table[name] ? ' missing' : ''}'> + <a href='#${name.to_url()}' onclick="Ø('query').bang('${name}')"> + <img src='media/ingredients/${name.to_path()}.png'/> + </a> + <t class='name'>${name.capitalize()}</t> + </li>` + } + return `<ul class='ingredients'>${html}</ul>` + } + + function count_ingredients (recipe) { + let ingredients = {} + for (cat in recipe.INGR) { + for (id in recipe.INGR[cat]) { + ingredients[id] = 1 + } + } + return Object.keys(ingredients).length + } + + function make_recipes (recipes) { + let html = '' + + // Sort by tag + + let categorized = {} + + for (name in recipes) { + let recipe = recipes[name] + if (!categorized[recipe.TAGS[0]]) { categorized[recipe.TAGS[0]] = [] } + recipe.name = name + categorized[recipe.TAGS[0]].push(recipe) + } + + for (cat in categorized) { + let recipes = categorized[cat] + html += `<h3>${cat.capitalize()}</h3>` + html += "<ul style='margin-bottom:15px'>" + for (id in recipes) { + let recipe = recipes[id] + html += `<li><a href="#${recipe.name.to_url()}" onclick="Ø('query').bang('${recipe.name.capitalize()}')">${recipe.name.capitalize()}</a></li>` + } + html += '</ul>' + } + return `<columns id='recipes'>${html}</columns>` + } +}