tadd geomyidae(8) interface - recipes - various cooking recipes HTML git clone git://src.adamsgaard.dk/recipes DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 15c985ca84451c5155bf968520b8abcc26836be6 DIR parent 0495a0d5578dac1824d8c8d92f64f22774697394 HTML Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Fri, 27 Aug 2021 12:07:28 +0200 add geomyidae(8) interface Diffstat: A index.dcgi | 55 +++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+), 0 deletions(-) --- DIR diff --git a/index.dcgi b/index.dcgi t@@ -0,0 +1,55 @@ +#!/bin/sh + +search="$1" +arguments="$2" +host="$3" +port="$4" + +recipedir="recipes/" + +printf '\n# RECIPE SEARCH\n\n' +printf 'Search for one or more items which must appear in the recipe +ingredient list (space separated, case insensitive).\n' + +gphfmt() { + while read -r l; do + if test -f "$l"; then + printf '[0|%s|/%s%s|server|port]\n' "$l" "$recipedir" "$l" + elif test -f "$l"; then + printf '[1|%s|/%s%s|server|port]\n' "$l" "$recipedir" "$l" + else + printf '%s\n' "$l" + fi + done +} + +if test -n "${search}"; then + if test "${arguments}" = "vegetarian"; then + results="$(./cookwhatveg "$search" | gphfmt)" + else + results="$(./cookwhat "$search" | gphfmt)" + fi + + n="$(printf '%s' "$results" | wc -l)" + if test "$n" -gt 0; then + if test "$n" -gt 1; then + printf '\n## Results (%d recipes)\n' "$n" + else + printf '\n## Just one result\n' + fi + printf '\n%s\n' "$results" + else + printf '\nNo recipes found\n' "$n" + fi +fi + +printf '\n' +printf '[7|Find a recipe: _____________________________________________|/%s|server|port]\n' "$recipedir" +printf '[7|Find a vegetarian recipe: __________________________________|/%s?vegetarian|server|port]\n' "$recipedir" + +printf '\n## Want to add a recipe?\n' +printf 'Please send a patch:\n' +printf '[h|git://src.adamsgaard.dk/recipes|URL:git://src.adamsgaard.dk/recipes|server|port]\n' +printf '[1|Source code view|/src/recipes|server|port]\n' + +printf '\n[1|<< back|/|server|port]\n'