X-Git-Url: http://git.rot13.org/?p=sysadmin-cookbook-html;a=blobdiff_plain;f=bin%2Fhtml.pl;h=0b0d8e2d248ffd0b1979a4f08999b2e0c330125e;hp=fcaeb3447b8a989013d2343107bb25da836cba26;hb=6162dd22a7d08579ca796ae0b68008d1b9877774;hpb=2e42311343086bd64df95273e46cb584b6649453 diff --git a/bin/html.pl b/bin/html.pl index fcaeb34..0b0d8e2 100755 --- a/bin/html.pl +++ b/bin/html.pl @@ -3,13 +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, @_ } @@ -30,35 +33,41 @@ sub file { my $changes = join("\n", map { my $d = $_->{date}; - $d =~ s{\.\d+Z}{}; + $d =~ s{:\d\d\.\d+Z}{}; $d =~ s{T}{ }; - qq|
  • $_->{msg} $d
  • | - } @{ $log->{logentry} } + my $r = $_->{revision}; + qq|
  • $_->{msg} $d
  • | + } reverse @{ $log->{logentry} } ); $path =~ s{^$recepies/*(.*?[^/]+)$}{$1} || next; return '' . qq|| - . ( $path =~ m{(\.sh|Makefile)$}i ? qq|$path| : '' ) + . ( $path =~ m{(\.sh|Makefile)$}i ? 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 = ''; sub header { - my ($level, $content) = @_; - my $display = $content; + my ($level, $name) = @_; + + my $display = $name; $display =~ s{^\d+[\.-]}{}; $display =~ s{-}{ }g; $display =~ s{\.\w+$}{}; - $content =~ s{\W+}{_}g; - html qq||; + + my $anchor = $name; + $anchor =~ s{]+>}{}g; + $anchor =~ s{\W+}{_}g; + + html qq||; html qq|$display|; if ( $last_level > $level ) { @@ -66,34 +75,89 @@ sub header { } elsif ( $last_level < $level ) { $toc_html .= "" foreach ( 1 .. $last_level ); +$feed_all->to_file( "rss/index.xml" ); + print qq| Sysadmin Cookbook @@ -108,6 +172,10 @@ h1 { padding: 0.3em; } +h1 .p { + color: #888; +} + .toc { font-size: 80%; } @@ -117,7 +185,8 @@ pre.changes { } pre.content { - padding: 1em; + padding: 0.5em; + margin: 1em; background: #eee; } @@ -125,10 +194,15 @@ li .date { font-family: monospace; color: #888; float: right; + margin-right: 1em; } + 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)