Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Better Indexing from Pod::Simple::HTMLBatch?

by Anonymous Monk
on May 16, 2013 at 15:47 UTC ( #1033855=note: print w/ replies, xml ) Need Help??


in reply to Better Indexing from Pod::Simple::HTMLBatch?

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


Comment on Re: Better Indexing from Pod::Simple::HTMLBatch?
Re^2: Better Indexing from Pod::Simple::HTMLBatch?
by QM (Vicar) on May 17, 2013 at 09:02 UTC
    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
        Thanks.

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2014-12-25 00:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls