Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
We don't bite newbies here... much
 
PerlMonks  

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

by QM (Vicar)
on May 17, 2013 at 09:02 UTC ( #1033954=note: print w/ replies, xml ) Need Help??


in reply to Re: Better Indexing from Pod::Simple::HTMLBatch?
in thread Better Indexing from Pod::Simple::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


Comment on Re^2: Better Indexing from Pod::Simple::HTMLBatch?
Re^3: Better Indexing from Pod::Simple::HTMLBatch?
by Anonymous Monk on May 21, 2013 at 04:08 UTC
    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://1033954]
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: (8)
As of 2014-04-17 05:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (440 votes), past polls