webpage.pl 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/usr/bin/perl
  2. # Construct the two pieces of my main puzzle collection web page that
  3. # need to vary with the set of puzzles: the big list of <span>s with
  4. # puzzle pictures and links etc, and the list of Windows executable
  5. # files down in the downloads section.
  6. use strict;
  7. use warnings;
  8. use HTML::Entities;
  9. my $gamedesc = shift @ARGV;
  10. open my $desc, "<", $gamedesc
  11. or die "$gamedesc: open: $!\n";
  12. open my $spans, ">", "wwwspans.html"
  13. or die "wwwspans.html: open: $!\n";
  14. open my $links, ">", "wwwlinks.html"
  15. or die "wwwspans.html: open: $!\n";
  16. my $n = 0;
  17. while (<$desc>) {
  18. chomp;
  19. my ($id, $win, $displayname, $description, $summary) = split /:/, $_;
  20. printf $spans
  21. '<span class="puzzle"><table>'.
  22. '<tr><th align="center">%s</th></tr>'.
  23. '<tr><td align="center">'.
  24. '<a href="js/%s.html"><img style="margin: 0.5em" alt="" title="%s" width=150 height=150 border=0 src="%s-web.png" /></a>'.
  25. '</td></tr>'.
  26. '<tr><td align="center" style="font-size: 70%%"><code>[</code>'.
  27. ' <a href="java/%s.html">java</a> '.
  28. '|'.
  29. ' <a href="js/%s.html">js</a> '.
  30. '|'.
  31. ' <a href="doc/%s.html#%s">manual</a> '.
  32. '<code>]</code><br><code>[</code>'.
  33. ' <a href="%s"><code>%s</code></a> '.
  34. '<code>]</code></td></tr>'.
  35. '<tr><td align="center">%s</td></tr></table></span>'.
  36. "\n",
  37. encode_entities($displayname),
  38. encode_entities($id),
  39. encode_entities($description),
  40. encode_entities($id),
  41. encode_entities($id),
  42. encode_entities($id),
  43. encode_entities($id),
  44. encode_entities($id),
  45. encode_entities($win),
  46. encode_entities($win),
  47. encode_entities($summary);
  48. if ($n > 0) {
  49. if ($n % 5 == 0) {
  50. print $links "<br />";
  51. } else {
  52. print $links " | ";
  53. }
  54. }
  55. printf $links '<a href="%s">%s</a>',
  56. encode_entities($win), encode_entities($win);
  57. $n++;
  58. }
  59. close $desc;
  60. close $spans;
  61. close $links;