Newer
Older
Import / web / internal.subflexion.com / search.sh
@John Ryland John Ryland on 22 Dec 2020 655 bytes import NUC files
#!/bin/bash

cd pages

MATCHED_FILENAMES=`ls *.md | grep -i "$1" | sed s/$/:/g`
MATCHED_CONTENTS=`grep -i "$1" *.md`
{ ls *.md | grep -i "$1" | sed s/$/:/g ; grep -i "$1" *.md ; } | sort -u -t: -k1,1 | while read LINE
do
    PAGE=`echo $LINE | cut -d ':' -f 1`
    CONTEXT=`echo $LINE | cut -d ':' -f 2-`
    if [ -f $PAGE ]
    then
      PAGE=`basename -s '.md' $PAGE`
      echo '<div class="panel panel-default"><div class="panel-heading"><h3 class="panel-title">'
      echo "<a href="view.php?page=$PAGE">$PAGE</a></h3>"
      echo '</div><div class="panel-body">'
      echo $CONTEXT | sed -e 's/<[^>]*>//g'
      echo '</div></div>'
    fi
done