summaryrefslogtreecommitdiff
path: root/bucky2/rest/dropsy-web.pl
diff options
context:
space:
mode:
authorJules Laplace <carbon@melanarchy.org>2013-08-02 17:23:25 -0500
committerJules Laplace <carbon@melanarchy.org>2013-08-02 17:23:25 -0500
commite76b691e78e273226cba9284cb8cd22a423319ed (patch)
treea58d22f69869fe2bf3885f81bdda4952f87ff6d7 /bucky2/rest/dropsy-web.pl
parent753f60c7d4769fa72d3b910e491f37db6f130898 (diff)
bucky2
Diffstat (limited to 'bucky2/rest/dropsy-web.pl')
-rwxr-xr-xbucky2/rest/dropsy-web.pl103
1 files changed, 103 insertions, 0 deletions
diff --git a/bucky2/rest/dropsy-web.pl b/bucky2/rest/dropsy-web.pl
new file mode 100755
index 0000000..af2304d
--- /dev/null
+++ b/bucky2/rest/dropsy-web.pl
@@ -0,0 +1,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;
+ }