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