From aab27f4797520292ad85354d305c61b76223d4c0 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sat, 12 Oct 2013 13:35:57 +0000 Subject: [PATCH] Improve factoids export to use tablesorter --- PBot/Factoids.pm | 62 ++++++++++++++++++++++++++++++++++++++++++------ PBot/VERSION.pm | 2 +- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/PBot/Factoids.pm b/PBot/Factoids.pm index 2aca3074..cd4bd50a 100644 --- a/PBot/Factoids.pm +++ b/PBot/Factoids.pm @@ -14,6 +14,7 @@ $VERSION = $PBot::PBot::VERSION; use HTML::Entities; use Time::HiRes qw(gettimeofday); use Carp (); +use POSIX qw(strftime); use PBot::FactoidModuleLauncher; use PBot::DualIndexHashObject; @@ -114,15 +115,31 @@ sub export_factoids { open FILE, "> $filename" or return "Could not open export path."; my $time = localtime; - print FILE "Last updated at $time\n"; + print FILE "\n\n"; + print FILE '' . "\n"; + print FILE '' . "\n"; + print FILE "\nLast updated at $time\n"; print FILE "

Candide's factoids

\n"; my $i = 0; + my $table_id = 1; foreach my $channel (sort keys %{ $self->factoids->hash }) { my $chan = $channel eq '.*' ? 'Global channel' : "Channel $channel"; - print FILE "
\n

$chan

\n
\n"; - print FILE "\n"; + print FILE "
\n

$chan

\n
\n"; + print FILE "
\n"; + print FILE "\n\n"; + print FILE "\n"; + print FILE "\n"; + print FILE "\n"; + print FILE "\n"; + print FILE "\n"; + print FILE "\n"; + print FILE "\n"; + print FILE "\n"; + print FILE "\n\n\n"; + $table_id++; + foreach my $trigger (sort keys %{ $self->factoids->hash->{$channel} }) { if($self->factoids->hash->{$channel}->{$trigger}->{type} eq 'text') { $i++; @@ -132,20 +149,51 @@ sub export_factoids { print FILE "\n"; } + print FILE "\n"; + print FILE "\n"; + + print FILE "\n"; + my $action = $self->factoids->hash->{$channel}->{$trigger}->{action}; $action =~ s/(.*?)http(s?:\/\/[^ ]+)/encode_entities($1) . "http" . encode_entities($2) . "<\/a>"/ge; $action =~ s/(.*)<\/a>(.*$)/"$1<\/a>" . encode_entities($2)/e; - print FILE "\n"; - - print FILE "\n\n"; + + if(exists $self->factoids->hash->{$channel}->{$trigger}->{edited_by}) { + print FILE "\n"; + print FILE "\n"; + } else { + print FILE "\n"; + print FILE "\n"; + } + + print FILE "\n"; + + if(exists $self->factoids->hash->{$channel}->{$trigger}->{last_referenced_on}) { + print FILE "\n"; + } else { + print FILE "\n"; + } + + print FILE "\n"; } } - print FILE "
ownercreated ontimes referencedfactoidlast edited byedited datelast referenced bylast referenced date
" . $self->factoids->hash->{$channel}->{$trigger}->{owner} . "" . encode_entities(strftime "%Y/%m/%d %H:%M:%S", localtime $self->factoids->hash->{$channel}->{$trigger}->{created_on}) . "" . $self->factoids->hash->{$channel}->{$trigger}->{ref_count} . "$trigger is " . $action . "- submitted by " . $self->factoids->hash->{$channel}->{$trigger}->{owner} . "
" . localtime($self->factoids->hash->{$channel}->{$trigger}->{created_on}) . "\n
" . $self->factoids->hash->{$channel}->{$trigger}->{edited_by} . "" . encode_entities(strftime "%Y/%m/%d %H:%M:%S", localtime $self->factoids->hash->{$channel}->{$trigger}->{edited_on}) . "" . $self->factoids->hash->{$channel}->{$trigger}->{ref_user} . "" . encode_entities(strftime "%Y/%m/%d %H:%M:%S", localtime $self->factoids->hash->{$channel}->{$trigger}->{last_referenced_on}) . "
\n"; + print FILE "\n\n"; } print FILE "
$i factoids memorized.
"; print FILE "
Last updated at $time\n"; + + print FILE "\n"; + print FILE "\n\n"; close(FILE); diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index ea7efa44..571a719f 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -13,7 +13,7 @@ use warnings; # These are set automatically by the build/commit script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 442, + BUILD_REVISION => 443, BUILD_DATE => "2013-10-12", };