Introduction
Introduction Statistics Contact Development Disclaimer Help
tAllow purely arguments control of the search output. - recipes - various cooki…
git clone git://src.adamsgaard.dk/recipes
Log
Files
Refs
Submodules
---
commit 1d6448b2fe5caab14f9afcf88d97635be94b447e
parent e0edbfac7024dc6f6ca06752839ef819120db3d3
Author: Christoph Lohmann <[email protected]>
Date: Fri, 27 Aug 2021 14:49:13 +0200
Allow purely arguments control of the search output.
* Format the source to a congruent if style.
* allow '+' as space replacement for complex scripted search
index.dcgi?vegetarian+milk+cabbage
index.dcgi?milk+cabbage
Diffstat:
M index.dcgi | 42 ++++++++++++++++++++++-------…
1 file changed, 30 insertions(+), 12 deletions(-)
---
diff --git a/index.dcgi b/index.dcgi
t@@ -8,14 +8,15 @@ port="$4"
recipedir="recipes/"
printf '\n# EMPTY-THE-FRIDGE COOKING RECIPE SEARCH\n\n'
-printf 'Search for one or more items which must appear in the recipe
-ingredient list (space separated, case insensitive).\n'
+printf 'Search for one or more items which must appear in the\nrecipe ingredie…
gphfmt() {
while read -r l; do
- if test -f "$l"; then
+ if [ -f "$l" ];
+ then
printf '[0|%s|/%s%s|server|port]\n' "$l" "$recipedir" …
- elif test -f "$l"; then
+ elif [ -f "$l" ];
+ then
printf '[1|%s|/%s%s|server|port]\n' "$l" "$recipedir" …
else
printf '%s\n' "$l"
t@@ -23,19 +24,35 @@ gphfmt() {
done
}
-if test -n "${search}"; then
- if test "${arguments}" = "vegetarian"; then
- results="$(./cookwhatveg $search | gphfmt)"
+searchvegetarian=0
+case "${arguments}" in
+vegetarian*)
+ arguments="$(printf "%s\n" "${arguments}" | cut -c 11-)"
+ searchvegetarian=1
+ ;;
+esac
+[ -n "${search}" ] && arguments="${arguments}+${search}"
+
+if [ -n "${arguments}" ];
+then
+ normalarguments="$(printf "${arguments}\n" | tr '+' ' ')"
+ if [ $searchvegetarian -eq 1 ];
+ then
+ results="$(./cookwhatveg "$normalarguments" | gphfmt)"
else
- results="$(./cookwhat $search | gphfmt)"
+ results="$(./cookwhat "$normalarguments" | 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): "%s" \n' "$n" "$sea…
+ if [ $n -gt 0 ];
+ then
+ if [ $n -gt 1 ];
+ then
+ printf '\n## Results (%d recipes): "%s" \n' \
+ "$n" "$normalarguments"
else
- printf '\n## Just one result: "%s" \n' "$search"
+ printf '\n## Just one result: "%s" \n' \
+ "$normalarguments"
fi
printf '\n%s\n' "$results"
else
t@@ -53,3 +70,4 @@ printf '[h|git://src.adamsgaard.dk/recipes|URL:git://src.ada…
printf '[1|Source code view|/src/recipes|server|port]\n'
printf '\n[1|<< back|/|server|port]\n'
+
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.