From: Sam H. v. a. <we...@ma...> - 2008-01-24 15:56:22
|
Log Message: ----------- use monobook-like look and feel fix some problems with indexing "module_version--subdir" dirs Modified Files: -------------- admintools: ww-make-docs ww-make-docs-from-cvs Revision Data ------------- Index: ww-make-docs =================================================================== RCS file: /webwork/cvs/system/admintools/ww-make-docs,v retrieving revision 1.6 retrieving revision 1.7 diff -Lww-make-docs -Lww-make-docs -u -r1.6 -r1.7 --- ww-make-docs +++ ww-make-docs @@ -15,6 +15,7 @@ use Data::Dumper; our @sections = ( + '/' => "(root)", bin => "Scripts", conf => "Config Files", doc => "Documentation", @@ -117,7 +118,17 @@ my $html_path = "$html_dir/$filename"; my $html_rel_path = defined $subdir ? "$subdir/$filename" : $filename; - #print "$pod_path - $pod_name\n"; + # deal with potential + if (not defined $subdir) { + my $source_root_last = $source_root; + $source_root_last =~ s|^.*/||; + if ($source_root_last =~ /^(.+)_(.+?)(?:--(.*))?$/) { + my ($module, $version, $extra) = ($1, $2, $3); + $subdir = $extra; # the subdir is appended to the dir name + } else { + $subdir = '/'; # fake subdir for "things in the root" + } + } $self->update_index($subdir, $html_rel_path, $pod_name); #my $podpp_path = do_podpp($pod_path); do_mkdir($html_dir); @@ -130,6 +141,45 @@ html_path => $html_path, ); #unlink $podpp_path; + # postprocess HTML to add SSI tags for header and footer + $self->postprocess_pod($html_path); +} + +sub postprocess_pod { + my ($self, $file) = @_; + my $fh = new IO::File($file, 'r+') + or die "Failed to open file '$file' for reading/writing: $!\n"; + my $title; + my $text = ""; + my $in_body = 0; + while (my $line = <$fh>) { + if ($in_body) { + if ($line =~ /^\s*<\/body>\s*$/) { + $in_body = 0; + next; + } + if ($line =~ /^\s*<hr \/>\s*$/) { + next; + } + $text .= $line; + } else { + if ($line =~ /^\s*<body.*>\s*$/) { + $in_body = 1; + next; + } + if ($line =~ /\s*<title>(.*)<\/title>.*$/) { + $title = $1; + } + } + } + seek $fh, 0, 0; + truncate $fh, 0; + print $fh "<!--#set var=\"title\" value=\"$title\" -->", "\n" if defined $title; + print $fh '<!--#include virtual="/doc/cvs/header.html" -->' . "\n"; + print $fh $text; + print $fh '<!--#include virtual="/doc/cvs/footer.html" -->' . "\n"; + my $mode = (stat $fh)[2] & 0777 | 0111; + chmod $mode, $fh; } sub update_index { @@ -151,11 +201,16 @@ my $section_order = $self->{section_order}; my $source_root = $self->{source_root}; $source_root =~ s|^.*/||; + my $dest_url = $self->{dest_url}; #print Dumper($idx); - my $header = "<html><head><title>Index $source_root</title></head><body>\n"; - my $content_start = "<h1>Index for $source_root</h1><ul>\n"; + #my $header = "<html><head><title>Index $source_root</title></head><body>\n"; + #my $content_start = "<h1>Index for $source_root</h1><ul>\n"; + + my $header = qq|<!--#set var="title" value="Index for $source_root" -->| . "\n" + . '<!--#include virtual="/doc/cvs/header.html" -->' . "\n"; + my $content_start = "<ul>"; my $content = ""; foreach my $section (@$section_order) { @@ -163,21 +218,27 @@ my $section_name = $sections->{$section}; $content_start .= "<li><a href=\"#$section\">$section_name</a></li>\n"; my @files = sort @{$idx->{$section}}; - $content .= "<h2><a name=\"$section\">$section_name</a></h2><ul>\n"; + $content .= "<a name=\"$section\"></a>\n"; + $content .= "<h2>$section_name</h2><ul>\n"; foreach my $file (sort { $a->[1] cmp $b->[1] } @files) { my ($path, $name) = @$file; $content .= "<li><a href=\"$path\">$name</a></li>\n"; } - $content .= "</ul><hr/>\n"; + #$content .= "</ul><hr/>\n"; + $content .= "</ul>\n"; } - $content_start .= "</ul><hr/>\n"; + $content_start .= "</ul>\n"; my $date = strftime "%a %b %e %H:%M:%S %Z %Y", localtime; - my $content_end = "<p>Generated $date</p>\n"; - my $footer = "</body></html>\n"; + #my $content_end = "<p>Generated $date</p>\n"; + #my $footer = "</body></html>\n"; + my $content_end = ""; + my $footer = '<!--#include virtual="/doc/cvs/footer.html" -->' . "\n"; my $fh = new IO::File($out_path, 'w') or die "Failed to open index '$out_path' for writing: $!\n"; print $fh $header, $content_start, $content, $content_end, $footer; + my $mode = (stat $fh)[2] & 0777 | 0111; + chmod $mode, $fh; } sub do_podpp { @@ -213,7 +274,7 @@ "--infile=$o{pod_path}", "--outfile=$o{html_path}", '--recurse', - '--header', + '--noheader', ); #print join(" ", 'pod2html', @args), "\n"; pod2html(@args); Index: ww-make-docs-from-cvs =================================================================== RCS file: /webwork/cvs/system/admintools/ww-make-docs-from-cvs,v retrieving revision 1.5 retrieving revision 1.6 diff -Lww-make-docs-from-cvs -Lww-make-docs-from-cvs -u -r1.5 -r1.6 --- ww-make-docs-from-cvs +++ ww-make-docs-from-cvs @@ -39,6 +39,8 @@ our $WW_MAKE_DOCS = '/home/sh002i/work/admintools/ww-make-docs'; #our $WW_MAKE_DOCS = '/home/sam/work/admintools/ww-make-docs'; +our $BASE_URL = 'http://webwork.maa.org/doc/cvs'; + our $v; # for verbose switch my @dirs; @@ -62,9 +64,27 @@ } } -my $fh = new IO::File("$DOC_DIR/index.html", 'w') - or die "failed to open '$DOC_DIR/index.html' for writing: $!\n"; -write_index($fh); +{ + my $fh = new IO::File("$DOC_DIR/index.html", 'w') + or die "failed to open '$DOC_DIR/index.html' for writing: $!\n"; + write_index_new($fh); + my $mode = (stat $fh)[2] & 0777 | 0111; + chmod $mode, $fh; +} +{ + my $fh = new IO::File("$DOC_DIR/header.html", 'w') + or die "failed to open '$DOC_DIR/header.html' for writing: $!\n"; + write_header($fh); + my $mode = (stat $fh)[2] & 0777 | 0111; + chmod $mode, $fh; +} +{ + my $fh = new IO::File("$DOC_DIR/footer.html", 'w') + or die "failed to open '$DOC_DIR/footer.html' for writing: $!\n"; + write_footer($fh); + my $mode = (stat $fh)[2] & 0777 | 0111; + chmod $mode, $fh; +} sub update_cvs { my ($dir) = @_; @@ -86,7 +106,7 @@ die "/bin/mkdir -p $dest_dir failed (exit=$exit signal=$signal core=$core)\n"; } - system $WW_MAKE_DOCS, $source_dir, $dest_dir; + system $WW_MAKE_DOCS, $source_dir, $dest_dir;#, $BASE_URL; if ($?) { my $exit = $? >> 8; my $signal = $? & 127; @@ -124,7 +144,7 @@ $index{$module}{$version} = $dir; } } else { - warn "unfamiliary dir format '$dir' -- not adding to index.\n"; + warn "unfamiliar dir format '$dir' -- not adding to index.\n"; } } @@ -154,3 +174,109 @@ print $fh "</body></html>\n"; } } + +sub write_index_new { + my $fh = shift; + print $fh <<'EOF'; +<!--#set var="title" value="Main Menu" --> +<!--#include virtual="/doc/cvs/header.html" --> +<p>Chose a product and version from the menu to the left.</p> +<!--#include virtual="/doc/cvs/footer.html" --> +EOF +} + +sub write_header { + my $fh = shift; + print $fh <<'EOF'; +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> + <head> + <!-- <base href="http://webwork.maa.org/" /> --> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <link rel="shortcut icon" href="/favicon.ico" /> + <!--#if expr="$title" --> + <title><!--#echo var="title" --> - WeBWorKDocs</title> + <!--#else --> + <title>WeBWorKDocs</title> + <!--#endif --> + <style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "/wiki/skins/monobook/main.css?42b"; /*]]>*/</style> + <link rel="stylesheet" type="text/css" media="print" href="/wiki/skins/common/commonPrint.css?42b" /> + <link rel="stylesheet" type="text/css" media="handheld" href="/wiki/skins/monobook/handheld.css?42b" /> + <!--[if lt IE 5.5000]><style type="text/css">@import "/wiki/skins/monobook/IE50Fixes.css?42b";</style><![endif]--> + <!--[if IE 5.5000]><style type="text/css">@import "/wiki/skins/monobook/IE55Fixes.css?42b";</style><![endif]--> + <!--[if IE 6]><style type="text/css">@import "/wiki/skins/monobook/IE60Fixes.css?42b";</style><![endif]--> + <!--[if IE 7]><style type="text/css">@import "/wiki/skins/monobook/IE70Fixes.css?42b";</style><![endif]--> + <!--[if lt IE 7]><script type="text/javascript" src="/wiki/skins/common/IEFixes.js?42b"></script> + <meta http-equiv="imagetoolbar" content="no" /><![endif]--> + </head> + <body class="mediawiki ns-0 ltr page-Main_Page"> + <div id="globalWrapper"> + <div id="column-content"> + <div id="content"> + <a name="top" id="top"></a> + <!--#if expr="$title" --> + <h1 class="firstHeading"><!--#echo var="title" --></h1> + <!--#endif --> + <div id="bodyContent"> + <h3 id="siteSub">From WeBWorK</h3> + <div id="contentSub"></div> + <div id="jump-to-nav">Jump to: <a href="#column-one">navigation</a></div> + <!-- <base href="http://devel.webwork.rochester.edu/doc/cvs/" /> --> + <!-- start content --> +EOF +} + +sub write_footer { + my $fh = shift; + print $fh <<'EOF'; + <!-- end content --> + <!-- <base href="http://webwork.maa.org/" /> --> + <div class="visualClear"></div> + </div> + </div> + </div> + <div id="column-one"> + <div class="portlet" id="p-logo"> + <a style="background-image: url(/webwork2_files/images/webwork_square.png);" href="/wiki/Main_Page" title="Main Page"></a> + </div> + <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script> + <div class='portlet' id='p-navigation-$module'> + <h5>Navigation</h5> + <div class='pBody'> + <ul> + <li><a href="/doc/cvs/">CVS Docs Home</a></li> + <li><a href="/wiki/Main_Page">WeBWorK Wiki</a></li> + <li><a href="/">WeBWorK Home</a></li> + </ul> + </div> + </div> +EOF + for my $module (sort keys %index) { + print $fh "<div class='portlet' id='p-navigation-$module'>\n"; + print $fh "<h5>$module</h5>\n"; + print $fh "<div class='pBody'>\n"; + print $fh "<ul>\n"; + for my $version (reverse sort keys %{$index{$module}}) { + if (ref $index{$module}{$version}) { + print $fh "<li>$version<ul>\n"; + for my $extra (sort keys %{$index{$module}{$version}}) { + print $fh "<li><a href=\"$BASE_URL/$index{$module}{$version}{$extra}\">$extra</a></li>\n"; + } + print $fh "</ul></li>\n"; + } else { + print $fh "<li><a href=\"$BASE_URL/$index{$module}{$version}\">$version</a></li>\n"; + } + } + print $fh "</ul>\n"; + print $fh "</div></div>\n"; + } + print $fh <<'EOF'; + </div><!-- end of the left (by default at least) column --> + <div class="visualClear"></div> + <script type="text/javascript">if (window.runOnloadHook) runOnloadHook();</script> + </div> + </body> +</html> + +EOF +} |