logo

Grimgrains

Unnamed repository; edit this file 'description' to name the repository.
commit: 858f1f10ab57de1ff512281b09979f72f0a9336d
parent 0abde445131245156b247f366277feaa1ea1e227
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date:   Sat, 30 Jun 2018 13:41:49 +1200

Updated the breadfruit picture

Diffstat:

Mindex.html1-
Mlinks/main.css23++++++++++++++---------
Cmedia/recipes/breadfruit.gnocchi.jpg -> media/recipes/breadfruit.gnocchi.1.jpg0
Mmedia/recipes/breadfruit.gnocchi.jpg0
Mriven.html1-
Mscripts/database/ingredients.js4----
Mscripts/database/recipes.js18++++++++++--------
Mscripts/graph.js5++---
Mscripts/nodes/query.js53++++++++++++++++++++++++++++++++++++++++++++---------
Mscripts/nodes/router.js22++++++++++++++--------
Mscripts/templates/home.js36+++++++++++++++++++++++++++++++++++-
Dscripts/templates/index.js50--------------------------------------------------
Mscripts/templates/ingredient.js7+++----
Mscripts/templates/recipe.js7+++----
14 files changed, 125 insertions(+), 102 deletions(-)

diff --git a/index.html b/index.html @@ -23,7 +23,6 @@ <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/index.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/links/main.css b/links/main.css @@ -42,28 +42,33 @@ h1,h2,h3,h4 { font-weight: normal; font-family: 'alte_haas_grotesk_bold'; margin #view #core #content #instructions i { background: #eee;font-size: 12px;text-transform: uppercase;padding: 5px 7.5px;display: inline;font-weight: bold;border-radius: 3px;color:#333 } #view #core #content #instructions code { font-size: 12px;text-transform: uppercase;padding: 3px 5.5px;display: inline;font-weight: bold;border-radius: 3px;border:2px solid black;} -#view #core #content list.ingredients { display: inline-block; margin-right:15px; font-size:0; padding-left:20px; } +#view #core #content list.ingredients { display: inline-block; margin-right:15px; font-size:0; padding-left:20px; margin-bottom:30px; } #view #core #content list.ingredients h3 { margin-left:-20px; } #view #core #content list.ingredients ln.ingredient { width: 100px;margin-left:-20px;min-height: 210px;display: inline-block;text-align: center;vertical-align: top;border: 2px dashed transparent;border-radius: 10px; } -#view #core #content list.ingredients ln.ingredient:hover { border-color: black; cursor: pointer; background:white; z-index:900; position: relative; } #view #core #content list.ingredients ln.ingredient:hover t.name { text-decoration: underline; } #view #core #content list.ingredients ln.ingredient.missing t.name { font-style: italic } #view #core #content list.ingredients ln.ingredient img { max-width: 100% } #view #core #content list.ingredients ln.ingredient t.name { display: block; font-family: 'alte_haas_grotesk_bold'; font-size:14px; margin-bottom: 5px;padding:0px 10px } #view #core #content list.ingredients ln.ingredient t.quantity { display: block; font-size:12px; } -#view #core #related { width:100%; border-top:2px solid black; padding-top:45px;} -#view #core #related ln { width: calc((100% / 3) - 10px); float:left; } +#view #core #related { width:100%;} +#view #core #related ln { width: calc((100% / 3) - 10px); float:left; overflow: hidden;} #view #core #related ln:nth-child(1), #view #core #related ln:nth-child(2) { margin-right:15px;} -#view #core #related ln a.photo { border-radius: 2px; display: block; height:160px; background-size:cover; margin-bottom:15px; } +#view #core #related ln a.photo { border-radius: 2px; display: block; height:160px; background-size:cover; margin-bottom:15px; background-position: center } #view #core #related ln t.name { display: block; font-family: 'alte_haas_grotesk_bold'; font-size:16px; margin-bottom: 5px; text-transform: capitalize; line-height: 30px } #view #core #related ln t.details { display: block; font-family: 'alte_haas_grotesk_regular'; font-size:14px; text-transform: capitalize; line-height: 30px; line-height: 18px } -#view #core #content #index { columns:3; font-size:14px; font-weight: bold} -#view #core #content #index ln { display: block } -#view #core #content #index ln a:hover { text-decoration: underline; cursor: pointer; } +#view #core #content #recipes { columns:3; font-size:14px; font-weight: bold} +#view #core #content #recipes ln { display: block } +#view #core #content #recipes ln a:hover { text-decoration: underline; cursor: pointer; } +#view #core #content #recipes h3 { margin-bottom:10px; } #view #footer { display: block; padding:15px 0px;font-family: 'alte_haas_grotesk_bold'; font-size:12px; margin-top:60px; } #view #footer a:hover { text-decoration: underline; cursor: pointer } - +@media (max-width: 950px) { + #view #core #content #recipes { columns:1; } + #view #core #content columns { columns:1; } + #view #core #related ln { width:100%; clear:both; float:none; height:330px; } + #view #core #related ln a.photo { height:200px; } +} diff --git a/media/recipes/breadfruit.gnocchi.jpg b/media/recipes/breadfruit.gnocchi.1.jpg Binary files differ. diff --git a/media/recipes/breadfruit.gnocchi.jpg b/media/recipes/breadfruit.gnocchi.jpg Binary files differ. diff --git a/riven.html b/riven.html @@ -24,7 +24,6 @@ <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/index.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.js b/scripts/database/ingredients.js @@ -21,10 +21,6 @@ Coffee - {{Fat Camel|https://www.facebook.com/Fat-Camel-Israeli-Cafe-111529865551331/}} - Whangarei, NZ > </columns> - - - - ~ LEGUMES Lentils diff --git a/scripts/database/recipes.js b/scripts/database/recipes.js @@ -2263,24 +2263,26 @@ BREADFRUIT GNOCCHI TIME : 90 SERV : 4 people DESC - & We are about to leave Tonga, the tropics and the land of bountiful breadfruit. This versatile fruit can be cooked into fries, eaten with coconut milk, made into chips, or like this recipe suggests, it can be made into gnocchi. - & Breadfruit has a taste and texture that resembles that of potato. And so, it only makes sense that it too, can be made into gnocchi. The flesh of the fruit can be kneaded easily, especially if the fruit is very ripe. I have tried to knead it when half-ripe, it works too, but requires added moisture and more kneading - not to mention that it doesn't have as much flavor. Ripe breadfruit develops a sweet taste, it can be difficult to catch it at the right moment, like avocados, sometimes it'll overripen overnight and be rendered uneatable. Because we like it so much, we've bought many and have had time to better tell when it can be eaten. The outside becomes very soft to the touch, but only just. + & We are about to leave Tonga, the tropics and the land of bountiful {{breadfruit}}. This versatile fruit can be cooked into fries, eaten with {{coconut milk}}, made into chips, or like this recipe suggests, it can be made into gnocchi. + % recipes/breadfruit.gnocchi.1.jpg + & Breadfruit has a taste and texture that resembles that of {{potato}}. And so, it only makes sense that it too, can be made into gnocchi. The flesh of the fruit can be kneaded easily, especially if the fruit is very ripe. I have tried to knead it when half-ripe, it works too, but requires added moisture and more kneading - not to mention that it doesn't have as much flavor. Ripe breadfruit develops a sweet taste, it can be difficult to catch it at the right moment, like avocados, sometimes it'll overripen overnight and be rendered uneatable. Because we like it so much, we've bought many and have had time to better tell when it can be eaten. The outside becomes very soft to the touch, but only just. & We serve these with a light sauce, to better taste the gnocchi. A sauce that we enjoy, is minced garlic and chili peppers cooked in olive oil. The sauce is poured overtop and sprinkled with bits of shredded nori. & If you happen by the south pacific and see a {{breadfruit|https://www.youtube.com/watch?v=hrZ5h0j8jTo}}, make some gnocchi. It's worth the effort. + % recipes/pan.fried.breadfruit.1.jpg INST Preparation - - Wait until your breadfruit is very ripe, soft to the touch. A softer breadfruit will be easier to knead, and will taste sweeter. - - Preheat oven to 425F. Rub outside of breadfruit with olive oil, and wrap with aluminium foil. Cook for 1 hour. + - Wait until your {{breadfruit}} is very ripe, soft to the touch. A softer breadfruit will be easier to knead, and will taste sweeter. + - Preheat oven to {#425F#}. Rub outside of breadfruit with {{olive oil}}, and wrap with aluminium foil. Cook for {#1 hour#}. - Remove foil, peel skin away, cut in half, and remove the seed. - - Let cool, and mash with your hands into a cohesive dough. Add flour, 1/4 cup at a time, until the breadfruit flesh stops sticking to your fingers. You may need more, or less, depending on the size of your fruit. - - Sprinkle your work surface with flour, take a golf-sized ball of dough, and roll it into a thin, finger-sized log. Cut the log into bite-sized pieces (around 2cm long) and repeat for the rest of the dough. - - At this point, you can choose to freeze the gnocchi, or to prepare them straight away. To cook them, bring a pot of water to a boil, add the gnocchi, and cook for 5 minutes or so, or until they start to rise to the surface. + - Let cool, and mash with your hands into a cohesive dough. Add {{flour}}, {#1/4 cup#} at a time, until the {{breadfruit}} flesh stops sticking to your fingers. You may need more, or less, depending on the size of your fruit. + - Sprinkle your work surface with {{flour}}, take a golf-sized ball of dough, and roll it into a thin, finger-sized log. Cut the log into bite-sized pieces (around 2cm long) and repeat for the rest of the dough. + - At this point, you can choose to freeze the gnocchi, or to prepare them straight away. To cook them, bring a pot of {{water}} to a boil, add the gnocchi, and cook for {#5 minutes#} or so, or {_until they start to rise to the surface_}. - Serve with a light sauce, to better taste the subtle, but sweet flavor of the breadfruit gnocchi. INGR Main Breadfruit : 1 small Olive oil : 1 tsp - All purpose flour : 1 1/4 cup, roughly + All purpose flour : 1 1/4 cup SPINACH FAUX CHEESE RAVIOLI DATE : 2017-16-10 diff --git a/scripts/graph.js b/scripts/graph.js @@ -15,7 +15,6 @@ function graph() Ø("template").create({x:5,y:2},TemplateNode), Ø("page").create({x:2,y:8},PageTemplate), Ø("search").create({x:5,y:14},SearchTemplate), - Ø("index").create({x:8,y:14},IndexTemplate), Ø("home").create({x:2,y:14},HomeTemplate), Ø("recipe").create({x:5,y:8},RecipeTemplate), Ø("ingredient").create({x:8,y:8},IngredientTemplate), @@ -30,7 +29,7 @@ function graph() Ø("core").create({x:10,y:11},DomNode), Ø("content").create({x:10,y:16},DomNode), Ø("related").create({x:14,y:16},DomNode,"list"), - Ø("footer").create({x:6,y:11},DomNode,"wr",`<a onclick="Ø('query').bang('index')">See All Recipes List</a><br/><a onclick="Ø('query').bang('about')">Grimgrains</a> © 2014—2018<br/><a href='http://100r.co/' target='_blank'>Hundred Rabbits</a>`), + Ø("footer").create({x:6,y:11},DomNode,"wr",`<a onclick="Ø('query').bang('about')">Grimgrains</a> © 2014—2018<br/><a href='http://100r.co/' target='_blank'>Hundred Rabbits</a>`), ]) // Model @@ -39,7 +38,7 @@ function graph() // Assoc Ø("template").syphon(["recipe","ingredient","page"]) - Ø("page").syphon(["home","search","index"]) + Ø("page").syphon(["home","search"]) Ø("template").connect(["view","document"]) Ø("view").bind(["header","core","footer"]) diff --git a/scripts/nodes/query.js b/scripts/nodes/query.js @@ -5,14 +5,50 @@ function QueryNode(id,rect) this.glyph = NODE_GLYPHS.entry this.label = "query" - this.bang = function(target = null) + this.bang = function(input = window.location.hash) { - var hash = window.location.hash.substring(1).replace(/[^0-9a-z]/gi," ").trim().toLowerCase() - if(hash == ""){ - hash = "home"; + var target = input.to_url() === '' ? 'home' : input.to_url() + + Ø("view").el.className = "loading" + + this.label = `${this.id}|${target}` + this.send(target) + + if(target === ''){ + window.history.replaceState(undefined, undefined, "#" + target) + } + else { + window.location.hash = target.to_url() } - this.label = `query:${hash}` - window.scrollTo(0,0); - this.send(target ? target : hash) + + setTimeout(()=>{ window.scrollTo(0,0); },250) } -}- \ No newline at end of file +} + +var detectBackOrForward = function(onBack, onForward) +{ + hashHistory = [window.location.hash]; + historyLength = window.history.length; + + return function() + { + var hash = window.location.hash, length = window.history.length; + if (hashHistory.length && historyLength == length) { + if (hashHistory[hashHistory.length - 2] == hash) { + hashHistory = hashHistory.slice(0, -1); + onBack(); + } else { + hashHistory.push(hash); + onForward(); + } + } else { + hashHistory.push(hash); + historyLength = length; + } + } +}; + +window.addEventListener("hashchange", detectBackOrForward( + function() { console.log("back"); Ø('query').bang() }, + function() { console.log("forward"); Ø('query').bang() } +)); diff --git a/scripts/nodes/router.js b/scripts/nodes/router.js @@ -6,28 +6,34 @@ function RouterNode(id,rect) this.receive = function(q) { - var q = q.toUpperCase(); + var target = q.indexOf(":") > -1 ? q.split(":")[0].replace(/\+/g," ") : q.replace(/\+/g," ") + var params = q.indexOf(":") > -1 ? q.split(":")[1] : null var db = this.request("database").database; + var data = find(target.toUpperCase(),db) - var type = find(q,db) + this.label = `${this.id}|${target}|${params}` + + console.log(this.id,`${data ? data.type : '?'}->${target}[${params}]`); - this.label = `router:${type}/${q}` this.send({ - name:q, - type:type, - result:db[type] ? db[type][q] : null, + name:target, + type:data ? data.type : null, + result:data ? data.result : null, + params:params, tables:db }) } function find(key,db) { + if(parseInt(key) > 0){ return null; } + for(id in db){ var table = db[id] if(table[key]){ - return id + return {type:id,result:table[key]} } } - return null + return {type:null,result:null} } } \ No newline at end of file diff --git a/scripts/templates/home.js b/scripts/templates/home.js @@ -12,11 +12,16 @@ function HomeTemplate(id,rect) var sorted_ingredients = sort_ingredients(ingredients); + var html = ` + ${make_ingredients(sorted_ingredients,q.tables.ingredients)} + <h1>Recipes</h1> + ${make_recipes(q.tables.recipes)} + ` return { title:`GrimGrains — Home`, view:{ core: { - content: make_ingredients(sorted_ingredients,q.tables.ingredients), + content: html, related: "" } } @@ -77,4 +82,33 @@ function HomeTemplate(id,rect) } return Object.keys(ingredients).length } + + function make_recipes(recipes) + { + var html = "" + + // Sort by tag + + var categorized = {} + + for(name in recipes){ + var 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){ + var recipes = categorized[cat] + html += `<h3>${cat.capitalize()}</h3>` + html += "<list style='margin-bottom:15px'>" + for(id in recipes){ + var recipe = recipes[id] + html += `<ln><a onclick="Ø('query').bang('${recipe.name.capitalize()}')">${recipe.name.capitalize()}</a></ln>` + + } + html += "</list>" + } + return `<columns id='recipes'>${html}</columns>`; + } } \ No newline at end of file diff --git a/scripts/templates/index.js b/scripts/templates/index.js @@ -1,49 +0,0 @@ -function IndexTemplate(id,rect) -{ - Node.call(this,id,rect); - - this.glyph = NODE_GLYPHS.render - - // Create the recipe body - - this.answer = function(q) - { - return { - title:`GrimGrains — Index`, - view:{ - core: { - content: make_list(q.tables.recipes) - } - } - } - } - - function make_list(recipes) - { - var html = "" - - // Sort by tag - - var categorized = {} - - for(name in recipes){ - var 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){ - var recipes = categorized[cat] - html += `<h3>${cat.capitalize()}</h3>` - html += "<list style='margin-bottom:15px'>" - for(id in recipes){ - var recipe = recipes[id] - html += `<ln><a onclick="Ø('query').bang('${recipe.name.capitalize()}')">${recipe.name.capitalize()}</a></ln>` - - } - html += "</list>" - } - return `<columns id='index'>${html}</columns>`; - } -}- \ No newline at end of file diff --git a/scripts/templates/ingredient.js b/scripts/templates/ingredient.js @@ -23,7 +23,6 @@ function IngredientTemplate(id,rect) function make_ingredient(name,ingredient,recipes) { - console.log(ingredient) var html = "" html += `<h1>${ingredient.TYPE ? ingredient.TYPE.capitalize()+"/" : ''}${name.capitalize()}</h1>` @@ -73,8 +72,8 @@ function IngredientTemplate(id,rect) var a = []; for(id in ingredients){ - var words = id.split(" ") - var index = similarity(name.split(" "),words); + var words = id.toLowerCase().split(" ") + var index = similarity(name.toLowerCase().split(" "),words); if(index > 0){ a.push([id,index]) } @@ -133,7 +132,7 @@ function IngredientTemplate(id,rect) for(i in recipe.INGR){ var ingredients = recipe.INGR[i]; for(n in ingredients){ - if(n.indexOf(name) < 0){ continue; } + if(n.indexOf(name.toUpperCase()) < 0){ continue; } h[id] = recipes[id] } } diff --git a/scripts/templates/recipe.js b/scripts/templates/recipe.js @@ -33,9 +33,8 @@ function RecipeTemplate(id,rect) <h2>${recipe.SERV} — ${recipe.TIME} minutes</h2> <columns>${new Runic(recipe.DESC)}</columns> - ${make_instructions(recipe)} - <h2>Ingredients</h2> - ${make_ingredients(recipe.INGR)}`; + ${make_ingredients(recipe.INGR)} + ${make_instructions(recipe)}`; return html } @@ -96,7 +95,7 @@ function RecipeTemplate(id,rect) for(id in recipes){ var recipe = recipes[id]; var index = similarity(target.TAGS,recipe.TAGS) - if(id != name){ + if(id.toLowerCase() != name.toLowerCase()){ a.push([id,index]) } }