]> git.openstreetmap.org Git - rails.git/blob - app/controllers/browse_controller.rb
Split come changset display logic into a helper
[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     @title = "#{I18n.t('browse.changeset.title')} | #{@changeset.id}"
66     @next = Changeset.where("id > ?", @changeset.id).order(:id => :asc).first
67     @prev = Changeset.where("id < ?", @changeset.id).order(:id => :desc).first
68
69     if @changeset.user.data_public?
70       @next_by_user = @changeset.user.changesets.where("id > ?", @changeset.id).order(:id => :asc).first
71       @prev_by_user = @changeset.user.changesets.where("id < ?", @changeset.id).order(:id => :desc).first
72     end
73   rescue ActiveRecord::RecordNotFound
74     render :action => "not_found", :status => :not_found
75   end
76
77   def note
78     @type = "note"
79     @note = Note.find(params[:id])
80     @title = "#{I18n.t('browse.note.title')} | #{@note.id}"
81     @next = Note.visible.where("id > ?", @note.id).order(:id => :asc).first
82     @prev = Note.visible.where("id < ?", @note.id).order(:id => :desc).first
83   rescue ActiveRecord::RecordNotFound
84     render :action => "not_found", :status => :not_found
85   end
86 end