diff options
| author | Simon Tatham <anakin@pobox.com> | 2015-01-13 20:04:18 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2015-01-13 20:04:18 +0000 |
| commit | 7cf7e37d65d59bc87977deb7e810f21b4b106797 (patch) | |
| tree | 75baadeec318c119724205be09a9f1d5672687a3 /webpage.pl | |
| parent | e3a8e64812f2fa783dc5644f04f267a291bc6098 (diff) | |
| download | puzzles-7cf7e37d65d59bc87977deb7e810f21b4b106797.zip puzzles-7cf7e37d65d59bc87977deb7e810f21b4b106797.tar.gz puzzles-7cf7e37d65d59bc87977deb7e810f21b4b106797.tar.bz2 puzzles-7cf7e37d65d59bc87977deb7e810f21b4b106797.tar.xz | |
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.
Diffstat (limited to 'webpage.pl')
| -rwxr-xr-x | webpage.pl | 69 |
1 files changed, 69 insertions, 0 deletions
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 <span>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 + '<span class="puzzle"><table>'. + '<tr><th align="center">%s</th></tr>'. + '<tr><td align="center">'. + '<image style="margin: 0.5em" alt="" title="%s" width=150 height=150 border=0 src="%s-web.png" />'. + '</td></tr>'. + '<tr><td align="center" style="font-size: 70%%"><code>[</code>'. + '<a href="java/%s.html">java</a>'. + '|'. + '<a href="js/%s.html">js</a>'. + '|'. + '<a href="doc/%s.html#%s">manual</a>'. + '<code>]</code><br><code>[</code>'. + '<a href="%s"><code>%s</code></a>'. + '<code>]</code></td></tr>'. + '<tr><td align="center">%s</td></tr></table></span>'. + "\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 "<br />"; + } else { + print $links " | "; + } + } + printf $links '<a href="%s">%s</a>', + encode_entities($win), encode_entities($win); + + $n++; +} + +close $desc; +close $spans; +close $links; |