projects
/
sysadmin-cookbook-html
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
more debug and unique anchors
[sysadmin-cookbook-html]
/
bin
/
html.pl
diff --git
a/bin/html.pl
b/bin/html.pl
index
f247856
..
e87f1a5
100755
(executable)
--- a/
bin/html.pl
+++ b/
bin/html.pl
@@
-41,9
+41,10
@@
sub file {
);
$path =~ s{^$recepies/*(.*?[^/]+)$}{$1} || next;
);
$path =~ s{^$recepies/*(.*?[^/]+)$}{$1} || next;
+warn "## path = $path\n";
return ''
. qq|<ul class=changes>$changes</ul>|
return ''
. qq|<ul class=changes>$changes</ul>|
- . ( $path =~ m{(\.sh|Makefile|\.conf|\.pl)$}i || -
e $path
? qq|<a class="path" href="$svn/view/recepies/$path">$path</a>| : '' )
+ . ( $path =~ m{(\.sh|Makefile|\.conf|\.pl)$}i || -
x "$recepies/$path"
? qq|<a class="path" href="$svn/view/recepies/$path">$path</a>| : '' )
. qq|<pre class=content>$content</pre>|
;
}
. qq|<pre class=content>$content</pre>|
;
}
@@
-53,17
+54,22
@@
find({ follow => 0, no_chdir => 1, wanted => sub {
push @names, $_ unless m{/\.} || m{^\.};
}}, $recepies );
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 {
sub header {
- my ($level, $name) = @_;
+ 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 $display = $name;
$display =~ s{^\d+[\.-]}{};
$display =~ s{-}{ }g;
$display =~ s{\.\w+$}{};
- my $anchor = $name;
+ my $anchor = $
full_
name;
$anchor =~ s{</?[^>]+>}{}g;
$anchor =~ s{\W+}{_}g;
$anchor =~ s{</?[^>]+>}{}g;
$anchor =~ s{\W+}{_}g;
@@
-72,8
+78,10
@@
sub header {
if ( $last_level > $level ) {
$toc_html .= "</ul>";
if ( $last_level > $level ) {
$toc_html .= "</ul>";
+ warn "## $last_level > $level toc /ul";
} elsif ( $last_level < $level ) {
$toc_html .= "<ul>";
} elsif ( $last_level < $level ) {
$toc_html .= "<ul>";
+ warn "## $last_level < $level toc ul";
}
$toc_html .= qq|<li><a href="#$anchor">$display</li>|;
$last_level = $level;
}
$toc_html .= qq|<li><a href="#$anchor">$display</li>|;
$last_level = $level;
@@
-124,7
+132,7
@@
sub add_feed_item_description {
foreach my $path ( sort @names ) {
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;
my $name = $path;
# $name =~ s{^$recepies.*?([^/]+)$}{$1} || next;
@@
-133,6
+141,8
@@
foreach my $path ( sort @names ) {
my @just_path = split m{/}, $path;
@just_path = splice @just_path, 1, -1;
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);
if ( -d $path ) {
add_item( splice(@item,0) );
my $h1 = join(' ',@just_path);
@@
-145,7
+155,7
@@
foreach my $path ( sort @names ) {
$to_path = " " . readlink $path;
next;
} else {
$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;
$to_path = '';
my $content = file $path;
html $content;