version 1.2, 2010/06/25 21:20:15 |
version 1.4, 2010/06/26 17:16:08 |
|
|
action => sub { |
action => sub { |
my ( $self, $action ) = @_; |
my ( $self, $action ) = @_; |
|
|
state $Actions = { |
state %Actions; |
location => { mtime => 0 }, |
|
speakers => { mtime => 0 }, |
|
talks => { mtime => 0 }, |
|
interests => { mtime => 0 }, |
|
users => { mtime => 0 }, |
|
}; |
|
return if !exists $Actions->{$action}; |
|
|
|
my $path = app->home->rel_file( 'data/' . $action ); |
my $path = app->home->rel_file( 'data/' . $action ); |
my $mtime = ( stat $path )[9]; |
|
|
|
if ( $mtime != $Actions->{$action}{mtime} ) { |
return if ! -e $path; |
|
my $mtime = ( stat _ )[9]; |
|
|
|
$Actions{$action}{mtime} //= 0; |
|
|
|
if ( $mtime != $Actions{$action}{mtime} ) { |
open my $fh, $path or die "Couldn't open [$path]: $!"; |
open my $fh, $path or die "Couldn't open [$path]: $!"; |
my $content = do { local $/; <$fh> }; |
my $content = do { local $/; <$fh> }; |
close $fh; |
close $fh; |
|
|
die $json->error; |
die $json->error; |
} |
} |
|
|
$Actions->{$action} = { |
$Actions{$action} = { |
mtime => $mtime, |
mtime => $mtime, |
data => $data, |
data => $data, |
}; |
}; |
} |
} |
|
|
return $Actions->{$action}{data}; |
return $Actions{$action}{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> |