aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--conf/httpd.conf6
-rwxr-xr-xweb/json.cgi34
2 files changed, 39 insertions, 1 deletions
diff --git a/conf/httpd.conf b/conf/httpd.conf
index de7fc0668..472c74caa 100644
--- a/conf/httpd.conf
+++ b/conf/httpd.conf
@@ -20,7 +20,7 @@
# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org
#
-# $Id: httpd.conf,v 1.38 2008-10-15 15:42:29 keith Exp $
+# $Id: httpd.conf,v 1.39 2009-07-01 09:45:12 louise Exp $
DirectoryIndex index.cgi
@@ -71,6 +71,10 @@ RewriteRule ^/report/([0-9]+)$ /index.cgi?id=$1 [QSA]
RewriteRule ^/report/([0-9]+) /report/$1 [R]
RewriteRule ^/alerts/?$ /alert [R=permanent]
+# JSON API for summaries of reports
+RewriteRule ^/json/problems/new$ /json.cgi?type=new_problems [QSA]
+RewriteRule ^/json/problems/fixed$ /json.cgi?type=fixed_problems [QSA]
+
ProxyPass /tilma/ http://tilma.mysociety.org/
ProxyPassReverse /tilma/ http://tilma.mysociety.org/
diff --git a/web/json.cgi b/web/json.cgi
new file mode 100755
index 000000000..91f2676a7
--- /dev/null
+++ b/web/json.cgi
@@ -0,0 +1,34 @@
+#!/usr/bin/perl -w -I../perllib
+
+# json.cgi:
+# A small JSON API for FixMyStreet
+#
+# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
+# Email: louise@mysociety.org. WWW: http://www.mysociety.org
+#
+# $Id: json.cgi,v 1.1 2009-07-01 09:45:12 louise Exp $
+
+use strict;
+use Error qw(:try);
+use JSON;
+use Standard;
+
+sub main {
+ my $q = shift;
+ my $problems;
+ my $type = $q->param('type') || '';
+ my $start_date = $q->param('start_date') || '';
+ my $end_date = $q->param('end_date') || '';
+ print $q->header( -type => 'text/html; charset=utf-8' );
+ if ($type eq 'new_problems'){
+ $problems = Problems::created_in_interval($start_date, $end_date);
+ } elsif ($type eq 'fixed_problems') {
+ $problems = Problems::fixed_in_interval($start_date, $end_date);
+ }
+ my $out = JSON::to_json($problems);
+ print $out;
+}
+
+
+Page::do_fastcgi(\&main);
+