X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=handlers%2F40_search.sh;h=6ac6dce6720066e71a2adb419f29dc633674f417;hb=634d3aa5daf5404f2d209512acf70c601ece5697;hp=ca068abca14d67b714c2e601ba344b824596cf59;hpb=368ca204df61a5e24c71d4697746603e2dcc94d5;p=shellwiki diff --git a/handlers/40_search.sh b/handlers/40_search.sh index ca068ab..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,14 +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% }"