X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=lib%2FOnis%2FPlugins%2FCore.pm;h=6babaed760463b917ec967f30d0a8194648fde38;hb=94c475154436950768e3686fa7030ee5fdb23e4e;hp=da58275e34682b4593e293f0d1fa5f2866c93a0c;hpb=9bac8d0b7d0c31b06300ec457c2503dd3fdae78d;p=onis.git
diff --git a/lib/Onis/Plugins/Core.pm b/lib/Onis/Plugins/Core.pm
index da58275..6babaed 100644
--- a/lib/Onis/Plugins/Core.pm
+++ b/lib/Onis/Plugins/Core.pm
@@ -17,14 +17,14 @@ complicated plugin so far.
=cut
-use Onis::Config qw/get_config/;
-use Onis::Html qw/html_escape get_filehandle/;
-use Onis::Language qw/translate/;
-use Onis::Users (qw(get_realname get_link get_image ident_to_name));
-use Onis::Data::Core qw#get_all_nicks nick_to_ident ident_to_nick get_main_nick register_plugin#;
-use Onis::Data::Persistent;
-
-@Onis::Plugins::Core::EXPORT_OK = (qw(get_core_nick_counters get_sorted_nicklist));
+use Onis::Config (qw(get_config));
+use Onis::Html (qw(html_escape get_filehandle));
+use Onis::Language (qw(translate));
+use Onis::Users (qw(get_realname get_link get_image chatter_to_name));
+use Onis::Data::Core (qw(get_all_nicks nick_to_ident ident_to_nick get_main_nick register_plugin));
+use Onis::Data::Persistent ();
+
+@Onis::Plugins::Core::EXPORT_OK = (qw(get_core_nick_counters get_sorted_nicklist nick_is_in_main_table));
@Onis::Plugins::Core::ISA = ('Exporter');
our $NickLinesCounter = Onis::Data::Persistent->new ('NickLinesCounter', 'nick',
@@ -53,6 +53,8 @@ our $QuoteData = {}; # Is generated before output. Nicks are merged according t
our $NickData = {}; # Same as above, but for nicks rather than quotes.
our $SortedNicklist = [];
+our $NicksInMainTable = {};
+
our @H_IMAGES = qw#dark-theme/h-red.png dark-theme/h-blue.png dark-theme/h-yellow.png dark-theme/h-green.png#;
our $QuoteCacheSize = 10;
our $QuoteMin = 30;
@@ -691,18 +693,21 @@ EOF
}
if ($DISPLAY_LINES ne 'NONE')
{
+ my $span = $DISPLAY_LINES eq 'BOTH' ? ' colspan="2"' : '';
$trans = translate ('Number of Lines');
- print $fh "
$trans | \n";
+ print $fh " $trans | \n";
}
if ($DISPLAY_WORDS ne 'NONE')
{
+ my $span = $DISPLAY_WORDS eq 'BOTH' ? ' colspan="2"' : '';
$trans = translate ('Number of Words');
- print $fh " $trans | \n";
+ print $fh " $trans | \n";
}
if ($DISPLAY_CHARS ne 'NONE')
{
+ my $span = $DISPLAY_CHARS eq 'BOTH' ? ' colspan="2"' : '';
$trans = translate ('Number of Characters');
- print $fh " $trans | \n";
+ print $fh " $trans | \n";
}
if ($DISPLAY_TIMES)
{
@@ -725,7 +730,7 @@ EOF
{
my $nick = $_;
my $ident = nick_to_ident ($nick);
- my $name = ident_to_name ($ident);
+ my $name = chatter_to_name ("$nick!$ident");
my $print = $name || $nick;
$linescount++;
@@ -735,6 +740,8 @@ EOF
# our table..
if ($linescount <= $LongLines)
{
+ $NicksInMainTable->{$nick} = $linescount;
+
my $quote = translate ('-- no quote available --');
if (@{$QuoteData->{$nick}})
@@ -804,50 +811,44 @@ EOF
if ($DISPLAY_LINES ne 'NONE')
{
- print $fh qq# #;
- if (($DISPLAY_LINES eq 'BOTH') or ($DISPLAY_LINES eq 'BAR'))
+ if (($DISPLAY_LINES eq 'BOTH') or ($DISPLAY_LINES eq 'NUMBER'))
{
- my $code = bar ($max_lines, $NickData->{$nick}{'lines'});
- print $fh $code;
+ my $num = $NickData->{$nick}{'lines_total'};
+ print $fh qq( | $num | \n);
}
- print $fh ' ' if ($DISPLAY_LINES eq 'BOTH');
- if (($DISPLAY_LINES eq 'BOTH') or ($DISPLAY_LINES eq 'NUMBER'))
+ if (($DISPLAY_LINES eq 'BOTH') or ($DISPLAY_LINES eq 'BAR'))
{
- print $fh $NickData->{$nick}{'lines_total'};
+ my $code = bar ($max_lines, $NickData->{$nick}{'lines'});
+ print $fh qq( $code | \n);
}
- print $fh "\n";
}
if ($DISPLAY_WORDS ne 'NONE')
{
- print $fh qq# #;
- if (($DISPLAY_WORDS eq 'BOTH') or ($DISPLAY_WORDS eq 'BAR'))
+ if (($DISPLAY_WORDS eq 'BOTH') or ($DISPLAY_WORDS eq 'NUMBER'))
{
- my $code = bar ($max_words, $NickData->{$nick}{'words'});
- print $fh $code;
+ my $num = $NickData->{$nick}{'words_total'};
+ print $fh qq( | $num | \n);
}
- print $fh ' ' if ($DISPLAY_WORDS eq 'BOTH');
- if (($DISPLAY_WORDS eq 'BOTH') or ($DISPLAY_WORDS eq 'NUMBER'))
+ if (($DISPLAY_WORDS eq 'BOTH') or ($DISPLAY_WORDS eq 'BAR'))
{
- print $fh $NickData->{$nick}{'words_total'};
+ my $code = bar ($max_words, $NickData->{$nick}{'words'});
+ print $fh qq( $code | \n);
}
- print $fh "\n";
}
if ($DISPLAY_CHARS ne 'NONE')
{
- print $fh qq# #;
- if (($DISPLAY_CHARS eq 'BOTH') or ($DISPLAY_CHARS eq 'BAR'))
+ if (($DISPLAY_CHARS eq 'BOTH') or ($DISPLAY_CHARS eq 'NUMBER'))
{
- my $code = bar ($max_chars, $NickData->{$nick}{'chars'});
- print $fh $code;
+ my $num = $NickData->{$nick}{'chars_total'};
+ print $fh qq( | $num | \n);
}
- print $fh ' ' if ($DISPLAY_CHARS eq 'BOTH');
- if (($DISPLAY_CHARS eq 'BOTH') or ($DISPLAY_CHARS eq 'NUMBER'))
+ if (($DISPLAY_CHARS eq 'BOTH') or ($DISPLAY_CHARS eq 'BAR'))
{
- print $fh $NickData->{$nick}{'chars_total'};
+ my $code = bar ($max_chars, $NickData->{$nick}{'chars'});
+ print $fh qq( $code | \n);
}
- print $fh "\n";
}
if ($DISPLAY_TIMES)
@@ -954,21 +955,16 @@ sub bar
confess () unless (ref ($source) eq 'ARRAY');
# BAR_WIDTH is a least 10
- my $max_width = $BAR_WIDTH - 4;
- my $factor = 1;
my $retval = '';
my $i;
my $j;
- if (!$max_num) { return ($retval); }
- $factor = $max_width / $max_num;
-
for ($i = 0; $i < 4; $i++)
{
my $sum = 0;
- my $width = 1;
my $img = $H_IMAGES[$i];
+ my $width;
for ($j = 0; $j < 6; $j++)
{
@@ -976,9 +972,9 @@ sub bar
$sum += $source->[$hour];
}
- $width += int (0.5 + ($sum * $factor));
+ $width = sprintf ("%.2f", 95 * $sum / $max_num);
- $retval .= qq#
);
@@ -1031,10 +1027,24 @@ sub get_sorted_nicklist
return ($SortedNicklist);
}
+=item B (I<$nick>)
+
+Returns the position of the nick in the main table or zero if it is not in the
+main table.
+
+=cut
+
+sub nick_is_in_main_table
+{
+ my $nick = shift;
+
+ return (defined ($NicksInMainTable->{$nick}) ? $NicksInMainTable->{$nick} : 0);
+}
+
=back
=head1 AUTHOR
-Florian octo Forster, Eocto at verplant.orgE
+Florian octo Forster Eocto at verplant.orgE
=cut