lilalo

diff l3-frontend @ 63:1864df6ccbfe

Новые команды дня разбиваются по секциям
author devi
date Fri Jan 27 00:06:41 2006 +0200 (2006-01-27)
parents c4bea959dbb1
children 3326053f9b23
line diff
     1.1 --- a/l3-frontend	Thu Jan 26 00:00:53 2006 +0200
     1.2 +++ b/l3-frontend	Fri Jan 27 00:06:41 2006 +0200
     1.3 @@ -22,11 +22,12 @@
     1.4  
     1.5  our %Stat;
     1.6  our %CommandsFDistribution; # Сколько раз в журнале встречается какая команда
     1.7 +our $table_number=1;
     1.8  
     1.9  my %mywi_cache_for;         # Кэш для экономии обращений к mywi
    1.10  
    1.11  sub make_comment;
    1.12 -sub make_new_commands_table;
    1.13 +sub make_new_entries_table;
    1.14  sub load_command_lines_from_xml;
    1.15  sub load_sessions_from_xml;
    1.16  sub sort_command_lines;
    1.17 @@ -173,7 +174,7 @@
    1.18          $CommandsFDistribution{$command}++;
    1.19          if (!$Commands_Description{$command}) {
    1.20              $mywi_cache_for{$command} ||= mywi_client ($command) || "";
    1.21 -            my $mywi = join ("\n", grep(/\([18]\)/, split(/\n/, $mywi_cache_for{$command})));
    1.22 +            my $mywi = join ("\n", grep(/\([18]|sh|script\)/, split(/\n/, $mywi_cache_for{$command})));
    1.23              $mywi =~ s/\s+/ /;
    1.24              if ($mywi !~ /^\s*$/) {
    1.25                  $Commands_Description{$command} = $mywi;
    1.26 @@ -410,6 +411,13 @@
    1.27      $Stat{ErrorCommands} ||= 0;
    1.28      $Stat{MistypedCommands} ||= 0;
    1.29  
    1.30 +    my %new_entries_of = (
    1.31 +        "1"     =>   "программы пользователя",
    1.32 +        "8"     =>   "программы администратора",
    1.33 +        "sh"    =>   "команды интерпретатора",
    1.34 +        "script"=>   "скрипты",
    1.35 +    );
    1.36 +
    1.37  COMMAND_LINE:
    1.38      for my $k (@Command_Lines_Index) {
    1.39  
    1.40 @@ -533,17 +541,22 @@
    1.41  
    1.42                  $result .= "<h3 id='day$last_day'>".$Day_Name[$last_wday]."</h3>";
    1.43  
    1.44 -                my $new_commands_section = make_new_commands_table(\@known_commands);
    1.45 +
    1.46 +
    1.47 +                for my $entry_class (keys %new_entries_of) {
    1.48 +                    my $new_commands_section = make_new_entries_table("$entry_class", \@known_commands);
    1.49 +
    1.50 +                    my $table_caption = "Таблица ".$table_number++.". Новые ".$new_entries_of{$entry_class}.". ".$Day_Name[$last_wday];
    1.51 +                    if ($new_commands_section) {
    1.52 +                        $result .= "<table class='new_commands_table'>"
    1.53 +                                .  "<tr class='new_commands_caption'><td colspan='2' align='right'>$table_caption</td></tr>"
    1.54 +                                .  "<tr class='new_commands_header'><td>Команда</td><td>Описание</td></tr>"
    1.55 +                                .  $new_commands_section 
    1.56 +                                .  "</table>"
    1.57 +                    }
    1.58 +
    1.59 +                }
    1.60                  @known_commands = keys %CommandsFDistribution;
    1.61 -
    1.62 -                if ($new_commands_section) {
    1.63 -                    $result .= "<h5>Новые команды</h5>"
    1.64 -                            .  "<table class='new_commands_table'>"
    1.65 -                            .  "<tr class='new_commands_header'><td>Команда</td><td>Описание</td></tr>"
    1.66 -                            .  $new_commands_section 
    1.67 -                            .  "</table>"
    1.68 -                }
    1.69 -
    1.70                  $result .= "<table width='100%'>\n";
    1.71                  $result .= $this_day_result;
    1.72                  $result .= "</table>";
    1.73 @@ -636,16 +649,22 @@
    1.74          $this_day_result .= "</tr>\n";
    1.75      }
    1.76      last: {
    1.77 -        my $new_commands_section = make_new_commands_table(\@known_commands);
    1.78 -        @known_commands = keys %CommandsFDistribution;
    1.79 +        $result .= "<h3 id='day$last_day'>".$Day_Name[$last_wday]."</h3>";
    1.80  
    1.81 -        $result .= "<h3 id='day$last_day'>".$Day_Name[$last_wday]."</h3>";
    1.82 -        if ($new_commands_section) {
    1.83 -            $result .= "<h5>Новые команды</h5>"
    1.84 -                    .  "<table class='new_commands_table'>"
    1.85 -                    .  "<tr class='new_commands_header'><td>Команда</td><td>Описание</td></tr>"
    1.86 -                    .  $new_commands_section 
    1.87 -                    .  "</table>"
    1.88 +        for my $entry_class (keys %new_entries_of) {
    1.89 +            my $new_commands_section = make_new_entries_table("$entry_class", \@known_commands);
    1.90 +            @known_commands = keys %CommandsFDistribution;
    1.91 +
    1.92 +            my $table_caption = "Таблица ".$table_number++.". Новые ".$new_entries_of{$entry_class}. ". ".$Day_Name[$last_wday];
    1.93 +            if ($new_commands_section) {
    1.94 +                $result .= "<table class='new_commands_table'>"
    1.95 +                        .  "<tr class='new_commands_caption'><td colspan='2' align='right'>$table_caption</td></tr>"
    1.96 +                        .  "<tr class='new_commands_header'><td>Команда</td><td>Описание</td></tr>"
    1.97 +                        .  $new_commands_section 
    1.98 +                        .  "</table>"
    1.99 +                        ;
   1.100 +            }
   1.101 +
   1.102          }
   1.103  
   1.104          $result .= "<table width='100%'>\n";
   1.105 @@ -657,8 +676,9 @@
   1.106  
   1.107  }
   1.108  
   1.109 -sub make_new_commands_table
   1.110 +sub make_new_entries_table
   1.111  {
   1.112 +    my $entries_class = shift;
   1.113      my @known_commands = @{$_[0]};
   1.114  
   1.115      my %count;
   1.116 @@ -677,7 +697,8 @@
   1.117          for my $c (reverse sort { $CommandsFDistribution{$a} <=> $CommandsFDistribution{$b} } @new_commands) {
   1.118                  $hint = make_comment($c);
   1.119                  my ($command, $hint) = $hint =~ m/(.*?) \s*- \s*(.*)/;
   1.120 -                $new_commands_section .= "<tr><td>$command</td><td>$hint</td></tr>"  if $hint;
   1.121 +                next unless $command =~ /\($entries_class\)/i;
   1.122 +                $new_commands_section .= "<tr><td valign='top'>$command</td><td>$hint</td></tr>"  if $hint;
   1.123          }
   1.124      }
   1.125      return $new_commands_section;