]> git.openstreetmap.org Git - rails.git/blob - app/controllers/browse_controller.rb
Use the right keyword this time...
[rails.git] / app / controllers / browse_controller.rb
1 class BrowseController < ApplicationController
2   layout 'site'
3
4   before_filter :authorize_web  
5   before_filter { |c| c.check_database_availability(true) }
6
7   def start 
8   end
9   
10   
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       @type = "relation"
26       render :action => "not_found", :status => :not_found
27     end
28   end
29   
30   def relation_history
31     begin
32       @relation = Relation.find(params[:id])
33      
34       @name = @relation.tags['name'].to_s 
35       if @name.length == 0:
36           @name = "#" + @relation.id.to_s
37       end
38         
39       @title = 'Relation History | ' + (@name)
40     rescue ActiveRecord::RecordNotFound
41       @type = "relation"
42       render :action => "not_found", :status => :not_found
43     end
44   end
45   
46   def way 
47     begin
48       @way = Way.find(params[:id])
49      
50       @name = @way.tags['name'].to_s 
51       if @name.length == 0:
52           @name = "#" + @way.id.to_s
53       end
54         
55       @title = 'Way | ' + (@name)
56       @next = Way.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @way.id }] ) 
57       @prev = Way.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @way.id }] ) 
58     rescue ActiveRecord::RecordNotFound
59       @type = "way"
60       render :action => "not_found", :status => :not_found
61     end
62   end
63   
64   def way_history 
65     begin
66       @way = Way.find(params[:id])
67      
68       @name = @way.tags['name'].to_s 
69       if @name.length == 0:
70           @name = "#" + @way.id.to_s
71       end
72         
73       @title = 'Way History | ' + (@name)
74     rescue ActiveRecord::RecordNotFound
75       @type = "way"
76       render :action => "not_found", :status => :not_found
77     end
78   end
79
80   def node 
81     begin
82       @node = Node.find(params[:id])
83      
84       @name = @node.tags_as_hash['name'].to_s 
85       if @name.length == 0:
86           @name = "#" + @node.id.to_s
87       end
88         
89       @title = 'Node | ' + (@name)
90       @next = Node.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @node.id }] ) 
91       @prev = Node.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @node.id }] ) 
92     rescue ActiveRecord::RecordNotFound
93       @type = "node"
94       render :action => "not_found", :status => :not_found
95     end
96   end
97   
98   def node_history 
99     begin
100       @node = Node.find(params[:id])
101      
102       @name = @node.tags_as_hash['name'].to_s 
103       if @name.length == 0:
104           @name = "#" + @node.id.to_s
105       end
106         
107       @title = 'Node History | ' + (@name)
108     rescue ActiveRecord::RecordNotFound
109       @type = "way"
110       render :action => "not_found", :status => :not_found
111     end
112   end
113   
114   def changeset
115     begin
116       @changeset = Changeset.find(params[:id])
117       @node_pages, @nodes = paginate(:old_nodes, :conditions => {:changeset_id => @changeset.id}, :per_page => 20, :parameter => 'node_page')
118       @way_pages, @ways = paginate(:old_ways, :conditions => {:changeset_id => @changeset.id}, :per_page => 20, :parameter => 'way_page')
119       @relation_pages, @relations = paginate(:old_relations, :conditions => {:changeset_id => @changeset.id}, :per_page => 20, :parameter => 'relation_page')
120       
121       @title = "Changeset | #{@changeset.id}"
122       @next = Changeset.find(:first, :order => "id ASC", :conditions => [ "id > :id", { :id => @changeset.id }] ) 
123       @prev = Changeset.find(:first, :order => "id DESC", :conditions => [ "id < :id", { :id => @changeset.id }] ) 
124     rescue ActiveRecord::RecordNotFound
125       @type = "changeset"
126       render :action => "not_found", :status => :not_found
127     end
128   end
129 end