Re: I have a few suggestions...
Daniel <centericq-CMtyRwdR+kLFwrUM129O6QC/[email protected]>
| Newsgroups | gmane.network.centericq |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Jul 26, 2006 at 08:00:19PM -0700, Stephen wrote: > greeting: > --- Chris Brown <[email protected]> wrote: > > > These are the things that I find bothersome about > > centericq, and I hope some > > day these ideas will be implemented: > > > > 1. Human-readable history files. Why don't the > > ~/.centericq/user/history > > files appear exactly as they do in onscreen > > scrollback in cicq? I find it very irritating to try > > to copy and paste large > > blocks of a conversation from history with the > > way it's currently structured. > > A nice script to read your history: > http://centericq.de/misc/cicqhist or use mine. It's attached. not sure why it never got put up centericq.de _______________________________________________ Cicq mailing list Cicq-xGejAJT2w6wWP6gT/[email protected] http://mailman.linuxpl.org/mailman/listinfo/cicq Questions? Check the FAQ first: http://centericq.de/faq/
cicq2html.pl
(text/x-perl, 4.8 KB)
#!/usr/bin/env perl
use POSIX qw(strftime);
use Data::Dumper;
use strict;
use File::Basename;
use Getopt::Long;
#NOTE: only yahoo, aim, msn, and icq
#### SETUP ###################################################################
my %opt;
GetOptions(\%opt,"out:s","help","root:s");
die "Output dir must exist.\n" if($opt{out} && ! -d $opt{out});
my $OUT = ($opt{out}) ? $opt{out} : ".";
my $ROOT = ($opt{root}) ? $opt{root} : "$ENV{HOME}/.centericq";
#### MAIN ####################################################################
if ($ARGV[0]) {
my $user = "$ROOT/$ARGV[0]";
my $who = userInfo($user);
contact2HTML($user,$who);
exit;
}
while(glob("$ROOT/[0-9aym]*")) {
next unless -d $_;
open INDEX, ">>$OUT/index.html";
$/="\n";
my $who = userInfo("$_");
printIndex(*INDEX,$who);
close INDEX;
contact2HTML($_,$who);
}
#### FUNCTIONS ###############################################################
sub printIndex {
my ($out,$who) = @_;
print $out qq|
<table border=0><tr><td width=150>
<a href="$$who{uin}.html">$$who{pref}</a><br>
</td><td width=150>
<a href="$$who{uin}.html">$$who{uin}</a><br>
</td><td>
<a href="$$who{uin}.html">$$who{protocol}</a><br>
</td></tr></table>
|;
}
sub userInfo {
my $user = shift;
my %who;
open FH, "<$user/info";
my @file = <FH>;
close FH;
$who{nick} = $file[0];
$who{first_name} = $file[1];
$who{last_name} = $file[2];
$who{email} = $file[3];
$who{user_nick} = $file[45];
$who{pref} = $who{user_nick} || $who{nick};
$who{uin} = basename($user);
my $protocol = substr($who{uin},0,1);
if ($protocol =~ /\d/) { $who{protocol} = "icq"; }
elsif ($protocol eq "m") { $who{protocol} = "msn"; }
elsif ($protocol eq "y") { $who{protocol} = "yahoo"; }
elsif ($protocol eq "a") { $who{protocol} = "aol"; }
unless ($who{protocol} eq "icq") { $who{uin} = substr($who{uin},1); }
while (my ($k,$v) = each %who) { chomp $v; $who{$k} = $v; }
return \%who;
}
sub contact2HTML {
my ($contact,$who) = @_;
$contact =~ s/\/+$//;
$/="\n";
open FH, "<$contact/history";
$$who{uin} ? open OUT, ">$OUT/$$who{uin}.html" : open OUT, ">&STDOUT";
$/='';
printHeader($who);
my $currentDay ="";
my $currentYear ="";
for (<FH>) {
my @bits = split '\n';
my ($trash1,$dir,$type,$time,$trash2,@bits) = @bits;
next unless $type eq "MSG";
my $Day = strftime "%a %b %e", localtime($time);
my $Year = strftime "%Y", localtime($time);
my $time = strftime "%H:%M:%S ", localtime($time);
$currentYear = newYear($currentYear,$Year);
$currentDay = newDay($currentDay,$Day);
print OUT "<TR> <TD class=time>$time </TD> ";
if ($dir eq "IN") { print OUT "<td class=them >$$who{pref}: </td>"; }
else { print OUT "<td class=me>Me:</td>"; }
my $msg = "@bits";
$msg =~ s///g;
$msg =~ s|http://(.*)\s|<a href="http://$1">http://$1</a>|g;
print OUT "<td colspan=100 class=msg>$msg </TD> </TR>\n";
}
close FH;
close OUT;
}
sub newDay {
my ($currentDay,$Day) = @_;
if ($currentDay ne "$Day") {
print OUT "</TABLE>" if $currentDay ne "";
$currentDay = $Day;
print OUT "</table></div>";
print OUT "<p><div class=table><span class=raised>$currentDay</span></tr>";
print OUT "<TABLE border=0>";
}
return $currentDay;
}
sub newYear {
my ($currentYear,$Year) = @_;
if ($currentYear ne "$Year") {
$currentYear = $Year;
print OUT "</table></div><p><font size=+2>$currentYear</font><hr>";
print OUT "<div><table>";
}
return $currentYear;
}
sub printHeader {
my $info = shift;
print OUT qq|
<body>
<STYLE TYPE="text/css">
body {
background-color: #8080B0;
font-family: arial;
}
.raised {
font-family: arial;
border: ridge black 2px;
position: relative;
top: -12px;
left: 12px;
padding: 4px;
background:#afafdf;
font-size: 13px;
}
.table {
background-color: #ddf;
margin-top: 15px;
border: ridge black 3px;
}
.me { font-size: 10pt; color: red }
.them { font-size: 10pt; color: blue }
.time { font-size: 10pt; color: black }
.msg { font-size: 10pt; color: black }
.heading { font-size: 18pt; color: black }
.caption {
font-weight: bold; text-align: left; font-size: 12pt; color: black
background: #7fffd4;
}
</STYLE>
<div class=heading>$$info{pref}</div><br>
|;
print OUT "<b>Name:</b> $$info{first_name} $$info{last_name}<br>\n";
print OUT "<b>Nick Name: </b> $$info{nick}<br>\n";
print OUT "<b>Screen Name (UIN): </b> $$info{uin}<br>\n";
print OUT "<b>Email:</b> $$info{email}<br>\n";
print OUT "<b>Protocol: </b> $$info{protocol} <br>\n";
}