]> git.openstreetmap.org Git - rails.git/blob - app/controllers/browse_controller.rb
Missed a couple close buttons
[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, :except => [:start]
8
9   def start
10     render :layout => false
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.preload(:way_tags, :containing_relation_members, :changeset => :user, :nodes => [:node_tags, :ways => :way_tags]).find(params[:id])
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   rescue ActiveRecord::RecordNotFound
35     render :action => "not_found", :status => :not_found
36   end
37   
38   def way_history
39     @type = "way"
40     @way = Way.preload(:way_tags, :old_ways => { :changeset => :user }).find(params[:id])
41   rescue ActiveRecord::RecordNotFound
42     render :action => "not_found", :status => :not_found
43   end
44
45   def node
46     @type = "node"
47     @node = Node.find(params[:id])
48     @next = Node.visible.where("id > ?", @node.id).order(:id => :asc).first
49     @prev = Node.visible.where("id < ?", @node.id).order(:id => :desc).first
50   rescue ActiveRecord::RecordNotFound
51     render :action => "not_found", :status => :not_found
52   end
53   
54   def node_history
55     @type = "node"
56     @node = Node.find(params[:id])
57   rescue ActiveRecord::RecordNotFound
58     render :action => "not_found", :status => :not_found
59   end
60   
61   def changeset
62     @type = "changeset"
63
64     @changeset = Changeset.find(params[:id])
65     @node_pages, @nodes = paginate(:old_nodes, :conditions => {:changeset_id => @changeset.id}, :per_page => 10, :parameter => 'node_page')
66     @way_pages, @ways = paginate(:old_ways, :conditions => {:changeset_id => @changeset.id}, :per_page => 10, :parameter => 'way_page')
67     @relation_pages, @relations = paginate(:old_relations, :conditions => {:changeset_id => @changeset.id}, :per_page => 10, :parameter => 'relation_page')
68       
69     @title = "#{I18n.t('browse.changeset.title')} | #{@changeset.id}"
70     @next = Changeset.where("id > ?", @changeset.id).order(:id => :asc).first
71     @prev = Changeset.where("id < ?", @changeset.id).order(:id => :desc).first
72
73     if @changeset.user.data_public?
74       @next_by_user = @changeset.user.changesets.where("id > ?", @changeset.id).order(:id => :asc).first
75       @prev_by_user = @changeset.user.changesets.where("id < ?", @changeset.id).order(:id => :desc).first
76     end
77   rescue ActiveRecord::RecordNotFound
78     render :action => "not_found", :status => :not_found
79   end
80
81   def note
82     @type = "note"
83     @note = Note.find(params[:id])
84     @title = "#{I18n.t('browse.note.title')} | #{@note.id}"
85     @next = Note.visible.where("id > ?", @note.id).order(:id => :asc).first
86     @prev = Note.visible.where("id < ?", @note.id).order(:id => :desc).first
87   rescue ActiveRecord::RecordNotFound
88     render :action => "not_found", :status => :not_found
89   end
90 end