Skip to content
This repository was archived by the owner on Jul 4, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions press/en/press.wml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,41 @@ some of the significant Tor-related stories that have popped up.</p>
</tr>
</thead>

<tr>
<td>2019 Jan 11</td>
<td>TechCrunch</td>
<td><a href='https://techcrunch.com/2019/01/11/tor-lessens-reliance-us-grants/'>
Tor pulls in record donations as it lessens reliance on US government grants</a></td>
</tr>

<tr>
<td>2019 Jan 01</td>
<td>Wired</td>
<td><a href='https://www.wired.com/story/tor-anonymity-easier-than-ever/'>
Tor Is Easier Than Ever. Time to Give It a Try</a></td>
</tr>

<tr>
<td>2018 Dec 18</td>
<td>BoingBoing</td>
<td><a href='https://boingboing.net/2018/12/18/charitablegivinguide.html'>
Charitable Giving Guide 2018</a></td>
</tr>

<tr>
<td>2018 Dec 10</td>
<td>ZDNet</td>
<td><a href='https://www.zdnet.com/article/half-of-the-tor-projects-funding-now-comes-from-the-private-sector/'>
Half of the Tor Project's funding now comes from the private sector</a></td>
</tr>

<tr>
<td>2018 Dec 10</td>
<td>CyberScoop</td>
<td><a href='https://www.cyberscoop.com/tor-funding-isabela-bagueros-december-2018/'>
"With new director, Tor seeks new funding sources and international growth"</a></td>
</tr>

<tr>
<td>2018 Nov 02</td>
<td>Motherboard</td>
Expand Down
37 changes: 26 additions & 11 deletions press/press.pl
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,53 @@
#use HTML::Escape qw/escape_html/;

my %pub; # save all publications
my $debug = 0;

sub debug {
my $msg = shift;
print "$msg\n" if $debug;
}
sub parse_line {
my $str = shift;
debug "Parsing:\n$str";
if ($str =~ /(\d+\/\d+\/\d+),([^,]+),(.+),(.+)/) { # magic regex :)
my $time = Time::Piece->strptime($1, "%m/%d/%y"); # given format: MM/DD/YY
my $date = $time->strftime("%Y %b %d");
chomp(my $source = $2);
$pub{$time->epoch} = "<tr>\n<td>$date</td>\n<td>$source</td>\n<td><a href='$4'>\n$3</a></td>\n</tr>\n\n";
$pub{$time->epoch} .= "<tr>\n<td>$date</td>\n<td>$source</td>\n<td><a href='$4'>\n$3</a></td>\n</tr>\n\n";
# TODO use uniqe keys to avoid .=
debug "Added: $pub{$time->epoch}"
}
}

unless (@ARGV) { print "Usage: $0 /path/to/csv/file > file\n"; exit 1; }
unless (@ARGV) { print "Usage: $0 [-d] /path/to/csv/file > file\n"; exit 1; }

# parse all arguments (hopefully existing files)
foreach my $arg (@ARGV) {
chomp($arg);
if (-f $arg) {
# we are lucky, this looks like a file
debug "arg: $arg";
if ($arg eq '-d') {
$debug++;
debug "Enabling debug output on request."
} elsif (-f "$arg") {
debug 'argument looks like a file.';
open my $fh, '<', $arg
or warn "Can't open '$arg': $!\n" and next;
or die "Can't open '$arg': $!\n";
debug "Reading $arg.";
foreach (<$fh>) {
parse_line $_;
# https://stackoverflow.com/questions/6373888/converting-newline-formatting-from-mac-to-windows
foreach my $line (split '\r', $_) {
parse_line $line;
}
}
close $fh;
close $fh; debug "Finished reading $arg."
} else {
# this is no file, let's assume we got piped a string to parse
debug 'argument is no file, assuming piped string.';
parse_line $arg;
}
}

# share our treasure with the world
my $str = join '', map { $pub{$_} } reverse sort keys %pub;
if ($str) { print $str; }
debug "Generated final html string (". (scalar keys %pub) ." entries):";
if ($str) { print "$str\nAdd above to press/en/press.wml.\n"; }
else { print "Nothing found.\n"; exit 1; }
# TODO one day i want to able to update press/en/press.wml directly