Просмотр исходного кода

SortByWords option by Matthew Cheetah Gabeler-Lee <msg2@po.cwru.edu>

Morten Brix Pedersen 24 лет назад
Родитель
Сommit
724307bfdc
4 измененных файлов с 71 добавлено и 19 удалено
  1. 4 0
      docs/Changelog
  2. 37 2
      docs/pisg-doc.sgml
  3. 3 0
      modules/Pisg.pm
  4. 27 17
      modules/Pisg/HTMLGenerator.pm

+ 4 - 0
docs/Changelog

@@ -1,3 +1,7 @@
+pisg (x.xx)
+   * SortByWords option added (thanks, Matthew Cheetah Gabeler-Lee
+     <msg2@po.cwru.edu>)
+
 pisg (0.38) - Thu Apr, 25th 2002
 pisg (0.38) - Thu Apr, 25th 2002
    * Grammar fixes in documentation (thanks, Azhrarn <diablo2@krock.com>)
    * Grammar fixes in documentation (thanks, Azhrarn <diablo2@krock.com>)
    * Added support for pircbot (http://www.jibble.org/pircbot.php)
    * Added support for pircbot (http://www.jibble.org/pircbot.php)

+ 37 - 2
docs/pisg-doc.sgml

@@ -1974,8 +1974,8 @@
     <refsynopsisdiv><programlisting>
     <refsynopsisdiv><programlisting>
       <![CDATA[
       <![CDATA[
         <channel="#channel">
         <channel="#channel">
-         Logfile = "channel.log"
-         Format = "mIRC"
+         logfile = "channel.log"
+         format = "mIRC"
          NickHistory = "3"
          NickHistory = "3"
         </channel>
         </channel>
 
 
@@ -2025,6 +2025,41 @@
     </refsect1>
     </refsect1>
     </refentry>
     </refentry>
 
 
+    <!-- *** SORTBYWORDS *** -->
+    <refentry id="SortByWords">
+
+    <refmeta> <refentrytitle>SortByWords</refentrytitle> </refmeta>
+
+    <refnamediv>
+    <refname>SortByWords</refname>
+    <refpurpose>Sort "most active nicks" by words</refpurpose>
+    </refnamediv>
+
+    <refsynopsisdiv><programlisting>
+      <![CDATA[
+        <channel="#channel">
+         logfile = "channel.log"
+         format = "xchat"
+         SortByWords = "0"
+        </channel>
+
+        <set SortByWords="1">
+      ]]>
+    </programlisting></refsynopsisdiv>
+
+    <refsect1>
+    <title>Description</title>
+    <para>
+    The default for the "Most Active Nicks" section - is to sort users by
+    lines. Enabling this will sort it by words instead.
+    </para>
+    </refsect1>
+    <refsect1>
+    <title>Default</title>
+    <para> 0 (disabled) </para>
+    </refsect1>
+    </refentry>
+
   <chapter id="reference-pictures">
   <chapter id="reference-pictures">
    <title>Picture options</title>
    <title>Picture options</title>
 
 

+ 3 - 0
modules/Pisg.pm

@@ -165,6 +165,9 @@ sub get_default_config_settings
         nicktracking => 0,
         nicktracking => 0,
         charset => 'iso-8859-1',
         charset => 'iso-8859-1',
 
 
+        # sorting
+        sortbywords => 0,
+
         # Misc settings
         # Misc settings
 
 
         foulwords => 'ass fuck bitch shit scheisse scheiße kacke arsch ficker ficken schlampe',
         foulwords => 'ass fuck bitch shit scheisse scheiße kacke arsch ficker ficken schlampe',

+ 27 - 17
modules/Pisg/HTMLGenerator.pm

@@ -220,7 +220,7 @@ sub _htmlfooter
     $hash{author_url} = "<a href=\"http://wtf.dk/hp/\" title=\"$author_hp\" class=\"background\">Morten Brix Pedersen</a>";
     $hash{author_url} = "<a href=\"http://wtf.dk/hp/\" title=\"$author_hp\" class=\"background\">Morten Brix Pedersen</a>";
 
 
     $hash{version} = $self->{cfg}->{version};
     $hash{version} = $self->{cfg}->{version};
-    
+
     my $hours = $self->_template_text('hours');
     my $hours = $self->_template_text('hours');
     my $mins = $self->_template_text('minutes');
     my $mins = $self->_template_text('minutes');
     my $secs = $self->_template_text('seconds');
     my $secs = $self->_template_text('seconds');
@@ -374,7 +374,12 @@ sub _activenicks
     . ($self->{cfg}->{showrandquote} ? "<td class=\"tdtop\"><b>".$self->_template_text('randquote')."</b></td>" : "")
     . ($self->{cfg}->{showrandquote} ? "<td class=\"tdtop\"><b>".$self->_template_text('randquote')."</b></td>" : "")
     );
     );
 
 
-    my @active = sort { $self->{stats}->{lines}{$b} <=> $self->{stats}->{lines}{$a} } keys %{ $self->{stats}->{lines} };
+    my @active;
+    if ($self->{cfg}->{sortbywords}) {
+        @active = sort { $self->{stats}->{words}{$b} <=> $self->{stats}->{words}{$a} } keys %{ $self->{stats}->{words} };
+    } else {
+        @active = sort { $self->{stats}->{lines}{$b} <=> $self->{stats}->{lines}{$a} } keys %{ $self->{stats}->{lines} };
+    }
     my $nicks = scalar keys %{ $self->{stats}->{lines} };
     my $nicks = scalar keys %{ $self->{stats}->{lines} };
 
 
     if ($self->{cfg}->{activenicks} > $nicks) { $self->{cfg}->{activenicks} = $nicks; }
     if ($self->{cfg}->{activenicks} > $nicks) { $self->{cfg}->{activenicks} = $nicks; }
@@ -414,7 +419,7 @@ sub _activenicks
         my $class = 'rankc';
         my $class = 'rankc';
         if ($c == 1) {
         if ($c == 1) {
             $class = 'hirankc';
             $class = 'hirankc';
-        } 
+        }
 
 
         my $lastseen;
         my $lastseen;
 
 
@@ -428,7 +433,7 @@ sub _activenicks
                 $lastseen = "$lastseen " .$self->_template_text('lastseen2');
                 $lastseen = "$lastseen " .$self->_template_text('lastseen2');
             }
             }
         }
         }
-        
+
         _html("<tr><td class=\"$class\" align=\"left\">$c</td>");
         _html("<tr><td class=\"$class\" align=\"left\">$c</td>");
 
 
         my $line = $self->{stats}->{lines}{$nick};
         my $line = $self->{stats}->{lines}{$nick};
@@ -461,19 +466,19 @@ sub _activenicks
         my $height = $self->{cfg}->{picheight};
         my $height = $self->{cfg}->{picheight};
         my $width = $self->{cfg}->{picwidth};
         my $width = $self->{cfg}->{picwidth};
         if ($self->{users}->{userpics}{$nick} && $self->{cfg}->{userpics} !~ /n/i) {
         if ($self->{users}->{userpics}{$nick} && $self->{cfg}->{userpics} !~ /n/i) {
-	    _html("<td style=\"background-color: $color\" align=\"center\">");
-	    if (defined $self->{users}->{biguserpics}{$nick}) {
-		_html("<a href=\"$self->{cfg}->{imagepath}$self->{users}->{biguserpics}{$nick}\">");
-	    }
+            _html("<td style=\"background-color: $color\" align=\"center\">");
+            if (defined $self->{users}->{biguserpics}{$nick}) {
+                _html("<a href=\"$self->{cfg}->{imagepath}$self->{users}->{biguserpics}{$nick}\">");
+            }
             if ($width ne '') {
             if ($width ne '') {
-		_html("<img valign=\"middle\" src=\"$self->{cfg}->{imagepath}$self->{users}->{userpics}{$nick}\" width=\"$width\" height=\"$height\" alt=\"$nick\" />");
+                _html("<img valign=\"middle\" src=\"$self->{cfg}->{imagepath}$self->{users}->{userpics}{$nick}\" width=\"$width\" height=\"$height\" alt=\"$nick\" />");
             } else {
             } else {
                 _html("<img valign=\"middle\" src=\"$self->{cfg}->{imagepath}$self->{users}->{userpics}{$nick}\" alt=\"$nick\" />");
                 _html("<img valign=\"middle\" src=\"$self->{cfg}->{imagepath}$self->{users}->{userpics}{$nick}\" alt=\"$nick\" />");
             }
             }
-	    if (defined $self->{users}->{biguserpics}{$nick}) {
-		_html("</a>");
-	    }
-	    _html("</td>");
+            if (defined $self->{users}->{biguserpics}{$nick}) {
+                _html("</a>");
+            }
+            _html("</td>");
         } elsif ($self->{cfg}->{defaultpic} ne '' && $self->{cfg}->{userpics} !~ /n/i)  {
         } elsif ($self->{cfg}->{defaultpic} ne '' && $self->{cfg}->{userpics} !~ /n/i)  {
             _html("<td style=\"background-color: $color\" align=\"center\"><img valign=\"middle\" src=\"$self->{cfg}->{imagepath}$self->{cfg}->{defaultpic}\" alt=\"\" /></td>");
             _html("<td style=\"background-color: $color\" align=\"center\"><img valign=\"middle\" src=\"$self->{cfg}->{imagepath}$self->{cfg}->{defaultpic}\" alt=\"\" /></td>");
         }
         }
@@ -498,8 +503,13 @@ sub _activenicks
             _html("<br /><b><i>" . $self->_template_text('nottop') . "</i></b><table><tr>");
             _html("<br /><b><i>" . $self->_template_text('nottop') . "</i></b><table><tr>");
             for (my $i = $self->{cfg}->{activenicks}; $i < $remain; $i++) {
             for (my $i = $self->{cfg}->{activenicks}; $i < $remain; $i++) {
                 unless ($i % 5) { if ($i != $self->{cfg}->{activenicks}) { _html("</tr><tr>"); } }
                 unless ($i % 5) { if ($i != $self->{cfg}->{activenicks}) { _html("</tr><tr>"); } }
-                my $lines = $self->{stats}->{lines}{$active[$i]};
-                _html("<td class=\"rankc10\">$active[$i] ($lines)</td>");
+                my $items;
+                if ($self->{cfg}->{sortbywords}) {
+                    $items = $self->{stats}->{words}{$active[$i]};
+                } else {
+                    $items = $self->{stats}->{lines}{$active[$i]};
+                }
+                _html("<td class=\"rankc10\">$active[$i] ($items)</td>");
             }
             }
             _html("</tr></table>");
             _html("</tr></table>");
         }
         }
@@ -713,7 +723,7 @@ sub _violent
     # They got attacked
     # They got attacked
     my @victims;
     my @victims;
     @victims = sort { $self->{stats}->{attacked}{$b} <=> $self->{stats}->{attacked}{$a} }
     @victims = sort { $self->{stats}->{attacked}{$b} <=> $self->{stats}->{attacked}{$a} }
-		    keys %{ $self->{stats}->{attacked} };
+                    keys %{ $self->{stats}->{attacked} };
 
 
     if(@victims) {
     if(@victims) {
         my %hash = (
         my %hash = (
@@ -1644,7 +1654,7 @@ sub _mostnicks
             my $nickused = join(", ", @{ $self->{stats}->{nicks}->{$sortnicks[$i]} });
             my $nickused = join(", ", @{ $self->{stats}->{nicks}->{$sortnicks[$i]} });
 
 
             next unless ($nickcount > 1);
             next unless ($nickcount > 1);
-            
+
             my $a = $i + 1;
             my $a = $i + 1;
             my $class = $a == 1 ? 'hirankc' : 'rankc';
             my $class = $a == 1 ? 'hirankc' : 'rankc';
             my $n = $nickcount > 1 ? $names1 : $names2;
             my $n = $nickcount > 1 ? $names1 : $names2;