version 1.3, 2010/06/26 17:14:52 |
version 1.5, 2010/06/27 01:52:33 |
|
|
use Mojolicious::Lite; |
use Mojolicious::Lite; |
use Mojo::JSON; |
use Mojo::JSON; |
|
|
use Data::Dumper; |
|
|
|
use 5.010; |
use 5.010; |
|
|
app->renderer->add_helper( |
app->renderer->add_helper( |
|
|
|
|
state %Actions; |
state %Actions; |
|
|
my $path = app->home->rel_file( 'data/' . $action ); |
my $path = app->home->rel_file( '../t/data/' . $action ); |
|
|
return if ! -e $path; |
return if !-e $path; |
my $mtime = ( stat _ )[9]; |
my $mtime = ( stat _ )[9]; |
|
|
$Actions{$action}{mtime} //= 0; |
$Actions{$action}{mtime} //= 0; |
|
|
my @data = @{$data}; |
my @data = @{$data}; |
foreach my $param ( $self->param ) { |
foreach my $param ( $self->param ) { |
my $value = $self->param($param); |
my $value = $self->param($param); |
@data = grep { ( !exists $_->{$param} ) || $value ~~ $_->{$param} } |
@data = grep { |
@data; |
ref $_ ne 'HASH' |
|
|| ( !exists $_->{$param} ) |
|
|| $value ~~ $_->{$param} |
|
} @data; |
} |
} |
$self->render_json( \@data ); |
$self->render_json( \@data ); |
}; |
}; |
|
|
|
|
@@ index.html.ep |
@@ index.html.ep |
% layout 'default'; |
% layout 'default'; |
Please try /api/action |
Please try /api/action, or see |
|
<a href="http://amd.home.net">amd.hope.net</a>. |
|
|
@@ layouts/default.html.ep |
@@ layouts/default.html.ep |
<!doctype html><html> |
<!doctype html><html> |