/[sysadmin-cookbook-html]/bin/html.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /bin/html.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 13 by dpavlin, Sat May 1 12:53:41 2010 UTC revision 14 by dpavlin, Sat Nov 30 23:55:35 2013 UTC
# Line 41  sub file { Line 41  sub file {
41          );          );
42    
43          $path =~ s{^$recepies/*(.*?[^/]+)$}{$1} || next;          $path =~ s{^$recepies/*(.*?[^/]+)$}{$1} || next;
44    warn "## path = $path\n";
45          return ''          return ''
46                  . qq|<ul class=changes>$changes</ul>|                  . qq|<ul class=changes>$changes</ul>|
47                  . ( $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>| : '' )
48                  . qq|<pre class=content>$content</pre>|                  . qq|<pre class=content>$content</pre>|
49                  ;                  ;
50  }  }
# Line 53  find({ follow => 0, no_chdir => 1, wante Line 54  find({ follow => 0, no_chdir => 1, wante
54          push @names, $_ unless m{/\.} || m{^\.};          push @names, $_ unless m{/\.} || m{^\.};
55  }}, $recepies );  }}, $recepies );
56    
57  my $last_level = 0;  warn "## names = ",dump( @names );
58  my $toc_html = '';  
59    our $last_level = 0;
60    our $toc_html = '';
61  sub header {  sub header {
62          my ($level, $name) = @_;          my ($level, $name, $full_name) = @_;
63            $full_name ||= $name;
64            $full_name =~ s{recepies/}{};
65            warn "## header $level $name [$full_name]\n";
66    
67          my $display = $name;          my $display = $name;
68          $display =~ s{^\d+[\.-]}{};          $display =~ s{^\d+[\.-]}{};
69          $display =~ s{-}{ }g;          $display =~ s{-}{ }g;
70          $display =~ s{\.\w+$}{};          $display =~ s{\.\w+$}{};
71    
72          my $anchor = $name;          my $anchor = $full_name;
73          $anchor =~ s{</?[^>]+>}{}g;          $anchor =~ s{</?[^>]+>}{}g;
74          $anchor =~ s{\W+}{_}g;          $anchor =~ s{\W+}{_}g;
75    
# Line 72  sub header { Line 78  sub header {
78    
79          if ( $last_level > $level ) {          if ( $last_level > $level ) {
80                  $toc_html .= "</ul>";                  $toc_html .= "</ul>";
81                    warn "## $last_level > $level toc /ul";
82          } elsif ( $last_level < $level ) {          } elsif ( $last_level < $level ) {
83                  $toc_html .= "<ul>";                  $toc_html .= "<ul>";
84                    warn "## $last_level < $level toc ul";
85          }          }
86          $toc_html .= qq|<li><a href="#$anchor">$display</li>|;          $toc_html .= qq|<li><a href="#$anchor">$display</li>|;
87          $last_level = $level;          $last_level = $level;
# Line 124  sub add_feed_item_description { Line 132  sub add_feed_item_description {
132    
133  foreach my $path ( sort @names ) {  foreach my $path ( sort @names ) {
134    
135          next if ( -d $path && ! -e "$path/.svn" );          next if ( -d $path && -e "$path/.svn" );
136    
137          my $name = $path;          my $name = $path;
138  #       $name =~ s{^$recepies.*?([^/]+)$}{$1} || next;  #       $name =~ s{^$recepies.*?([^/]+)$}{$1} || next;
# Line 133  foreach my $path ( sort @names ) { Line 141  foreach my $path ( sort @names ) {
141          my @just_path = split m{/}, $path;          my @just_path = split m{/}, $path;
142          @just_path = splice @just_path, 1, -1;          @just_path = splice @just_path, 1, -1;
143    
144            warn "## ?? $path";
145    
146          if ( -d $path ) {          if ( -d $path ) {
147                  add_item( splice(@item,0) );                  add_item( splice(@item,0) );
148                  my $h1 = join(' ',@just_path);                  my $h1 = join(' ',@just_path);
# Line 145  foreach my $path ( sort @names ) { Line 155  foreach my $path ( sort @names ) {
155                  $to_path = " " . readlink $path;                  $to_path = " " . readlink $path;
156                  next;                  next;
157          } else {          } else {
158                  header 2, $name . $to_path;                  header 2, $name . $to_path, $path;
159                  $to_path = '';                  $to_path = '';
160                  my $content = file $path;                  my $content = file $path;
161                  html $content;                  html $content;

Legend:
Removed from v.13  
changed lines
  Added in v.14

  ViewVC Help
Powered by ViewVC 1.1.26