6 my $svn = "http://svn.rot13.org/index.cgi/sysadmin-cookbook";
7 my $recepies = 'recepies/';
11 use Data::Dump qw/dump/;
13 use Regexp::Common qw /URI/;
17 sub html { push @html, @_ }
19 my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"');
20 my $escape_re = join '|' => keys %escape;
24 my $content = read_file $path;
25 $content =~ s{[\n\r\s]+$}{}s;
26 $content =~ s/($escape_re)/$escape{$1}/gs;
27 $content =~ s[$RE{URI}{HTTP}{-keep}][<a href="$1">$1</a>]gs;
29 my $log = XMLin( scalar `svn log --xml $path`,
30 ForceArray => [ 'logentry' ],
32 my $changes = join("\n",
35 $d =~ s{:\d\d\.\d+Z}{};
37 my $r = $_->{revision};
38 qq|<li>$_->{msg} <a class="date" title="r$r" href="$svn/revision?rev=$r">$d</a></li>|
39 } reverse @{ $log->{logentry} }
42 $path =~ s{^$recepies/*(.*?[^/]+)$}{$1} || next;
44 . qq|<ul class=changes>$changes</ul>|
45 . ( $path =~ m{(\.sh|Makefile)$}i ? qq|<a class="path" href="$svn/view/recepies/$path">$path</a>| : '' )
46 . qq|<pre class=content>$content</pre>|
51 find({ follow => 0, no_chdir => 1, wanted => sub {
52 push @names, $_ unless m{/\.} || m{^\.};
58 my ($level, $content) = @_;
59 my $display = $content;
60 $display =~ s{^\d+[\.-]}{};
62 $display =~ s{\.\w+$}{};
63 $content =~ s{\W+}{_}g;
64 html qq|<a name=$content></a>|;
65 html qq|<h$level>$display</h$level>|;
67 if ( $last_level > $level ) {
69 } elsif ( $last_level < $level ) {
72 $toc_html .= qq|<li><a href="#$content">$display</li>|;
81 my $feed = XML::FeedPP::RSS->new();
82 $feed->title( "Sysadmin Cookbook" . ( $name ? " :: $name" : '' ) );
83 $feed->link( "http://sysadmin-cookbook.rot13.org/" . ( $name ? "#$name" : '' ) );
84 #$feed->pubDate( "Thu, 23 Feb 2006 14:43:43 +0900" );
88 our $feed_all = new_feed;
91 my $content = join("\n", @_);
92 return unless $name && $content;
94 add_feed_item_description($feed_all, $name, "http://sysadmin-cookbook.rot13.org/rss/$name.xml", $content);
96 my $item_feed = new_feed( $name );
97 add_feed_item_description($item_feed, $name, "http://sysadmin-cookbook.rot13.org/#$name", $content);
98 $item_feed->to_file("rss/$name.xml");
103 sub add_feed_item_description {
104 my ( $feed, $name, $url, $description ) = @_;
105 my $item = $feed->add_item( $url );
106 $item->title( $name );
107 #$item->pubDate( "2006-02-23T14:43:43+09:00" );
108 $item->description( $description );
111 foreach my $path ( sort @names ) {
113 next if ( -d $path && ! -e "$path/.svn" );
116 $name =~ s{^$recepies.*?([^/]+)$}{$1} || next;
120 add_item( splice(@item,0) );
124 } elsif ( -l $path ) {
125 $to_path = " " . readlink $path;
128 header 2, $name . $to_path;
130 my $content = file $path;
132 push @item, qq|<h4>$name</h4>\n$content|;
137 $toc_html .= "</ul>" foreach ( 1 .. $last_level );
139 $feed_all->to_file( "rss/index.xml" );
143 <title>Sysadmin Cookbook</title>
145 <link type=text/css rel=stylesheet href="style.css">
147 <style type=text/css>
170 font-family: monospace;
178 <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/hr/"><img alt="Creative Commons License" style="border-width:0; float: right" src="http://i.creativecommons.org/l/by-nc-sa/3.0/hr/88x31.png" /></a>
179 <span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/Text" property="dc:title" rel="dc:type">Sysadmin Cookbook</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="http://www.rot13.org/~dpavlin/" property="cc:attributionName" rel="cc:attributionURL">Dobrica Pavlinusic</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/hr/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Croatia License</a>.
181 <small><a href="$svn">Source code repository</a></small>
183 . "<div class=toc>$toc_html</div>"