]> git.plutz.net Git - shellwiki/blobdiff - themes/default.sh
fancier search results with teasers and page titles
[shellwiki] / themes / default.sh
index 5b2f1edd55a261ec566e37820c122af0d8a08313..fefde75925b1907263214531b54b5d8ce38b6f81 100755 (executable)
@@ -136,7 +136,7 @@ theme_revisions(){ theme_page "$@"; }
 
 theme_search(){
   local words="$*"
-  # STDIN: read result pages line by line
+  # STDIN: [STRING page][TAB][STRING teaser]
 
   theme_page - "$(_ Search results): ${words}" <<-EOF
        <article>
@@ -145,8 +145,14 @@ theme_search(){
            <input type="search" name="q" value="$(HTML $words)"><button class="search" type="submit">$(_ Search)</button>
          </form>
          <ol class="searchresults">
-           $( while read p; do
-             printf '<li><a href="%s">%s</a></li>' "$(URL "$p")" "$(HTML "$p")"
+           $(while read -r p t; do
+             path="$(UNSTRING "$p")" pfrag="${path%/}" title=''
+              while [ "$pfrag" ]; do
+                title="$(page_title "$pfrag")/$title"
+                pfrag="${pfrag%/*}"
+              done
+             printf '<li><a href="%s">%s</a><p>%s</p></li>' \
+                "$(URL "$path")" "$(HTML "/$title")" "$(UNSTRING "$t" |HTML)"
            done)
          </ol>
        </article>