]> git.openstreetmap.org Git - rails.git/blob - app/controllers/browse_controller.rb
Link ways and nodes backwards and forwards.
[rails.git] / app / controllers / browse_controller.rb
1 class BrowseController < ApplicationController
2   before_filter :authorize_web  
3   layout 'site'
4
5   def index
6     @nodes = Node.find(:all, :order => "timestamp DESC", :limit=> 20)  
7   end
8   
9   def relation 
10     begin
11       @relation = Relation.find(params[:id])
12      
13       @name = @relation.tags['name'].to_s 
14       if @name.length == 0:
15         @name = "#" + @relation.id.to_s
16       end
17         
18       @title = 'Relation | ' + (@name)
19     rescue ActiveRecord::RecordNotFound
20       render :nothing => true, :status => :not_found
21     end
22   end
23   
24   def relation_history
25     begin
26       @relation = Relation.find(params[:id])
27      
28       @name = @relation.tags['name'].to_s 
29       if @name.length == 0:
30         @name = "#" + @relation.id.to_s
31       end
32         
33       @title = 'Relation History | ' + (@name)
34     rescue ActiveRecord::RecordNotFound
35       render :nothing => true, :status => :not_found
36     end
37   end
38   
39   def way 
40     begin
41       @way = Way.find(params[:id])
42      
43       @name = @way.tags['name'].to_s 
44       if @name.length == 0:
45         @name = "#" + @way.id.to_s
46       end
47         
48       @title = 'Way | ' + (@name)
49     rescue ActiveRecord::RecordNotFound
50       render :nothing => true, :status => :not_found
51     end
52   end
53   
54   def way_history 
55     begin
56       @way = Way.find(params[:id])
57      
58       @name = @way.tags['name'].to_s 
59       if @name.length == 0:
60         @name = "#" + @way.id.to_s
61       end
62         
63       @title = 'Way History | ' + (@name)
64     rescue ActiveRecord::RecordNotFound
65       render :nothing => true, :status => :not_found
66     end
67   end
68
69   def node 
70     begin
71       @node = Node.find(params[:id])
72      
73       @name = @node.tags_as_hash['name'].to_s 
74       if @name.length == 0:
75         @name = "#" + @node.id.to_s
76       end
77         
78       @title = 'Node | ' + (@name)
79     rescue ActiveRecord::RecordNotFound
80       render :nothing => true, :status => :not_found
81     end
82   end
83   
84   def node_history 
85     begin
86       @node = Node.find(params[:id])
87      
88       @name = @node.tags_as_hash['name'].to_s 
89       if @name.length == 0:
90         @name = "#" + @node.id.to_s
91       end
92         
93       @title = 'Node History | ' + (@name)
94     rescue ActiveRecord::RecordNotFound
95       render :nothing => true, :status => :not_found
96     end
97   end
98 end