X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=macros%2Fsearch;fp=macros%2Fsearch;h=e8207c2eb4c46b2c41702fb905ab9aa5c07efa8b;hb=a9486c540a7379a8dbdbfdbbe9152fd47b235e77;hp=3951e97307115804ce13f8d6c0ea2f45791d30d8;hpb=6e3173e44ef8bdfa48a787a0349a86dfd2499f4c;p=shellwiki diff --git a/macros/search b/macros/search index 3951e97..e8207c2 100755 --- a/macros/search +++ b/macros/search @@ -25,23 +25,33 @@ I="$_DATA/index" _(){ printf %s\\n "$*"; } [ "${LANGUAGE}" -a -r "${_EXEC}/l10n/${LANGUAGE}.sh" ] && . "${_EXEC}/l10n/${LANGUAGE}.sh" -show_form=true show_hits='' action='' query='' +show_form=true show_hits='' action='' query='' show_query='' hlevel='3' alt='' set -- "$@" -- while [ $# -gt 0 ]; do case $1 in --no-form|--noform) show_form=''; shift 1;; --hits|--results) + [ ! "$show_query" ] && show_query=true show_hits='true'; shift 1;; + --query|--show-query) + show_query=true; shift 1;; + --no-query) + show_query=false; shift 1;; --action) action="$(HTML "$2")"; shift 2;; --action=*|action=*) - action="$(HTML "${2#*=}")"; shift 1;; + action="$(HTML "${1#*=}")"; shift 1;; + --h1|--h2|--h3|--h4|--h5|--h6) + hlevel="${1#--h}"; shift 1;; + --alt) + alt="$2"; shift 2;; --) shift 1; break;; *) set -- "$@" "$1"; shift 1;; esac; done [ $# -gt 0 ] && query="$*" || query="$(GET q)" +[ ! "$show_query" ] && show_query=false searchteaser() { local file="$1" words db3_data @@ -74,7 +84,7 @@ searchteaser() { } } -if [ ! "$action" -a "$LANGUAGE_DEFAULT" ]; then +if [ ! "$action" -a "$LANGUAGE" != "$LANGUAGE_DEFAULT" ]; then action="./:${LANGUAGE}/[search]" elif [ ! "$action" ]; then action="./[search]" @@ -84,7 +94,7 @@ if [ "${show_form}" = true ]; then cat <<-EOF EOF @@ -110,7 +120,6 @@ if [ "${show_hits}" = true ]; then ') EOF - printf '' + | { while read -r p t; do + [ ! "$path" ] && printf '' + [ ! "$path" -a "$alt" -a "$query" ] \ + && printf '' "$(HTML "$alt")" + } fi