X-Git-Url: http://git.rot13.org/?p=sysadmin-cookbook-html;a=blobdiff_plain;f=bin%2Fhtml.pl;h=fd355f1ccdc9303e279b4c6214365f7cfac24db0;hp=35827eb8bf8fbe7fcd2d652fe011f2f2bcdc7065;hb=HEAD;hpb=c13b4194deff3dd1b19d73c6a4849649d54dfbc1
diff --git a/bin/html.pl b/bin/html.pl
index 35827eb..fd355f1 100755
--- a/bin/html.pl
+++ b/bin/html.pl
@@ -41,9 +41,10 @@ sub file {
);
$path =~ s{^$recepies/*(.*?[^/]+)$}{$1} || next;
+warn "## path = $path\n";
return ''
. qq|
|
- . ( $path =~ m{(\.sh|Makefile)$}i ? qq|$path| : '' )
+ . ( $path =~ m{(\.sh|Makefile|\.conf|\.pl)$}i || -x "$recepies/$path" ? qq|$path| : '' )
. qq|$content
|
;
}
@@ -53,24 +54,36 @@ find({ follow => 0, no_chdir => 1, wanted => sub {
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) = @_;
- my $display = $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+$}{};
- $content =~ s{\W+}{_}g;
- html qq||;
+
+ 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 .= "";
+ warn "## $last_level < $level toc ul";
}
- $toc_html .= qq|- $display
|;
+ $toc_html .= qq|- $display
|;
$last_level = $level;
}
@@ -106,7 +119,7 @@ sub add_item {
mkfilepath $file;
$item_feed->to_file($file);
- warn "# $name\n";
+ warn "# $name $file\n";
}
sub add_feed_item_description {
@@ -119,7 +132,7 @@ sub add_feed_item_description {
foreach my $path ( sort @names ) {
- next if ( -d $path && ! -e "$path/.svn" );
+ next if ( -d $path && -e "$path/.svn" );
my $name = $path;
# $name =~ s{^$recepies.*?([^/]+)$}{$1} || next;
@@ -128,6 +141,8 @@ foreach my $path ( sort @names ) {
my @just_path = split m{/}, $path;
@just_path = splice @just_path, 1, -1;
+ warn "## ?? $path";
+
if ( -d $path ) {
add_item( splice(@item,0) );
my $h1 = join(' ',@just_path);
@@ -140,7 +155,7 @@ foreach my $path ( sort @names ) {
$to_path = " " . readlink $path;
next;
} else {
- header 2, $name . $to_path;
+ header 2, $name . $to_path, $path;
$to_path = '';
my $content = file $path;
html $content;