]> git.openstreetmap.org Git - rails.git/blob - app/controllers/old_node_controller.rb
2590fd24aefbac64035b0e31e7c04dfa76de1612
[rails.git] / app / controllers / old_node_controller.rb
1 class OldNodeController < ApplicationController
2   require 'xml/libxml'
3
4   session :off
5   before_filter :check_api_readable
6   after_filter :compress_output
7
8   def history
9     begin
10       node = Node.find(params[:id])
11
12       doc = OSM::API.new.get_xml_doc
13
14       node.old_nodes.each do |old_node|
15         doc.root << old_node.to_xml_node
16       end
17
18       render :text => doc.to_s, :content_type => "text/xml"
19     rescue ActiveRecord::RecordNotFound
20       render :nothing => true, :status => :not_found
21     rescue
22       render :nothing => true, :status => :internal_server_error
23     end
24   end
25   
26   def version
27     begin
28       old_node = OldNode.find(:first, :conditions => {:id => params[:id], :version => params[:version]} )
29       if old_node.nil?
30         # (RecordNotFound is not raised with find :first...)
31         render :nothing => true, :status => :not_found
32         return
33       end
34       
35       response.headers['Last-Modified'] = old_node.timestamp.rfc822
36
37       doc = OSM::API.new.get_xml_doc
38       doc.root << old_node.to_xml_node
39
40       render :text => doc.to_s, :content_type => "text/xml"
41     rescue
42       render :nothing => true, :status => :internal_server_error
43     end
44   end
45 end