]> git.plutz.net Git - shellwiki/blobdiff - handlers/40_search.sh
search class for search form
[shellwiki] / handlers / 40_search.sh
index f057e45fee3a15cbfa6cb4120b03fccfc6d651b8..6ac6dce6720066e71a2adb419f29dc633674f417 100644 (file)
@@ -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 '<li><a href="%s">%s</a></li>' "$(URL "$page")" "$(HTML "$page")"
+  printf '%s\n' "$page"
 done \
-| theme_page - <<-EOF
-       <article>
-         <h1>$(_ "Search results")</h1>
-         <form method=GET>
-            <input class="search" name="q" placeholder="$(_ Search)" value="$(HTML $words)"><button class="search" type="submit">$(_ Search)</button>
-         </form>
-         <ol class="searchresults">
-           $(cat)
-         </ol>
-       </article>
-       EOF
+| theme_search "${words%       }"