Skip to content

Commit

Permalink
built a bit more on the web version
Browse files Browse the repository at this point in the history
Doesn't quite work yet, though. The SVG doesn't show up in the browser.
  • Loading branch information
Carl Masak committed Jun 1, 2009
1 parent b916228 commit c06e28c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
31 changes: 27 additions & 4 deletions bin/web-druid
Expand Up @@ -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}";
Expand All @@ -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>';
}
3 changes: 3 additions & 0 deletions lib/Druid/Webapp.pm
Expand Up @@ -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 {
Expand Down

0 comments on commit c06e28c

Please sign in to comment.