commit: d99bfa27f68259248fa5240de340df2c793045b9
parent e8575b48db2e3760e066f203751e75464f558e19
Author: neauoire <aliceffekt@gmail.com>
Date: Thu, 19 Dec 2019 15:00:42 -0500
Progress on new site builder
Diffstat:
6 files changed, 147 insertions(+), 61 deletions(-)
diff --git a/source/build.sh b/source/build.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+cc -std=c99 -DDEBUG -Wall -Wpedantic -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -lm -Og -fsanitize=address -fsanitize=undefined main.c -o main
+
+./main+
\ No newline at end of file
diff --git a/source/ingredient.c b/source/ingredient.c
@@ -0,0 +1,25 @@
+
+typedef struct {
+ int id;
+ char *name;
+ char *description;
+} Ingredient;
+
+typedef struct {
+ Ingredient *ingredient;
+ char *quantity;
+} Serving;
+
+Ingredient create_ingredient(char *name, char *description) {
+ Ingredient a;
+ a.name = name;
+ a.description = description;
+ return a;
+}
+
+Serving create_serving(Ingredient *ingredient, char *quantity) {
+ Serving a;
+ a.ingredient = ingredient;
+ a.quantity = quantity;
+ return a;
+}+
\ No newline at end of file
diff --git a/source/ingredients.c b/source/ingredients.c
@@ -0,0 +1,9 @@
+
+Ingredient black_sesame_seeds = create_ingredient("black_sesame_seeds","descr");
+Ingredient coconut_oil = create_ingredient("coconut_oil","descr");
+Ingredient brown_rice_syrup = create_ingredient("brown_rice_syrup","descr");
+Ingredient puffed_rice = create_ingredient("puffed_rice","descr");
+Ingredient kinako = create_ingredient("kinako","descr");
+Ingredient salt = create_ingredient("salt","descr");
+
+// Ingredient *ingredients[] = {&pepper};+
\ No newline at end of file
diff --git a/source/main.c b/source/main.c
@@ -1,70 +1,14 @@
#include "stdio.h"
-// cc -std=c99 -Wall main.c -o main -lm; and ./main
-
-typedef struct {
- int id;
- char *name;
- char *description;
-} Ingredient;
-
-typedef struct {
- Ingredient *ingredient;
- char *quantity;
-} Serving;
-
-typedef struct {
- int id;
- char *name;
- char *description;
- int servings_len;
- Serving servings[10];
-} Recipe;
-
-Recipe create_recipe(int id, char *name, char *description) {
- Recipe a;
- a.id = id;
- a.name = name;
- a.description = description;
- a.servings_len = 0;
- return a;
-}
-
-Ingredient create_ingredient(char *name, char *description) {
- Ingredient a;
- a.name = name;
- a.description = description;
- return a;
-}
-
-Serving create_serving(Ingredient *ingredient, char *quantity) {
- Serving a;
- a.ingredient = ingredient;
- a.quantity = quantity;
- return a;
-}
-
-void print_recipe(Recipe recipe) {
- printf("recipe #%d: %s - %s\n",recipe.id,recipe.name,recipe.description);
- // int len = sizeof(recipe.ingredients)/sizeof(recipe.ingredients[0]);
- // printf("%d\n", len);
- // for(int i = 0; i < len; ++i) {
- // printf("ingredient: %s\n", recipe.ingredients[i]);
- // }
-}
-
-void add_serving(Recipe *r, Ingredient *i, char *quantity){
- r->servings[r->servings_len] = create_serving(i,quantity);
- r->servings_len++;
-}
+#include "ingredient.c"
+#include "recipe.c"
int main(void) {
- Ingredient pepper = create_ingredient("pepper","pepper is good");
- Recipe cake = create_recipe(16,"cake","Some cake description. トチシマクチトシ");
- add_serving(&cake,&pepper,"1tbs");
+ #include "ingredients.c"
+ #include "recipes.c"
- print_recipe(cake);
+ print_recipe(rice_treat);
return (0);
}
\ No newline at end of file
diff --git a/source/recipe.c b/source/recipe.c
@@ -0,0 +1,48 @@
+
+typedef struct {
+ char *name;
+ char *portions;
+ char *description;
+ int date;
+ int time;
+ int instructions_len;
+ char *instructions[256];
+ int servings_len;
+ Serving servings[10];
+} Recipe;
+
+Recipe create_recipe(char *name, char *portions, int date, int time) {
+ Recipe a;
+ a.name = name;
+ a.portions = portions;
+ a.date = date;
+ a.time = time;
+ a.servings_len = 0;
+ return a;
+}
+
+void add_recipe_description(Recipe *r, char *description){
+ r->description = description;
+}
+
+void add_recipe_instruction(Recipe *r, char *instruction){
+ r->instructions[r->instructions_len] = instruction;
+ r->instructions_len++;
+}
+
+void add_recipe_serving(Recipe *r, Ingredient *i, char *quantity){
+ r->servings[r->servings_len] = create_serving(i,quantity);
+ r->servings_len++;
+}
+
+void print_recipe(Recipe recipe) {
+ printf("name:%s, portions:%s date:%d time:%d\n",recipe.name,recipe.portions,recipe.date,recipe.time);
+ printf("===========\nInstructions:\n");
+ for(int i = 0; i < recipe.instructions_len; ++i) {
+ printf("%s\n", recipe.instructions[i]);
+ }
+ printf("===========\nIngredients:\n");
+ for(int i = 0; i < recipe.servings_len; ++i) {
+ printf("%s %s\n", recipe.servings[i].ingredient->name,recipe.servings[i].quantity);
+ }
+}
diff --git a/source/recipes.c b/source/recipes.c
@@ -0,0 +1,51 @@
+
+Recipe rice_treat = create_recipe("sesame puffed rice treat","12 servings",20161207,60);
+
+add_recipe_description(&rice_treat, "<p>A simple and fun dessert, using two of my favorite ingredients, {{kinako}} and {{black sesame seeds}}. Both of these ingredients lend themselves well to sweets, with a complex nutty taste.</p><p>Kinako is roasted soybean flour. It is often used to coat confectionaries in Japan. It's a healthy topping and flavouring which contains B vitamins and protein.</p>");
+
+add_recipe_instruction(&rice_treat, "Bring a pan to medium heat, and add {_1/3 cup_} of {{black sesame seeds}}. Toast until fragrant, you'll know they're ready because they'll start popping and crackling. Remove from heat, and let cool. ");
+add_recipe_instruction(&rice_treat, "Grind the toasted sesame seeds with a mortar and pestle, or your pulverizer of choice.");
+add_recipe_instruction(&rice_treat, "Heat a {_1/4 cup_} of {{coconut oil}} in a pot at medium heat until fully melted, then stir in {_1/2 cup_} of {{brown rice syrup}} and the ground sesame seeds. Cook for {#5 minutes#}, stirring all the while.");
+add_recipe_instruction(&rice_treat, "Remove from heat, stir in {_1/4 tsp_} of {{salt}}, then add {_4 cups_} of {{puffed rice}} cereal and mix well. Transfer to a greased square baking dish (8x8 pyrex dish is fine) and pack it down using a spatula. You can also overlay a sheet of parchment paper and to push down with your hands. ");
+add_recipe_instruction(&rice_treat, "Refrigerate for {#1 hour#}.");
+add_recipe_instruction(&rice_treat, "Sprinkle {_1/4 cup_} of {{kinako flour}} over the rice crispy treats and cut into squares.");
+
+add_recipe_serving(&rice_treat, &black_sesame_seeds, "1/3 cup");
+add_recipe_serving(&rice_treat, &coconut_oil, "1/4 cup");
+add_recipe_serving(&rice_treat, &brown_rice_syrup, "1/2 cup");
+add_recipe_serving(&rice_treat, &puffed_rice, ": 4 cups");
+add_recipe_serving(&rice_treat, &kinako, "1/4 cup");
+add_recipe_serving(&rice_treat, &salt, "1/4 tsp");
+
+
+// SESAME PUFFED RICE TREAT
+// DATE : 2016-12-07
+// TAGS
+// dessert
+// TIME : 60
+// SERV : 12 servings
+// DESC
+// & A simple and fun dessert, using two of my favorite ingredients, {{kinako}} and {{black sesame seeds}}. Both of these ingredients lend themselves well to sweets, with a complex nutty taste.
+// & Kinako is roasted soybean flour. It is often used to coat confectionaries in Japan. It's a healthy topping and flavouring which contains B vitamins and protein.
+// INST
+// Preparation
+// - Bring a pan to medium heat, and add {_1/3 cup_} of {{black sesame seeds}}. Toast until fragrant, you'll know they're ready because they'll start popping and crackling. Remove from heat, and let cool.
+// - Grind the toasted sesame seeds with a mortar and pestle, or your pulverizer of choice.
+// - Heat a {_1/4 cup_} of {{coconut oil}} in a pot at medium heat until fully melted, then stir in {_1/2 cup_} of {{brown rice syrup}} and the ground sesame seeds. Cook for {#5 minutes#}, stirring all the while.
+// - Remove from heat, stir in {_1/4 tsp_} of {{salt}}, then add {_4 cups_} of {{puffed rice}} cereal and mix well. Transfer to a greased square baking dish (8x8 pyrex dish is fine) and pack it down using a spatula. You can also overlay a sheet of parchment paper and to push down with your hands.
+// - Refrigerate for {#1 hour#}.
+// - Sprinkle {_1/4 cup_} of {{kinako flour}} over the rice crispy treats and cut into squares.
+// INGR
+// Main
+// Black sesame seeds : 1/3 cup
+// Coconut oil : 1/4 cup
+// Brown Rice Syrup : 1/2 cup
+// Puffed Rice : 4 cups
+// Kinako : 1/4 cup
+// Salt : 1/4 tsp
+
+
+
+// add_serving(&cake,&pepper,"1tbs");
+
+// Recipe *recipes[] = {&rice_treat};+
\ No newline at end of file