Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2010-09-12 15:16:30 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2010-09-12 15:16:30 (GMT)
commit19f49247d9fdd2774b32f1ccaeab61765fe816fa (patch)
treed772cc5268d9064028bf54a47c27856cea008bd8
parent785a58587ea3a47777f01a2176c87c8d8201a12b (diff)
Support meetings in webui; use simple nick colorizer based on name hashes
-rwxr-xr-xcgi/channel-index.pl27
-rw-r--r--cgi/channels/parrot.tmpl4
-rw-r--r--cgi/channels/perl6.tmpl7
-rw-r--r--cgi/nickfilter.js2
-rwxr-xr-xcgi/out.pl215
-rwxr-xr-xcgi/search.pl3
-rw-r--r--cgi/sugar.css16
-rw-r--r--cgi/template/channel-index.tmpl11
-rw-r--r--cgi/template/day-linkblock.tmpl4
-rw-r--r--cgi/template/day-meetings.tmpl23
-rw-r--r--cgi/template/day.tmpl6
-rw-r--r--cgi/template/footer.tmpl2
-rw-r--r--cgi/template/line.tmpl4
-rw-r--r--ilbot.sql3
-rw-r--r--lib/IrcLog/NickColorizer.pm94
-rw-r--r--lib/IrcLog/WWW.pm26
16 files changed, 305 insertions, 142 deletions
diff --git a/cgi/channel-index.pl b/cgi/channel-index.pl
index 1c50542..577b137 100755
--- a/cgi/channel-index.pl
+++ b/cgi/channel-index.pl
@@ -16,15 +16,16 @@ go();
sub go {
my $q = new CGI;
my $channel = $q->url_param('channel');
+ my $meetings = $q->param("meetings") || 0;
print "Content-Type: text/html; charset=utf-8\n\n";
- my $cache_name = $channel . '|' . gmt_today();
+ my $cache_name = $channel . '|' . $meetings . '|' . gmt_today();
my $cache = new Cache::FileCache({ namespace => 'irclog' });
my $data = $cache->get($cache_name);
if (! defined $data) {
- $data = get_channel_index($channel);
- $cache->set($data, '2 hours');
+ $data = get_channel_index($channel, $meetings);
+ $cache->set($cache_name, $data, '2 hours');
}
print $data;
@@ -36,11 +37,12 @@ sub test_calendar {
my $dates = [qw( 2009-09-28 2009-09-30
2009-10-01 2009-10-02 2009-10-05 2009-10-12 )];
- print calendar_for_channel($channel, $dates, $base_url);
+ print calendar_for_channel($channel, 0, $dates, $base_url);
}
sub get_channel_index {
my $channel = shift;
+ my $meetings = shift;
my $conf = Config::File::read_config_file('cgi.conf');
my $base_url = $conf->{BASE_URL} || q{/};
@@ -52,28 +54,33 @@ sub get_channel_index {
# we are evil and create a calendar entry for month between the first
# and last date
my $dbh = get_dbh();
- my $get_dates = 'SELECT DISTINCT day FROM irclog WHERE channel = ? ORDER BY day';
+ my $get_dates = 'SELECT DISTINCT day FROM irclog WHERE nick IS NOT NULL '.
+ 'AND channel = ? '.
+ ($meetings ? 'AND meeting IS NOT NULL ' : '').
+ 'ORDER BY day';
my $dates = $dbh->selectcol_arrayref($get_dates, undef, '#' . $channel);
$t->param(CHANNEL => $channel);
+ $t->param(MEETINGS => $meetings ? '/meetings' : '');
+ $t->param(MEETINGS_SUBURL => '/meetings');
$t->param(BASE_URL => $base_url);
- $t->param(CALENDAR => calendar_for_channel($channel, $dates, $base_url));
+ $t->param(CALENDAR => calendar_for_channel($channel, $meetings, $dates, $base_url));
return $t->output;
}
sub calendar_for_channel {
- my ($channel, $dates, $base_url) = @_;
+ my ($channel, $meetings, $dates, $base_url) = @_;
$channel =~ s/\A\#//smx;
my (%months, %link);
for my $date (@$dates) {
my ($Y, $M, $D) = split '-', $date;
- $link{$date} = "$base_url$channel/$date";
+ $link{$date} = "$base_url$channel/" . ($meetings ? 'meetings/' : '') . "$date";
$months{"$Y-$M"}++;
}
my @months = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
- my @days = qw( S M T W T F S );
+ my @days = qw( M T W T F S S );
my $dayhead = join '' => map "<th>$_</th>" => @days;
my $html = qq{<div class="calendars">\n};
@@ -81,7 +88,7 @@ sub calendar_for_channel {
for my $month (reverse sort keys %months) {
my ($Y, $M) = split '-', $month;
my $title = $months[$M - 1] . ' ' . $Y;
- my @weeks = calendar($M, $Y);
+ my @weeks = calendar($M, $Y, 1);
push @weeks, [] while @weeks < 6;
$html .= qq{<table class="calendar">\n<thead>\n<tr class="calendar_title"><th colspan="7">$title</th></tr>\n<tr class="day_names">$dayhead</tr>\n</thead>\n<tbody>\n};
diff --git a/cgi/channels/parrot.tmpl b/cgi/channels/parrot.tmpl
deleted file mode 100644
index a70d8c3..0000000
--- a/cgi/channels/parrot.tmpl
+++ /dev/null
@@ -1,4 +0,0 @@
-<p><a href="http://www.parrot.org/">Parrot</a>
- | <a href="http://www.slimies.de/raxref-parrot_rakudo.html">source cross
- referenced</a>
-</p>
diff --git a/cgi/channels/perl6.tmpl b/cgi/channels/perl6.tmpl
deleted file mode 100644
index 73846b7..0000000
--- a/cgi/channels/perl6.tmpl
+++ /dev/null
@@ -1,7 +0,0 @@
-<p> <a href="http://perl6.org/">Perl 6</a>
- | <a href="http://www.rakudo.org/">Rakudo</a>
- | <a href="http://perlcabal.org/syn/">Specs</a>
- | <a href="http://www.parrot.org/">Parrot</a>
- | <a href="http://www.slimies.de/raxref-parrot_rakudo.html">source cross
- referenced</a>
-</p>
diff --git a/cgi/nickfilter.js b/cgi/nickfilter.js
index 07939f0..124e416 100644
--- a/cgi/nickfilter.js
+++ b/cgi/nickfilter.js
@@ -65,7 +65,7 @@ $(document).ready(function() {
} catch(e) { alert(e) }
$("#"+filter_toggle_id).append(
- '<a href="javascript:filtering_on()">Turn on filtering by nick</a>'
+ '<a href="javascript:filtering_on()" class="nick_filtering">Turn on filtering by nick</a>'
);
$("#"+filter_toggle_id).show();
diff --git a/cgi/out.pl b/cgi/out.pl
index ba79a82..3d2b617 100755
--- a/cgi/out.pl
+++ b/cgi/out.pl
@@ -27,36 +27,37 @@ my $base_url = $conf->{BASE_URL} || q{/};
# unable to handle arrays, just hashes.
# map nicks to CSS classes.
-my @colors = (
- ['TimToady', 'nick_timtoady'],
- ['audreyt', 'nick_audreyt'],
- ['evalbot', 'bots'],
- ['exp_evalbot', 'bots'],
- ['p6eval', 'bots'],
- ['lambdabot', 'bots'],
- ['pugs_svnbot', 'bots'],
- ['pugs_svn', 'bots'],
- ['specbot', 'bots'],
- ['speckbot', 'bots'],
- ['pasteling', 'bots'],
- ['rakudo_svn', 'bots'],
- ['purl', 'bots'],
- ['svnbotlt', 'bots'],
- ['dalek', 'bots'],
- ['hugme', 'bots'],
- ['garfield', 'bots'],
+my %colors = (
+ 'TimToady' => 'nick_timtoady',
+ 'audreyt', => 'nick_audreyt',
+ 'evalbot', => 'bots',
+ 'exp_evalbot', => 'bots',
+ 'p6eval', => 'bots',
+ 'lambdabot', => 'bots',
+ 'pugs_svnbot', => 'bots',
+ 'pugs_svn', => 'bots',
+ 'specbot', => 'bots',
+ 'speckbot', => 'bots',
+ 'pasteling', => 'bots',
+ 'rakudo_svn', => 'bots',
+ 'purl', => 'bots',
+ 'svnbotlt', => 'bots',
+ 'dalek', => 'bots',
+ 'hugme', => 'bots',
+ 'garfield', => 'bots',
);
# additional classes for nicks, sorted by frequency of speech:
my @nick_classes = map { "nick$_" } (1 .. 9);
# Default channel: this channel will be shown if no channel=... arg is given
-my $default_channel = 'perl6';
+my $default_channel = 'sugar-newbies';
# End of config
my $q = new CGI;
my $dbh = get_dbh();
my $channel = $q->param('channel') || $default_channel;
+my $meetings = $q->param('meetings') || 0;
my $date = $q->param('date') || gmt_today();
if ($date eq 'today') {
$date = gmt_today();
@@ -70,24 +71,34 @@ if ($date eq gmt_today()) {
print http_header();
}
+my $full_date = $date;
+($date, ) = split('T', $date) if $meetings;
if ($channel !~ m/\A[.\w-]+\z/smx){
# guard against channel=../../../etc/passwd or so
confess 'Invalid channel name';
}
-my $count;
-{
- my $sth = $dbh->prepare_cached('SELECT COUNT(*) FROM irclog WHERE day = ?');
- $sth->execute($date);
+my $count = 0;
+
+if (abs(date($date) - date(gmt_today())) > 1) {
+ my $sth;
+ if ($meetings && $date != $full_date) {
+ $sth = $dbh->prepare_cached(
+ 'SELECT COUNT(*) FROM irclog WHERE meeting = ? AND channel = ?');
+ $sth->execute($full_date, $channel);
+ } else {
+ $sth = $dbh->prepare_cached(
+ 'SELECT COUNT(*) FROM irclog WHERE day = ? AND channel = ?');
+ $sth->execute($date, $channel);
+ }
$sth->bind_columns(\$count);
$sth->fetch();
$sth->finish();
}
-
{
- my $cache_key = $channel . '|' . $date . '|' . $count;
+ my $cache_key = $channel . '|' . $meetings . '|' . $full_date . '|' . $count;
# the average #perl6 day produces 100k to 400k of HTML, so with
# 50MB we have about 150 pages in the cache. Since most hits are
# the "today" page and those of the last 7 days, we still get a very
@@ -101,56 +112,110 @@ my $count;
if (defined $data){
print $data;
} else {
- $data = irclog_output($date, $channel);
+ $data = irclog_output();
$cache->set($cache_key, $data);
print $data;
}
}
sub irclog_output {
- my ($date, $channel) = @_;
-
my $full_channel = q{#} . $channel;
+ my @messages;
+ my @meeting_times;
+ my $template;
+ my $title;
+
+ if ($meetings && $date eq $full_date) {
+ my $sth = $dbh->prepare(
+ 'SELECT DISTINCT meeting FROM irclog ' .
+ 'WHERE day = ? AND channel = ? AND meeting IS NOT NULL');
+ $sth->execute($date, $full_channel);
+
+ while (my @row = $sth->fetchrow_array()) {
+ my ($date_, $time) = split(' ', $row[0]);
+ my $meeting = join('T', $date_, $time);
+ push @meeting_times, { meeting => $meeting, time => $time };
+ }
+
+ if (@meeting_times == 1) {
+ $full_date = $meeting_times[0]{'meeting'};
+ } else {
+ $template = 'template/day-meetings.tmpl';
+ $title = $channel . ($meetings ? ' meetings' : '') . ', ' . $date;
+ }
+ }
+
+ unless ($template) {
+ $template = 'template/day.tmpl';
+ irclog_populate_messages(\@messages);
+ $title = $channel . ($meetings ? ' meeting' : '') . ', ' . join(' ', split('T', $full_date));
+ }
+
my $t = HTML::Template->new(
- filename => 'template/day.tmpl',
+ filename => $template,
loop_context_vars => 1,
global_vars => 1,
die_on_bad_params => 0,
);
$t->param(ADMIN => 1) if ($q->param('admin'));
+ $t->param(
+ BASE_URL => $base_url,
+ CHANNEL => $channel,
+ TITLE => $title,
+ MEETINGS => $meetings ? '/meetings' : '',
+ MEETING_TIMES => \@meeting_times,
+ MESSAGES => \@messages,
+ DATE => $full_date,
+ );
- {
- my $clf = "channels/$channel.tmpl";
- if (-e $clf) {
- $t->param(CHANNEL_LINKS => q{} . read_file($clf));
+# check if previous/next date exists in database
+ unless ($meetings) {
+ my $q1 = $dbh->prepare(
+ 'SELECT COUNT(*) FROM irclog ' .
+ 'WHERE day = ? AND channel = ? AND NOT spam');
+ # Date::Simple magic ;)
+ my $tomorrow = date($date) + 1;
+ $q1->execute($tomorrow, $full_channel);
+ my ($res) = $q1->fetchrow_array();
+ if ($res){
+ my $next_url = $base_url . "$channel/$tomorrow";
+ # where the hell does the leading double slash come from?
+ $next_url =~ s{^//+}{/};
+ $t->param(NEXT_URL => $next_url);
}
- }
- $t->param(BASE_URL => $base_url);
- my $self_url = $base_url . "/$channel/$date";
- my $db = $dbh->prepare('SELECT id, nick, timestamp, line FROM irclog '
- . 'WHERE day = ? AND channel = ? AND NOT spam ORDER BY id');
- $db->execute($date, $full_channel);
-
-
-# determine which colors to use for which nick:
- {
- my $count = scalar @nick_classes + scalar @colors + 1;
- my $q1 = $dbh->prepare('SELECT nick, COUNT(nick) AS c FROM irclog'
- . ' WHERE day = ? AND channel = ? AND not spam'
- . " GROUP BY nick ORDER BY c DESC LIMIT $count");
- $q1->execute($date, $full_channel);
- while (my @row = $q1->fetchrow_array and @nick_classes){
- next unless length $row[0];
- my $n = quotemeta $row[0];
- unless (grep { $_->[0] =~ m/\A$n/smx } @colors){
- push @colors, [$row[0], shift @nick_classes];
- }
+
+ my $yesterday = date($date) - 1;
+ $q1->execute($yesterday, $full_channel);
+ ($res) = $q1->fetchrow_array();
+ if ($res){
+ my $prev_url = $base_url . "$channel/$yesterday";
+ $prev_url =~ s{^//+}{/};
+ $t->param(PREV_URL => $prev_url);
}
-# $t->param(DEBUG => Dumper(\@colors));
}
- my @msg;
+ return my_encode($t->output);
+}
+
+sub irclog_populate_messages {
+ my $messages = shift;
+
+ my $full_channel = q{#} . $channel;
+ my $self_url = $base_url . "/$channel/$date";
+ my $db;
+
+ if ($meetings) {
+ $db = $dbh->prepare(
+ 'SELECT id, nick, timestamp, line FROM irclog ' .
+ 'WHERE meeting = ? AND channel = ? AND NOT spam ORDER BY id');
+ $db->execute($full_date, $full_channel);
+ } else {
+ $db = $dbh->prepare(
+ 'SELECT id, nick, timestamp, line FROM irclog ' .
+ 'WHERE day = ? AND channel = ? AND NOT spam ORDER BY id');
+ $db->execute($date, $full_channel);
+ }
my $line = 1;
my $prev_nick = q{};
@@ -165,14 +230,14 @@ sub irclog_output {
my $message = $row[3];
next if $message =~ m/^\s*\[off\]/i;
- push @msg, message_line( {
+ push @$messages, message_line( {
id => $id,
nick => $nick,
timestamp => $timestamp,
message => $message,
line_number => ++$line_number,
prev_nick => $prev_nick,
- colors => \@colors,
+ colors => \%colors,
self_url => $self_url,
channel => $channel,
},
@@ -180,40 +245,6 @@ sub irclog_output {
);
$prev_nick = $nick;
}
-
- $t->param(
- CHANNEL => $channel,
- MESSAGES => \@msg,
- DATE => $date,
- );
-
-# check if previous/next date exists in database
- {
- my $q1 = $dbh->prepare('SELECT COUNT(*) FROM irclog '
- . 'WHERE channel = ? AND day = ? AND NOT spam');
- # Date::Simple magic ;)
- my $tomorrow = date($date) + 1;
- $q1->execute($full_channel, $tomorrow);
- my ($res) = $q1->fetchrow_array();
- if ($res){
- my $next_url = $base_url . "$channel/$tomorrow";
- # where the hell does the leading double slash come from?
- $next_url =~ s{^//+}{/};
- $t->param(NEXT_URL => $next_url);
- }
-
- my $yesterday = date($date) - 1;
- $q1->execute($full_channel, $yesterday);
- ($res) = $q1->fetchrow_array();
- if ($res){
- my $prev_url = $base_url . "$channel/$yesterday";
- $prev_url =~ s{^//+}{/};
- $t->param(PREV_URL => $prev_url);
- }
-
- }
-
- return my_encode($t->output);
}
diff --git a/cgi/search.pl b/cgi/search.pl
index 358176e..ce7663e 100755
--- a/cgi/search.pl
+++ b/cgi/search.pl
@@ -122,6 +122,7 @@ if (length($nick) or length($qs)){
$q1->execute(@args);
my @days;
my $c = 0;
+ my %colors;
my $line_number = 1; # not really needed any more
@@ -150,7 +151,7 @@ if (length($nick) or length($qs)){
message => $r2[3],
line_number => $line_number++,
prev_nick => $prev_nick,
- colors => [],
+ colors => \%colors,
link_url => $base_url . "out.pl?channel=$short_channel;date=$row[0]",
channel => $channel,
date => $found_day,
diff --git a/cgi/sugar.css b/cgi/sugar.css
index bf3cd67..848ba1f 100644
--- a/cgi/sugar.css
+++ b/cgi/sugar.css
@@ -23,8 +23,8 @@ hr { color: #c9f1d7; background-color: #c9f1d7; border-width: 1px; }
}
.header {
- margin-top: -4px;
- font-size: 48px;
+ margin-top: 22px;
+ font-size: 32px;
font-weight: lighter;
}
@@ -103,3 +103,15 @@ table {
text-align: right;
width: 54%;
}
+
+.index_mode {
+ float: right;
+}
+
+.calendar td {
+ color: gray;
+}
+
+.nick_filtering {
+ float: right;
+}
diff --git a/cgi/template/channel-index.tmpl b/cgi/template/channel-index.tmpl
index 8a76461..e6fc982 100644
--- a/cgi/template/channel-index.tmpl
+++ b/cgi/template/channel-index.tmpl
@@ -7,8 +7,17 @@
<div class="content">
<div class='box'>
<p>
- <a href="<TMPL_VAR NAME=BASE_URL><TMPL_VAR NAME=CHANNEL>/today">Today</a>
+ <a href="<TMPL_VAR NAME=BASE_URL><TMPL_VAR NAME=CHANNEL><TMPL_VAR NAME=MEETINGS>/today">Today</a>
<TMPL_INCLUDE linkblock.tmpl>
+ <span class="index_mode">
+ <TMPL_IF MEETINGS>
+ <a href="<TMPL_VAR NAME=BASE_URL><TMPL_VAR NAME=CHANNEL>">Full logs</a> |
+ <a><strong>Meetings</strong></a>
+ <TMPL_ELSE>
+ <a><strong>Full logs</strong></a> |
+ <a href="<TMPL_VAR NAME=BASE_URL><TMPL_VAR NAME=CHANNEL><TMPL_VAR NAME=MEETINGS_SUBURL>">Meetings</a>
+ </TMPL_IF>
+ </span>
</p>
</div>
diff --git a/cgi/template/day-linkblock.tmpl b/cgi/template/day-linkblock.tmpl
index 68eb209..0b18610 100644
--- a/cgi/template/day-linkblock.tmpl
+++ b/cgi/template/day-linkblock.tmpl
@@ -1,8 +1,8 @@
<TMPL_IF NAME=PREV_URL>
<a href="<TMPL_VAR NAME=PREV_URL>">&nbsp;&#171; Previous day</a> |
</TMPL_IF>
-<a href="<TMPL_VAR NAME=BASE_URL><TMPL_VAR NAME=CHANNEL>">Index</a> |
-<a href="<TMPL_VAR NAME=BASE_URL><TMPL_VAR NAME=CHANNEL>/today">Today</a>
+<a href="<TMPL_VAR NAME=BASE_URL><TMPL_VAR NAME=CHANNEL><TMPL_VAR NAME=MEETINGS>">Index</a> |
+<a href="<TMPL_VAR NAME=BASE_URL><TMPL_VAR NAME=CHANNEL><TMPL_VAR NAME=MEETINGS>/today">Today</a>
<TMPL_IF NAME=NEXT_URL>
| <a href="<TMPL_VAR NAME=NEXT_URL>">Next day &#187;</a>
</TMPL_IF>
diff --git a/cgi/template/day-meetings.tmpl b/cgi/template/day-meetings.tmpl
new file mode 100644
index 0000000..e4fc55d
--- /dev/null
+++ b/cgi/template/day-meetings.tmpl
@@ -0,0 +1,23 @@
+<TMPL_INCLUDE NAME="header.tmpl">
+
+<div class='title'>
+ <h1 class="header">#<TMPL_VAR TITLE></h1>
+</div>
+
+<div class="content">
+ <div class='box'>
+ <p><TMPL_INCLUDE NAME='day-linkblock.tmpl'></p>
+ </div>
+
+ <ul>
+ <TMPL_LOOP MEETING_TIMES>
+ <li><a href="<TMPL_VAR BASE_URL><TMPL_VAR CHANNEL>/meetings/<TMPL_VAR MEETING>"><TMPL_VAR TIME></a></li>
+ </TMPL_LOOP>
+ </ul>
+
+ <TMPL_INCLUDE footer.tmpl>
+</div>
+
+</body>
+
+</html>
diff --git a/cgi/template/day.tmpl b/cgi/template/day.tmpl
index 336b6ba..797c7fd 100644
--- a/cgi/template/day.tmpl
+++ b/cgi/template/day.tmpl
@@ -1,14 +1,13 @@
<TMPL_INCLUDE NAME="header.tmpl">
<div class='title'>
- <h1 class="header">#<TMPL_VAR CHANNEL>, <TMPL_VAR DATE></h1>
+ <h1 class="header">#<TMPL_VAR TITLE></h1>
</div>
<div class="content">
<div class='box'>
- <TMPL_VAR NAME=CHANNEL_LINKS DEFAULT="">
<p>
- <TMPL_INCLUDE NAME='day-linkblock.tmpl'> |
+ <TMPL_INCLUDE NAME='day-linkblock.tmpl'>
<a style="display: none;" id="filter_toggle"></a>
</p>
@@ -45,7 +44,6 @@
<div class='box'>
<p><TMPL_INCLUDE NAME='day-linkblock.tmpl'></p>
- <TMPL_VAR NAME=CHANNEL_LINKS DEFAULT="">
</div>
<TMPL_INCLUDE footer.tmpl>
diff --git a/cgi/template/footer.tmpl b/cgi/template/footer.tmpl
index 1007ef2..0fb0545 100644
--- a/cgi/template/footer.tmpl
+++ b/cgi/template/footer.tmpl
@@ -1,6 +1,6 @@
<div class="foot">
<p>
- Powered by <a href="http://moritz.faui2k3.org/en/ilbot">ilbot</a>/<a href="http://wiki.sugarlabs.org/go/Service/IRC_bot">Modified</a>.<br />
+ Powered by <a href="http://moritz.faui2k3.org/en/ilbot">ilbot</a>/<a href="http://git.sugarlabs.org/projects/ilbot">Modified</a>.<br />
<a href="http://wiki.sugarlabs.org/go/Service/IRC_bot#Administrative_contact">Support</a>
</p>
</div>
diff --git a/cgi/template/line.tmpl b/cgi/template/line.tmpl
index 0c4d81b..02acb48 100644
--- a/cgi/template/line.tmpl
+++ b/cgi/template/line.tmpl
@@ -3,7 +3,7 @@
<td class="checkbox"><input type="checkbox" name="range" value="<TMPL_VAR ID>" size="1" style="width:1em"/></td>
<td class="checkbox"><input type="checkbox" name="single" value="<TMPL_VAR ID>" size="1" style="width:1em"/></td>
</TMPL_IF>
- <td class="time" id="i_<TMPL_VAR ID>"><a href="<TMPL_VAR BASE_URL><TMPL_VAR CHANNEL>/<TMPL_VAR DATE>#i_<TMPL_VAR ID>"><TMPL_VAR TIME></a></td>
- <td class="nick<TMPL_IF NICK_CLASS> <TMPL_VAR NICK_CLASS></TMPL_IF>"><TMPL_VAR NICK></td>
+ <td class="time" id="i_<TMPL_VAR ID>"><a href="<TMPL_VAR BASE_URL><TMPL_VAR CHANNEL><TMPL_VAR MEETINGS>/<TMPL_VAR DATE>#i_<TMPL_VAR ID>"><TMPL_VAR TIME></a></td>
+ <td class="nick<TMPL_IF NICK_CLASS> <TMPL_VAR NICK_CLASS></TMPL_IF>"<TMPL_IF NICK_COLOR> style="color: <TMPL_VAR NICK_COLOR>;"</TMPL_IF>><TMPL_VAR NICK></td>
<td class="msg<TMPL_IF MSG_CLASS> <TMPL_VAR MSG_CLASS></TMPL_IF> <TMPL_VAR NAME=SEARCH_FOUND DEFAULT=''>"><TMPL_VAR NAME=MESSAGE ESCAPE=0></td>
</tr>
diff --git a/ilbot.sql b/ilbot.sql
index 0845e15..7fb6a76 100644
--- a/ilbot.sql
+++ b/ilbot.sql
@@ -19,13 +19,13 @@
-- Table structure for table `irclog`
--
-DROP TABLE IF EXISTS `irclog`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `irclog` (
`id` int(11) NOT NULL auto_increment,
`channel` varchar(30) default NULL,
`day` char(10) default NULL,
+ `meeting` datetime default NULL,
`nick` varchar(40) default NULL,
`timestamp` int(11) default NULL,
`line` mediumtext,
@@ -34,6 +34,7 @@ CREATE TABLE `irclog` (
KEY `nick_index` (`nick`),
KEY `day_index` (`day`),
KEY `irclog_day_channel_idx` (`day`,`channel`),
+ KEY `irclog_meeting_channel_idx` (`meeting`, `channel`),
KEY `channel_idx` (`channel`),
FULLTEXT KEY `message_index` (`line`)
) ENGINE=MyISAM AUTO_INCREMENT=2357358 DEFAULT CHARSET=utf8;
diff --git a/lib/IrcLog/NickColorizer.pm b/lib/IrcLog/NickColorizer.pm
new file mode 100644
index 0000000..996d3c7
--- /dev/null
+++ b/lib/IrcLog/NickColorizer.pm
@@ -0,0 +1,94 @@
+# Code was generated by python code:
+#
+# import plplot
+#
+# palette = file(__file__[:-3] + '.pm', 'w')
+# palette.write('# Code was generated by python code:\n#\n')
+# palette.write(''.join(['#\t%s' % i for i in file(__file__).readlines()]))
+#
+# palette.write('\npackage IrcLog::NickColorizer;\n\n')
+# palette.write('our @palette = (\n')
+# for h in range(0, 360, 10):
+# for l in [2, 4]:
+# r, g, b = plplot.plhlsrgb(h, (1.0 / 6) * l, 0.75)
+# color = '#%02x%02x%02x' % (int(r * 255), int(g * 255), int(b * 255))
+# palette.write('\t"%s",\n' % color)
+# palette.write(');')
+#
+
+package IrcLog::NickColorizer;
+
+our @palette = (
+ "#941515",
+ "#e96a6a",
+ "#942a15",
+ "#e97f6a",
+ "#943f15",
+ "#e9946a",
+ "#945515",
+ "#e9aa6a",
+ "#946a15",
+ "#e9bf6a",
+ "#947f15",
+ "#e9d46a",
+ "#949415",
+ "#e9e96a",
+ "#7f9415",
+ "#d4e96a",
+ "#6a9415",
+ "#bfe96a",
+ "#559415",
+ "#aae96a",
+ "#3f9415",
+ "#94e96a",
+ "#2a9415",
+ "#7fe96a",
+ "#159415",
+ "#6ae96a",
+ "#15942a",
+ "#6ae97f",
+ "#15943f",
+ "#6ae994",
+ "#159455",
+ "#6ae9aa",
+ "#15946a",
+ "#6ae9bf",
+ "#15947f",
+ "#6ae9d4",
+ "#159494",
+ "#6ae9e9",
+ "#157f94",
+ "#6ad4e9",
+ "#156a94",
+ "#6abfe9",
+ "#155594",
+ "#6aaae9",
+ "#153f94",
+ "#6a94e9",
+ "#152a94",
+ "#6a7fe9",
+ "#151594",
+ "#6a6ae9",
+ "#2a1594",
+ "#7f6ae9",
+ "#3f1594",
+ "#946ae9",
+ "#551594",
+ "#aa6ae9",
+ "#6a1594",
+ "#bf6ae9",
+ "#7f1594",
+ "#d46ae9",
+ "#941594",
+ "#e96ae9",
+ "#94157f",
+ "#e96ad4",
+ "#94156a",
+ "#e96abf",
+ "#941555",
+ "#e96aaa",
+ "#94153f",
+ "#e96a94",
+ "#94152a",
+ "#e96a7f",
+); \ No newline at end of file
diff --git a/lib/IrcLog/WWW.pm b/lib/IrcLog/WWW.pm
index 5c99bf0..8376571 100644
--- a/lib/IrcLog/WWW.pm
+++ b/lib/IrcLog/WWW.pm
@@ -10,6 +10,7 @@ use POSIX qw(ceil);
use Config::File;
use Carp qw(confess cluck);
use utf8;
+use B;
my $uri_regexp = $RE{URI}{HTTP};
$uri_regexp =~ s/http/https?/g;
@@ -35,6 +36,7 @@ use constant TAB_WIDTH => 4;
use constant NBSP => decode_entities("&nbsp;");
use constant ENTITIES => qq{<>"&};
+use IrcLog::NickColorizer;
sub http_header {
my $config = shift || {};
@@ -511,20 +513,16 @@ sub message_line {
$h{NICK} = "";
push @classes, 'cont';
}
- # determine nick color:
- # Now that we give each <tr> (with a non-special message) classes of
- # 'nick' and "nick_$nick", this is probably better done with CSS:
- #
- # tr.nick_TimToady td.nick { color: green; font-weight: bold; }
- # tr.nick_KyleHa td.nick { color: #005500; }
- # tr.nick_tann_ td.nick { color: #ff0077; }
-
-NICK: foreach (@$colors){
- my $n = quotemeta $_->[0];
- if ($nick =~ m/^$n/ or $nick =~ m/^\* $n/){
- $h{NICK_CLASS} = $_->[1];
- last NICK;
- }
+
+ # determine nick color according to its nick name hash
+ my $nick_strip = $nick;
+ $nick_strip =~ s/^[\W_0-9]+//;
+ $nick_strip =~ s/[\W_0-9]+$//;
+ if (exists($colors->{$nick_strip})) {
+ $h{NICK_CLASS} = $colors->{$nick_strip};
+ } else {
+ $h{NICK_COLOR} = $IrcLog::NickColorizer::palette[
+ hex(B::hash($nick_strip)) % @IrcLog::NickColorizer::palette];
}
if ($nick =~ /\A\*\ /smx) {