search bar

This commit is contained in:
lickthecheese 2020-03-18 20:02:21 -04:00
parent f251c397f4
commit 848618f778
6 changed files with 101 additions and 11 deletions

1
footer.html Normal file
View File

@ -0,0 +1 @@
</div>

6
genout
View File

@ -1,6 +0,0 @@
#!/bin/bash
PA=`cat -`
echo
echo "["`head -n 1 $PA`"]("`head -n 2 $PA | tail -n 1`")"

View File

@ -0,0 +1,18 @@
<!DOCTYPE HTML>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>tser - lickthecheese's cgi based search engine</title>
<h1>tser</h1>
lickthecheese's cgi based search engine
<div class='wrapper'>
<div class='box search-container'>
<form action="./">
<input type="text" placeholder="Search.." name="q">
<button type="submit"><i class="fa fa-search"></i></button>
</form>
</div>

View File

@ -12,9 +12,11 @@ Q=$(echo "$QUERY_STRING" | sed -n 's/^.*q=\([^&]*\).*$/\1/p' | sed "s/%20/ /g" |
if [[ $Q ]]
then
./tser $Q | cmark
./tser $Q
[[ $(./tser $Q) ]] || echo "No results :("
[[ $(./tser $Q) ]] || echo "<div class='box'>No results :(</div>"
fi
cat footer.html

74
style.css Normal file
View File

@ -0,0 +1,74 @@
body {
background: black;
font-family: monospace;
color: #aea;
}
.preview, .box {
border: 1px solid #aea;
padding: 10px;
border-radius: 10px;
margin-top: 5px;
}
.wrapper {
width: 700px;
margin: 0 auto;
}
a {
text-decoration: none;
color: #aea;
}
a:hover {
text-decoration: underline;
}
code, kbd, pre {
background: #333;
color: #aea;
}
pre {
padding: 10px;
border-radius: 2px;
border: 1px solid #aea;
}
.search-container input[type=text] {
padding: 6px;
margin-top: 3px;
font-size: 17px;
border: 3px solid #aea;
color: #aea;
background: #333;
}
.search-container button {
float: left;
padding: 8px 10px;
margin-top: 3px;
margin-right: 16px;
background: #333;
font-size: 17px;
border: none;
cursor: pointer;
color:#aea;
}
.search-container button:hover {
background: #111;
}
@media screen and (max-width:700px) {
.wrapper {
width: 100%;
}
}

7
tser
View File

@ -1,10 +1,11 @@
#!/bin/bash
QUERY=`echo $1 | tr ' ' '|'`
QUERY=`echo $1 | tr ' ' '|' | sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g'`
for fn in `grep -rlE $QUERY content`;do
echo $fn | ./genout
for fn in `grep -rlEi $QUERY content`;do
PA=$fn
echo "<div class='box'><a href='"`head -n 2 $PA | tail -n 1`"'>"`head -n 1 $PA`"</a><p>"`grep -i $QUERY $PA | sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g' | head -n 5`"</p></div>"
done