From 2e42311343086bd64df95273e46cb584b6649453 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sat, 16 May 2009 21:44:27 +0000 Subject: [PATCH 1/1] better html design, make links clickable, files downloadable and nice lists of changes git-svn-id: file:///home/dpavlin/private/svn/sysadmin-cookbook-html@4 3e18072f-9615-4e06-9d3a-648eafba3f8d --- bin/html.pl | 56 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/bin/html.pl b/bin/html.pl index 0a591fa..fcaeb34 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,13 +101,32 @@ print qq| --> | -- 2.20.1