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, @_ }
my $content = read_file $path;
$content =~ s{[\n\r\s]+$}{}s;
$content =~ s/($escape_re)/$escape{$1}/gs;
+ $content =~ s[$RE{URI}{HTTP}{-keep}][<a href="$1">$1</a>]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|<li>$_->{msg} <span class="date">$d</span></li>|
+ } @{ $log->{logentry} }
+ );
+
+ $path =~ s{^$recepies/*(.*?[^/]+)$}{$1} || next;
return ''
- . "<pre class=changes>" . `svn log $path` . "</pre>"
- . "<pre class=content>$content</pre>"
+ . qq|<ul class=changes>$changes</ul>|
+ . ( $path =~ m{(\.sh|Makefile)$}i ? qq|<a class="path" href="recepies/$path">$path</a>| : '' )
+ . qq|<pre class=content>$content</pre>|
;
}
my $display = $content;
$display =~ s{^\d+[\.-]}{};
$display =~ s{-}{ }g;
+ $display =~ s{\.\w+$}{};
+ $content =~ s{\W+}{_}g;
html qq|<a name=$content></a>|;
html qq|<h$level>$display</h$level>|;
$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 );
}
<link type=text/css rel=stylesheet href="style.css">
-->
<style type=text/css>
+
+h1 {
+ background: #000;
+ color: #fff;
+ padding: 0.3em;
+}
+
+.toc {
+ font-size: 80%;
+}
+
pre.changes {
color: #444;
}
+
pre.content {
padding: 1em;
background: #eee;
}
+
+li .date {
+ font-family: monospace;
+ color: #888;
+ float: right;
+}
+
</style>
</head><body>
|