New
authorMike Taylor <mike@indexdata.com>
Thu, 28 Sep 2006 16:48:00 +0000 (16:48 +0000)
committerMike Taylor <mike@indexdata.com>
Thu, 28 Sep 2006 16:48:00 +0000 (16:48 +0000)
web/htdocs/details/doc.mc [new file with mode: 0644]
web/htdocs/doc.html [new file with mode: 0644]

diff --git a/web/htdocs/details/doc.mc b/web/htdocs/details/doc.mc
new file mode 100644 (file)
index 0000000..8d71d8a
--- /dev/null
@@ -0,0 +1,58 @@
+%# $Id: doc.mc,v 1.1 2006-09-28 16:48:20 mike Exp $
+<%once>
+use Pod::Html;
+use IO::Dir;
+</%once>
+<%perl>
+my $module = $r->param("module");
+if (!defined $module) {
+    print "     <ul>\n";
+    render_doc_links($LIBDIR, "ZOOM", 6);
+    print "     </ul>\n";
+} else {
+    print "<b>Documentation for '$module'</b>\n";
+    { my $dir = "/tmp/pod2html"; mkdir $dir; chdir $dir || die $!; }
+    # For some reason, output to standard output doesn't appear
+    my $name = "ZOOM.html";
+    pod2html("$LIBDIR/$module", "--outfile=$name");
+    open F, "<$name" or die "can't open '$name': $!";
+    my $text = join("", <F>);
+    close F;
+    $text =~ s/.*?<body.*?>//gs;
+    $text =~ s/<\/body.*//gs;
+    print $text;
+}
+
+sub render_doc_links {
+    my($base, $dir, $level) = @_;
+
+    my $dh = new IO::Dir("$base/$dir")
+       or die "can't open directory handle for '$base/$dir'";
+
+    print " " x $level, "<li><b>$dir</b></li>\n";
+    print " " x $level, "<ul>\n";
+
+    my(@files, @dirs);
+    while (my $file = $dh->read()) {
+       if ($file eq "." || $file eq ".." || $file eq "CVS") {
+           next;
+       } elsif (-d "$base/$dir/$file") {
+           push @dirs, $file;
+       } else {
+           push @files, $file;
+       }
+    }
+
+    foreach my $file (sort @files) {
+       print(" " x $level,
+             qq[ <li><a href="?module=$dir/$file">$file</a></li>\n]);
+    }
+
+    foreach my $file (sort @dirs) {
+       render_doc_links($base, "$dir/$file", $level+1);
+    }
+
+    print " " x $level, "</ul>\n";
+    undef $dh;
+}
+</%perl>
diff --git a/web/htdocs/doc.html b/web/htdocs/doc.html
new file mode 100644 (file)
index 0000000..424d5db
--- /dev/null
@@ -0,0 +1,3 @@
+%# $Id: doc.html,v 1.1 2006-09-28 16:48:00 mike Exp $
+<& /chrome/layout.mc, %ARGS, component => "/details/doc.mc",
+    title => defined $ARGS{module} ? $ARGS{module} : "Documentation" &>