From: Paul Hänsch Date: Tue, 9 Apr 2024 14:31:40 +0000 (+0200) Subject: improved styling and options of search macro X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=a9486c540a7379a8dbdbfdbbe9152fd47b235e77;p=shellwiki improved styling and options of search macro --- 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 diff --git a/pages/[wiki]/search/#page.md b/pages/[wiki]/search/#page.md index 598bbb8..c6d93cd 100644 --- a/pages/[wiki]/search/#page.md +++ b/pages/[wiki]/search/#page.md @@ -3,4 +3,4 @@ Search Results ============== -<> +<> diff --git a/pages/[wiki]/search/:de/#page.md b/pages/[wiki]/search/:de/#page.md index 0a3ae08..49ae0bd 100644 --- a/pages/[wiki]/search/:de/#page.md +++ b/pages/[wiki]/search/:de/#page.md @@ -3,4 +3,4 @@ Suchergebnisse ============== -<> +<> diff --git a/themes/default.css b/themes/default.css index c7eb6dd..a1ea010 100644 --- a/themes/default.css +++ b/themes/default.css @@ -173,20 +173,32 @@ input.search, input[type="search"] { max-width: 80%; max-width: calc(100% - 2.5em); } +p.search.hits { text-align: center; } ul.search.hits, ol.search.hits { margin-left: auto; margin-right: auto; width: 100%; max-width: 540pt; - text-align: center; list-style: none; + padding-left: 0; +} +.search.hits li { + padding: 0 .75em; +} +.search.hits li:hover { + background-color: #F4F4F4; } .search.hits li a { display: block; } .search.hits li p { - display: inline-block; margin: 0 auto .5em auto; white-space: pre-line; } +.search.hits p.path { + color: #444; + font-size: .875em; + margin-top: -.5em; + margin-left: 1.5ex; +} table { min-width: 50%;