X-Git-Url: http://git.rot13.org/?p=sysadmin-cookbook-html;a=blobdiff_plain;f=bin%2Fhtml.pl;h=013077d45edb3ae2a0de68d0d459e6b95cc384f7;hp=0a591fafe793b60c92175e68b639da65bc695f88;hb=039a7fec75df2c7da1742a5e593f65f3f5b084fd;hpb=54c82eb6d404da8cdb0ada498b8b129a93573510 diff --git a/bin/html.pl b/bin/html.pl index 0a591fa..013077d 100755 --- a/bin/html.pl +++ b/bin/html.pl @@ -8,6 +8,8 @@ my $recepies = '/srv/sysadmin-cookbook/recepies'; use File::Find; use File::Slurp; use Data::Dump qw/dump/; +use XML::Simple; +use Regexp::Common qw /URI/; my @html; sub html { push @html, @_ } @@ -20,9 +22,25 @@ sub file { my $content = read_file $path; $content =~ s{[\n\r\s]+$}{}s; $content =~ s/($escape_re)/$escape{$1}/gs; + $content =~ s[$RE{URI}{HTTP}{-keep}][$1]gs; + + my $log = XMLin( scalar `svn log --xml $path`, + ForceArray => [ 'logentry' ], + ); + my $changes = join("\n", + map { + my $d = $_->{date}; + $d =~ s{\.\d+Z}{}; + $d =~ s{T}{ }; + qq|
  • $_->{msg} $d
  • | + } @{ $log->{logentry} } + ); + + $path =~ s{^$recepies/*(.*?[^/]+)$}{$1} || next; return '' - . "
    " . `svn log $path` . "
    " - . "
    $content
    " + . qq|| + . ( $path =~ m{(\.sh|Makefile)$}i ? qq|$path| : '' ) + . qq|
    $content
    | ; } @@ -38,6 +56,8 @@ sub header { my $display = $content; $display =~ s{^\d+[\.-]}{}; $display =~ s{-}{ }g; + $display =~ s{\.\w+$}{}; + $content =~ s{\W+}{_}g; html qq||; html qq|$display|; @@ -50,20 +70,23 @@ sub header { $last_level = $level; } +my $to_path = ''; + foreach my $path ( sort @names ) { my $name = $path; - $name =~ s{^$recepies.*?([^/]+)$}{$1}; + $name =~ s{^$recepies.*?([^/]+)$}{$1} || next; next unless $name; if ( -d $path ) { header 1,$name; + $to_path = ''; } elsif ( -l $path ) { - my $to = readlink $path; - header 2,$name; - html $to; + $to_path = " " . readlink $path; + next; } else { - header 2, $name; + header 2, $name . $to_path; + $to_path = ''; html file( $path ); } @@ -78,15 +101,37 @@ print qq| --> + Creative Commons License + Sysadmin Cookbook by Dobrica Pavlinusic is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Croatia License. | . "
    $toc_html
    " , join("\n", @html)