Introduces config options userdetails_number, userdetails_conversations_number.
Removed bar_width and bar_height in many plugins.
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::Data::Persistent ();
=head1 NAME
our $ConversationCache = Onis::Data::Persistent->new ('ConversationCache', 'partners', qw(time0 time1 time2 time3));
our $ConversationData = {};
-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 $BAR_WIDTH = 100;
+our @HorizontalImages = qw#dark-theme/h-red.png dark-theme/h-blue.png dark-theme/h-yellow.png dark-theme/h-green.png#;
if (get_config ('horizontal_images'))
{
for ($i = 0; $i < 4; $i++)
{
next unless (defined ($tmp[$i]));
- $H_IMAGES[$i] = $tmp[$i];
+ $HorizontalImages[$i] = $tmp[$i];
}
}
-if (get_config ('bar_width'))
+
+our $NumConversations = 10;
+if (get_config ('conversations_number'))
{
- my $tmp = get_config ('bar_width');
+ my $tmp = get_config ('conversations_number');
$tmp =~ s/\D//g;
- $BAR_WIDTH = 2 * $tmp if ($tmp >= 10);
+ $NumConversations = $tmp if ($tmp);
}
register_plugin ('TEXT', \&add);
my $title = translate ('Conversation partners');
my $max_num = 0;
- my $factor = 0;
-
- my @img = get_config ('horizontal_images');
- # FIXME
- my @data = get_top (10);
+ my @data = get_top ($NumConversations);
return (undef) unless (@data);
for (@data)
$max_num = $sum1 if ($max_num < $sum1);
}
- $factor = $BAR_WIDTH / $max_num;
-
print $fh <<EOF;
<table class="plugin conversations">
<tr>
<tr>
EOF
- print $fh ' <td class="bar left">';
- for (3, 2, 1, 0)
+ print $fh ' <td class="bar horizontal left">';
+ for (my $i = 3; $i >= 0; $i--)
{
- my $i = $img[$_];
- my $w = int (0.5 + ($rec->{'nicks'}{$nick0}[$_] * $factor));
- my $c = '';
- $w ||= 1;
-
- $w = $w . 'px';
+ my $width = sprintf ("%.2f", 95 * $rec->{'nicks'}{$nick0}[$i] / $max_num);
+ my $image = $HorizontalImages[$i];
+ my $class = '';
- if ($_ == 3) { $c = qq# class="first"#; }
- elsif ($_ == 0) { $c = qq# class="last"#; }
+ if ($i == 3) { $class = qq# class="first"#; }
+ elsif ($i == 0) { $class = qq# class="last"#; }
- print $fh qq#<img src="$i" style="width: $w;"$c alt="" />#;
+ print $fh qq#<img src="$image" style="width: $width%;"$class alt="" />#;
}
-
- print $fh qq#</td>\n <td class="bar right">#;
-
- for (0, 1, 2, 3)
+ print $fh qq#</td>\n <td class="bar horizontal right">#;
+ for (my $i = 0; $i < 4; $i++)
{
- my $i = $img[$_];
- my $w = int (0.5 + ($rec->{'nicks'}{$nick1}[$_] * $factor));
- my $c = '';
- $w ||= 1;
-
- $w = $w . 'px';
+ my $width = sprintf ("%.2f", 95 * $rec->{'nicks'}{$nick1}[$i] / $max_num);
+ my $image = $HorizontalImages[$i];
+ my $class = '';
- if ($_ == 0) { $c = qq# class="first"#; }
- elsif ($_ == 3) { $c = qq# class="last"#; }
+ if ($i == 0) { $class = qq# class="first"#; }
+ elsif ($i == 3) { $class = qq# class="last"#; }
- print $fh qq#<img src="$i" style="width: $w;"$c alt=""/>#;
+ print $fh qq#<img src="$image" style="width: $width%;"$class alt="" />#;
}
print $fh "</td>\n </tr>\n";
}
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 @HorizontalImages = 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;
our $QuoteMax = 80;
-our $WORD_LENGTH = 5;
-our $SORT_BY = 'LINES';
-our $DISPLAY_LINES = 'BOTH';
-our $DISPLAY_WORDS = 'NONE';
-our $DISPLAY_CHARS = 'NONE';
-our $DISPLAY_TIMES = 0;
-our $DISPLAY_IMAGES = 0;
-our $DEFAULT_IMAGE = '';
-our $BAR_HEIGHT = 130;
-our $BAR_WIDTH = 100;
+our $SortBy = 'LINES';
+our $DisplayLines = 'BOTH';
+our $DisplayWords = 'NONE';
+our $DisplayChars = 'NONE';
+our $DisplayTimes = 0;
+our $DisplayImages = 0;
+our $DefaultImage = '';
our $LongLines = 50;
our $ShortLines = 10;
$QuoteMax = $tmp if ($tmp);
}
-=item B<min_word_length>: I<5>
-
-Sets how many word-characters in a row are considered to be a word. Or, in more
-normal terms: Sets the minimum length for words..
-
-=cut
-
-if (get_config ('min_word_length'))
-{
- my $tmp = get_config ('min_word_length');
- $tmp =~ s/\D//g;
- $WORD_LENGTH = $tmp if ($tmp);
-}
-
=item B<display_lines>: I<BOTH>
Choses wether to display B<lines> as I<BAR>, I<NUMBER>, I<BOTH> or not at all
if (($tmp eq 'NONE') or ($tmp eq 'BAR') or ($tmp eq 'NUMBER') or ($tmp eq 'BOTH'))
{
- $DISPLAY_LINES = $tmp;
+ $DisplayLines = $tmp;
}
else
{
if (($tmp eq 'NONE') or ($tmp eq 'BAR') or ($tmp eq 'NUMBER') or ($tmp eq 'BOTH'))
{
- $DISPLAY_WORDS = $tmp;
+ $DisplayWords = $tmp;
}
else
{
if (($tmp eq 'NONE') or ($tmp eq 'BAR') or ($tmp eq 'NUMBER') or ($tmp eq 'BOTH'))
{
- $DISPLAY_CHARS = $tmp;
+ $DisplayChars = $tmp;
}
else
{
if ($tmp =~ m/true|on|yes/i)
{
- $DISPLAY_TIMES = 1;
+ $DisplayTimes = 1;
}
elsif ($tmp =~ m/false|off|no/i)
{
- $DISPLAY_TIMES = 0;
+ $DisplayTimes = 0;
}
else
{
if ($tmp =~ m/true|on|yes/i)
{
- $DISPLAY_IMAGES = 1;
+ $DisplayImages = 1;
}
elsif ($tmp =~ m/false|off|no/i)
{
- $DISPLAY_IMAGES = 0;
+ $DisplayImages = 0;
}
else
{
if (get_config ('default_image'))
{
- $DEFAULT_IMAGE = get_config ('default_image');
+ $DefaultImage = get_config ('default_image');
}
=item B<sort_by>: I<LINES>
if (($tmp eq 'LINES') or ($tmp eq 'WORDS') or ($tmp eq 'CHARS'))
{
- $SORT_BY = $tmp;
+ $SortBy = $tmp;
}
else
{
next;
}
- $H_IMAGES[$i] = $tmp[$i];
+ $HorizontalImages[$i] = $tmp[$i];
}
}
-=item B<bar_height>: I<130>
-
-Sets the height (in pixels) of the highest vertical graph.
-
-=cut
-
-if (get_config ('bar_height'))
-{
- my $tmp = get_config ('bar_height');
- $tmp =~ s/\D//g;
- $BAR_HEIGHT = $tmp if ($tmp >= 10);
-}
-
-=item B<bar_width>: I<100>
-
-Sets the width (in pixels) of the widest horizontal graph.
-
-=cut
-
-if (get_config ('bar_width'))
-{
- my $tmp = get_config ('bar_width');
- $tmp =~ s/\D//g;
- $BAR_WIDTH = $tmp if ($tmp >= 10);
-}
-
=item B<longlines>: I<50>
Sets the number of rows of the main ranking table.
{
my $max = 0; # the most lines that were written in one hour..
my $total = 0; # the total amount of lines we wrote..
- my $factor = 0; # used to find a bar's height
my @data = qw(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0);
$max = 1;
}
- $factor = (($BAR_HEIGHT - 1) / $max);
-
my $header = translate ('When do we actually talk here?');
print $fh "<h2>$header</h2>\n",
qq#<table class="hours">\n#,
my $fh = get_filehandle () or die;
- my $sort_field = lc ($SORT_BY);
+ my $sort_field = lc ($SortBy);
my $trans;
$trans = translate ('Most active nicks');
print $fh "<h2>$trans</h2>\n";
- if ($SORT_BY eq 'LINES')
+ if ($SortBy eq 'LINES')
{
$trans = translate ('Nicks sorted by numbers of lines written');
}
- elsif ($SORT_BY eq 'WORDS')
+ elsif ($SortBy eq 'WORDS')
{
$trans = translate ('Nicks sorted by numbers of words written');
}
- else # ($SORT_BY eq 'CHARS')
+ else # ($SortBy eq 'CHARS')
{
$trans = translate ('Nicks sorted by numbers of characters written');
}
<tr>
<td class="invis"> </td>
EOF
- if ($DISPLAY_IMAGES)
+ if ($DisplayImages)
{
$trans = translate ('Image');
print $fh " <th>$trans</th>\n";
$trans = translate ('Nick');
print $fh " <th>$trans</th>\n";
}
- if ($DISPLAY_LINES ne 'NONE')
+ if ($DisplayLines ne 'NONE')
{
- my $span = $DISPLAY_LINES eq 'BOTH' ? ' colspan="2"' : '';
+ my $span = $DisplayLines eq 'BOTH' ? ' colspan="2"' : '';
$trans = translate ('Number of Lines');
print $fh " <th$span>$trans</th>\n";
}
- if ($DISPLAY_WORDS ne 'NONE')
+ if ($DisplayWords ne 'NONE')
{
- my $span = $DISPLAY_WORDS eq 'BOTH' ? ' colspan="2"' : '';
+ my $span = $DisplayWords eq 'BOTH' ? ' colspan="2"' : '';
$trans = translate ('Number of Words');
print $fh " <th$span>$trans</th>\n";
}
- if ($DISPLAY_CHARS ne 'NONE')
+ if ($DisplayChars ne 'NONE')
{
- my $span = $DISPLAY_CHARS eq 'BOTH' ? ' colspan="2"' : '';
+ my $span = $DisplayChars eq 'BOTH' ? ' colspan="2"' : '';
$trans = translate ('Number of Characters');
print $fh " <th$span>$trans</th>\n";
}
- if ($DISPLAY_TIMES)
+ if ($DisplayTimes)
{
$trans = translate ('When?');
print $fh " <th>$trans</th>\n";
print $fh " <tr>\n",
qq# <td class="numeration"># . $linescount . "</td>\n";
- if ($DISPLAY_IMAGES)
+ if ($DisplayImages)
{
- if ($DEFAULT_IMAGE and !$image)
+ if ($DefaultImage and !$image)
{
- $image = $DEFAULT_IMAGE;
+ $image = $DefaultImage;
}
print $fh qq# <td class="image">#;
print $fh qq#$print</td>\n#;
}
- if ($DISPLAY_LINES ne 'NONE')
+ if ($DisplayLines ne 'NONE')
{
- if (($DISPLAY_LINES eq 'BOTH') or ($DISPLAY_LINES eq 'NUMBER'))
+ if (($DisplayLines eq 'BOTH') or ($DisplayLines eq 'NUMBER'))
{
my $num = $NickData->{$nick}{'lines_total'};
print $fh qq( <td class="counter">$num</td>\n);
}
- if (($DISPLAY_LINES eq 'BOTH') or ($DISPLAY_LINES eq 'BAR'))
+ if (($DisplayLines eq 'BOTH') or ($DisplayLines eq 'BAR'))
{
my $code = bar ($max_lines, $NickData->{$nick}{'lines'});
print $fh qq( <td class="bar horizontal">$code</td>\n);
}
}
- if ($DISPLAY_WORDS ne 'NONE')
+ if ($DisplayWords ne 'NONE')
{
- if (($DISPLAY_WORDS eq 'BOTH') or ($DISPLAY_WORDS eq 'NUMBER'))
+ if (($DisplayWords eq 'BOTH') or ($DisplayWords eq 'NUMBER'))
{
my $num = $NickData->{$nick}{'words_total'};
print $fh qq( <td class="counter">$num</td>\n);
}
- if (($DISPLAY_WORDS eq 'BOTH') or ($DISPLAY_WORDS eq 'BAR'))
+ if (($DisplayWords eq 'BOTH') or ($DisplayWords eq 'BAR'))
{
my $code = bar ($max_words, $NickData->{$nick}{'words'});
print $fh qq( <td class="bar horizontal">$code</td>\n);
}
}
- if ($DISPLAY_CHARS ne 'NONE')
+ if ($DisplayChars ne 'NONE')
{
- if (($DISPLAY_CHARS eq 'BOTH') or ($DISPLAY_CHARS eq 'NUMBER'))
+ if (($DisplayChars eq 'BOTH') or ($DisplayChars eq 'NUMBER'))
{
my $num = $NickData->{$nick}{'chars_total'};
print $fh qq( <td class="counter">$num</td>\n);
}
- if (($DISPLAY_CHARS eq 'BOTH') or ($DISPLAY_CHARS eq 'BAR'))
+ if (($DisplayChars eq 'BOTH') or ($DisplayChars eq 'BAR'))
{
my $code = bar ($max_chars, $NickData->{$nick}{'chars'});
print $fh qq( <td class="bar horizontal">$code</td>\n);
}
}
- if ($DISPLAY_TIMES)
+ if ($DisplayTimes)
{
my $code = bar ($NickData->{$nick}{'chars_total'}, $NickData->{$nick}{'chars'});
- print $fh qq# <td class="bar">$code</td>\n#;
+ print $fh qq# <td class="bar horizontal">$code</td>\n#;
}
print $fh qq# <td class="quote">$quote</td>\n#,
my $col_in_this_table = ($linescount - $LongLines - 1) % 6;
my $total = 0;
- if ($SORT_BY eq 'LINES')
+ if ($SortBy eq 'LINES')
{
$total = $NickData->{$nick}{'lines_total'};
}
- elsif ($SORT_BY eq 'WORDS')
+ elsif ($SortBy eq 'WORDS')
{
$total = $NickData->{$nick}{'words_total'};
}
- else # ($SORT_BY eq 'CHARS')
+ else # ($SortBy eq 'CHARS')
{
$total = $NickData->{$nick}{'chars_total'};
}
confess () unless (ref ($source) eq 'ARRAY');
- # BAR_WIDTH is a least 10
my $retval = '';
my $i;
for ($i = 0; $i < 4; $i++)
{
my $sum = 0;
- my $img = $H_IMAGES[$i];
+ my $img = $HorizontalImages[$i];
my $width;
for ($j = 0; $j < 6; $j++)
use Onis::Plugins::Bignumbers (qw(get_bignumbers));
use Onis::Plugins::Interestingnumbers (qw(get_interestingnumbers));
-our $DISPLAY_IMAGES = 0;
-our $DEFAULT_IMAGE = '';
+our $DisplayImages = 0;
+our $DefaultImage = '';
register_plugin ('OUTPUT', \&output);
-our $SORT_BY = 'lines';
-if (get_config ('sort_by'))
+our $NumUserdetails = 10;
+if (get_config ('userdetails_number'))
{
- my $tmp = get_config ('sort_by');
- $tmp = lc ($tmp);
-
- if (($tmp eq 'lines') or ($tmp eq 'words') or ($tmp eq 'chars'))
- {
- $SORT_BY = $tmp;
- }
- else
- {
- # The Core plugin already complained about this..
- }
-}
-our $PLUGIN_MAX = 10;
-if (get_config ('plugin_max'))
-{
- my $tmp = get_config ('plugin_max');
+ my $tmp = get_config ('userdetails_number');
$tmp =~ s/\D//g;
- $PLUGIN_MAX = $tmp if ($tmp);
+ $NumUserdetails = $tmp if ($tmp);
}
+
if (get_config ('display_images'))
{
my $tmp = get_config ('display_images');
if ($tmp =~ m/true|on|yes/i)
{
- $DISPLAY_IMAGES = 1;
+ $DisplayImages = 1;
}
elsif ($tmp =~ m/false|off|no/i)
{
- $DISPLAY_IMAGES = 0;
+ $DisplayImages = 0;
}
else
{
}
if (get_config ('default_image'))
{
- $DEFAULT_IMAGE = get_config ('default_image');
+ $DefaultImage = get_config ('default_image');
}
-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 @HorizontalImages = qw#dark-theme/h-red.png dark-theme/h-blue.png dark-theme/h-yellow.png dark-theme/h-green.png#;
if (get_config ('horizontal_images'))
{
my @tmp = get_config ('horizontal_images');
next;
}
- $H_IMAGES[$i] = $tmp[$i];
+ $HorizontalImages[$i] = $tmp[$i];
}
}
-our @V_IMAGES = qw#images/ver0n.png images/ver1n.png images/ver2n.png images/ver3n.png#;
+our @VerticalImages = qw#images/ver0n.png images/ver1n.png images/ver2n.png images/ver3n.png#;
if (get_config ('vertical_images'))
{
my @tmp = get_config ('vertical_images');
next;
}
- $V_IMAGES[$i] = $tmp[$i];
+ $VerticalImages[$i] = $tmp[$i];
}
}
-our $BAR_HEIGHT = 130;
-if (get_config ('bar_height'))
-{
- my $tmp = get_config ('bar_height');
- $tmp =~ s/\D//g;
- $BAR_HEIGHT = $tmp if ($tmp >= 10);
-}
-#$BAR_HEIGHT = int ($BAR_HEIGHT / 2);
-
-our $BAR_WIDTH = 100;
-if (get_config ('bar_width'))
+our $ConversationsNumber = 10;
+if (get_config ('userdetails_conversations_number'))
{
- my $tmp = get_config ('bar_width');
+ my $tmp = get_config ('userdetails_conversations_number');
$tmp =~ s/\D//g;
- $BAR_WIDTH = $tmp if ($tmp >= 10);
+ $ConversationsNumber = $tmp if ($tmp);
}
our $LongtermDays = 7;
my @nicks = @$nicks_ref;
my $nick_data = {};
- splice (@nicks, $PLUGIN_MAX) if (scalar (@nicks) > $PLUGIN_MAX);
+ splice (@nicks, $NumUserdetails) if (scalar (@nicks) > $NumUserdetails);
for (@nicks)
{
print $fh qq#<table class="plugin userdetails">\n#,
qq# <tr>\n#,
- qq# <th colspan="#, $DISPLAY_IMAGES ? 4 : 3, qq#">$trans</th>\n#,
+ qq# <th colspan="#, $DisplayImages ? 4 : 3, qq#">$trans</th>\n#,
qq# </tr>\n#;
for (@nicks)
my $ptr = $nick_data->{$nick};
print $fh qq# <tr>\n#,
- qq# <th colspan="#, $DISPLAY_IMAGES ? 4 : 3, qq#" class="nick">$print</th>\n#,
+ qq# <th colspan="#, $DisplayImages ? 4 : 3, qq#" class="nick">$print</th>\n#,
qq# </tr>\n#,
qq# <tr>\n#;
- if ($DISPLAY_IMAGES)
+ if ($DisplayImages)
{
my $link = get_link ($name);
my $image = get_image ($name);
- if ($DEFAULT_IMAGE and !$image)
+ if ($DefaultImage and !$image)
{
- $image = $DEFAULT_IMAGE;
+ $image = $DefaultImage;
}
print $fh qq# <td class="image" rowspan="2">#;
</tr>
EOF
- for (my $i = 0; $i < $PLUGIN_MAX and $i < scalar (@others); $i++)
+ for (my $i = 0; $i < $ConversationsNumber and $i < scalar (@others); $i++)
{
my $other = $others[$i];
my $other_name = nick_to_name ($other) || $other;
for (my $k = 0; $k < 4; $k++)
{
- my $img = $H_IMAGES[$k];
+ my $img = $HorizontalImages[$k];
my $num = $ptr->{'conversations'}{$other}{'nicks'}{$nick}[$k];
my $width = sprintf ("%.2f", 95 * $num / $max_conv);
{
$num = 0;
- my $img = $V_IMAGES[int ($i / 6)];
+ my $img = $VerticalImages[int ($i / 6)];
my $height;
$num = $ptr->{'chars'}[$i];
{
my $num = $nick_data->{$nick}{'weekdays'}{$day}[$i];
my $height = sprintf ("%.2f", 95 * $num / $max_weekdays);
- my $img = $V_IMAGES[$i];
+ my $img = $VerticalImages[$i];
print $fh qq# <td class="bar vertical">#,
qq#<img src="$img" alt="" class="first last" style="height: $height\%;" />#,
{
my $num = $nick_data->{$nick}{'longterm'}[$i][$j];
my $height = sprintf ("%.2f", 95 * $num / $max_longterm);
- my $img = $V_IMAGES[$j];
+ my $img = $VerticalImages[$j];
print $fh qq# <td class="bar vertical">#,
qq#<img src="$img" alt="" class="first last" style="height: $height\%;" />#,
Sets the minimum and maximum length of a quote. Too short quotes may be not
very typical for a person, too long quotes may clutter the layout.
+=item B<conversations_number>: I<number>;
+
+=item B<userdetails_conversations_number>: I<number>;
+
+Number of conversations partners to include in the output (or in the
+conversations section of the userdetails plugin).
+
=item B<soliloquies_count>: I<number>;
Sets how many lines without interruption are considered a soliloquy.
The Words-Plugin will ignore words with less than this characters.
+=item B<userdetails_number>: I<number>;
+
+The number of nicks to print userdetails for.
+
=back
=head1 AUTHOR
/* * * */
+table.big_ranking td.bar
+{
+ width: 100px;
+}
+
table.big_ranking td.bar img
{
height: 15px;
}
+table.big_ranking td.counter
+{
+ text-align: right;
+}
+
table.big_ranking td.image
{
padding: 1px;
height: 10px;
}
+table.big_ranking td.bar
+{
+ width: 100px;
+}
+
+table.big_ranking td.counter
+{
+ background-color: #f8f8f8;
+ color: black;
+ border: none;
+ text-align: right;
+}
+
table.big_ranking td.image img,
table.userdetails td.image img
{
table.big_ranking td.bar
{
font-size: smaller;
+ width: 100px;
}
-table.big_ranking td.bar img.first
+table.big_ranking td.counter
{
- border: none;
-}
-
-table.big_ranking td.bar img.last
-{
- border: none;
+ text-align: right;
}
table.big_ranking td.image img
{
- width: auto;
- height: auto;
width: 50px;
height: 50px;
-
}
table.conversations