commit 885fed741dab4c82a5b83014ff88cac743214a4d
parent 67cc77eca4f37acd6e8e15a3eff7404ea6f3e033
Author: uriel@engel.se.cat-v.org <unknown>
Date: Sat, 20 Dec 2008 02:57:01 +0100
Simplify dir listing handler, and deal better with corner cases.
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/bin/werc.rc b/bin/werc.rc
@@ -21,7 +21,7 @@ fn gentitle {
# Don't change var name or trailing ';', dirfilter might be changed from _werc/config!
# TODO: Specify the canonical path input format handled by dirfilter
-dirfilter = '/\/[._]/d; /'^$forbidden_uri_chars^'/d; /\/(robots\.txt|sitemap\.txt|index\.(md|html|txt|tpl))$/d; /_werc\/?$/d; s,^\./,,; s,\.(md|html|txt)$,,; '
+dirfilter = 's,/\./,/,g; /\/[._]/d; /'^$forbidden_uri_chars^'/d; /\/(robots\.txt|sitemap\.txt|index\.(md|html|txt|tpl))$/d; /_werc\/?$/d; s,^\./,,; s,\.(md|html|txt)$,,; '
# To be used from config files
fn hide_paths {
@@ -100,9 +100,9 @@ fn txt_handler {
fn dir_listing_handler {
d = `{basename -d $1}
- dt = `{echo $d|sed -e 's,.*//,,g' -e 's,/$,,' -e 's,/, / ,g'}
- echo '<h1 class="dir-list-head">'^$"dt^'</h1> <ul class="dir-list">'
- ls -F $d | sed -e 's/\*$//; '^$dirfilter' s,^'$sitedir'/.*/([^/]+/?)$,<li><a href="\1">\1</a></li>,'
+ echo $d|sed 's,.*//,,g; s,/$,,; 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 $d/. | sed -e 's/\*$//; '^$dirfilter' s,.*/([^/]+/?)$,<li><a href="\1">\1</a></li>,'
echo '</ul>'
}