]> git.openstreetmap.org Git - rails.git/blob - app/controllers/browse_controller.rb
Add attrib
[rails.git] / app / controllers / browse_controller.rb
1 class BrowseController < ApplicationController
2   layout 'site', :except => [ :start ]
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.visible.where("id > ?", @relation.id).order("id ASC").first
16     @prev = Relation.visible.where("id < ?", @relation.id).order("id DESC").first
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.visible.where("id > ?", @way.id).order("id ASC").first
32     @prev = Way.visible.where("id < ?", @way.id).order("id DESC").first
33   rescue ActiveRecord::RecordNotFound
34     render :action => "not_found", :status => :not_found
35   end
36   
37   def way_history
38     @type = "way"
39     @way = Way.find(params[:id], :include => [:way_tags, {:old_ways => {:changeset => :user}}])
40   rescue ActiveRecord::RecordNotFound
41     render :action => "not_found", :status => :not_found
42   end
43
44   def node
45     @type = "node"
46     @node = Node.find(params[:id])
47     @next = Node.visible.where("id > ?", @node.id).order("id ASC").first
48     @prev = Node.visible.where("id < ?", @node.id).order("id DESC").first
49   rescue ActiveRecord::RecordNotFound
50     render :action => "not_found", :status => :not_found
51   end
52   
53   def node_history
54     @type = "node"
55     @node = Node.find(params[:id])
56   rescue ActiveRecord::RecordNotFound
57     render :action => "not_found", :status => :not_found
58   end
59   
60   def changeset
61     @type = "changeset"
62
63     @changeset = Changeset.find(params[:id])
64     @node_pages, @nodes = paginate(:old_nodes, :conditions => {:changeset_id => @changeset.id}, :per_page => 20, :parameter => 'node_page')
65     @way_pages, @ways = paginate(:old_ways, :conditions => {:changeset_id => @changeset.id}, :per_page => 20, :parameter => 'way_page')
66     @relation_pages, @relations = paginate(:old_relations, :conditions => {:changeset_id => @changeset.id}, :per_page => 20, :parameter => 'relation_page')
67       
68     @title = "#{I18n.t('browse.changeset.title')} | #{@changeset.id}"
69     @next = Changeset.where("id > ?", @changeset.id).order("id ASC").first
70     @prev = Changeset.where("id < ?", @changeset.id).order("id DESC").first
71
72     if @changeset.user.data_public?
73       @next_by_user = Changeset.where("user_id = ? AND id > ?", @changeset.user_id, @changeset.id).order("id ASC").first
74       @prev_by_user = Changeset.where("user_id = ? AND id < ?", @changeset.user_id, @changeset.id).order("id DESC").first
75     end
76   rescue ActiveRecord::RecordNotFound
77     render :action => "not_found", :status => :not_found
78   end
79
80   def note
81     @type = "note"
82     @note = Note.find(params[:id])
83     @title = "#{I18n.t('browse.note.title')} | #{@note.id}"
84     @next = Note.find(:first, :order => "id ASC", :conditions => [ "status != 'hidden' AND id > :id", { :id => @note.id }] )
85     @prev = Note.find(:first, :order => "id DESC", :conditions => [ "status != 'hidden' AND id < :id", { :id => @note.id }] )
86   rescue ActiveRecord::RecordNotFound
87     render :action => "not_found", :status => :not_found
88   end
89 end