chiark / gitweb /
Build test HTML wrapper pages for the Javascript puzzles.
authorSimon Tatham <anakin@pobox.com>
Wed, 20 Sep 2017 09:22:28 +0000 (10:22 +0100)
committerSimon Tatham <anakin@pobox.com>
Wed, 20 Sep 2017 17:03:44 +0000 (18:03 +0100)
This should make it less annoying for me to do local testing of the JS
output of a build, before I push a change. There's a new
build.out/jstest directory containing .html files suitable for loading
in a local browser, which refer to the JS files via an appropriate
relative path to the existing build.out/js directory.

Buildscr
html/jspage.pl

index d66150242ff3663f0babfef8f3df9c393cebab53..b8a585b43ea5c31dd74549b697f85d5a907cb03e 100644 (file)
--- a/Buildscr
+++ b/Buildscr
@@ -158,6 +158,16 @@ delegate emscripten
   return puzzles/js/*.js
 enddelegate
 
+# Build a set of wrapping HTML pages for easy testing of the
+# Javascript puzzles. These aren't quite the same as the versions that
+# will go on my live website, because those ones will substitute in a
+# different footer, and not have to link to the .js files with the
+# ../js/ prefix. But these ones should be good enough to just open
+# using a file:// URL in a browser after running a build, and make
+# sure the main functionality works.
+in puzzles do mkdir jstest
+in puzzles/jstest do ../html/jspage.pl --jspath=../js/ /dev/null ../html/*.html
+
 # 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
@@ -179,6 +189,7 @@ deliver puzzles/puzzles.zip $@
 deliver puzzles/puzzles.msi puzzles-$(Version)-installer.msi
 deliver puzzles/*.jar java/$@
 deliver puzzles/js/*.js js/$@
+deliver puzzles/jstest/*.html jstest/$@
 deliver puzzles/html/*.html html/$@
 deliver puzzles/html/*.pl html/$@
 deliver puzzles/wwwspans.html $@
index 37eea305caab599bd8e5113bf5195719f68074f2..b409783f150b5b9008460e85db8e046732f3c81d 100755 (executable)
@@ -3,6 +3,17 @@
 use strict;
 use warnings;
 
+my $jspath = "";
+while ($ARGV[0] =~ /^-/) {
+    my $opt = shift @ARGV;
+    last if $opt eq "--";
+    if ($opt =~ /^--jspath=(.+)$/) {
+        $jspath = $1;
+    } else {
+        die "jspage.pl: unrecognised option '$opt'\n";
+    }
+}
+
 open my $footerfile, "<", shift @ARGV or die "footer: open: $!\n";
 my $footer = "";
 $footer .= $_ while <$footerfile>;
@@ -62,7 +73,7 @@ EOF
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=ASCII" />
 <title>${puzzlename}, ${unfinishedtitlefragment}from Simon Tatham's Portable Puzzle Collection</title>
-<script type="text/javascript" src="${filename}.js"></script>
+<script type="text/javascript" src="${jspath}${filename}.js"></script>
 <style class="text/css">
 /* Margins and centring on the top-level div for the game menu */
 #gamemenu { margin-top: 0; margin-bottom: 0.5em; text-align: center }