3 |
use warnings; |
use warnings; |
4 |
use strict; |
use strict; |
5 |
|
|
6 |
|
my $svn = "http://svn.rot13.org/index.cgi/sysadmin-cookbook"; |
7 |
my $recepies = 'recepies/'; |
my $recepies = 'recepies/'; |
8 |
|
|
9 |
use File::Find; |
use File::Find; |
11 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
12 |
use XML::Simple; |
use XML::Simple; |
13 |
use Regexp::Common qw /URI/; |
use Regexp::Common qw /URI/; |
14 |
|
use XML::FeedPP; |
15 |
|
|
16 |
my @html; |
my @html; |
17 |
sub html { push @html, @_ } |
sub html { push @html, @_ } |
35 |
$d =~ s{:\d\d\.\d+Z}{}; |
$d =~ s{:\d\d\.\d+Z}{}; |
36 |
$d =~ s{T}{ }; |
$d =~ s{T}{ }; |
37 |
my $r = $_->{revision}; |
my $r = $_->{revision}; |
38 |
qq|<li>$_->{msg} <a class="date" title="r$r" href="http://svn.rot13.org/index.cgi/sysadmin-cookbook/revision?rev=$r">$d</a></li>| |
qq|<li>$_->{msg} <a class="date" title="r$r" href="$svn/revision?rev=$r">$d</a></li>| |
39 |
} reverse @{ $log->{logentry} } |
} reverse @{ $log->{logentry} } |
40 |
); |
); |
41 |
|
|
42 |
$path =~ s{^$recepies/*(.*?[^/]+)$}{$1} || next; |
$path =~ s{^$recepies/*(.*?[^/]+)$}{$1} || next; |
43 |
return '' |
return '' |
44 |
. qq|<ul class=changes>$changes</ul>| |
. qq|<ul class=changes>$changes</ul>| |
45 |
. ( $path =~ m{(\.sh|Makefile)$}i ? qq|<a class="path" href="recepies/$path">$path</a>| : '' ) |
. ( $path =~ m{(\.sh|Makefile)$}i ? qq|<a class="path" href="$svn/view/recepies/$path">$path</a>| : '' ) |
46 |
. qq|<pre class=content>$content</pre>| |
. qq|<pre class=content>$content</pre>| |
47 |
; |
; |
48 |
} |
} |
74 |
} |
} |
75 |
|
|
76 |
my $to_path = ''; |
my $to_path = ''; |
77 |
|
our @item; |
78 |
|
|
79 |
|
sub new_feed { |
80 |
|
my $name = shift; |
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" ); |
85 |
|
return $feed; |
86 |
|
} |
87 |
|
|
88 |
|
our $feed_all = new_feed; |
89 |
|
sub add_item { |
90 |
|
my $name = shift; |
91 |
|
my $content = join("\n", @_); |
92 |
|
return unless $name && $content; |
93 |
|
|
94 |
|
add_feed_item_description($feed_all, $name, "http://sysadmin-cookbook.rot13.org/rss/$name.xml", $content); |
95 |
|
|
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"); |
99 |
|
|
100 |
|
warn "# $name\n"; |
101 |
|
} |
102 |
|
|
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 ); |
109 |
|
} |
110 |
|
|
111 |
foreach my $path ( sort @names ) { |
foreach my $path ( sort @names ) { |
112 |
|
|
117 |
next unless $name; |
next unless $name; |
118 |
|
|
119 |
if ( -d $path ) { |
if ( -d $path ) { |
120 |
|
add_item( splice(@item,0) ); |
121 |
header 1,$name; |
header 1,$name; |
122 |
$to_path = ''; |
$to_path = ''; |
123 |
|
push @item, $name; |
124 |
} elsif ( -l $path ) { |
} elsif ( -l $path ) { |
125 |
$to_path = " " . readlink $path; |
$to_path = " " . readlink $path; |
126 |
next; |
next; |
127 |
} else { |
} else { |
128 |
header 2, $name . $to_path; |
header 2, $name . $to_path; |
129 |
$to_path = ''; |
$to_path = ''; |
130 |
html file( $path ); |
my $content = file $path; |
131 |
|
html $content; |
132 |
|
push @item, qq|<h4>$name</h4>\n$content|; |
133 |
} |
} |
134 |
|
|
135 |
}; |
}; |
136 |
|
|
137 |
$toc_html .= "</ul>" foreach ( 1 .. $last_level ); |
$toc_html .= "</ul>" foreach ( 1 .. $last_level ); |
138 |
|
|
139 |
|
$feed_all->to_file( "rss/index.xml" ); |
140 |
|
|
141 |
print qq| |
print qq| |
142 |
<html><head> |
<html><head> |
143 |
<title>Sysadmin Cookbook</title> |
<title>Sysadmin Cookbook</title> |
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> |
<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>. |
<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>. |
180 |
<br /> |
<br /> |
181 |
<small><a href="http://svn.rot13.org/index.cgi/sysadmin-cookbook/">Source code repository</a></small> |
<small><a href="$svn">Source code repository</a></small> |
182 |
| |
| |
183 |
. "<div class=toc>$toc_html</div>" |
. "<div class=toc>$toc_html</div>" |
184 |
, join("\n", @html) |
, join("\n", @html) |