1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
#!/usr/bin/perl
use lib "../lib";
use Rest::Topsy;
use Rest::Dailyrotten;
my $topsy = new Rest::Topsy;
my $dr = new Rest::Dailyrotten;
$topsy->url('http://twitter.com/dailyrotten');
my $entries = $topsy->topsy_load;
my $stories = $dr->dailyrotten_load;
my $topsy_map = {};
map { $topsy_map->{$_->{'description'}} = $_->{'total'} } @$entries;
my $dr_topsy_match = [];
foreach my $day (@$stories)
{
my $is_ffa = 1;
foreach my $story (reverse @{ $day->{'post'} })
{
my $title = $story->{'title'};
my $rec =
{
date => nice_date($day->{'file'}),
title => $title,
forum => $story->{'comments'},
ffa => $is_ffa,
url => $story->{'url'},
};
$is_ffa = 0;
if (exists($topsy_map->{$title}))
{
$rec->{'topsy'} = $topsy_map->{$title},
}
push @$dr_topsy_match, $rec;
}
if ($dr_topsy_match->[-1]->{'forum'} > 100)
{ $dr_topsy_match->[-1]->{'ffa'} = 1; }
}
print_report("title", [(sort { lc $a->{'title'} cmp lc $b->{'title'} } @$dr_topsy_match)]);
print_report("date", [(sort { $b->{'date'} cmp $a->{'date'} } @$dr_topsy_match )]);
print_report("topsy", [(sort { $b->{'topsy'} <=> $a->{'topsy'} } @$dr_topsy_match)]);
print_report("forum", [(sort { $b->{'forum'} <=> $a->{'forum'} } @$dr_topsy_match)]);
sub print_report
{
my ($title, $matches) = @_;
my $out .= header($title);
foreach my $p (@$matches)
{
$out .= "<tr>";
$out .= "<td align='right'>". $p->{'date'} ."</td>";
my $ffa_class = " bold" if $p->{'ffa'};
$out .= "<td align='right' class='$ffa_class'>". $p->{'forum'} ."</td>";
my $topsy_class = " bold" if $p->{'topsy'} > 100;
$out .= "<td align='right' class='topsy$topsy_class'>". $p->{'topsy'} ."</td>";
$out .= "<td align='left'><a href=\"$p->{'url'}\">". $p->{'title'} ."</a></td>";
$out .= "</tr>";
}
$out .= footer();
$topsy->write_data("../tmp/dr/".$title.".html", $out);
}
sub header
{ my $current = shift; my $out .= <<__HEADER__;
<html>
<head>
<style type="text/css">
<!--
body {font-size: 13px; }
th {font-size: 13px; text-align: left;}
td {font-size: 13px; }
td a {font-size: 16px; }
td.topsy a {font-size: 16px;}
td.topsy a {display: none;}
td.bold { font-weight: bold; }
-->
</style>
</head>
<body>
<b>date</b> = date posted on <a href="http://www.dailyrotten.com/">daily rotten</a> = date twittered<br>
<b>forum</b> = comments on dailyrotten forum (FFAs are bold)<br>
<b>topsy</b> = number of other people tweeting this story as calculated by <a href="http://topsy.com/twitter/dailyrotten">topsy</a><br>
<b>title</b> = title of article<br>
<table border=0 cellpadding=0 cellspacing=5>
<tbody>
<tr>
<th>
__HEADER__
$out .= join "</th><th>", map { $current eq $_ ? "<b>$_</b>" : "<a href='$_.html'>$_</a>" } qw[date forum topsy title];
$out .= "</th></tr>";
return $out;
}
sub footer
{ return "</tbody></table></body></html>"; }
sub nice_date
{
my ($date) = @_;
$date =~ s/^_//;
$date =~ s/\.html$//;
return $date;
}
|