logo

Grimgrains

Unnamed repository; edit this file 'description' to name the repository.
commit: 6e2a698d6799cc42261960b9b57c471c74b6f665
parent 3cd5d3918657ba80e69ed9574fcbdcda888d2e24
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date:   Thu,  8 Mar 2018 11:03:38 +1300

Progress on the ingredient template

Diffstat:

Mindex.html10++++++----
Mriven.html2++
Mscripts/database/ingredients.js35++++++++++++++++++++++++++++++++++-
Mscripts/graph.js7+++++--
Mscripts/nodes/indental.js6+++---
Mscripts/nodes/router.js23++++++++++-------------
Ascripts/templates/ingredient.js46++++++++++++++++++++++++++++++++++++++++++++++
Ascripts/templates/page.js37+++++++++++++++++++++++++++++++++++++
8 files changed, 143 insertions(+), 23 deletions(-)

diff --git a/index.html b/index.html @@ -11,12 +11,14 @@ <script src="scripts/nodes/indental.js"></script> <script src="scripts/nodes/template.js"></script> <script src="scripts/nodes/dom.js"></script> - + <script src="scripts/templates/recipe.js"></script> + <script src="scripts/templates/ingredient.js"></script> + <script src="scripts/templates/page.js"></script> - <script src="scripts/dictionary/ingredients.js"></script> - <script src="scripts/dictionary/recipes.js"></script> - <script src="scripts/dictionary/pages.js"></script> + <script src="scripts/database/ingredients.js"></script> + <script src="scripts/database/recipes.js"></script> + <script src="scripts/database/pages.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/riven.html b/riven.html @@ -14,6 +14,8 @@ <script src="scripts/nodes/dom.js"></script> <script src="scripts/templates/recipe.js"></script> + <script src="scripts/templates/ingredient.js"></script> + <script src="scripts/templates/page.js"></script> <script src="scripts/database/ingredients.js"></script> <script src="scripts/database/recipes.js"></script> diff --git a/scripts/database/ingredients.js b/scripts/database/ingredients.js @@ -110,40 +110,73 @@ Onion Cucumber Details : [#006633 pickled] Cucumbers are usually more than 90% water. + Tags + other vegetables Eggplant Details : [#6620B3] + Tags + other vegetables Zucchini Details : [#006633] + Tags + other vegetables Chile Details : [#006633 green] + Tags + other vegetables Peppers Details : [red#94191C yellow#FFD800 green#006633] The misleading name 'pepper' was given by Christopher Columbus when he brought back a plant to europe. The word pepper was given to all spices in europe that had a hot and pungent taste. Tomato Details : [paste#94191C dried heirloom#94191C] The tomatoes can also be dried with an oven. + Tags + other vegetables Avocado Details : [#006633] Avocado trees dont self-pollinate, they need another avocado tree nearby to bear fruit. + Tags + other vegetables Pumpkin Details : [#FF6600] The darker the skin of the pumpkin, the higher the beta carotene content. + Tags + other vegetables Olives Details : [green black] + Tags + other vegetables Palm Details : [#EFEFEF heart] Heart of palm is a vegetable that is harvested from the inner core of certain palm trees. They can be eaten as is, but they're especially delicious when tossed into a salad. Squash Details : [#FF6600 acorn] The seeds of the acorn squash can be eaten, they're delicious when roasted! + Tags + other vegetables Artichokes Details : Missing. + Tags + other vegetables Asparagus Details : Missing. + Tags + other vegetables Bamboo shoots Details : Missing. + Tags + other vegetables Breadfruit Details : Missing + Tags + other vegetables Scallions Details : [#006633] In some countries scallions are mistakenly referred to as 'shallots'. + Tags + other vegetables Spinach - Details : [#006633] During the cold war, wine with added spinach juice was given to weakened soldiers. + Color : #006633 + Desc : During the cold war, wine with added spinach juice was given to weakened soldiers. + Tags + other vegetables Alfaalfa sprouts Details : Missing + Tags + other vegetables ~ BERRIES diff --git a/scripts/graph.js b/scripts/graph.js @@ -15,8 +15,10 @@ function graph() Ø("template").create({x:2,y:2},TemplateNode), Ø("recipe").create({x:2,y:7},RecipeTemplate), + Ø("ingredient").create({x:5,y:7},IngredientTemplate), + Ø("page").create({x:8,y:7},PageTemplate), - Ø("main").create({x:8,y:7},DomNode), + Ø("main").create({x:12,y:7},DomNode), Ø("header").create({x:2,y:12},DomNode), Ø("logo").create({x:2,y:17},DomNode), @@ -30,9 +32,10 @@ function graph() ]) Ø("router").syphon("database") - Ø("database").syphon(["recipes"]) + Ø("database").syphon(["recipes","ingredients","pages"]) Ø("template").syphon("recipe") + Ø("template").syphon("ingredient") Ø("template").bind("main") Ø("main").bind(["header","body","footer"]) diff --git a/scripts/nodes/indental.js b/scripts/nodes/indental.js @@ -35,7 +35,7 @@ function IndentalNode(id,rect) for(id in lines){ var line = lines[id]; if(line.skip || line.indent > 0){ continue; } - h[line.content] = format(line) + h[line.content.toUpperCase()] = format(line) } return h } @@ -46,9 +46,9 @@ function IndentalNode(id,rect) var h = {}; for(id in line.children){ var child = line.children[id]; - if(child.key){ h[child.key] = child.value } + if(child.key){ h[child.key.toUpperCase()] = child.value } else if(child.children.length == 0){ a.push(child.content) } - else{ h[child.content] = format(child) } + else{ h[child.content.toUpperCase()] = format(child) } } return a.length > 0 ? a : h } diff --git a/scripts/nodes/router.js b/scripts/nodes/router.js @@ -7,27 +7,24 @@ function RouterNode(id,rect) this.receive = function(q) { + var q = q.toUpperCase(); var db = this.request("database").database; - // var type = find(q,db) + var type = find(q,db) - console.log("-----") - console.log(db.recipes) - console.log("-----") - - // this.label = `Router(${type})` - // this.send({ - // name:q, - // type:type, - // result:db[type].hash[q], - // tables:db - // }) + this.label = `Router(${type})` + this.send({ + name:q, + type:type, + result:db[type][q], + tables:db + }) } function find(key,db) { for(id in db){ - var table = db[id].hash + var table = db[id] if(table[key]){ return id } diff --git a/scripts/templates/ingredient.js b/scripts/templates/ingredient.js @@ -0,0 +1,46 @@ +function IngredientTemplate(id,rect) +{ + Node.call(this,id,rect); + + this.glyph = NODE_GLYPHS.render + + // Create the recipe body + + this.answer = function(t) + { + var ingredient = t.result; + var html = ""; + + console.log(t) + + html += ` + <h1>${t.name}</h1> + <p>${ingredient.DESC}</p> + <p>${ingredient.TAGS}</p> + <h4>Related</h4> + <list>${related(t.name,ingredient.TAGS[0],sort(t.tables.ingredients))}</list>`; + + return html + } + + function sort(o) + { + return Object.keys(o).sort().reduce((r, k) => (r[k] = o[k], r), {}); + } + + function related(name,tag,ingredients) + { + var html = "" + for(id in ingredients){ + var ingredient = ingredients[id] + if(!ingredient.TAGS || ingredient.TAGS.indexOf(tag) < 0 || id == name){ continue; } + html += `<ln>${id.capitalize()}</ln>` + } + return html; + } +} + +String.prototype.capitalize = function() +{ + return this.charAt(0).toUpperCase() + this.slice(1).toLowerCase(); +} diff --git a/scripts/templates/page.js b/scripts/templates/page.js @@ -0,0 +1,36 @@ +function PageTemplate(id,rect) +{ + Node.call(this,id,rect); + + this.glyph = NODE_GLYPHS.render + + // Create the recipe body + + this.answer = function(q) + { + console.log(q.result) + + var recipe = q.result + var html = ""; + + html += ` + <h1>${q.name}</h1> + <h2>${recipe.date}</h2> + <h3>${recipe.serv} — ${recipe.time} minutes</h3> + <p>${recipe.desc}</p> + <h4>Ingredients</h4> + <list>${list(recipe.ingr)}</list>`; + + return html + } + + function list(items) + { + var html = "" + for(id in items){ + html += `<ln>${id} -> ${items[id]}</ln>` + // html += list(items[id]) + } + return html; + } +}+ \ No newline at end of file