diff options
author | John Ankarström <john@ankarstrom.se> | 2021-05-06 14:30:32 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-05-06 14:30:32 +0200 |
commit | d514585bbb54482ee62070bc86a7447a657afaee (patch) | |
tree | 9e8b46af9df7dfafa3fd66f111d48f9653bac52f | |
download | perlisdead-d514585bbb54482ee62070bc86a7447a657afaee.tar.gz |
First commit
-rw-r--r-- | gen.pl | 62 | ||||
-rw-r--r-- | run/benchmark | 20 | ||||
l--------- | run/blogs | 1 | ||||
l--------- | run/cpan | 1 | ||||
-rw-r--r-- | run/p5p | 31 | ||||
l--------- | run/reddit | 1 | ||||
-rw-r--r-- | run/rss | 34 | ||||
-rw-r--r-- | src/index.html | 73 | ||||
-rw-r--r-- | src/style.css | 40 |
9 files changed, 263 insertions, 0 deletions
@@ -0,0 +1,62 @@ +#!/usr/bin/perl + +# gen.pl -- generate static files for perlisdead.org + +use strict; +use warnings; +use experimental 'switch'; +use File::Copy; +use FindBin '$Bin'; + +# Change directory to script path +chdir $Bin; + +# Generate index.html +mkdir 'out' if ! -d 'out'; +open my $f, '<', 'src/index.html' or die "Could not open < src/index.html: $!"; +open my $g, '>', 'out/index.html.tmp' or die "Could not open > out/index.html.tmp: $!"; +for (<$f>) { + when (/^\.inc (.*)/) { + open my $h, '<', "inc/$1" or do { + warn "Could not open inc/$1: $!"; + next; + }; + print $g $_ while <$h>; + close $h; + } + when (/^\.eval (.*)/) { + no strict; no warnings; no experimental; + local *STDOUT = $g; + eval $1; + warn $@ if $@; + } + when (/^\.run (.*)/) { + open my $h, '<', "run/$1" or do { + warn "Could not open run/$1: $!"; + next; + }; + my $c = do { local $/; <$h> }; + close $h; + local *STDOUT = $g; + local $0 = "run/$1"; + no strict; no warnings; no experimental; + eval $c; + warn $@ if $@; + # I guess you could just shell out instead... + } + default { + print $g $_; + } +} +close $g; +close $f; + +# Copy static files +opendir my $dh, 'src' or die "Could not open directory src: $!"; +while (readdir $dh) { + copy "src/$_" => "out/$_" unless /^\./ or /^index\.html$/; +} +closedir $dh; + +# Rename temporary file +move 'out/index.html.tmp' => 'out/index.html'; diff --git a/run/benchmark b/run/benchmark new file mode 100644 index 0000000..4c20e0e --- /dev/null +++ b/run/benchmark @@ -0,0 +1,20 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +my @cmd = ( + q{date}, + q{perl5.32.0 -le 'print "Hello world!"'}, + q{python3.7 -c 'print("Hello world!")'}, + q{ruby26 -e 'puts "Hello world!"'}, +); +my @res; +for (1..3) { + @res = (); + for (reverse @cmd) { + (my $q = $_) =~ s/'/'"'"'/g; + push @res, "\$ time $_\n" . `bash -c 'time $q' 2>&1`; + } +} +print join("\n", reverse @res); diff --git a/run/blogs b/run/blogs new file mode 120000 index 0000000..81cf1df --- /dev/null +++ b/run/blogs @@ -0,0 +1 @@ +rss
\ No newline at end of file diff --git a/run/cpan b/run/cpan new file mode 120000 index 0000000..81cf1df --- /dev/null +++ b/run/cpan @@ -0,0 +1 @@ +rss
\ No newline at end of file @@ -0,0 +1,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; diff --git a/run/reddit b/run/reddit new file mode 120000 index 0000000..81cf1df --- /dev/null +++ b/run/reddit @@ -0,0 +1 @@ +rss
\ No newline at end of file @@ -0,0 +1,34 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use HTML::Entities; +use XML::Feed; +use Encode qw(decode encode); + +my %feeds = ( + blogs => 'http://blogs.perl.org/atom.xml', + reddit => 'https://www.reddit.com/r/perl/.rss', + cpan => 'https://metacpan.org/feed/recent', +); +(my $name = $0) =~ s,.*/,,; + +my $feed = XML::Feed->parse(URI->new($feeds{$name})) + or die XML::Feed->errstr; +my @entries = $feed->entries; + +# Print summary of five latest entries +for my $entry (@entries[0..4]) { + my $d = encode_entities $entry->issued->ymd; + my $f = encode_entities decode('utf8', $entry->author); + my $s = encode_entities decode('utf8', $entry->title); + my $l = encode_entities $entry->link; + print <<HTML +<div class="entry"> +<div class="date">$d</div> +<div class="from">$f</div> +<div class="subject"><a href="$l">$s</a></div> +</div> +HTML +} diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..679f9d2 --- /dev/null +++ b/src/index.html @@ -0,0 +1,73 @@ +<!DOCTYPE html> +<html lang="en"> +<head> +<meta charset="utf-8"/> +<title>Perl is Dead</title> +<link rel="stylesheet" type="text/css" href="style.css"/> +<meta name="description" content=""Perl is dead" is an urban legend and conspiracy theory alleging that famous programming language Perl, created by Larry Wall, died on 19 July 2000 and was secretly replaced by a whitespace-sensitive look-alike."/> +</head> +<body> +<h1 id="title">Perl is Dead<span style="color: #ccc;">?</span></h1> + +<p class="intro"> +<b>"Perl is dead"</b> is an urban legend and conspiracy theory alleging +that famous programming language Perl, created by Larry Wall, died +on 19 July 2000 and was secretly replaced by a whitespace-sensitive +look-alike. The rumour began circulating around 2000, but grew in +popularity after being reported on American news site Slashdot in +2005. Proponents based the theory on perceived clues found in Wall +speeches and Perl book covers. Clue-hunting proved infectious, and +within a few weeks had become an international phenomenon. +<cite>(paraphrased from <a href="https://en.wikipedia.org/wiki/Paul_is_dead">Wikipedia</a>…)</cite> + +<div style="float: right; border: 1px dashed #ccc; padding: 0 1em; margin: 1em -210px 1em 1em;"> +<pre> +.run benchmark +</pre> +</div> + +<p> +<b>Jokes aside, Perl is not dead.</b> +It is still an excellent choice for a host of applications. +It still has – by far – the fastest startup time among +all its competitors, as you can see in the figure to the right. +Every millisecond counts if you're building a command-line utility. + +<p> +<b>Furthermore, the language and its community continues to evolve +into the 2020s</b>. Below is a summary of the recent activity of various +Perl forums as of +.eval print scalar localtime, ".\n"; + +<div class="box" id="p5p" style="margin-left: -100px; width: 460px;"> +<h2>Latest messages on the <a href="https://lists.perl.org/list/perl5-porters.html">perl5-porters</a> mailing list</h2> +.run p5p +</div> + +<div class="box" id="blogs"> +<h2>Latest articles on <a href="http://blogs.perl.org">blogs.perl.org</a></h2> +.run blogs +</div> + +<div class="box" id="reddit"> +<h2>Latest posts on the <a href="https://reddit.com/r/perl">/r/perl</a> subreddit</h2> +.run reddit +</div> + +<div class="box" id="irc"> +<h2>Latest messages on the <a href="https://kiwiirc.com/nextclient/irc.freenode.net/#perl">#perl</a> IRC channel</h2> +.run irc +</div> + +<div class="box" id="perlmonks"> +<h2>Latest nodes on <a href="https://www.perlmonks.org">PerlMonks</a></h2> +.run perlmonks +</div> + +<div class="box" id="cpan"> +<h2>Latest uploads to <a href="https://metacpan.org">CPAN</a></h2> +.run cpan +</div> + +</body> +</html> diff --git a/src/style.css b/src/style.css new file mode 100644 index 0000000..f02e3f0 --- /dev/null +++ b/src/style.css @@ -0,0 +1,40 @@ +body { + font: 16px/1.4 Arial, Helvetica, sans-serif; + width: 600px; + margin: 0 auto; + padding: 0 1em; +} + +h1, h2, h3, h4, h5, h6 { + font-family: "Times New Roman", Times, serif; +} + +pre, code, tt { + font-size: 14px; +} + +h1#title { + text-align: center; +} + +p.intro { + font-size: 18px; + color: #d00; + margin: 0 1.8em; + text-align: justify; +} +p.intro cite { + font-size: 14px; + color: black; + opacity: 0.8; + font-style: normal; +} + +.box { + border: 1px dashed #ccc; + padding: 0 1em; + margin: 1em 0; +} +.box h2 { + font-size: 18px; +} |