]> git.plutz.net Git - shellwiki/blobdiff - themes/default.sh
themeable search page
[shellwiki] / themes / default.sh
index 85febeef60e7274563a2e62c0d59698e7088bb12..5e38ee4583f743c9240464022648d864bee9aeaf 100755 (executable)
@@ -131,6 +131,25 @@ theme_editor(){
 
 theme_revisions(){ theme_page "$@"; }
 
+theme_search(){
+  local words="$*"
+  # STDIN: read result pages line by line
+
+  theme_page - <<-EOF
+       <article>
+         <h1>$([ "$words" ] && _ "Search results" || _ "Search" )</h1>
+         <form method=GET>
+           <input class="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")"
+           done)
+         </ol>
+       </article>
+       EOF
+}
+
 theme_attachments(){
   local page="$1" title
   title="${page%/}"; title="${title##*/}"