8 |
use File::Find; |
use File::Find; |
9 |
use File::Slurp; |
use File::Slurp; |
10 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
11 |
|
use XML::Simple; |
12 |
|
use Regexp::Common qw /URI/; |
13 |
|
|
14 |
my @html; |
my @html; |
15 |
sub html { push @html, @_ } |
sub html { push @html, @_ } |
22 |
my $content = read_file $path; |
my $content = read_file $path; |
23 |
$content =~ s{[\n\r\s]+$}{}s; |
$content =~ s{[\n\r\s]+$}{}s; |
24 |
$content =~ s/($escape_re)/$escape{$1}/gs; |
$content =~ s/($escape_re)/$escape{$1}/gs; |
25 |
|
$content =~ s[$RE{URI}{HTTP}{-keep}][<a href="$1">$1</a>]gs; |
26 |
|
|
27 |
|
my $log = XMLin( scalar `svn log --xml $path`, |
28 |
|
ForceArray => [ 'logentry' ], |
29 |
|
); |
30 |
|
my $changes = join("\n", |
31 |
|
map { |
32 |
|
my $d = $_->{date}; |
33 |
|
$d =~ s{\.\d+Z}{}; |
34 |
|
$d =~ s{T}{ }; |
35 |
|
qq|<li>$_->{msg} <span class="date">$d</span></li>| |
36 |
|
} @{ $log->{logentry} } |
37 |
|
); |
38 |
|
|
39 |
|
$path =~ s{^$recepies/*(.*?[^/]+)$}{$1} || next; |
40 |
return '' |
return '' |
41 |
. "<pre class=changes>" . `svn log $path` . "</pre>" |
. qq|<ul class=changes>$changes</ul>| |
42 |
. "<pre class=content>$content</pre>" |
. ( $path =~ m{(\.sh|Makefile)$}i ? qq|<a class="path" href="recepies/$path">$path</a>| : '' ) |
43 |
|
. qq|<pre class=content>$content</pre>| |
44 |
; |
; |
45 |
} |
} |
46 |
|
|
56 |
my $display = $content; |
my $display = $content; |
57 |
$display =~ s{^\d+[\.-]}{}; |
$display =~ s{^\d+[\.-]}{}; |
58 |
$display =~ s{-}{ }g; |
$display =~ s{-}{ }g; |
59 |
|
$display =~ s{\.\w+$}{}; |
60 |
|
$content =~ s{\W+}{_}g; |
61 |
html qq|<a name=$content></a>|; |
html qq|<a name=$content></a>|; |
62 |
html qq|<h$level>$display</h$level>|; |
html qq|<h$level>$display</h$level>|; |
63 |
|
|
70 |
$last_level = $level; |
$last_level = $level; |
71 |
} |
} |
72 |
|
|
73 |
|
my $to_path = ''; |
74 |
|
|
75 |
foreach my $path ( sort @names ) { |
foreach my $path ( sort @names ) { |
76 |
|
|
77 |
my $name = $path; |
my $name = $path; |
78 |
$name =~ s{^$recepies.*?([^/]+)$}{$1}; |
$name =~ s{^$recepies.*?([^/]+)$}{$1} || next; |
79 |
next unless $name; |
next unless $name; |
80 |
|
|
81 |
if ( -d $path ) { |
if ( -d $path ) { |
82 |
header 1,$name; |
header 1,$name; |
83 |
|
$to_path = ''; |
84 |
} elsif ( -l $path ) { |
} elsif ( -l $path ) { |
85 |
my $to = readlink $path; |
$to_path = " " . readlink $path; |
86 |
header 2,$name; |
next; |
|
html $to; |
|
87 |
} else { |
} else { |
88 |
header 2, $name; |
header 2, $name . $to_path; |
89 |
|
$to_path = ''; |
90 |
html file( $path ); |
html file( $path ); |
91 |
} |
} |
92 |
|
|
101 |
<link type=text/css rel=stylesheet href="style.css"> |
<link type=text/css rel=stylesheet href="style.css"> |
102 |
--> |
--> |
103 |
<style type=text/css> |
<style type=text/css> |
104 |
|
|
105 |
|
h1 { |
106 |
|
background: #000; |
107 |
|
color: #fff; |
108 |
|
padding: 0.3em; |
109 |
|
} |
110 |
|
|
111 |
|
.toc { |
112 |
|
font-size: 80%; |
113 |
|
} |
114 |
|
|
115 |
pre.changes { |
pre.changes { |
116 |
color: #444; |
color: #444; |
117 |
} |
} |
118 |
|
|
119 |
pre.content { |
pre.content { |
120 |
padding: 1em; |
padding: 1em; |
121 |
background: #eee; |
background: #eee; |
122 |
} |
} |
123 |
|
|
124 |
|
li .date { |
125 |
|
font-family: monospace; |
126 |
|
color: #888; |
127 |
|
float: right; |
128 |
|
} |
129 |
|
|
130 |
</style> |
</style> |
131 |
</head><body> |
</head><body> |
132 |
| |
| |