and nice lists of changes
git-svn-id: file:///home/dpavlin/private/svn/sysadmin-cookbook-html@4
3e18072f-9615-4e06-9d3a-
648eafba3f8d
use File::Find;
use File::Slurp;
use Data::Dump qw/dump/;
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 @html;
sub html { push @html, @_ }
my $content = read_file $path;
$content =~ s{[\n\r\s]+$}{}s;
$content =~ s/($escape_re)/$escape{$1}/gs;
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;
- . "<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;
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>|;
html qq|<a name=$content></a>|;
html qq|<h$level>$display</h$level>|;
foreach my $path ( sort @names ) {
my $name = $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;
next unless $name;
if ( -d $path ) {
header 1,$name;
- my $to = readlink $path;
- header 2,$name;
- html $to;
+ $to_path = " " . readlink $path;
+ next;
+ header 2, $name . $to_path;
+ $to_path = '';
<link type=text/css rel=stylesheet href="style.css">
-->
<style type=text/css>
<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.changes {
color: #444;
}
pre.content {
padding: 1em;
background: #eee;
}
pre.content {
padding: 1em;
background: #eee;
}
+
+li .date {
+ font-family: monospace;
+ color: #888;
+ float: right;
+}
+