ref: ce30272174a45d7ea85906ab30d42ed9336fce4f
parent: 9d6b7b3b654f87092acd1d2350bad560cca7250e
author: sl <[email protected]>
date: Sat Feb 14 02:09:27 EST 2009
Don't execute perm_redirects directly from conf_perm_redirect to avoid tripping over sitemaps and other code that sources config files but doesn't want to actually *do* anything. Also hide paths with simple or pattern redirects from sitemaps.
--- a/bin/werc.rc
+++ b/bin/werc.rc
@@ -81,6 +81,8 @@
}
cd $werc_root
+ if(~ $#perm_redir_to 1)
+ perm_redirect $perm_redir_to
f=();t=()
for(i in $perm_redir_patterns) {
if(~ $#f 0)
--- a/bin/wercconf.rc
+++ b/bin/wercconf.rc
@@ -1,9 +1,11 @@
# To be used from config files
fn conf_perm_redirect {
if(~ $#* 1)
- perm_redirect $1
- if not
+ perm_redir_to=$1
+ if not {
perm_redir_patterns=($perm_redir_patterns $1 $2)
+ conf_hide_paths $1 # XXX Will hide paths even if replacement string is the same as matched sctring.
+ }
}
fn conf_hide_paths {
--- a/lib/sitemap.tpl
+++ b/lib/sitemap.tpl
@@ -39,20 +39,22 @@
if(test -f $d/_werc/config)
. ./$d/_werc/config
- echo '<ul class="sitemap-list">'
+ if(~ $#perm_redir_to 0) {
+ echo '<ul class="sitemap-list">'
- for(i in `{ls -dF $d^*/ $d^*.md $d^*.html $d^*.txt >[2]/dev/null | sed $dirfilter}) {
- desc=`{get_file_title $i}
- u=`{echo $i|sed 's!'$sitedir'!!; '$dirclean's!/index$!/!; '}
- if(! ~ $#desc 0 && ! ~ $desc '')
- desc=' - '$"desc
- n=`{echo /$u|sed 's/_/ /g; s,.*/([^/]+)/?$,\1,'}
- echo '<li><a href="'$base_url$u'">'^$"n^'</a>' $"desc '</li>'
- echo $base_url^$u >> $tmpfile
- if(test -d $i)
- @{ listDir $i }
+ for(i in `{ls -dF $d^*/ $d^*.md $d^*.html $d^*.txt >[2]/dev/null | sed $dirfilter}) {
+ desc=`{get_file_title $i}
+ u=`{echo $i|sed 's!'$sitedir'!!; '$dirclean's!/index$!/!; '}
+ if(! ~ $#desc 0 && ! ~ $desc '')
+ desc=' - '$"desc
+ n=`{echo /$u|sed 's/_/ /g; s,.*/([^/]+)/?$,\1,'}
+ echo '<li><a href="'$base_url$u'">'^$"n^'</a>' $"desc '</li>'
+ echo $base_url^$u >> $tmpfile
+ if(test -d $i)
+ @{ listDir $i }
+ }
+ echo '</ul>'
}
- echo '</ul>'
}
fltr_cache listDir $sitedir/