]> git.openstreetmap.org Git - rails.git/blob - app/controllers/browse_controller.rb
Update title on pushState, closes #33
[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     @relation = Relation.find(params[:id])
12     @next = Relation.visible.where("id > ?", @relation.id).order(:id => :asc).first
13     @prev = Relation.visible.where("id < ?", @relation.id).order(:id => :desc).first
14   rescue ActiveRecord::RecordNotFound
15     render :action => "not_found", :status => :not_found
16   end
17   
18   def relation_history
19     @type = "relation"
20     @relation = Relation.find(params[:id])
21   rescue ActiveRecord::RecordNotFound
22     render :action => "not_found", :status => :not_found
23   end
24   
25   def way
26     @type = "way"
27     @way = Way.preload(:way_tags, :containing_relation_members, :changeset => :user, :nodes => [:node_tags, :ways => :way_tags]).find(params[:id])
28     @next = Way.visible.where("id > ?", @way.id).order(:id => :asc).first
29     @prev = Way.visible.where("id < ?", @way.id).order(:id => :desc).first
30   rescue ActiveRecord::RecordNotFound
31     render :action => "not_found", :status => :not_found
32   end
33   
34   def way_history
35     @type = "way"
36     @way = Way.preload(:way_tags, :old_ways => { :changeset => :user }).find(params[:id])
37   rescue ActiveRecord::RecordNotFound
38     render :action => "not_found", :status => :not_found
39   end
40
41   def node
42     @type = "node"
43     @node = Node.find(params[:id])
44     @next = Node.visible.where("id > ?", @node.id).order(:id => :asc).first
45     @prev = Node.visible.where("id < ?", @node.id).order(:id => :desc).first
46   rescue ActiveRecord::RecordNotFound
47     render :action => "not_found", :status => :not_found
48   end
49   
50   def node_history
51     @type = "node"
52     @node = Node.find(params[:id])
53   rescue ActiveRecord::RecordNotFound
54     render :action => "not_found", :status => :not_found
55   end
56   
57   def changeset
58     @type = "changeset"
59
60     @changeset = Changeset.find(params[:id])
61     @node_pages, @nodes = paginate(:old_nodes, :conditions => {:changeset_id => @changeset.id}, :per_page => 10, :parameter => 'node_page')
62     @way_pages, @ways = paginate(:old_ways, :conditions => {:changeset_id => @changeset.id}, :per_page => 10, :parameter => 'way_page')
63     @relation_pages, @relations = paginate(:old_relations, :conditions => {:changeset_id => @changeset.id}, :per_page => 10, :parameter => 'relation_page')
64       
65     @next = Changeset.where("id > ?", @changeset.id).order(:id => :asc).first
66     @prev = Changeset.where("id < ?", @changeset.id).order(:id => :desc).first
67
68     if @changeset.user.data_public?
69       @next_by_user = @changeset.user.changesets.where("id > ?", @changeset.id).order(:id => :asc).first
70       @prev_by_user = @changeset.user.changesets.where("id < ?", @changeset.id).order(:id => :desc).first
71     end
72   rescue ActiveRecord::RecordNotFound
73     render :action => "not_found", :status => :not_found
74   end
75
76   def note
77     @type = "note"
78     @note = Note.find(params[:id])
79     @next = Note.visible.where("id > ?", @note.id).order(:id => :asc).first
80     @prev = Note.visible.where("id < ?", @note.id).order(:id => :desc).first
81   rescue ActiveRecord::RecordNotFound
82     render :action => "not_found", :status => :not_found
83   end
84 end