Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Axel 'fREW' Schmidt committed Sep 27, 2015
1 parent 55ebcc7 commit d784b69
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
1 change: 1 addition & 0 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ requires 'Config::Station';
requires 'namespace::clean';
requires 'Web::Simple';
requires 'Text::Xslate';
requires 'HTML::Zoom';

on test => sub {
requires 'Test::More';
Expand Down
33 changes: 29 additions & 4 deletions lib/WWW/RetroPie/Game/Picker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use autodie;
use IO::All;
use Text::Xslate;
use Config::Station;
use HTML::Zoom;

sub to_app { shift->to_psgi_app(@_) }

Expand Down Expand Up @@ -66,10 +67,34 @@ sub dispatch_request {
linked => $links{$_->name}
}, io->dir($self->_config->real_roms_dir, $system)->all;

$self->_html_200('all_games', {
system => $system,
games => \@games,
})
my $template = <<'HTML';
<html>
<body>
<ul>
<li id="games">
<span class="game"></span> [
<a class="unpick">Unpick</a>
]
</li>
</ul>
</body>
</html>
HTML
my $fh = HTML::Zoom->from_html($template)
->select('#games')
->repeat_content([
map {
my $game = $_;
sub {
$_->select('.name')->replace_content($game->{name});
$_->select('.unpick')->add_to_attribute(
href => "/selected/$system/$game->{name}/pick"
);
}
} @games
])
->to_fh;
[200, [content_type => 'text/html'], $fh ]
},
'/*/...' => sub {
my ($game) = $_[1];
Expand Down

0 comments on commit d784b69

Please sign in to comment.