ref: 6a11fe86feaaf80529add6f1e54705237bbf054f
parent: edbd4dd076ecda47f2ad7c4e3ca1e30f27bdbeac
author: sl <uriel@engel.se.cat-v.org>
date: Fri May 29 06:04:27 EDT 2009
Do not set handler if man page doesn't exist so we can provide proper 404 (or other fall-back) Make 'Intro' page title fixing case-insensitive to deal with Plan B man pages.
--- a/apps/wman/app.rc
+++ b/apps/wman/app.rc
@@ -20,8 +20,17 @@
wman_cp='man'
wman_pe=.^$"wman_cat
}
- if(! ~ $"wman_cat '')
+
+ if(! ~ $"wman_cat '') {
wman_cat_path=$wman_man_path^/^$"wman_cp^$p(1)
+ if(! ~ $"wman_page '') {
+ wman_page_file=$wman_page^$"wman_pe
+ # Hack to handle 0intro files.
+ if(~ $wman_page intro && test -f $wman_cat_path^/0^$"wman_page_file)
+ wman_page_file=0^$"wman_page_file
+ wman_page_file=$wman_cat_path^/^$"wman_page_file
+ }
+ }
wman_cat_list=`{ls -F $wman_man_path/*/ \
| sed -e $wman_junk_filter -e 's!.*/([^/]+)/[^/]+$!\1!; /[0-9]+/!d' \
@@ -34,7 +43,8 @@
if not if(~ $req_path $wman_base_uri^*) {
#^*/[a-z0-9]*[a-z]* $wman_base_uri^*/*[a-z]*[a-z0-9] $wman_base_uri^*/[a-z])
if(echo $req_path | grep -s '^'^$wman_base_uri^'/*[0-9]+/[0-9a-z\-\+\.]+$')
- handler_body_main=(tpl_handler apps/wman/man_page.tpl)
+ if(test -f $wman_page_file) # Check for 404
+ handler_body_main=(tpl_handler apps/wman/man_page.tpl)
if not if(~ $req_path $wman_base_uri^*/)
handler_body_main=(tpl_handler apps/wman/page_list.tpl)
if not if(~ $p(2) [A-Z]* [0-9][A-Z]*) # Correct badly capitalized links
@@ -53,7 +63,7 @@
}
fn wman_get_section_desc {
- cat $wman_man_path/^$"wman_cp^$1/0intro* >[2]/dev/null| sed '1,2d; s!intro \\- introduction to !!; 3q;'
+ cat $wman_man_path/^$"wman_cp^$1/0intro* >[2]/dev/null| sed '1,2d; s!intro \\- [Ii]ntroduction to !!; 3q;'
}
fn wman_page_gen {
--- a/apps/wman/man_page.tpl
+++ b/apps/wman/man_page.tpl
@@ -1,12 +1,7 @@
<pre>
%{
-# Hack to handle 0intro files.
-f=$wman_page^$"wman_pe
-if(~ $wman_page intro && test -f $wman_cat_path^/0^$f)
- f=0^$f
-
-wman_page_gen $wman_cat_path^/^$f
+wman_page_gen $wman_page_file
%}
</pre>