Add table of contents to quotegrabs html export

This commit is contained in:
Pragmatic Software 2013-10-13 10:23:20 +00:00
parent 7cf8e91ab2
commit b6a09e50e3
2 changed files with 12 additions and 2 deletions

View File

@ -116,7 +116,6 @@ sub export_quotegrabs() {
return "Not enabled" if not defined $self->{export_path};
my $text;
my $table_id = 1;
my $last_channel = "";
my $had_table = 0;
open FILE, "> $self->{export_path}" or return "Could not open export path.";
my $time = localtime;
@ -125,9 +124,20 @@ sub export_quotegrabs() {
print FILE '<script type="text/javascript" src="js/jquery.tablesorter.js"></script>' . "\n";
print FILE "</head>\n<body><i>Generated at $time</i><hr><h2>Candide's Quotegrabs</h2>\n";
my $i = 0;
my $last_channel = "";
foreach my $quotegrab (sort { $$a{channel} cmp $$b{channel} or $$a{nick} cmp $$b{nick} } @{ $self->{quotegrabs} }) {
if(not $quotegrab->{channel} =~ /^$last_channel$/i) {
print FILE "<a href='#" . $quotegrab->{channel} . "'>" . encode_entities($quotegrab->{channel}) . "</a><br>\n";
$last_channel = $quotegrab->{channel};
}
}
$last_channel = "";
foreach my $quotegrab (sort { $$a{channel} cmp $$b{channel} or $$a{nick} cmp $$b{nick} } @{ $self->{quotegrabs} }) {
if(not $quotegrab->{channel} =~ /^$last_channel$/i) {
print FILE "</tbody>\n</table>\n" if $had_table;
print FILE "<a name='" . $quotegrab->{channel} . "'></a>\n";
print FILE "<hr><h3>$quotegrab->{channel}</h3><hr>\n";
print FILE "<table border=\"0\" id=\"table$table_id\" class=\"tablesorter\">\n";
print FILE "<thead>\n<tr>\n";

View File

@ -13,7 +13,7 @@ use warnings;
# These are set automatically by the build/commit script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 448,
BUILD_REVISION => 449,
BUILD_DATE => "2013-10-13",
};