Add search.dcgi and search.sh. - gopher-lawn - The gopher lawn gopher directory project.
HTML git clone git://bitreich.org/gopher-lawn/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/gopher-lawn/
DIR Log
DIR Files
DIR Refs
DIR Tags
---
DIR commit cc5c00a7617d4f9b57199acf97114767806566a5
DIR parent de5a9a0a3bef5d6cc972b585452865d927727f41
HTML Author: Christoph Lohmann <20h@r-36.net>
Date: Sun, 10 May 2020 18:20:47 +0200
Add search.dcgi and search.sh.
Diffstat:
A search.dcgi | 32 +++++++++++++++++++++++++++++++
A search.sh | 24 ++++++++++++++++++++++++
2 files changed, 56 insertions(+), 0 deletions(-)
---
DIR diff --git a/search.dcgi b/search.dcgi
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# Adapted from gopher://kalos.mine.nu/0/software/search_lawn.dcgi
+#
+
+IDX="index.gph"
+STRIP="/lawn/"
+
+search="$1"
+arguments="$2"
+host="$3"
+port="$4"
+
+printf "\n"
+printf " T H E G O P H E R L A W N\n"
+printf "\n"
+printf "________________________________S_E_A_R_C_H_______________________________\n"
+
+if [ -z "${search}" ];
+then
+ printf "Please enter your search query.\n"
+ printf "[7|Gopher Lawn Search|/lawn/search.dcgi|server|port]\n"
+else
+ printf "Search Results\n"
+ ./search.sh "${search}"
+ printf "\n"
+ printf "[7|Search Again|/lawn/search.dcgi|server|port]\n"
+fi
+
+printf "\n"
+printf "[1|Back to the lawn.|/lawn|server|port]\n"
+
DIR diff --git a/search.sh b/search.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+# Adapted from: gopher://kalos.mine.nu/0/software/search_lawn.dcgi
+
+if [ $# -lt 1 ];
+then
+ printf "usage: %s search\n" "$(basename "$0")" >&2
+ exit 1
+fi
+
+IDX="index.gph"
+STRIP="/lawn/"
+
+X_GOPHER_SEARCH="$1"
+
+IFS='
+'
+grep "^\[.*|/lawn.*|server|port]" ${IDX} | cut -d "|" -f 3 | while read -r sel; do
+ subdir="${sel##$STRIP}"
+ [ -d "$subdir" ] && {
+ grep -i "${X_GOPHER_SEARCH}" "$subdir/index.gph" | grep "^\[" | grep -v "server\|port"
+ }
+done
+