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