Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Do you know where your variables are?
 
PerlMonks  

Better Indexing from Pod::Simple::HTMLBatch?

by QM (Vicar)
on May 16, 2013 at 15:33 UTC ( #1033854=perlquestion: print w/ replies, xml ) Need Help??
QM has asked for the wisdom of the Perl Monks concerning the following question:

I've just picked up Pod::Simple::HTMLBatch, running it on a large existing codebase. (It works great.)

I notice that it doesn't create index.html files below the first level. That is, if I have ./One/Two/Three/Four.pm, it creates ./index.html, and ./One/index.html, but not below that. Also, the top level index has a list of all modules in the tree, not just at that level.

What I'd like it to do is mirror the module tree in the output dir, including an index.html in each directory. Also, If there's ./One/Two/Three.pm and ./One/Two/Three/Four.pm, I'd like to see the index.html in ./One/Two/Three list Three.html and Three/.

Does anyone have a solution, quick hack, or alternative so it will DWIW?

-QM
--
Quantum Mechanics: The dreams stuff is made of

Comment on Better Indexing from Pod::Simple::HTMLBatch?
Re: Better Indexing from Pod::Simple::HTMLBatch?
by Anonymous Monk on May 16, 2013 at 15:47 UTC

    That is, if I have ./One/Two/Three/Four.pm, it creates ./index.html, and ./One/index.html, but not below that.

    I don't get that, I only get one index.html in the output -- I think you have leftovers :)

    including an index.html in each directory.

    I think your best best is to run an index.html generator after running htmlbatch

      I think you have leftovers
      Yes, you are correct. I had run it on subtrees earlier, trying to get what I wanted, and didn't clean up.

      Admitting I haven't looked, can someone point to a simple index generator?

      -QM
      --
      Quantum Mechanics: The dreams stuff is made of

        I couldn't find one but I had most of this lying around , seems plain :)
        #!/usr/bin/perl -- use Path::Class; use constant THISFILE => file( __FILE__ )->absolute->stringify; use constant THISDIR => file( THISFILE )->dir->stringify; use strict; use warnings; use File::Find::Rule; use Data::Dump qw/ dd pp /; use POSIX(); use CGI(); # for hourly backups our $today = POSIX::strftime('%Y-%m-%d-%H', localtime); Main( @ARGV ); exit( 0 ); sub Fudge { use Errno(); join qq/\n/, "Error @_", map { " $_" } int( $! ) . q/ / . $!, int( $^E ) . q/ / . $^E, #~ grep( { $!{$_} } keys %! ), q/ /; } use List::MoreUtils 'uniq'; sub Main { @_ or die "Usage: $0 dir-to-make-indexes-beneath \n"; my @dirs = uniq( map { dir( $_ )->absolute } find( directory => in + => \@_ ) ) ; for my $dir ( @dirs ){ chdir $dir or die Fudge("chdir $dir"); my $title = $dir->basename; if( -e 'index.html'){ rename 'index.html', "index.html.$today.bak" or die Fudge(qq{ $dir / rename 'index.html', "index.ht +ml.$today.bak" }); } my $files = join ' ', '<tr>'. ( faFile("../", '../index.html') ).'</tr>', map { '<tr>'. ( -f $_ ? faFile($_) : faFile("$_/", "$_/index.html") ) .'</tr>' } grep { -e $_ } grep { not /^index\.html(\.\d\d\d\d-\d\d-\d\d-\d\d\.bak)?$/ +} glob '*';;; open my($ih), '>', 'index.html' or die Fudge("$title/index.htm +l"); print $ih qq{<!doctype html><html>}, qq{<title>@{[ CGI::escapeHTML( $title ) ]}</title><body>}, qq{<!--@{[scalar localtime]}-->}, qq{<table>$files</table></body></html>}; close $ih; } } sub faFile { my $a = CGI::a({ -href => $_[1] // $_[0] }, $_[0] ); my( $size, $modtime ) = (stat $_[0] )[ 7, 9 ]; "<td>$size</td><td>$a</td><td>".gmtime($modtime).'</td>' } __END__ $ perl makeindex.html.pl dir-test-dir $ gtree -f dir-test-dir dir-test-dir |-- dir-test-dir/Fort | |-- dir-test-dir/Fort/Knox.html | |-- dir-test-dir/Fort/index.html | |-- dir-test-dir/Fort/index.html.2013-05-17-12.bak | |-- dir-test-dir/Fort/index.html.2013-05-17-15.bak | |-- dir-test-dir/Fort/index.html.2013-05-17-16.bak |-- dir-test-dir/Fort.html |-- dir-test-dir/index.html |-- dir-test-dir/index.html.2013-05-17-12.bak |-- dir-test-dir/index.html.2013-05-17-15.bak |-- dir-test-dir/index.html.2013-05-17-16.bak

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1033854]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2014-04-18 17:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (471 votes), past polls