summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]search_cgi12
-rwxr-xr-xsearch_repo6
2 files changed, 14 insertions, 4 deletions
diff --git a/search_cgi b/search_cgi
index 624ad2e..425ce55 100644..100755
--- a/search_cgi
+++ b/search_cgi
@@ -4,8 +4,10 @@ echo "Content-type: text/html\n\n"
query="${QUERY_STRING}"
-
-echo "<html><body><div>Search for: </div><form method='GET' action='/cgi-bin/search_cgi'>"
+echo "<html><head><style type='text/css'>"
+echo "body{padding: 20px; margin: 40px auto;line-height: 1.6;font-size: 18px; color:#444;}"
+echo "</style></head>"
+echo "<body><div>Search for: </div><form method='GET' action='/cgi-bin/search_cgi'>"
echo "<input type='text' name='query'></input>"
echo "<input type='submit' value='Search!'></input>"
echo "</form>"
@@ -17,15 +19,17 @@ terms=$(echo "${query}" | tr '&' '\n' | grep -E "^query" | sed -E 's/^query=//')
if [ -z "$terms" ]; then
exit 0
else
- search=$(echo "$terms" | sed -E 's/\%20/ /g')
+ search=$(echo "$terms" | sed -E 's/\+/ /g')
res=$(./search_repo ./ $search )
if [ -z "$res" ]; then
echo "<p>No results for \"$search\":"
exit 0;
else
echo "<p>Results for \"$search\""
+ echo "<ul>\n"
for r in $res; do
- echo "<div><a href=\"$r\" target='new'>$r</a></div>\n"
+ echo "<li><div><a href=\"$r\" target='new'>$r</a></div></li>\n"
done
+ echo "</ul>"
fi
fi
diff --git a/search_repo b/search_repo
index 65dd9c5..0f4f42c 100755
--- a/search_repo
+++ b/search_repo
@@ -15,10 +15,16 @@ shift
WORDS="$@"
query=$(echo "$WORDS" | sed -E 's/\ /\|/g')
+echo "$query"
cd "$FOLDER"
+repos=$(find ./ -type d | grep -E "\/.*\/" | grep -Ei "$query" | \
+ sed -E 's/.\/([a-z]+)\//\1:\/\//1')
+
res=$(grep -Eric "$query" | grep -v ":0$" | sort -t ':' -rnk2 | \
sed -E 's/([a-z]+)\//\1:\/\//1;s/\/[^\/]*$//' )
+echo "$repos" | grep -Ei "^[a-z]+://"
+echo "--" >&2
echo "$res" | grep -Ei "^[a-z]+://"