]> git.openstreetmap.org Git - rails.git/blob - app/controllers/browse_controller.rb
Remove unused gem and add a comment where it was replaced
[rails.git] / app / controllers / browse_controller.rb
1 class BrowseController < ApplicationController
2   layout 'site'
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, :except => [:start]
8
9   def start 
10     render :partial => "sidebar"
11   end
12   
13   def relation
14     @type = "relation"
15     @relation = Relation.find(params[:id])
16     @next = Relation.visible.where("id > ?", @relation.id).order("id ASC").first
17     @prev = Relation.visible.where("id < ?", @relation.id).order("id DESC").first
18   rescue ActiveRecord::RecordNotFound
19     render :action => "not_found", :status => :not_found
20   end
21   
22   def relation_history
23     @type = "relation"
24     @relation = Relation.find(params[:id])
25   rescue ActiveRecord::RecordNotFound
26     render :action => "not_found", :status => :not_found
27   end
28   
29   def way
30     @type = "way"
31     @way = Way.find(params[:id], :include => [:way_tags, {:changeset => :user}, {:nodes => [:node_tags, {:ways => :way_tags}]}, :containing_relation_members])
32     @next = Way.visible.where("id > ?", @way.id).order("id ASC").first
33     @prev = Way.visible.where("id < ?", @way.id).order("id DESC").first
34
35     # Used for edit link, takes approx middle node of way
36     @midnode = @way.nodes[@way.nodes.length/2]
37   rescue ActiveRecord::RecordNotFound
38     render :action => "not_found", :status => :not_found
39   end
40   
41   def way_history
42     @type = "way"
43     @way = Way.find(params[:id], :include => [:way_tags, {:old_ways => {:changeset => :user}}])
44   rescue ActiveRecord::RecordNotFound
45     render :action => "not_found", :status => :not_found
46   end
47
48   def node
49     @type = "node"
50     @node = Node.find(params[:id])
51     @next = Node.visible.where("id > ?", @node.id).order("id ASC").first
52     @prev = Node.visible.where("id < ?", @node.id).order("id DESC").first
53   rescue ActiveRecord::RecordNotFound
54     render :action => "not_found", :status => :not_found
55   end
56   
57   def node_history
58     @type = "node"
59     @node = Node.find(params[:id])
60   rescue ActiveRecord::RecordNotFound
61     render :action => "not_found", :status => :not_found
62   end
63   
64   def changeset
65     @type = "changeset"
66
67     @changeset = Changeset.find(params[:id])
68     @node_pages, @nodes = paginate(:old_nodes, :conditions => {:changeset_id => @changeset.id}, :per_page => 20, :parameter => 'node_page')
69     @way_pages, @ways = paginate(:old_ways, :conditions => {:changeset_id => @changeset.id}, :per_page => 20, :parameter => 'way_page')
70     @relation_pages, @relations = paginate(:old_relations, :conditions => {:changeset_id => @changeset.id}, :per_page => 20, :parameter => 'relation_page')
71       
72     @title = "#{I18n.t('browse.changeset.title')} | #{@changeset.id}"
73     @next = Changeset.where("id > ?", @changeset.id).order("id ASC").first
74     @prev = Changeset.where("id < ?", @changeset.id).order("id DESC").first
75
76     if @changeset.user.data_public?
77       @next_by_user = Changeset.where("user_id = ? AND id > ?", @changeset.user_id, @changeset.id).order("id ASC").first
78       @prev_by_user = Changeset.where("user_id = ? AND id < ?", @changeset.user_id, @changeset.id).order("id DESC").first
79     end
80   rescue ActiveRecord::RecordNotFound
81     render :action => "not_found", :status => :not_found
82   end
83 end