--- tree.pl.orig	2004-01-21 20:38:46.000000000 +0900
+++ tree.pl	2004-01-23 20:04:26.000000000 +0900
@@ -28,7 +28,7 @@
 
 $conf::cgi = 0;				# Set to 1 to run tree.pl as a CGI script
 $conf::basedir_cgi = "/home/www";	# CGI mode only: list which directory
-$conf::templatefile = "tree-template.html";	# The template (set to "" to disable it)
+$conf::templatefile = "support/tree-template.m4";	# The template (set to "" to disable it)
 $conf::baseurl = "";		# Set first part of any URL (leave empty if unsure)
 
 ### The options below have sensible defaults, if tree.pl doesn't work ###
@@ -36,14 +36,15 @@
 
 # Default-files' names (files like index.html that are shown if you use
 # the URL of a directory):
-@conf::defaultfiles = ('index.html', 'index.htm', 'index.php');
+#@conf::defaultfiles = ('index.html', 'index.htm', 'index.php');
+@conf::defaultfiles = ('topdir.html');
 
 # Here you can decide which files will be listed, depending on the
 # files' suffix. Comment in the appropriate line:
 # List all files:
-@conf::file_suffixes = ();
+#@conf::file_suffixes = ();
 # Only list typical web files:
-#@conf::file_suffixes = ('shtml', 'html', 'htm', 'pdf');
+@conf::file_suffixes = ('shtml', 'html', 'htm', 'pdf');
 # Only list typical multimedia files:
 #@conf::file_suffixes = ('mp3', 'wav', 'avi', 'wmv', 'mpg', 'mpeg');
 # Only list files that have no suffix:
@@ -60,7 +61,7 @@
 #@conf::includefiles = ('*/');
 
 # Do not include these files/directories:
-@conf::excludefiles = ();
+@conf::excludefiles = ('*/CVS/', '*/tree_img/', '/support/*', '/kernel-docs-2.6/*', 'Configure.*', '/index.html');
 # To exclude one directory use this:
 #@conf::excludefiles = ('/secret/*');
 # To exclude more than one directory use this:
@@ -68,8 +69,12 @@
 
 # How should the files be linked? URL, TITLE, UPDATED, SIZE, DATE, and TIME
 # will be replaced by actual values:
+#$conf::link =<<EOF;
+#<a href="URL">TITLE</a> UPDATED <span class="info">SIZE kB, DATE TIME</span>
+#EOF
 $conf::link =<<EOF;
-<a href="URL">TITLE</a> UPDATED <span class="info">SIZE kB, DATE TIME</span>
+<dl><dt><a href="URL"><strong>TITLE</strong></a> UPDATED</dt>
+<dd>CONT</dd></dl>
 EOF
 
 # Link all directories, even those without default files?
@@ -81,9 +86,10 @@
 EOF
 
 # How to mark files that were recently modified:
-$conf::updatedtag = '<strong>updated</strong> ';
+#$conf::updatedtag = '<strong>updated</strong> ';
+$conf::updatedtag = '<span class="new">new</span> ';
 # Mark those files modified more recently than $conf::update_hours hours (0 = option off):
-$conf::update_hours = 3*24;
+$conf::update_hours = 30*24;
 
 # Date format. %Y = year, %m = month, %d = day
 # On a Unix system use 'man strftime' to get a list of all 
@@ -290,9 +296,9 @@
 	# Ignore uninteresting suffixes for files:
 	if( -f $f ) {
 		my ($suffix) = ($f =~ m/.*\.(.*?)$/);
-		#if( !$suffix ) {
-		#	return 0;
-		#}
+		if( !$suffix ) {
+			return 0;
+		}
 		if( scalar(@conf::file_suffixes) > 0 ) {
 			if( !grep(/^$suffix$/, @conf::file_suffixes) ) {
 				return 0;
@@ -344,7 +350,8 @@
 	
 	# maybe it doesn't make sense to link a directory without a default file:
 	my $default_file = has_defaultfile($file);
-	if( !$conf::link_all_directories && -d $file && !$default_file ) {
+	if(( !$conf::link_all_directories && -d $file && !$default_file ) or
+	   $default_file ) {
 		$link = $conf::nolink;
 	}
 
@@ -364,8 +371,12 @@
 	$link =~ s/URL/$conf::baseurl.my_uri_escape($url);/igse;
 
 	my $title = cleanup(get_file_title($file, $short_url));
+	$title =~ s/JF: Linux Kernel 2.6 Documentation: //;
 	$link =~ s/TITLE/$title/gs;
 
+	my $cont = load_cont_part($file);
+	$link =~ s/CONT/$cont/gs;
+
 	# Recently modified?:
 	my $update;
 	if( is_it_modified($file) ) {
@@ -507,6 +518,25 @@
 	return $string;
 }
 
+# Load part of a file until <!-- CONT --> is reached (to save time for big files).
+sub load_cont_part($)
+{
+	my $file = shift;
+	my $string = "";
+	return '' if( -B $file );
+	open(INPUT, "<$file") ||
+		(warn "Error: $0: Cannot open '$file': $!" and return "");
+	while(<INPUT>) {
+		if( $_ =~ m#<!-- CONT -->(.*?)$# ) {
+		    $string = $1;
+		    last;
+		}
+	}
+	close(INPUT);
+	
+	return $string;
+}
+
 # Check if file was modified recently. Return 1 or 0.
 sub is_it_modified($)
 {
