Added POD to Onis::Plugins::Weekdays
authorocto <octo>
Sat, 16 Apr 2005 09:53:53 +0000 (09:53 +0000)
committerocto <octo>
Sat, 16 Apr 2005 09:53:53 +0000 (09:53 +0000)
Added Weeksdays to Userdetails.
Updated light-theme's stylesheet. Other themes are to do..

lib/Onis/Plugins/Userdetails.pm
lib/Onis/Plugins/Weekdays.pm
lib/Onis/Users.pm
reports/light-theme/style.css

index 66aa39e..66e9903 100644 (file)
@@ -10,6 +10,7 @@ use Onis::Data::Core (qw(get_main_nick register_plugin nick_to_name));
 use Onis::Users (qw(ident_to_name get_link get_image));
 
 use Onis::Plugins::Core (qw(get_core_nick_counters get_sorted_nicklist));
 use Onis::Users (qw(ident_to_name get_link get_image));
 
 use Onis::Plugins::Core (qw(get_core_nick_counters get_sorted_nicklist));
+use Onis::Plugins::Weekdays (qw(get_weekdays));
 use Onis::Plugins::Conversations (qw(get_conversations));
 use Onis::Plugins::Bignumbers (qw(get_bignumbers));
 use Onis::Plugins::Interestingnumbers (qw(get_interestingnumbers));
 use Onis::Plugins::Conversations (qw(get_conversations));
 use Onis::Plugins::Bignumbers (qw(get_bignumbers));
 use Onis::Plugins::Interestingnumbers (qw(get_interestingnumbers));
@@ -136,8 +137,6 @@ sub output
 {
        my $nicks_ref = get_sorted_nicklist ();
        
 {
        my $nicks_ref = get_sorted_nicklist ();
        
-       my $max = $PLUGIN_MAX;
-       
        my $fh = get_filehandle ();
 
        my $trans = translate ('Detailed nick stats');
        my $fh = get_filehandle ();
 
        my $trans = translate ('Detailed nick stats');
@@ -145,17 +144,19 @@ sub output
 
        my $max_time = 0;
        my $max_conv = 0;
 
        my $max_time = 0;
        my $max_conv = 0;
+       my $max_weekday = 0;
 
        my @nicks = @$nicks_ref;
        my $nick_data = {};
 
 
        my @nicks = @$nicks_ref;
        my $nick_data = {};
 
-       splice (@nicks, $max) if (scalar (@nicks) > $max);
+       splice (@nicks, $PLUGIN_MAX) if (scalar (@nicks) > $PLUGIN_MAX);
 
        for (@nicks)
        {
                my $nick = $_;
 
                $nick_data->{$nick} = get_core_nick_counters ($nick);
 
        for (@nicks)
        {
                my $nick = $_;
 
                $nick_data->{$nick} = get_core_nick_counters ($nick);
+               $nick_data->{$nick}{'weekdays'} = get_weekdays ($nick);
                $nick_data->{$nick}{'conversations'} = get_conversations ($nick);
                $nick_data->{$nick}{'bignumbers'} = get_bignumbers ($nick);
                $nick_data->{$nick}{'interestingnumbers'} = get_interestingnumbers ($nick);
                $nick_data->{$nick}{'conversations'} = get_conversations ($nick);
                $nick_data->{$nick}{'bignumbers'} = get_bignumbers ($nick);
                $nick_data->{$nick}{'interestingnumbers'} = get_interestingnumbers ($nick);
@@ -173,6 +174,17 @@ sub output
                        $num = $ptr->[0] + $ptr->[1] + $ptr->[2] + $ptr->[3];
                        $max_conv = $num if ($max_conv < $num);
                }
                        $num = $ptr->[0] + $ptr->[1] + $ptr->[2] + $ptr->[3];
                        $max_conv = $num if ($max_conv < $num);
                }
+
+               for (keys %{$nick_data->{$nick}{'weekdays'}})
+               {
+                       my $day = $_;
+                       my $ptr = $nick_data->{$nick}{'weekdays'}{$day};
+
+                       for (my $i = 0; $i < 4; $i++)
+                       {
+                               $max_weekday = $ptr->[$i] if ($max_weekday < $ptr->[$i]);
+                       }
+               }
        }
 
        my $time_factor = 0;
        }
 
        my $time_factor = 0;
@@ -190,7 +202,7 @@ sub output
        
        print $fh qq#<table class="plugin userdetails">\n#,
        qq#  <tr>\n#,
        
        print $fh qq#<table class="plugin userdetails">\n#,
        qq#  <tr>\n#,
-       qq#    <th colspan="#, $DISPLAY_IMAGES ? 3 : 2, qq#">$trans</th>\n#,
+       qq#    <th colspan="#, $DISPLAY_IMAGES ? 4 : 3, qq#">$trans</th>\n#,
        qq#  </tr>\n#;
 
        for (@nicks)
        qq#  </tr>\n#;
 
        for (@nicks)
@@ -201,7 +213,7 @@ sub output
                my $ptr = $nick_data->{$nick};
 
                print $fh qq#  <tr>\n#,
                my $ptr = $nick_data->{$nick};
 
                print $fh qq#  <tr>\n#,
-               qq#    <th colspan="#, $DISPLAY_IMAGES ? 3 : 2, qq#" class="nick">$print</th>\n#,
+               qq#    <th colspan="#, $DISPLAY_IMAGES ? 4 : 3, qq#" class="nick">$print</th>\n#,
                qq#  </tr>\n#,
                qq#  <tr>\n#;
 
                qq#  </tr>\n#,
                qq#  <tr>\n#;
 
@@ -304,51 +316,7 @@ sub output
                        printf $fh ("      $trans<br />\n", $num);
                }
 
                        printf $fh ("      $trans<br />\n", $num);
                }
 
-               # actions # TODO
-               # exclamation ratio # TODO
-               # # of nicks
-               #
-               # chats with
-               # lines per day
-
-               print $fh qq#    </td>\n  </tr>\n  <tr>\n    <td class="houractivity">\n#;
-               
-               if (defined ($ptr->{'chars'}))
-               {
-                       print $fh qq#      <table class="hours">\n        <tr class="bars">\n#;
-                       
-                       for (my $i = 0; $i < 24; $i++)
-                       {
-                               $num = 0;
-
-                               my $img = $V_IMAGES[int ($i / 6)];
-                               my $height;
-
-                               $num  = $ptr->{'chars'}[$i];
-
-                               $height = sprintf ("%.2f", 95 * $num / $max_time);
-
-                               print $fh qq#          <td class="bar vertical"><img src="$img" alt="$num chars" #,
-                               qq#class="first last" style="height: $height\%;" /></td>\n#;
-                       }
-
-                       print $fh <<EOF;
-        </tr>
-       <tr class="numeration">
-         <td colspan="6" class="numeration">0-5</td>
-         <td colspan="6" class="numeration">6-11</td>
-         <td colspan="6" class="numeration">12-17</td>
-         <td colspan="6" class="numeration">18-23</td>
-       </tr>
-      </table>
-EOF
-               }
-               else
-               {
-                       print '&nbsp;';
-               }
-
-               print $fh qq#    </td>\n    <td class="convpartners">\n#;
+               print $fh qq#    </td>\n    <td>\n#;
                
                if (%{$ptr->{'conversations'}})
                {
                
                if (%{$ptr->{'conversations'}})
                {
@@ -370,7 +338,7 @@ EOF
                        $trans = translate ('Talks to');
 
                        print $fh <<EOF;
                        $trans = translate ('Talks to');
 
                        print $fh <<EOF;
-      <table>
+      <table class="conversations">
         <tr>
          <td colspan="2">$trans:</td>
        </tr>
         <tr>
          <td colspan="2">$trans:</td>
        </tr>
@@ -383,13 +351,14 @@ EOF
                                my $total = 0;
 
                                print $fh "        <tr>\n",
                                my $total = 0;
 
                                print $fh "        <tr>\n",
-                               qq#          <td class="nick">$other_name</td>\n#,
-                               qq#          <td class="bar">#;
+                               qq#          <td class="nick right">$other_name</td>\n#,
+                               qq#          <td class="bar horizontal right">#;
 
                                for (my $k = 0; $k < 4; $k++)
                                {
                                        my $img = $H_IMAGES[$k];
 
                                for (my $k = 0; $k < 4; $k++)
                                {
                                        my $img = $H_IMAGES[$k];
-                                       my $width = int (0.5 + ($conv_factor * $ptr->{'conversations'}{$other}{'nicks'}{$nick}[$k])) || 1;
+                                       my $num = $ptr->{'conversations'}{$other}{'nicks'}{$nick}[$k];
+                                       my $width = sprintf ("%.2f", 95 * $num / $max_conv);
                                        
                                        print $fh qq#<img src="$img" alt="" #;
                                        if ($k == 0)
                                        
                                        print $fh qq#<img src="$img" alt="" #;
                                        if ($k == 0)
@@ -400,7 +369,7 @@ EOF
                                        {
                                                print $fh qq#class="last" #;
                                        }
                                        {
                                                print $fh qq#class="last" #;
                                        }
-                                       print $fh qq#style="width: ${width}px;" />#;
+                                       print $fh qq#style="width: $width\%;" />#;
                                }
                                
                                print $fh "</td>\n        </tr>\n";
                                }
                                
                                print $fh "</td>\n        </tr>\n";
@@ -412,6 +381,92 @@ EOF
                {
                        print $fh '&nbsp;';
                }
                {
                        print $fh '&nbsp;';
                }
+               print $fh qq#    </td>\n  </tr>\n#,
+               qq#  <tr>\n    <td>\n#;
+               
+               if (defined ($ptr->{'chars'}))
+               {
+                       print $fh qq#      <table class="hours">\n        <tr class="bars">\n#;
+                       
+                       for (my $i = 0; $i < 24; $i++)
+                       {
+                               $num = 0;
+
+                               my $img = $V_IMAGES[int ($i / 6)];
+                               my $height;
+
+                               $num  = $ptr->{'chars'}[$i];
+
+                               $height = sprintf ("%.2f", 95 * $num / $max_time);
+
+                               print $fh qq#          <td class="bar vertical"><img src="$img" alt="$num chars" #,
+                               qq#class="first last" style="height: $height\%;" /></td>\n#;
+                       }
+
+                       print $fh <<EOF;
+        </tr>
+       <tr class="numeration">
+         <td colspan="6" class="numeration">0-5</td>
+         <td colspan="6" class="numeration">6-11</td>
+         <td colspan="6" class="numeration">12-17</td>
+         <td colspan="6" class="numeration">18-23</td>
+       </tr>
+      </table>
+EOF
+               }
+               else
+               {
+                       print '&nbsp;';
+               }
+
+               print $fh qq#    </td>\n    <td>\n#;
+
+               #weekly
+               if (%{$nick_data->{$nick}{'weekdays'}})
+               {
+                       my $data = $nick_data->{$nick}{'weekdays'};
+                       my @days = (qw(mon tue wed thu fri sat sun));
+
+                       print $fh qq#      <table class="weekdays">\n#,
+                       qq#        <tr class="bars">\n#;
+
+                       for (@days)
+                       {
+                               my $day = $_;
+                               for (my $i = 0; $i < 4; $i++)
+                               {
+                                       my $num = $nick_data->{$nick}{'weekdays'}{$day}[$i];
+                                       my $height = sprintf ("%.2f", 95 * $num / $max_weekday);
+                                       my $class = '';
+                                       my $img = $V_IMAGES[$i];
+
+                                       print $fh qq#          <td class="bar vertical">#,
+                                       qq#<img src="$img" alt="" class="first last" style="height: $height\%;" />#,
+                                       qq#</td>\n#;
+                               }
+                       }
+
+                       print $fh qq#        </tr>\n#,
+                       qq#        <tr class="numeration">\n#;
+
+                       for (@days)
+                       {
+                               my $day = $_;
+                               my $trans = translate ($day);
+                               
+                               print $fh qq#          <td colspan="4" class="numeration $day">$trans</td>\n#;
+                       }
+
+                       print $fh qq#        </tr>\n#,
+                       qq#      </table>\n#;
+               }
+
+               print $fh qq#    </td>\n    <td>\n#;
+
+               #longterm
+               print $fh qq#      &nbsp;\n#;
+
+               print $fh qq#    </td>\n  </tr>\n#;
        }
 
        print $fh "</table>\n\n";
        }
 
        print $fh "</table>\n\n";
index dd27ad9..2a7172b 100644 (file)
@@ -3,12 +3,23 @@ package Onis::Plugins::Weekdays;
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
+use Exporter;
+
 use Onis::Config (qw(get_config));
 use Onis::Html (qw(get_filehandle));
 use Onis::Language (qw(translate));
 use Onis::Data::Core (qw(register_plugin get_main_nick nick_to_ident nick_to_name));
 use Onis::Data::Persistent ();
 
 use Onis::Config (qw(get_config));
 use Onis::Html (qw(get_filehandle));
 use Onis::Language (qw(translate));
 use Onis::Data::Core (qw(register_plugin get_main_nick nick_to_ident nick_to_name));
 use Onis::Data::Persistent ();
 
+=head1 NAME
+
+Onis::Plugins::Weekdays - Activity based on weekdays
+
+=cut
+
+@Onis::Plugins::Weekdays::EXPORT_OK = (qw(get_weekdays));
+@Onis::Plugins::Weekdays::ISA = ('Exporter');
+
 register_plugin ('TEXT', \&add);
 register_plugin ('ACTION', \&add);
 register_plugin ('OUTPUT', \&output);
 register_plugin ('TEXT', \&add);
 register_plugin ('ACTION', \&add);
 register_plugin ('OUTPUT', \&output);
@@ -26,13 +37,15 @@ qw(
 our $WeekdayData = {};
 our @Weekdays = (qw(sun mon tue wed thu fri sat));
 
 our $WeekdayData = {};
 our @Weekdays = (qw(sun mon tue wed thu fri sat));
 
-our $BarHeight = 130;
-if (get_config ('bar_height'))
-{
-       my $tmp = get_config ('bar_height');
-       $tmp =~ s/\D//g;
-       $BarHeight = $tmp if ($tmp >= 10);
-}
+=head1 CONFIGURATION OPTIONS
+
+=over 4
+
+=item B<vertical_images>: I<image0>, I<image1>, I<image2>, I<image3>;
+
+Sets the images used for vertical bars.
+
+=cut
 
 our @VImages = get_config ('vertical_images');
 if (scalar (@VImages) != 4)
 
 our @VImages = get_config ('vertical_images');
 if (scalar (@VImages) != 4)
@@ -40,6 +53,10 @@ if (scalar (@VImages) != 4)
        @VImages = qw#images/ver0n.png images/ver1n.png images/ver2n.png images/ver3n.png#;
 }
 
        @VImages = qw#images/ver0n.png images/ver1n.png images/ver2n.png images/ver3n.png#;
 }
 
+=back
+
+=cut
+
 my $VERSION = '$Id$';
 print STDERR $/, __FILE__, ": $VERSION" if ($::DEBUG);
 
 my $VERSION = '$Id$';
 print STDERR $/, __FILE__, ": $VERSION" if ($::DEBUG);
 
@@ -122,7 +139,6 @@ sub output
        
        my $max = 0;
        my $total = 0;
        
        my $max = 0;
        my $total = 0;
-       my $bar_factor = 0;
 
        for (@order)
        {
 
        for (@order)
        {
@@ -135,8 +151,6 @@ sub output
                }
        }
        
                }
        }
        
-       $bar_factor = $BarHeight / $max;
-       
        print $fh qq#<table class="plugin weekdays">\n  <tr class="bars">\n#;
        for (@order)
        {
        print $fh qq#<table class="plugin weekdays">\n  <tr class="bars">\n#;
        for (@order)
        {
@@ -167,3 +181,44 @@ sub output
        }
        print $fh "  </tr>\n</table>\n\n";
 }
        }
        print $fh "  </tr>\n</table>\n\n";
 }
+
+=head1 EXPORTED FUNCTIONS
+
+=over 4
+
+=item B<get_weekdays> (I<$nick>)
+
+Returns a hashref with the weekday information for I<$nick>. Numbers are
+character counters. The returned data has the following format:
+
+  {
+    sun => [0, 0, 0, 0],
+    mon => [0, 0, 0, 0],
+    tue => [0, 0, 0, 0],
+    wed => [0, 0, 0, 0],
+    thu => [0, 0, 0, 0],
+    fri => [0, 0, 0, 0],
+    sat => [0, 0, 0, 0]
+  }
+
+=cut
+
+sub get_weekdays
+{
+       my $nick = shift;
+
+       if (!defined ($WeekdayData->{$nick}))
+       {
+               return ({});
+       }
+
+       return ($WeekdayData->{$nick});
+}
+
+=back
+
+=head1 AUTHOR
+
+Florian octo Forster E<lt>octo at verplant.orgE<gt>
+
+=cut
index 8699be7..20c2e3f 100644 (file)
@@ -341,3 +341,5 @@ sub get_image
 =head1 AUTHOR
 
 Florian octo Forster E<lt>octo at verplant.orgE<gt>
 =head1 AUTHOR
 
 Florian octo Forster E<lt>octo at verplant.orgE<gt>
+
+=cut
index aae0209..8e2906a 100644 (file)
@@ -221,12 +221,16 @@ table.userdetails td.convpartners td.bar img
        height: 4px;
 }
 
        height: 4px;
 }
 
-table.userdetails table.hours tr.bars
+table.userdetails table.hours tr.bars,
+table.userdetails table.weekdays tr.bars,
+table.userdetails table.longterm tr.bars
 {
        height: 75px;
 }
 
 {
        height: 75px;
 }
 
-table.userdetails table.hours tr.bars td.bar img
+table.userdetails table.hours tr.bars td.bar img,
+table.userdetails table.weekdays tr.bars td.bar img,
+table.userdetails table.longterm tr.bars td.bar img
 {
        width: 3px;
 }
 {
        width: 3px;
 }