_(){ printf %s\\n "$*"; }
[ "${LANGUAGE}" -a -r "${_EXEC}/l10n/${LANGUAGE}.sh" ] && . "${_EXEC}/l10n/${LANGUAGE}.sh"
-show_form=true show_hits='' action=''
+show_form=true show_hits='' action='' query=''
set -- "$@" --
while [ $# -gt 0 ]; do case $1 in
*) set -- "$@" "$1"; shift 1;;
esac; done
+[ $@ -gt 0 ] && query="$*" || query="$(GET q)"
+
searchteaser() {
local file="$1" words db3_data
local w l nc nl hits mhits cont mcont
fi
if [ "${show_form}" = true ]; then
- printf '<form class="macro search" method="GET" action="%s">
- <input type="search" placeholder="%s" name="q" value="%s"><button type="submit" class="search">%s</button>
-</form>' "$action" "$(_ Search)" "$([ "$show_hits" = true ] && GET q |HTML)" "$(_ Search)"
+ cat <<-EOF
+ <form class="macro search" method="GET" action="${action}">
+ <input type="search" placeholder="$(_ Search)" name="q"
+ value="$([ "$show_hits" = true ] && printf %s\\n "$query" |HTML)"
+ ><button type="submit" class="search">$(_ Search)</button>
+ </form>
+ EOF
fi
if [ "${show_hits}" = true ]; then
{ read tags; read ntags; read words; } <<-EOF
- $(GET q | awk '
+ $(printf %s\\n "${query}" | awk '
BEGIN { # Field separator FS should include punctuation, including Unicode Block U+2000 - U+206F
if ( length("¡") == 1 ) # Utf-8 aware AWK
FS = "([] \\t\\n\\r\"'\''()*+,./:;<=>?\\\\^_`{|}~[-]|%[0-9A-Fa-f]{2}|'"$(printf '[\342\200\200-\342\201\257]')"')+";
settings)
w_user_update |"$_EXEC/cgilite/html-sh.sed"
;;
- search)
- if [ "$LANGUAGE_DEFAULT" ]; then
- printf '<form class="search" method="GET" action="./:%s/[search]">
- <input type="search" placeholder="%s" name="q" value=""><button type="submit" class="search">%s</button>
- </form>' "$LANGUAGE" "$(_ Search)" "$(_ Search)"
- else
- printf '<form class="search" method="GET" action="./[search]">
- <input type="search" placeholder="%s" name="q" value=""><button type="submit" class="search">%s</button>
- </form>' "$(_ Search)" "$(_ Search)"
- fi
- ;;
esac