aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/public_body_controller.rb20
-rw-r--r--app/views/help/api.rhtml4
-rw-r--r--config/routes.rb1
3 files changed, 23 insertions, 2 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb
index 560206900..0a2e72a5a 100644
--- a/app/controllers/public_body_controller.rb
+++ b/app/controllers/public_body_controller.rb
@@ -47,6 +47,26 @@ class PublicBodyController < ApplicationController
@track_thing = TrackThing.create_track_for_public_body(@public_body)
@feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss] } ]
+
+ respond_to do |format|
+ format.html { @has_json = true }
+ format.json {
+ render :json => {
+ :id => @public_body.id,
+ :url_name => @public_body.url_name,
+ :name => @public_body.name,
+ :short_name => @public_body.short_name,
+ # :request_email # we hide this behind a captcha, to stop people doing bulk requests easily
+ :created_at => @public_body.created_at,
+ :updated_at => @public_body.updated_at,
+ # :version, :last_edit_editor, :last_edit_comment # history, not done yet
+ :home_page => @public_body.calculated_home_page,
+ :notes => @public_body.notes,
+ :publication_scheme => @public_body.publication_scheme,
+ :tags => @public_body.tag_array,
+ }
+ }
+ end
end
def view_email
diff --git a/app/views/help/api.rhtml b/app/views/help/api.rhtml
index 9679f3cc7..6f34755b2 100644
--- a/app/views/help/api.rhtml
+++ b/app/views/help/api.rhtml
@@ -50,8 +50,8 @@ tips</a> for details.
<h2> 3. JSON structured data </h2>
-<p>Some pages have JSON feeds, which let you download information about objects
-in a structured form. Find them by:
+<p>Request and public authority pages have JSON feeds, which let you download
+information about objects in a structured form. Find them by:
<ul>
<li>Adding <tt>.json</tt> to the end of the URL. </li>
<li>Look for the <tt>&lt;link rel="alternate" type="application/json"&gt;</tt> tag in the head of the HTML. </li>
diff --git a/config/routes.rb b/config/routes.rb
index 6205f2446..a54884088 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -82,6 +82,7 @@ ActionController::Routing::Routes.draw do |map|
body.list_public_bodies "/body/list/:tag", :action => 'list'
body.list_public_bodies_redirect "/local/:tag", :action => 'list_redirect'
body.show_public_body "/body/:url_name", :action => 'show'
+ body.show_public_body "/body/:url_name.:format", :action => 'show'
body.view_public_body_email "/body/:url_name/view_email", :action => 'view_email'
body.all_public_bodies_csv "/body/all-authorities.csv", :action => 'list_all_csv'
end