aboutsummaryrefslogtreecommitdiff
path: root/run/p5p
blob: ebb0c62eababb6619912ad78cbe28ad157687b06 (plain)
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
#!/usr/bin/perl

use strict;
use warnings;
use Net::NNTP;
use HTML::Entities;

my $nntp = Net::NNTP->new('nntp.perl.org') or die "Cannot contact nntp.perl.org: $!";
my ($count, $first, $last) = $nntp->group('perl.perl5.porters');

my %d = %{$nntp->xhdr('Date', [$last-10, $last])};
my %f = %{$nntp->xhdr('From', [$last-10, $last])};
my %s = %{$nntp->xhdr('Subject', [$last-10, $last])};

# TODO: Escape potential HTML characters

for ((reverse sort keys %d)[0..4]) {
	$_ = encode_entities($_) for ($d{$_}, $f{$_}, $s{_});
	$f{$_} =~ s,@[^.]*\.,@<i>hidden</i>.,;
	print <<HTML;
<p>
<div style="font-size: 80%; margin: 0;">
<span class="date" style="line-height: 1;">Date: $d{$_}</span>
<br/><span class="from">From: $f{$_}</span>
</div>
<span class="subject">Subject: <a href="https://www.nntp.perl.org/group/perl.perl5.porters/0/0/msg$_.html">$s{$_}</a></span>
</p>
HTML
}

$nntp->quit;