X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=handlers%2F40_search.sh;h=6ac6dce6720066e71a2adb419f29dc633674f417;hb=3c949f9f02cddc9d1cd30174342aae1d58175999;hp=1d37989eb4c760679e63dd096a6b9e68dbf5153b;hpb=d9a3dee90a669c88bd6b4b0fa553e01ed1e729a1;p=shellwiki diff --git a/handlers/40_search.sh b/handlers/40_search.sh index 1d37989..6ac6dce 100644 --- a/handlers/40_search.sh +++ b/handlers/40_search.sh @@ -8,9 +8,9 @@ I="$_DATA/index" words="$( GET q | 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]')"')+"; + FS = "([] \\t\\n\\r!\"#'\''()*+,./:;<=>?\\\\^_`{|}~[-]|%[0-9A-Fa-f]{2}|'"$(printf '[\342\200\200-\342\201\257]')"')+"; else # UTF-8 Hack - FS = "([] \t\n\r!\"#'\''()*+,./:;<=>?\\^_`{|}~[-]|%[0-9A-Fa-f]{2}|'"$(printf '\342\200[\200-\277]|\342\201[\201-\257]')"')+"; + FS = "([] \\t\\n\\r!\"#'\''()*+,./:;<=>?\\\\^_`{|}~[-]|%[0-9A-Fa-f]{2}|'"$(printf '\342\200[\200-\277]|\342\201[\201-\257]')"')+"; fi } { for (n = 1; n <= NF; n++) printf "%s ", tolower($n); } @@ -36,17 +36,12 @@ done \ | sort -nr \ | while read freq doc; do page="$(UNSTRING "$doc")" + [ "${page%*/\[*\]/*}" != "$page" ] && continue + if [ "$LANGUAGE_DEFAULT" ]; then + [ -d "${_DATA}/pages/${page}/:${LANGUAGE}/" ] && continue + [ "${page%/:*/}" = "${page%/:${LANGUAGE}/}" ] || continue + fi acl_read "$page" || continue - printf '
  • %s
  • ' "$(URL "$page")" "$(HTML "$page")" + printf '%s\n' "$page" done \ -| theme_page - <<-EOF -
    -
    -

    $(_ "Search results")

    - -
    -
      - $(cat) -
    -
    - EOF +| theme_search "${words% }"