Simplify dir listing handler, and deal better with corner cases.
This commit is contained in:
parent
28b82f244b
commit
33b98d278e
1 changed files with 4 additions and 4 deletions
|
|
@ -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>'
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue