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