shithub: werc

Download patch

ref: dfcd7aff584c9f2b84db7e55bee0168aa82e75a5
parent: 5317c9ab46d64b9ac0c1e37cf6cf8c1cbd20b6d9
author: Uriel <u@berlinblue.org>
date: Mon Jun 28 05:06:45 EDT 2010

Make dir listings a bit prettier by replacing [-_] with spaces.

--- a/bin/corehandlers.rc
+++ b/bin/corehandlers.rc
@@ -75,9 +75,9 @@
     d=`{basename -d $1}
     if(~ $#d 0)
         d='/'
-    echo $d|sed 's,.*//,,g; s,/$,,; s,/, / ,g; s,.*,<h1 class="dir-list-head">&</h1> <ul class="dir-list">,'
+    echo $d|sed 's,.*//,,g; s,/$,,; s,/, / ,g; s/[\-_]/ /g; s,.*,<h1 class="dir-list-head">&</h1> <ul class="dir-list">,'
     # Symlinks suck: '/.' forces ls to list the linked dir if $d is a symlink.
-    ls -F $dir_listing_ls_opts $sitedir$d/. | sed $dirfilter$dirclean' s,.*/([^/]+/?)$,<li><a href="\1">\1</a></li>,'
+    ls -F $dir_listing_ls_opts $sitedir$d/. | sed $dirfilter$dirclean | awk '{match($0, "/[^/]*/?$"); l=substr($0, RSTART+1, RLENGTH-1);n=l; gsub(/[\-_]/, " ", n); print "<li><a href=\""l"\">"n"</a></li>"; }'
     echo '</ul>'
 }