logo

Grimgrains

Unnamed repository; edit this file 'description' to name the repository.
commit: ccc330166d5ed958ce856ab6c333f67d6a6c8e9e
parent 78be7b603dd2c0a44312e99c013f7bf32f8ac608
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date:   Fri,  9 Mar 2018 11:51:35 +1300

Progress on ingredients

Diffstat:

Mlinks/main.css4++--
Mscripts/database/ingredients.js164++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
Mscripts/nodes/query.js2+-
Mscripts/templates/ingredient.js73+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
4 files changed, 221 insertions(+), 22 deletions(-)

diff --git a/links/main.css b/links/main.css @@ -7,7 +7,7 @@ img { max-width: 100% } h1,h2,h3,h4 { font-weight: normal; font-family: 'alte_haas_grotesk_bold'; margin-bottom: 30px } -#view { max-width: 800px; margin:0px auto; padding:90px 30px; } +#view { max-width: 900px; margin:0px auto; padding:90px 30px; } #view #header { margin-bottom:60px;} #view #header #logo img { max-width: 240px; display: block; margin:0px auto; } @@ -19,7 +19,7 @@ h1,h2,h3,h4 { font-weight: normal; font-family: 'alte_haas_grotesk_bold'; margin #view #core #content h1 { text-transform: capitalize; font-size:36px; max-width:400px } #view #core #content h2 { text-transform: capitalize; font-size:28px; } #view #core #content h3 { text-transform: capitalize; font-size:24px; border-bottom:2px solid black; line-height: 45px } -#view #core #content p { font-size:18px; margin-bottom: 30px; max-width:600px; } +#view #core #content p { font-size:18px; margin-bottom: 30px; max-width:600px; line-height: 26px } #view #core #content img { margin-bottom: 30px; border-radius: 2px } #view #core #content img.photo { width:100%; } #view #core #content columns { columns:2; display: block; margin-bottom:30px; column-gap: 30px } diff --git a/scripts/database/ingredients.js b/scripts/database/ingredients.js @@ -3,10 +3,19 @@ DATABASE.ingredients = ` Lentils Details : [red#FF6600 beluga#000000 green] Lentils are considered to be one of the best foods because their chemical structures are not altered by cooking. Lens is the latin name for lentil. + +Beluga Lentils + Color : #000000 + Tempeh Details : [#875A2C] Missing. Peanut Details : [butter] Missing. +Peanut Butter + Details : Missing. + + + Peanuts Details : Missing. Soy beans @@ -28,8 +37,17 @@ Mungbeans Broccoli Details : No description. + Cabbage Details : [red#6620B3 sauerkraut#C820B3] Red cabbage can be used as a natural colorant, it needs to be boiled and mixed with vinegar to keep its colour + Tags + Cruciferous + +Red Cabbage + Details : Red cabbage can be used as a natural colorant, it needs to be boiled and mixed with vinegar to keep its colour + Tags + Cruciferous + Kale Details : [#006633] Some people grow kale for their ornamental leaves, in colours varying in red, pink and even lavender. They are beautiful and eatable! Arugula @@ -127,10 +145,16 @@ Chile 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 + +Tomato Paste + Details : The tomatoes can also be dried with an oven. + Tags + other vegetables Avocado Color : #006633 @@ -206,49 +230,129 @@ Mixed Berries ~ OTHER FRUITS Banana - Details : [#FFD800] Missing. + Details : Missing. + Color : #FFD800 + Tags + Other Fruits + Kiwi - Details : [#006633] Missing. + Details : Missing. + Color : 006633 + Tags + Other Fruits + Apple Details : [sauce juice] Missing. + Tags + Other Fruits + Apples Details : Missing. + Tags + Other Fruits + Lemon - Details : [#FFD800 juice zest] Lemon juice can be used as an invisible ink, revealed with heat. + Details : [juice zest] Lemon juice can be used as an invisible ink, revealed with heat. + Color : #FFD800 + Tags + Other Fruits + Orange - Details : [#FF6600 juice jam] In the early 16th century, the orange was considered a luxury item and rich people would grow it in private conservatories called "orangeries". + Details : [juice jam] In the early 16th century, the orange was considered a luxury item and rich people would grow it in private conservatories called "orangeries". + Color : #FF6600 + Tags + Other Fruits + Pear - Details : [#875A2C Bartlett Bosc] + Details : [Bartlett Bosc] + Color : #875A2C + Tags + Other Fruits + Papaya - Details : [#FF6600] + Details : [] + Color : #FF6600 + Tags + Other Fruits + Pomegranate - Details : [#94191C juice] + Details : [ juice] + Color : #94191C + Tags + Other Fruits + Mango - Details : [#FFD800] + Details : [] + Color : #FFD800 + Tags + Other Fruits + Lime - Details : [#006633 juice] + Details : [ juice] + Color : #006633 + Tags + Other Fruits + Persimmon - Details : [#FF6600 hachiya] Unripe persimmon can be frozen outside during winter to help speed up the ripening process. + Details : [ hachiya] Unripe persimmon can be frozen outside during winter to help speed up the ripening process. + Color : #FF6600 + Tags + Other Fruits + Dates - Details : [#875A2C deglet_noor caramel] Date palms have been around for at least 50 million years + Details : [ deglet_noor caramel] Date palms have been around for at least 50 million years + Color : #875A2C + Tags + Other Fruits + Pamplemousse Details : [juice] Missing. + Tags + Other Fruits + Rhubarb Details : [jam] Missing. + Tags + Other Fruits + Apricot Details : [jam]Missing. + Tags + Other Fruits + Starfruit Details : Missing. + Tags + Other Fruits + Mixed fruits Details : Missing. + Tags + Other Fruits + Coconut Details : Missing. + Tags + Other Fruits + Date Details : Missing. + Tags + Other Fruits + Plums Details : Missing. + Tags + Other Fruits + Pineapple +Tags + Other Fruits + Details : Missing. + Tags + Other Fruits + ~ SPICES @@ -345,11 +449,20 @@ Corn Oats Details : [#EFEFEF] If oat flour is used alone in baking, the flour wont rise. Best to mix it with other types of flour! Rice - Details : [white#EFEFEF black#000000 puffed brown#875A2C basmati black_glutinous wholegrain_brown noodles] Preparing puffed rice this way makes it less perishable. Brown rice is a wholegrain rice that has a nutty flavour, it's also more nutritious and chewier than white rice. Brown rice is producted by only removing the outermost husk, while white rice has several other layers removed. It is best to soak the rice for a day before cooking it to obtain a more nutritionally complete food, soaking it beforehand activates various enzymes in the rice. + Details : Preparing puffed rice this way makes it less perishable. Brown rice is a wholegrain rice that has a nutty flavour, it's also more nutritious and chewier than white rice. Brown rice is producted by only removing the outermost husk, while white rice has several other layers removed. It is best to soak the rice for a day before cooking it to obtain a more nutritionally complete food, soaking it beforehand activates various enzymes in the rice. +Basmati Rice +White Rice +Black Rice +Puffed Rice +Brown Rice +Black Glutinous Rice +Wholegrain Brown Rice +Rice Noodles + Flour Details : [all_purpose#EFEFEF rice] Plain flour has an average protein content, making it versatile to use in almost any recipe that requires flour. Spelt flour was a staple food during the Bronze age all the way up to medieval times. Brown rice flour is sometimes used as a base to grow mushrooms. Einkorn wheat was one of the first plants to be domesticated and cultivated. It has a high percentage of protein, more than regular wheat. It also has high levels of fat, phosphorus, potassium, pyridoxine (a form of vitamin b6) and beta-carotene, making it more nutritious than other kinds of grains. Another great thing about einkorn is that it isn't as toxic to people on gluten-free diets, it as yet to be proven but it should definitely be looked into! -Wheat - Details : [semolina noodles bread crackers pita] Missing. +Wheat Semolina + Details : Missing. Oatmeal Details : Missing. Cornmeal @@ -417,16 +530,33 @@ B12 supplement ~ TEA -Matcha - Details : [#006633 powder] Only Tencha can be used to make matcha. +Matcha Powder + Details : Only Tencha can be used to make matcha. + Color : #006633 + Tags + Tea + Houjicha - Details : [#875A2C] KitKat in japan has a houjicha flavour. + Details : KitKat in japan has a houjicha flavour. + color : #875A2C + Tags + Tea Hibiscus Details : [tea] Missing. + Tags + Tea + Mint tea Details : Missing. + Tags + Tea + Lapsang souchong Details : Missing. + color : #875A2C + Tags + Tea + ~ COFFEE diff --git a/scripts/nodes/query.js b/scripts/nodes/query.js @@ -12,7 +12,7 @@ function QueryNode(id,rect) hash = "home"; } this.label = `query:${hash}` - console.log(target) + window.scrollTo(0,0); this.send(target ? target : hash) } } \ No newline at end of file diff --git a/scripts/templates/ingredient.js b/scripts/templates/ingredient.js @@ -12,20 +12,89 @@ function IngredientTemplate(id,rect) return { core: { - content: make_ingredient(t.name,ingredient), + content: make_ingredient(t.name,t.tables.recipes), related:make_related(related_recipes(t.name,t.tables.recipes)) } } } - function make_ingredient(name,ingredient) + function make_ingredient(name,recipes) { var html = "" html += `<h1>${name.capitalize()}</h1>` + html += `${make_similar(name,recipes)}` return html } + function make_similar(name,recipes) + { + var html = "" + var ingredients = find_ingredients(recipes); + var similar_ingredients = find_similar_ingredients(name,ingredients) + + for(id in similar_ingredients){ + if(similar_ingredients[id][1] < 1){ break;} + var name = similar_ingredients[id][0]; + html += ` + <ln class='ingredient'> + <a onclick="Ø('query').bang('${name}')" href='#${name.to_url()}'> + <img src='media/ingredients/${name.to_path()}.png'/> + </a> + <t class='name'>${name.capitalize()}</t> + </ln>` + } + console.log(similar_ingredients.length) + return similar_ingredients.length > 1 ? `<h2>Related Ingredients</h2><list class='ingredients'>${html}<hr /></list>` : '' + } + + function find_ingredients(recipes) + { + var h = {} + for(id in recipes){ + var recipe = recipes[id]; + for(id in recipe.INGR){ + var category = recipe.INGR[id]; + for(name in category){ + h[name] = h[name] ? h[name]+1 : 1 + } + } + } + return h + } + + function find_similar_ingredients(name,ingredients) + { + var a = []; + + for(id in ingredients){ + var words = id.split(" ") + var index = similarity(name.split(" "),words); + if(index > 0){ + a.push([id,index]) + } + } + + a.sort(function(a, b) { + return a[1] - b[1]; + }); + + return a.reverse(); + } + + function similarity(a,b) + { + var score = 0; + for(a_id in a){ + var word_a = a[a_id]; + for(b_id in b){ + var word_b = b[b_id]; + score += word_a == word_b ? 1 : 0 + } + } + return score + } + function make_related(recipes) { var html = ""