From 7cf7e37d65d59bc87977deb7e810f21b4b106797 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 13 Jan 2015 20:04:18 +0000 Subject: Script to autogenerate pieces of the web page. This should simplify the process of adding a new puzzle, by automating the part where I have to manually edit index.html separately from the main build step. --- webpage.pl | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 webpage.pl (limited to 'webpage.pl') diff --git a/webpage.pl b/webpage.pl new file mode 100755 index 0000000..800b183 --- /dev/null +++ b/webpage.pl @@ -0,0 +1,69 @@ +#!/usr/bin/perl + +# Construct the two pieces of my main puzzle collection web page that +# need to vary with the set of puzzles: the big list of s with +# puzzle pictures and links etc, and the list of Windows executable +# files down in the downloads section. + +use strict; +use warnings; +use HTML::Entities; + +open my $desc, "<", "gamedesc.txt" + or die "gamedesc.txt: open: $!\n"; + +open my $spans, ">", "wwwspans.html" + or die "wwwspans.html: open: $!\n"; + +open my $links, ">", "wwwlinks.html" + or die "wwwspans.html: open: $!\n"; + +my $n = 0; +while (<$desc>) { + chomp; + my ($id, $win, $displayname, $description, $summary) = split /:/, $_; + + printf $spans + ''. + ''. + ''. + ''. + '
%s
'. + ''. + '
['. + 'java'. + '|'. + 'js'. + '|'. + 'manual'. + ']
['. + '%s'. + ']
%s
'. + "\n", + encode_entities($displayname), + encode_entities($description), + encode_entities($id), + encode_entities($id), + encode_entities($id), + encode_entities($id), + encode_entities($id), + encode_entities($win), + encode_entities($win), + encode_entities($summary); + + if ($n > 0) { + if ($n % 5 == 0) { + print $links "
"; + } else { + print $links " | "; + } + } + printf $links '%s', + encode_entities($win), encode_entities($win); + + $n++; +} + +close $desc; +close $spans; +close $links; -- cgit v1.1