X-Git-Url: http://git.rot13.org/?p=sysadmin-cookbook-html;a=blobdiff_plain;f=bin%2Fhtml.pl;h=e87f1a5a177fa7d70782b73f2608f9b4e1986cac;hp=cd9485dd7bfcef053c81061da450f6c72e8e947c;hb=2288b8c924fe41d554463a1dc12fe08ace48e630;hpb=bace34e122e1331e987af50ddad063ce136416a5 diff --git a/bin/html.pl b/bin/html.pl index cd9485d..e87f1a5 100755 --- a/bin/html.pl +++ b/bin/html.pl @@ -3,11 +3,16 @@ use warnings; use strict; -my $recepies = '/srv/sysadmin-cookbook/recepies'; +my $svn = "http://svn.rot13.org/index.cgi/sysadmin-cookbook"; +my $recepies = 'recepies/'; use File::Find; use File::Slurp; +use File::Path; use Data::Dump qw/dump/; +use XML::Simple; +use Regexp::Common qw /URI/; +use XML::FeedPP; my @html; sub html { push @html, @_ } @@ -20,54 +25,149 @@ sub file { my $content = read_file $path; $content =~ s{[\n\r\s]+$}{}s; $content =~ s/($escape_re)/$escape{$1}/gs; + $content =~ s[$RE{URI}{HTTP}{-keep}][$1]gs; + + my $log = XMLin( scalar `svn log --xml $path`, + ForceArray => [ 'logentry' ], + ); + my $changes = join("\n", + map { + my $d = $_->{date}; + $d =~ s{:\d\d\.\d+Z}{}; + $d =~ s{T}{ }; + my $r = $_->{revision}; + qq|
  • $_->{msg} $d
  • | + } reverse @{ $log->{logentry} } + ); + + $path =~ s{^$recepies/*(.*?[^/]+)$}{$1} || next; +warn "## path = $path\n"; return '' - . "
    " . `svn log $path` . "
    " - . "
    $content
    " + . qq|| + . ( $path =~ m{(\.sh|Makefile|\.conf|\.pl)$}i || -x "$recepies/$path" ? qq|$path| : '' ) + . qq|
    $content
    | ; } my @names; find({ follow => 0, no_chdir => 1, wanted => sub { - push @names, $_ unless m{/\.}; + push @names, $_ unless m{/\.} || m{^\.}; }}, $recepies ); -my $last_level = 0; -my $toc_html = ''; +warn "## names = ",dump( @names ); + +our $last_level = 0; +our $toc_html = ''; sub header { - my ($level, $content) = @_; - html qq||; - html qq|$content|; + my ($level, $name, $full_name) = @_; + $full_name ||= $name; + $full_name =~ s{recepies/}{}; + warn "## header $level $name [$full_name]\n"; + + my $display = $name; + $display =~ s{^\d+[\.-]}{}; + $display =~ s{-}{ }g; + $display =~ s{\.\w+$}{}; + + my $anchor = $full_name; + $anchor =~ s{]+>}{}g; + $anchor =~ s{\W+}{_}g; + + html qq||; + html qq|$display|; if ( $last_level > $level ) { $toc_html .= ""; + warn "## $last_level > $level toc /ul"; } elsif ( $last_level < $level ) { $toc_html .= "" foreach ( 1 .. $last_level ); +$feed_all->to_file( "rss/index.xml" ); + print qq| Sysadmin Cookbook @@ -75,15 +175,44 @@ print qq| --> + Creative Commons License + Sysadmin Cookbook by Dobrica Pavlinusic is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Croatia License. +
    + Source code repository | . "
    $toc_html
    " , join("\n", @html)