]> git.openstreetmap.org Git - rails.git/blob - app/controllers/browse_controller.rb
adding more translations
[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
8   def start 
9   end
10   
11   
12   
13   def 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     @type = "relation"
19     render :action => "not_found", :status => :not_found
20   end
21   
22   def relation_history
23     @relation = Relation.find(params[:id])
24   rescue ActiveRecord::RecordNotFound
25     @type = "relation"
26     render :action => "not_found", :status => :not_found
27   end
28   
29   def 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   rescue ActiveRecord::RecordNotFound
34     @type = "way"
35     render :action => "not_found", :status => :not_found
36   end
37   
38   def way_history
39     @way = Way.find(params[:id], :include => [:way_tags, {:old_ways => {:changeset => :user}}])
40   rescue ActiveRecord::RecordNotFound
41     @type = "way"
42     render :action => "not_found", :status => :not_found
43   end
44
45   def node
46     @node = Node.find(params[:id])
47     @next = Node.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @node.id }] )
48     @prev = Node.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @node.id }] )
49   rescue ActiveRecord::RecordNotFound
50     @type = "node"
51     render :action => "not_found", :status => :not_found
52   end
53   
54   def node_history
55     @node = Node.find(params[:id])
56   rescue ActiveRecord::RecordNotFound
57     @type = "way"
58     render :action => "not_found", :status => :not_found
59   end
60   
61   def changeset
62     @changeset = Changeset.find(params[:id])
63     @node_pages, @nodes = paginate(:old_nodes, :conditions => {:changeset_id => @changeset.id}, :per_page => 20, :parameter => 'node_page')
64     @way_pages, @ways = paginate(:old_ways, :conditions => {:changeset_id => @changeset.id}, :per_page => 20, :parameter => 'way_page')
65     @relation_pages, @relations = paginate(:old_relations, :conditions => {:changeset_id => @changeset.id}, :per_page => 20, :parameter => 'relation_page')
66       
67     @title = "#{I18n.t('browse.changeset.title')} | #{@changeset.id}"
68     @next = Changeset.find(:first, :order => "id ASC", :conditions => [ "id > :id", { :id => @changeset.id }] ) 
69     @prev = Changeset.find(:first, :order => "id DESC", :conditions => [ "id < :id", { :id => @changeset.id }] ) 
70   rescue ActiveRecord::RecordNotFound
71     @type = "changeset"
72     render :action => "not_found", :status => :not_found
73   end
74 end