]> git.openstreetmap.org Git - rails.git/blob - app/controllers/browse_controller.rb
7380ac5bb0b83f8fe288821153f37cc44c078f7f
[rails.git] / app / controllers / browse_controller.rb
1 class BrowseController < ApplicationController
2   layout :map_layout
3
4   before_filter :authorize_web  
5   before_filter :set_locale 
6   before_filter { |c| c.check_database_readable(true) }
7   around_filter :web_timeout
8
9   def relation
10     @type = "relation"
11     @feature = Relation.find(params[:id])
12     render 'feature'
13   rescue ActiveRecord::RecordNotFound
14     render :action => "not_found", :status => :not_found
15   end
16
17   def relation_history
18     @type = "relation"
19     @feature = Relation.find(params[:id])
20     render 'history'
21   rescue ActiveRecord::RecordNotFound
22     render :action => "not_found", :status => :not_found
23   end
24
25   def way
26     @type = "way"
27     @feature = Way.preload(:way_tags, :containing_relation_members, :changeset => :user, :nodes => [:node_tags, :ways => :way_tags]).find(params[:id])
28     render 'feature'
29   rescue ActiveRecord::RecordNotFound
30     render :action => "not_found", :status => :not_found
31   end
32
33   def way_history
34     @type = "way"
35     @feature = Way.preload(:way_tags, :old_ways => { :changeset => :user }).find(params[:id])
36     render 'history'
37   rescue ActiveRecord::RecordNotFound
38     render :action => "not_found", :status => :not_found
39   end
40
41   def node
42     @type = "node"
43     @feature = Node.find(params[:id])
44     render 'feature'
45   rescue ActiveRecord::RecordNotFound
46     render :action => "not_found", :status => :not_found
47   end
48
49   def node_history
50     @type = "node"
51     @feature = Node.find(params[:id])
52     render 'history'
53   rescue ActiveRecord::RecordNotFound
54     render :action => "not_found", :status => :not_found
55   end
56
57   def changeset
58     @type = "changeset"
59     @changeset = Changeset.find(params[:id])
60     @node_pages, @nodes = paginate(:old_nodes, :conditions => {:changeset_id => @changeset.id}, :per_page => 10, :parameter => 'node_page')
61     @way_pages, @ways = paginate(:old_ways, :conditions => {:changeset_id => @changeset.id}, :per_page => 20, :parameter => 'way_page')
62     @relation_pages, @relations = paginate(:old_relations, :conditions => {:changeset_id => @changeset.id}, :per_page => 20, :parameter => 'relation_page')
63   rescue ActiveRecord::RecordNotFound
64     render :action => "not_found", :status => :not_found
65   end
66
67   def note
68     @type = "note"
69     @note = Note.find(params[:id])
70   rescue ActiveRecord::RecordNotFound
71     render :action => "not_found", :status => :not_found
72   end
73 end