logo

Grimgrains

[mirror] Plant-based cooking website <https://grimgrains.com/>
commit: a7ea4c80f4b92b4d6d1d066c368e7e3fff2d9309
parent c453ccf65424aaa97db4ee45cc346613ac7ceebf
Author: neauoire <aliceffekt@gmail.com>
Date:   Fri, 24 Jan 2020 09:12:04 -0500

Moved all includes to same fn

Diffstat:

Msite/about.html24++++++++++++++++++++++--
Msite/meals.html2+-
Msite/nutrition.html3++-
Msite/tools.html3++-
Msrc/main.c235+++++++++++++++++++++++--------------------------------------------------------
5 files changed, 94 insertions(+), 173 deletions(-)

diff --git a/site/about.html b/site/about.html @@ -1 +1,21 @@ -<!DOCTYPE html><html lang='en'><head><meta charset='utf-8'><meta name='description' content='Grim Grains is an illustrated food blog, it features plant-based (vegan) recipes.'><meta name='viewport' content='width=device-width, initial-scale=1.0'><meta name='twitter:card' content='summary'><meta name='twitter:site' content='@RekkaBell'><meta name='twitter:title' content='Grimgrains'><meta name='twitter:description' content='An illustrated food blog.'><meta name='twitter:creator' content='@RekkaBell'><meta name='twitter:image' content='https://grimgrains.com/media/services/icon.jpg'><meta property='og:title' content='Grimgrains'><meta property='og:type' content='article'><meta property='og:url' content='http://grimgrains.com/'><meta property='og:image' content='https://grimgrains.com/media/services/icon.jpg'><meta property='og:description' content='An illustrated food blog.'><meta property='og:site_name' content='Grimgrains'><title>GrimGrains — About</title><link rel='stylesheet' type='text/css' href='../links/main.css'></head><body class='about'><header><a id='logo' href='home.html'><img src='../media/interface/logo.png' alt='Grimgrains'></a></header><nav><ul><li class='home'><a href='home.html'>Home</a></li><li class='recipes'><a href='home.html#recipes'>Recipes</a></li><li class='about'><a href='about.html'>About</a></li><li class='tools'><a href='tools.html'>Tools</a></li><li class='nutrition'><a href='nutrition.html'>Nutrition</a></li><li class='right'><a href='http://twitter.com/grimgrains' target='_blank'>Twitter</a></li></ul></nav><main class='about'><h1>About</h1><p>We started <b>Grimgrains</b> to teach ourselves how to cook. This blog, which now doubles as a travel diary, helps track our habits as we adapt to the localy available produce. All of these recipes are plant-based, and tree-nut free.</p><img src= '../media/pages/about/galley.jpg'/><p>We are <a href='http://kokorobot.ca/' class='external' target='_blank'>Rekka Bellum</a>(illustrator) and <a href='http://xxiivv.com' class='external' target='_blank'>Devine Lu Linvega</a>(developer), living on a small sailboat somewhere on the shores of the Pacific Ocean. <a href='http://100r.co' class='external' target='_blank'>Hundredrabbits</a> is the name of our floating studio, we write softwares and recipes as we sail around the world looking for new ingredients.</p><p>This website showcases our favourite creations, along with hand-drawn illustrations for each ingredient. The pages were generated entirely in the classic C99 programming language, and the sources can be found on <a href='https://github.com/hundredrabbits/Grimgrains' class='external' target='_blank'>Github</a>.</p><p>If you have any question, you can find us on on <a rel='me' href='https://merveilles.town/@rek'>Mastodon</a>.</p><img src= '../media/interface/toast.jpg' width='300'/><h3>Copyright policy</h3><p>You may adapt our recipes, but a link back or mention would be nice :).</p><p>The assets of grimgrains.com, unless stated otherwise, are <a href='http://100r.co/' class='external' target='_blank'>©hundredrabbits</a>. Photographs, drawings or text should not be used, published, reprinted or modified without our permission. The source code of the website is under the <a href='https://github.com/hundredrabbits/Grimgrains/blob/master/LICENSE' class='external' target='_blank'>MIT License</a>.</p><p>All recipes featured on grimgrains.com are our own, unless stated otherwise. The information is for food enthusiasts like ourselves, we do not claim to be all-knowing. Nor are we health professionals. Our views are our own, we encourage openness and curiosity whenever possible.</p><h3>Privacy statement</h3><p>We reserve the right to alter the blog at our own discretion. Words addressed to us in private will not be shared, nor will we use any of it in future publications.</p></main><footer><a href='about.html'>Grimgrains</a> © 2014—2020<br><a href='http://100r.co/' target='_blank'>Hundred Rabbits</a></footer></body></html> -\ No newline at end of file +<!DOCTYPE html><html lang='en'><head><meta charset='utf-8'><meta name='description' content='Grim Grains is an illustrated food blog, it features plant-based (vegan) recipes.'><meta name='viewport' content='width=device-width, initial-scale=1.0'><meta name='twitter:card' content='summary'><meta name='twitter:site' content='@RekkaBell'><meta name='twitter:title' content='Grimgrains'><meta name='twitter:description' content='An illustrated food blog.'><meta name='twitter:creator' content='@RekkaBell'><meta name='twitter:image' content='https://grimgrains.com/media/services/icon.jpg'><meta property='og:title' content='Grimgrains'><meta property='og:type' content='article'><meta property='og:url' content='http://grimgrains.com/'><meta property='og:image' content='https://grimgrains.com/media/services/icon.jpg'><meta property='og:description' content='An illustrated food blog.'><meta property='og:site_name' content='Grimgrains'><title>GrimGrains — about</title><link rel='stylesheet' type='text/css' href='../links/main.css'></head><body class='about'><header><a id='logo' href='home.html'><img src='../media/interface/logo.png' alt='Grimgrains'></a></header><nav><ul><li class='home'><a href='home.html'>Home</a></li><li class='recipes'><a href='home.html#recipes'>Recipes</a></li><li class='about'><a href='about.html'>About</a></li><li class='tools'><a href='tools.html'>Tools</a></li><li class='nutrition'><a href='nutrition.html'>Nutrition</a></li><li class='right'><a href='http://twitter.com/grimgrains' target='_blank'>Twitter</a></li></ul></nav><main class='about'><h1>About</h1> + +<p>We started <b>Grimgrains</b> to teach ourselves how to cook. This blog, which now doubles as a travel diary, helps track our habits as we adapt to the localy available produce. All of these recipes are plant-based, and tree-nut free.</p> + +<img src= '../media/pages/about/galley.jpg'/> + +<p>We are <a href='http://kokorobot.ca/' class='external' target='_blank'>Rekka Bellum</a>(illustrator) and <a href='http://xxiivv.com' class='external' target='_blank'>Devine Lu Linvega</a>(developer), living on a small sailboat somewhere on the shores of the Pacific Ocean. <a href='http://100r.co' class='external' target='_blank'>Hundredrabbits</a> is the name of our floating studio, we write softwares and recipes as we sail around the world looking for new ingredients.</p> + +<p>This website showcases our favourite creations, along with hand-drawn illustrations for each ingredient. The pages were generated entirely in the classic C99 programming language, and the sources can be found on <a href='https://github.com/hundredrabbits/Grimgrains' class='external' target='_blank'>Github</a>.</p> + +<p>If you have any question, you can find us on <a rel='me' href='https://merveilles.town/@rek'>Mastodon</a>.</p> + +<img src= '../media/interface/toast.jpg' width='300'/> + +<h3>Copyright policy</h3><p>You may adapt our recipes, but a link back or mention would be nice :).</p> + +<p>The assets of grimgrains.com, unless stated otherwise, are <a href='http://100r.co/' class='external' target='_blank'>©hundredrabbits</a>. Photographs, drawings or text should not be used, published, reprinted or modified without our permission. The source code of the website is under the <a href='https://github.com/hundredrabbits/Grimgrains/blob/master/LICENSE' class='external' target='_blank'>MIT License</a>.</p> + +<p>All recipes featured on grimgrains.com are our own, unless stated otherwise. The information is for food enthusiasts like ourselves, we do not claim to be all-knowing. Nor are we health professionals. Our views are our own, we encourage openness and curiosity whenever possible.</p> + +<h3>Privacy statement</h3><p>We reserve the right to alter the blog at our own discretion. Words addressed to us in private will not be shared, nor will we use any of it in future publications.</p></main><footer><a href='about.html'>Grimgrains</a> © 2014—2020<br><a href='http://100r.co/' target='_blank'>Hundred Rabbits</a></footer></body></html> +\ No newline at end of file diff --git a/site/meals.html b/site/meals.html @@ -1,4 +1,4 @@ -<!DOCTYPE html><html lang='en'><head><meta charset='utf-8'><meta name='description' content='Grim Grains is an illustrated food blog, it features plant-based (vegan) recipes.'><meta name='viewport' content='width=device-width, initial-scale=1.0'><meta name='twitter:card' content='summary'><meta name='twitter:site' content='@RekkaBell'><meta name='twitter:title' content='Grimgrains'><meta name='twitter:description' content='An illustrated food blog.'><meta name='twitter:creator' content='@RekkaBell'><meta name='twitter:image' content='https://grimgrains.com/media/services/icon.jpg'><meta property='og:title' content='Grimgrains'><meta property='og:type' content='article'><meta property='og:url' content='http://grimgrains.com/'><meta property='og:image' content='https://grimgrains.com/media/services/icon.jpg'><meta property='og:description' content='An illustrated food blog.'><meta property='og:site_name' content='Grimgrains'><title>GrimGrains — Meals</title><link rel='stylesheet' type='text/css' href='../links/main.css'></head><body class='meals'><header><a id='logo' href='home.html'><img src='../media/interface/logo.png' alt='Grimgrains'></a></header><nav><ul><li class='home'><a href='home.html'>Home</a></li><li class='recipes'><a href='home.html#recipes'>Recipes</a></li><li class='about'><a href='about.html'>About</a></li><li class='tools'><a href='tools.html'>Tools</a></li><li class='nutrition'><a href='nutrition.html'>Nutrition</a></li><li class='right'><a href='http://twitter.com/grimgrains' target='_blank'>Twitter</a></li></ul></nav><main><p>A record of what Devine & I eat, everyday, for a period of 2 weeks. This experiment was done while we lived on land, during winter. All recipes are portioned for 2 people, except breakfasts (we don't eat the same thing).</p> +<!DOCTYPE html><html lang='en'><head><meta charset='utf-8'><meta name='description' content='Grim Grains is an illustrated food blog, it features plant-based (vegan) recipes.'><meta name='viewport' content='width=device-width, initial-scale=1.0'><meta name='twitter:card' content='summary'><meta name='twitter:site' content='@RekkaBell'><meta name='twitter:title' content='Grimgrains'><meta name='twitter:description' content='An illustrated food blog.'><meta name='twitter:creator' content='@RekkaBell'><meta name='twitter:image' content='https://grimgrains.com/media/services/icon.jpg'><meta property='og:title' content='Grimgrains'><meta property='og:type' content='article'><meta property='og:url' content='http://grimgrains.com/'><meta property='og:image' content='https://grimgrains.com/media/services/icon.jpg'><meta property='og:description' content='An illustrated food blog.'><meta property='og:site_name' content='Grimgrains'><title>GrimGrains — meals</title><link rel='stylesheet' type='text/css' href='../links/main.css'></head><body class='meals'><header><a id='logo' href='home.html'><img src='../media/interface/logo.png' alt='Grimgrains'></a></header><nav><ul><li class='home'><a href='home.html'>Home</a></li><li class='recipes'><a href='home.html#recipes'>Recipes</a></li><li class='about'><a href='about.html'>About</a></li><li class='tools'><a href='tools.html'>Tools</a></li><li class='nutrition'><a href='nutrition.html'>Nutrition</a></li><li class='right'><a href='http://twitter.com/grimgrains' target='_blank'>Twitter</a></li></ul></nav><main class='meals'><p>A record of what Devine & I eat, everyday, for a period of 2 weeks. This experiment was done while we lived on land, during winter. All recipes are portioned for 2 people, except breakfasts (we don't eat the same thing).</p> <p><a href='#day1'>day 1</a> | <a href='#day2'>day 2</a> | <a href='#day3'>day 3</a> | <a href='#day4'>day 4</a> | <a href='#day5'>day 5</a> | <a href='#day6'>day 6</a> | <a href='#day7'>day 7</a> | <a href='#day8'>day 8</a> | <a href='#day9'>day 9</a> | <br><a href='#day10'>day 10</a> | <a href='#day11'>day 11</a> | <a href='#day12'>day 12</a> | <a href='#day13'>day 13</a> | <a href='#day14'>day 14</a></p> diff --git a/site/nutrition.html b/site/nutrition.html @@ -1,4 +1,5 @@ -<!DOCTYPE html><html lang='en'><head><meta charset='utf-8'><meta name='description' content='Grim Grains is an illustrated food blog, it features plant-based (vegan) recipes.'><meta name='viewport' content='width=device-width, initial-scale=1.0'><meta name='twitter:card' content='summary'><meta name='twitter:site' content='@RekkaBell'><meta name='twitter:title' content='Grimgrains'><meta name='twitter:description' content='An illustrated food blog.'><meta name='twitter:creator' content='@RekkaBell'><meta name='twitter:image' content='https://grimgrains.com/media/services/icon.jpg'><meta property='og:title' content='Grimgrains'><meta property='og:type' content='article'><meta property='og:url' content='http://grimgrains.com/'><meta property='og:image' content='https://grimgrains.com/media/services/icon.jpg'><meta property='og:description' content='An illustrated food blog.'><meta property='og:site_name' content='Grimgrains'><title>GrimGrains — Nutrition</title><link rel='stylesheet' type='text/css' href='../links/main.css'></head><body class='nutrition'><header><a id='logo' href='home.html'><img src='../media/interface/logo.png' alt='Grimgrains'></a></header><nav><ul><li class='home'><a href='home.html'>Home</a></li><li class='recipes'><a href='home.html#recipes'>Recipes</a></li><li class='about'><a href='about.html'>About</a></li><li class='tools'><a href='tools.html'>Tools</a></li><li class='nutrition'><a href='nutrition.html'>Nutrition</a></li><li class='right'><a href='http://twitter.com/grimgrains' target='_blank'>Twitter</a></li></ul></nav><main class='nutrition'><h1><a id="nutrition">Nutrition</a></h1> +<!DOCTYPE html><html lang='en'><head><meta charset='utf-8'><meta name='description' content='Grim Grains is an illustrated food blog, it features plant-based (vegan) recipes.'><meta name='viewport' content='width=device-width, initial-scale=1.0'><meta name='twitter:card' content='summary'><meta name='twitter:site' content='@RekkaBell'><meta name='twitter:title' content='Grimgrains'><meta name='twitter:description' content='An illustrated food blog.'><meta name='twitter:creator' content='@RekkaBell'><meta name='twitter:image' content='https://grimgrains.com/media/services/icon.jpg'><meta property='og:title' content='Grimgrains'><meta property='og:type' content='article'><meta property='og:url' content='http://grimgrains.com/'><meta property='og:image' content='https://grimgrains.com/media/services/icon.jpg'><meta property='og:description' content='An illustrated food blog.'><meta property='og:site_name' content='Grimgrains'><title>GrimGrains — nutrition</title><link rel='stylesheet' type='text/css' href='../links/main.css'></head><body class='nutrition'><header><a id='logo' href='home.html'><img src='../media/interface/logo.png' alt='Grimgrains'></a></header><nav><ul><li class='home'><a href='home.html'>Home</a></li><li class='recipes'><a href='home.html#recipes'>Recipes</a></li><li class='about'><a href='about.html'>About</a></li><li class='tools'><a href='tools.html'>Tools</a></li><li class='nutrition'><a href='nutrition.html'>Nutrition</a></li><li class='right'><a href='http://twitter.com/grimgrains' target='_blank'>Twitter</a></li></ul></nav><main class='nutrition'><h1>Nutrition</h1> + <p>The information in this guide may change as research develops. If you are concerned about your intake of vitamin and minerals, we highly recommend seeing a <b>dietitian</b> who specializes in plant-based diets.</p> <ul> <li><a href="#protein">Protein</a></li> diff --git a/site/tools.html b/site/tools.html @@ -1,4 +1,5 @@ -<!DOCTYPE html><html lang='en'><head><meta charset='utf-8'><meta name='description' content='Grim Grains is an illustrated food blog, it features plant-based (vegan) recipes.'><meta name='viewport' content='width=device-width, initial-scale=1.0'><meta name='twitter:card' content='summary'><meta name='twitter:site' content='@RekkaBell'><meta name='twitter:title' content='Grimgrains'><meta name='twitter:description' content='An illustrated food blog.'><meta name='twitter:creator' content='@RekkaBell'><meta name='twitter:image' content='https://grimgrains.com/media/services/icon.jpg'><meta property='og:title' content='Grimgrains'><meta property='og:type' content='article'><meta property='og:url' content='http://grimgrains.com/'><meta property='og:image' content='https://grimgrains.com/media/services/icon.jpg'><meta property='og:description' content='An illustrated food blog.'><meta property='og:site_name' content='Grimgrains'><title>GrimGrains — Tools</title><link rel='stylesheet' type='text/css' href='../links/main.css'></head><body class='tools'><header><a id='logo' href='home.html'><img src='../media/interface/logo.png' alt='Grimgrains'></a></header><nav><ul><li class='home'><a href='home.html'>Home</a></li><li class='recipes'><a href='home.html#recipes'>Recipes</a></li><li class='about'><a href='about.html'>About</a></li><li class='tools'><a href='tools.html'>Tools</a></li><li class='nutrition'><a href='nutrition.html'>Nutrition</a></li><li class='right'><a href='http://twitter.com/grimgrains' target='_blank'>Twitter</a></li></ul></nav><main class='tools'><h1>Tools</h1> +<!DOCTYPE html><html lang='en'><head><meta charset='utf-8'><meta name='description' content='Grim Grains is an illustrated food blog, it features plant-based (vegan) recipes.'><meta name='viewport' content='width=device-width, initial-scale=1.0'><meta name='twitter:card' content='summary'><meta name='twitter:site' content='@RekkaBell'><meta name='twitter:title' content='Grimgrains'><meta name='twitter:description' content='An illustrated food blog.'><meta name='twitter:creator' content='@RekkaBell'><meta name='twitter:image' content='https://grimgrains.com/media/services/icon.jpg'><meta property='og:title' content='Grimgrains'><meta property='og:type' content='article'><meta property='og:url' content='http://grimgrains.com/'><meta property='og:image' content='https://grimgrains.com/media/services/icon.jpg'><meta property='og:description' content='An illustrated food blog.'><meta property='og:site_name' content='Grimgrains'><title>GrimGrains — tools</title><link rel='stylesheet' type='text/css' href='../links/main.css'></head><body class='tools'><header><a id='logo' href='home.html'><img src='../media/interface/logo.png' alt='Grimgrains'></a></header><nav><ul><li class='home'><a href='home.html'>Home</a></li><li class='recipes'><a href='home.html#recipes'>Recipes</a></li><li class='about'><a href='about.html'>About</a></li><li class='tools'><a href='tools.html'>Tools</a></li><li class='nutrition'><a href='nutrition.html'>Nutrition</a></li><li class='right'><a href='http://twitter.com/grimgrains' target='_blank'>Twitter</a></li></ul></nav><main class='tools'><h1>Tools</h1> + <p>Entering a store, with the goal of purchasing kitchenware can be a dizzying experience. There are many choices, but few are worth your money and attention. An ideal kitchen will have as few items as possible, be composed of things that make you happy and that you chose with purpose. With this in mind, for a tool to be awarded a place in your home, it needs to be effective and versatile. I made this list of notes on what to look for in a tool, based on experience and research:</p><img src='../media/pages/tools.jpg'> <ul> <li><b>Durability</b>: Choose a material that will last, of finer grade, or that can be composted.</li> diff --git a/src/main.c b/src/main.c @@ -158,43 +158,43 @@ void build_recipe(Recipe *recipe) { to_lowercase(recipe->name, filename, STR_BUF_LEN); char filepath[STR_BUF_LEN]; snprintf(filepath, STR_BUF_LEN, "../site/%s.html", filename); - FILE *myfile = fopen(filepath, "w"); + FILE *f = fopen(filepath, "w"); - fprintf(myfile, html_head, recipe->name, "recipe"); - fputs(html_header, myfile); - fputs(html_nav, myfile); + fprintf(f, html_head, recipe->name, "recipe"); + fputs(html_header, f); + fputs(html_nav, f); - fputs("<main class='recipe'>", myfile); - fprintf(myfile, "<h1>%s</h1>", recipe->name); - fprintf(myfile, "<h2>%s — %d minutes</h2>", recipe->portions, recipe->time); - fprintf(myfile, "<img src='../media/recipes/%s.jpg'/>", filename); - fprintf(myfile, "<p class='col2'>%s</p>", recipe->description); + fputs("<main class='recipe'>", f); + fprintf(f, "<h1>%s</h1>", recipe->name); + fprintf(f, "<h2>%s — %d minutes</h2>", recipe->portions, recipe->time); + fprintf(f, "<img src='../media/recipes/%s.jpg'/>", filename); + fprintf(f, "<p class='col2'>%s</p>", recipe->description); for (int i = 0; i < recipe->parts_len; ++i) { - fputs("<dl class='ingredients'>", myfile); - fprintf(myfile, "<h3>%s</h3>", recipe->parts[i]->name); + fputs("<dl class='ingredients'>", f); + fprintf(f, "<h3>%s</h3>", recipe->parts[i]->name); for (int i2 = 0; i2 < recipe->parts[i]->servings_len; ++i2) { char ingr_path[STR_BUF_LEN]; to_lowercase(recipe->parts[i]->servings[i2].ingredient->name, ingr_path, STR_BUF_LEN); - fprintf(myfile, + fprintf(f, "<dt><a href='%s.html'><img " "src='../media/ingredients/%s.png'/><b>%s</b> <u>%s</u></a></dt>", ingr_path, ingr_path, recipe->parts[i]->servings[i2].ingredient->name, recipe->parts[i]->servings[i2].quantity); } - fputs("</dl>", myfile); - fputs("<ul class='instructions'>", myfile); + fputs("</dl>", f); + fputs("<ul class='instructions'>", f); for (int i2 = 0; i2 < recipe->parts[i]->instructions_len; ++i2) { - fprintf(myfile, "<li>%s</li>", recipe->parts[i]->instructions[i2]); + fprintf(f, "<li>%s</li>", recipe->parts[i]->instructions[i2]); } - fputs("</ul>", myfile); + fputs("</ul>", f); } - fputs("</main>", myfile); + fputs("</main>", f); - fputs(html_footer, myfile); + fputs(html_footer, f); - fclose(myfile); + fclose(f); } void build_ingredient(Ingredient *ingredient) { @@ -203,27 +203,27 @@ void build_ingredient(Ingredient *ingredient) { to_lowercase(ingredient->name, filename, STR_BUF_LEN); char filepath[STR_BUF_LEN]; snprintf(filepath, STR_BUF_LEN, "../site/%s.html", filename); - FILE *myfile = fopen(filepath, "w"); + FILE *f = fopen(filepath, "w"); - fprintf(myfile, html_head, ingredient->name, "ingredient"); - fputs(html_header, myfile); - fputs(html_nav, myfile); + fprintf(f, html_head, ingredient->name, "ingredient"); + fputs(html_header, f); + fputs(html_nav, f); - fputs("<main class='ingredient'>", myfile); - fprintf(myfile, "<h1>%s</h1>", ingredient->name); - fprintf(myfile, "<img class='right' src='../media/ingredients/%s.png'/>", + fputs("<main class='ingredient'>", f); + fprintf(f, "<h1>%s</h1>", ingredient->name); + fprintf(f, "<img class='right' src='../media/ingredients/%s.png'/>", filename); - fprintf(myfile, "<p>%s</p>", ingredient->description); + fprintf(f, "<p>%s</p>", ingredient->description); if (ingredient->parent) { - fprintf(myfile, "<h2>%s</h2>", ingredient->parent->name); - fprintf(myfile, "<p class='small'>%s</p>", ingredient->parent->description); + fprintf(f, "<h2>%s</h2>", ingredient->parent->name); + fprintf(f, "<p class='small'>%s</p>", ingredient->parent->description); } - fputs("<hr/>", myfile); - fputs("</main>", myfile); + fputs("<hr/>", f); + fputs("</main>", f); - fputs(html_footer, myfile); + fputs(html_footer, f); - fclose(myfile); + fclose(f); } void build_home(Ingredient *ingredients[], int ingredients_len, @@ -232,173 +232,79 @@ void build_home(Ingredient *ingredients[], int ingredients_len, char *filename = "home"; char filepath[STR_BUF_LEN]; snprintf(filepath, STR_BUF_LEN, "../site/%s.html", filename); - FILE *myfile = fopen(filepath, "w"); + FILE *f = fopen(filepath, "w"); - fprintf(myfile, html_head, "Home", "home"); - fputs(html_header, myfile); - fputs(html_nav, myfile); + fprintf(f, html_head, "Home", "home"); + fputs(html_header, f); + fputs(html_nav, f); - fputs("<main class='home'>", myfile); - fprintf(myfile, "<h1>%d Ingredients</h1>", ingredients_len); + fputs("<main class='home'>", f); + fprintf(f, "<h1>%d Ingredients</h1>", ingredients_len); - fputs("<dl class='ingredients'>", myfile); + fputs("<dl class='ingredients'>", f); for (int i = 0; i < ingredients_len; ++i) { char ingr_path[STR_BUF_LEN]; to_lowercase(ingredients[i]->name, ingr_path, STR_BUF_LEN); - fprintf(myfile, + fprintf(f, "<dt><a href='%s.html'><img " "src='../media/ingredients/%s.png'/><b>%s</b></a></dt>", ingr_path, ingr_path, ingredients[i]->name); } - fputs("</dl>", myfile); + fputs("</dl>", f); - fprintf(myfile, "<h1 id='recipes'>%d Recipes</h1>", recipes_len); + fprintf(f, "<h1 id='recipes'>%d Recipes</h1>", recipes_len); - fputs("<ul class='recipes col3'>", myfile); + fputs("<ul class='recipes col3'>", f); for (int i = 0; i < lifestyle + 1; ++i) { - fprintf(myfile, "<h3>%s</h3>", recipe_type_names[i]); + fprintf(f, "<h3>%s</h3>", recipe_type_names[i]); for (int j = 0; j < recipes_by_types_len[i]; ++j) { char recipe_path[STR_BUF_LEN]; to_lowercase(recipes_by_types[i][j], recipe_path, STR_BUF_LEN); - fprintf(myfile, "<li><a href='%s.html'>%s</a></li>", recipe_path, + fprintf(f, "<li><a href='%s.html'>%s</a></li>", recipe_path, recipes_by_types[i][j]); } } - fputs("</main>", myfile); + fputs("</main>", f); - fputs(html_footer, myfile); + fputs(html_footer, f); - fclose(myfile); + fclose(f); } -void build_about() { -// New strings - char *filename = "about"; +void build_inc(char *name) { + char *filename = name; char filepath[STR_BUF_LEN]; snprintf(filepath, STR_BUF_LEN, "../site/%s.html", filename); - FILE *myfile = fopen(filepath, "w"); + FILE *f = fopen(filepath, "w"); - fprintf(myfile, html_head, "About", "about"); - fputs(html_header, myfile); - fputs(html_nav, myfile); + char incpath[STR_BUF_LEN]; + snprintf(incpath, STR_BUF_LEN, "inc/%s.htm", filename); - fputs("<main>", myfile); - char buffer[4096]; - FILE *fp = fopen("inc/about.htm", "r"); - if(fp == NULL){ return; } - - for (;;) { - size_t sz = fread(buffer, 1, sizeof(buffer), fp); - if (sz) { - fwrite(buffer, 1, sz, myfile); - } else if (feof(fp) || ferror(fp)) { - break; - } - } - fclose(fp); - fputs("</main>", myfile); - - fputs(html_footer, myfile); - - fclose(myfile); -} - -void build_meals() { -// New strings - char *filename = "meals"; - char filepath[STR_BUF_LEN]; - snprintf(filepath, STR_BUF_LEN, "../site/%s.html", filename); - FILE *myfile = fopen(filepath, "w"); + fprintf(f, html_head, name, name); + fputs(html_header, f); + fputs(html_nav, f); - fprintf(myfile, html_head, "Meals", "meals"); - fputs(html_header, myfile); - fputs(html_nav, myfile); - - fputs("<main>", myfile); + fprintf(f, "<main class='%s'>", name); char buffer[4096]; - FILE *fp = fopen("inc/meals.htm", "r"); + FILE *fp = fopen(incpath, "r"); if(fp == NULL){ return; } for (;;) { size_t sz = fread(buffer, 1, sizeof(buffer), fp); if (sz) { - fwrite(buffer, 1, sz, myfile); + fwrite(buffer, 1, sz, f); } else if (feof(fp) || ferror(fp)) { break; } } fclose(fp); - fputs("</main>", myfile); + fputs("</main>", f); - fputs(html_footer, myfile); + fputs(html_footer, f); - fclose(myfile); -} - -void build_nutrition() { -// New strings - char *filename = "nutrition"; - char filepath[STR_BUF_LEN]; - snprintf(filepath, STR_BUF_LEN, "../site/%s.html", filename); - FILE *myfile = fopen(filepath, "w"); - - fprintf(myfile, html_head, "Nutrition", "nutrition"); - fputs(html_header, myfile); - fputs(html_nav, myfile); - - fputs("<main class='nutrition'>", myfile); - char buffer[4096]; - FILE *fp = fopen("inc/nutrition.htm", "r"); - if(fp == NULL){ return; } - - for (;;) { - size_t sz = fread(buffer, 1, sizeof(buffer), fp); - if (sz) { - fwrite(buffer, 1, sz, myfile); - } else if (feof(fp) || ferror(fp)) { - break; - } - } - fclose(fp); - fputs("</main>", myfile); - - fputs(html_footer, myfile); - - fclose(myfile); -} - -void build_tools() { -// New strings - char *filename = "tools"; - char filepath[STR_BUF_LEN]; - snprintf(filepath, STR_BUF_LEN, "../site/%s.html", filename); - FILE *myfile = fopen(filepath, "w"); - - fprintf(myfile, html_head, "Tools", "tools"); - fputs(html_header, myfile); - fputs(html_nav, myfile); - - fputs("<main class='tools'>", myfile); - char buffer[4096]; - FILE *fp = fopen("inc/tools.htm", "r"); - if(fp == NULL){ return; } - - for (;;) { - size_t sz = fread(buffer, 1, sizeof(buffer), fp); - if (sz) { - fwrite(buffer, 1, sz, myfile); - } else if (feof(fp) || ferror(fp)) { - break; - } - } - fclose(fp); - fputs("</main>", myfile); - - fputs(html_footer, myfile); - - fclose(myfile); + fclose(f); } int main(void) { @@ -423,17 +329,10 @@ int main(void) { build_home(ingredients, ingredients_len, recipes_len); printf("Built home\n"); - build_about(); - printf("Built about\n"); - - build_nutrition(); - printf("Built nutrition\n"); - - build_tools(); - printf("Built tools\n"); - - build_meals(); - printf("Built meals\n"); + build_inc("about"); + build_inc("nutrition"); + build_inc("tools"); + build_inc("meals"); return (0); }