Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Better Indexing from Pod::Simple::HTMLBatch?

by QM (Parson)
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/, 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/ and ./One/Two/Three/, 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?

Quantum Mechanics: The dreams stuff is made of

  • Comment on Better Indexing from Pod::Simple::HTMLBatch?

Replies are listed 'Best First'.
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/, 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?

      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', " +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 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1033854]
Approved by marto
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2017-08-17 18:52 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (290 votes). Check out past polls.