format.rss
format.js
format.xml
- format.json { render :json => @notes.to_json }
+ format.json
format.gpx
end
end
respond_to do |format|
format.xml
format.rss
- format.json { render :json => @note.to_json }
+ format.json
format.gpx
end
end
format.rss { render :action => :list }
format.js
format.xml { render :action => :list }
- format.json { render :json => @notes.to_json }
+ format.json { render :action => :list }
format.gpx { render :action => :list }
end
end
def author_name
self.comments.first.author_name
end
-
- # Custom JSON output routine for notes
- def to_json(options = {})
- super options.reverse_merge(
- :methods => [ :lat, :lon ],
- :only => [ :id, :status, :created_at ],
- :include => {
- :comments => {
- :only => [ :event, :author_name, :created_at, :body ]
- }
- }
- )
- end
end
--- /dev/null
+{
+ "type": "Feature",
+ "geometry": {
+ "type": "Point",
+ "coordinates": [ <%= note.lon %>, <%= note.lat %> ]
+ },
+ "properties": {
+ "id": <%= note.id %>,
+ "date_created": "<%= note.created_at %>",
+ "nearby": "<%= note.nearby_place %>",
+ "status": "<%= note.status %>",
+<% if note.status == "closed" -%>
+ "closed_at": "<%= note.closed_at %>",
+<% end -%>
+ "comments": [
+ <%= render :partial => "note_comment", :collection => note.comments, :spacer_template => "note_spacer" -%>
+ ]
+ }
+}
--- /dev/null
+{
+ "date": "<%= note_comment.created_at %>",
+<% unless note_comment.author_id.nil? -%>
+ "uid": <%= note_comment.author_id %>,
+<% end -%>
+ "user": "<%= note_comment.author_name %>",
+ "text": "<%= note_comment.body %>"
+}
--- /dev/null
+{
+ "type": "FeatureCollection",
+ "features": [
+ <%= render :partial => "note", :collection => @notes, :spacer_template=> "note_spacer" -%>
+ ]
+}