Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

built a bit more on the web version

Doesn't quite work yet, though. The SVG doesn't show up in the browser.
  • Loading branch information...
commit c06e28c843e9bf6814b378c3343e97359d267559 1 parent b916228
@masak authored
Showing with 30 additions and 4 deletions.
  1. +27 −4 bin/web-druid
  2. +3 −0  lib/Druid/Webapp.pm
View
31 bin/web-druid
@@ -11,10 +11,15 @@ sub request($c) {
if $r.req_method eq 'GET' {
# log request info to the standard error stream
warn "{hhmm} GET {$r.url.path} {$r.header('User-Agent')}";
- my $qs = $r.url.path ~~ / '?' (.*) $/
- ?? $0
- !! '';
- $c.send_response( Druid::Webapp.page($qs) );
+ if $r.url.path eq '/board.svg' {
+ $c.send_response( svg-board() );
+ }
+ else {
+ my $qs = $r.url.path ~~ / '?' (.*) $/
+ ?? $0
+ !! '';
+ $c.send_response( Druid::Webapp.page($qs) );
+ }
}
else {
warn "{hhmm} rejected {$r.req_method} {$r.url.path}";
@@ -39,3 +44,21 @@ sub hhmm {
my $hhmm = "{$h.fmt('%02d')}:{$m.fmt('%02d')}";
return $hhmm;
}
+
+sub svg-board() {
+ return '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg xmlns="http://www.w3.org/2000/svg"
+ version="1.0"
+ width="400"
+ height="400">
+ <rect
+ width="400"
+ height="400"
+ x="0"
+ y="0"
+ style="opacity:1;fill:none;stroke:#000000;stroke-width:2;"
+ />
+</svg>';
+}
View
3  lib/Druid/Webapp.pm
@@ -16,6 +16,9 @@ class Druid::Webapp {
head { title { 'Druid' } }
body {
pre { $view }
+ object :type<image/svg+xml>, :data</board.svg>, {
+ 'alternate text'
+ }
ul {
for $game.possible-moves() -> $move {
li {
Please sign in to comment.
Something went wrong with that request. Please try again.