8 our $json_filename = "/srv/analysis.sesse.net/www/analysis.json";
10 my $cv = AnyEvent->condvar;
13 my $inotify = Linux::Inotify2->new;
14 $inotify->watch($json_filename, IN_MODIFY, sub {
19 my $inotify_w = AnyEvent->io (
20 fh => $inotify->fileno, poll => 'r', cb => sub { $inotify->poll }
22 my $wait = AnyEvent->timer (
24 cb => sub { $cv->send; },
27 # Yes, this is reinventing If-Modified-Since, but browsers are so incredibly
28 # unpredictable on this, so blargh.
30 if (defined($cgi->param('ims')) && $cgi->param('ims') ne '') {
31 $ims = $cgi->param('ims');
33 my $time = (stat($json_filename))[9];
35 # If we have something that's modified since IMS, send it out at once
41 # If not, wait, then send.
46 open my $fh, "<", $json_filename
47 or die "$json_filename: $!";
53 my $time = (stat($fh))[9];
56 print CGI->header(-type=>'text/json',
57 -x_remoteglot_last_modified=>$time,
58 -access_control_allow_origin=>'http://analysis.sesse.net',
59 -access_control_expose_headers=>'X-Remoteglot-Last-Modified',