chiark / gitweb /
Script to autogenerate pieces of the web page.
authorSimon Tatham <anakin@pobox.com>
Tue, 13 Jan 2015 20:04:18 +0000 (20:04 +0000)
committerSimon Tatham <anakin@pobox.com>
Tue, 13 Jan 2015 20:04:18 +0000 (20:04 +0000)
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.

Buildscr
CHECKLST.txt
webpage.pl [new file with mode: 0755]

index e3997a061129078fc975f25202d03e1faea0262a..e63df1bd92df55baf1c5d049c06daf5de0a604bf 100644 (file)
--- a/Buildscr
+++ b/Buildscr
@@ -146,6 +146,9 @@ delegate emscripten
   return puzzles/js/*.js
 enddelegate
 
+# Build the autogenerated pieces of the main web page.
+in puzzles do perl webpage.pl
+
 # Set up .htaccess containing a redirect for the archive filename.
 in puzzles do echo "AddType application/octet-stream .chm" > .htaccess
 in puzzles do echo "AddType application/octet-stream .hlp" >> .htaccess
@@ -169,6 +172,8 @@ deliver puzzles/*.jar java/$@
 deliver puzzles/js/*.js js/$@
 deliver puzzles/html/*.html html/$@
 deliver puzzles/html/*.pl html/$@
+deliver puzzles/wwwspans.html $@
+deliver puzzles/wwwlinks.html $@
 
 # deliver puzzles/puzzles.armv4.cab $@ # (not built at the moment)
 
index 169f8341ed619dfe15be13f39160ea761e7a8ef5..715f7466461d7f2bf5bd2a7c524861d045fb6d7e 100644 (file)
@@ -59,17 +59,11 @@ might have been involved.
 Check in!
 
 Put the puzzle on the web:
- - run puzzlesnap first
- - make sure the screenshot and Windows binary have arrived in the www
-   directory, and that the .jar file and its accompanying web page has
-   arrived in the java subdirectory
- - add an entry in the puzzles list in index.html
- - add the Windows executable name to the list further down
-   index.html
- - adjust the copyright in index.html if the puzzle is by a new
+ - run puzzlesnap.sh
+ - adjust the copyright in index-mid.html if the puzzle is by a new
    author
- - test that the binary link and the docs link work
- - test that the Java version works
+ - check that the new puzzle has appeared on the staging web page
+ - test both Windows binary links, the docs link, the Javascript
+   version and the Java version
  - run webupdate
- - test again
- - check in the change to index.html
+ - test all those things once more on the live website
diff --git a/webpage.pl b/webpage.pl
new file mode 100755 (executable)
index 0000000..800b183
--- /dev/null
@@ -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;