summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/src/html/javapage.pl
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2017-04-29 18:21:56 -0400
committerFranklin Wei <git@fwei.tk>2017-04-29 18:24:42 -0400
commit881746789a489fad85aae8317555f73dbe261556 (patch)
treecec2946362c4698c8db3c10f3242ef546c2c22dd /apps/plugins/puzzles/src/html/javapage.pl
parent03dd4b92be7dcd5c8ab06da3810887060e06abd5 (diff)
downloadrockbox-881746789a489fad85aae8317555f73dbe261556.tar.gz
rockbox-881746789a489fad85aae8317555f73dbe261556.zip
puzzles: refactor and resync with upstream
This brings puzzles up-to-date with upstream revision 2d333750272c3967cfd5cd3677572cddeaad5932, though certain changes made by me, including cursor-only Untangle and some compilation fixes remain. Upstream code has been moved to its separate subdirectory and future syncs can be done by simply copying over the new sources. Change-Id: Ia6506ca5f78c3627165ea6791d38db414ace0804
Diffstat (limited to 'apps/plugins/puzzles/src/html/javapage.pl')
-rwxr-xr-xapps/plugins/puzzles/src/html/javapage.pl104
1 files changed, 104 insertions, 0 deletions
diff --git a/apps/plugins/puzzles/src/html/javapage.pl b/apps/plugins/puzzles/src/html/javapage.pl
new file mode 100755
index 0000000000..cd5e6a1669
--- /dev/null
+++ b/apps/plugins/puzzles/src/html/javapage.pl
@@ -0,0 +1,104 @@
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6open my $footerfile, "<", shift @ARGV or die "footer: open: $!\n";
7my $footer = "";
8$footer .= $_ while <$footerfile>;
9close $footerfile;
10
11for my $arg (@ARGV) {
12 $arg =~ /(.*\/)?([^\/]+)\.html$/ or die;
13 my $filename = $2;
14 open my $gamefile, "<", $arg or die "$arg: open: $!\n";
15 my $unfinished = 0;
16 my $docname = $filename;
17 chomp(my $puzzlename = <$gamefile>);
18 while ($puzzlename =~ s/^([^:=]+)(=([^:]+))?://) {
19 if ($1 eq "unfinished") {
20 $unfinished = 1;
21 } elsif ($1 eq "docname") {
22 $docname = $3;
23 } else {
24 die "$arg: unknown keyword '$1'\n";
25 }
26 }
27 my $instructions = "";
28 $instructions .= $_ while <$gamefile>;
29 close $gamefile;
30
31 open my $outpage, ">", "${filename}.html";
32
33 my $unfinishedtitlefragment = $unfinished ? "an unfinished puzzle " : "";
34 my $unfinishedheading = $unfinished ? "<h2 align=center>an unfinished puzzle</h2>\n" : "";
35 my $unfinishedpara;
36 my $links;
37 if ($unfinished) {
38 $unfinishedpara = <<EOF;
39<p>
40You have found your way to a page containing an <em>unfinished</em>
41puzzle in my collection, not linked from the <a href="../">main
42puzzles page</a>. Don't be surprised if things are hard to understand
43or don't work as you expect.
44EOF
45 $links = <<EOF;
46<p align="center">
47<a href="../">Back to main puzzles page</a> (which does not link to this)
48EOF
49 } else {
50 $unfinishedpara = "";
51 $links = <<EOF;
52<p align="center">
53<a href="../doc/${docname}.html#${docname}">Full instructions</a>
54|
55<a href="../">Back to main puzzles page</a>
56EOF
57 }
58
59 print $outpage <<EOF;
60<html>
61<head>
62<title>${puzzlename}, ${unfinishedtitlefragment}from Simon Tatham's Portable Puzzle Collection</title>
63<link rel="stylesheet" type="text/css" href="../../sitestyle.css" name="Simon Tatham's Home Page Style">
64<script type="text/javascript" src="resize-puzzle-applet.js"></script>
65</head>
66<body onLoad="initResizablePuzzleApplet();">
67<h1 align=center>${puzzlename}</h1>
68${unfinishedheading}
69<h2 align=center>from Simon Tatham's Portable Puzzle Collection</h2>
70
71${unfinishedpara}
72
73<p align="center">
74<table cellpadding="0">
75<tr>
76<td>
77<applet id="applet" archive="${filename}.jar" code="PuzzleApplet"
78 width="700" height="500">
79</applet>
80</td>
81<td>
82<div id="eresize" style="width:5px;height:500px;cursor:e-resize;"></div>
83</td>
84</tr>
85<td>
86<div id="sresize" style="width:700px;height:5px;cursor:s-resize;"></div>
87</td>
88<td>
89<div id="seresize" style="width:5px;height:5px;cursor:se-resize;"></div>
90</td>
91</tr>
92</table>
93
94${instructions}
95
96${links}
97
98${footer}
99</body>
100</html>
101EOF
102
103 close $outpage;
104}