]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/browse_controller.rb
Merge 14059:14394 from trunk.
[rails.git] / app / controllers / browse_controller.rb
index f3a04519cbd362b5f8133a1c7c079d7ef9dda7ff..10145a50a2d93c5e02d9626155ca7060b3dd8160 100644 (file)
@@ -7,9 +7,7 @@ class BrowseController < ApplicationController
   def start 
   end
   
-  def index
-    @nodes = Node.find(:all, :order => "timestamp DESC", :limit=> 20)  
-  end
+  
   
   def relation 
     begin
@@ -17,14 +15,15 @@ class BrowseController < ApplicationController
      
       @name = @relation.tags['name'].to_s 
       if @name.length == 0:
-       @name = "#" + @relation.id.to_s
+          @name = "#" + @relation.id.to_s
       end
        
       @title = 'Relation | ' + (@name)
       @next = Relation.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @relation.id }] ) 
       @prev = Relation.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @relation.id }] ) 
     rescue ActiveRecord::RecordNotFound
-      render :nothing => true, :status => :not_found
+      @type = "relation"
+      render :action => "not_found", :status => :not_found
     end
   end
   
@@ -34,12 +33,13 @@ class BrowseController < ApplicationController
      
       @name = @relation.tags['name'].to_s 
       if @name.length == 0:
-       @name = "#" + @relation.id.to_s
+          @name = "#" + @relation.id.to_s
       end
        
       @title = 'Relation History | ' + (@name)
     rescue ActiveRecord::RecordNotFound
-      render :nothing => true, :status => :not_found
+      @type = "relation"
+      render :action => "not_found", :status => :not_found
     end
   end
   
@@ -49,14 +49,15 @@ class BrowseController < ApplicationController
      
       @name = @way.tags['name'].to_s 
       if @name.length == 0:
-       @name = "#" + @way.id.to_s
+          @name = "#" + @way.id.to_s
       end
        
       @title = 'Way | ' + (@name)
       @next = Way.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @way.id }] ) 
       @prev = Way.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @way.id }] ) 
     rescue ActiveRecord::RecordNotFound
-      render :nothing => true, :status => :not_found
+      @type = "way"
+      render :action => "not_found", :status => :not_found
     end
   end
   
@@ -66,12 +67,13 @@ class BrowseController < ApplicationController
      
       @name = @way.tags['name'].to_s 
       if @name.length == 0:
-       @name = "#" + @way.id.to_s
+          @name = "#" + @way.id.to_s
       end
        
       @title = 'Way History | ' + (@name)
     rescue ActiveRecord::RecordNotFound
-      render :nothing => true, :status => :not_found
+      @type = "way"
+      render :action => "not_found", :status => :not_found
     end
   end
 
@@ -81,14 +83,15 @@ class BrowseController < ApplicationController
      
       @name = @node.tags_as_hash['name'].to_s 
       if @name.length == 0:
-       @name = "#" + @node.id.to_s
+          @name = "#" + @node.id.to_s
       end
        
       @title = 'Node | ' + (@name)
       @next = Node.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @node.id }] ) 
       @prev = Node.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @node.id }] ) 
     rescue ActiveRecord::RecordNotFound
-      render :nothing => true, :status => :not_found
+      @type = "node"
+      render :action => "not_found", :status => :not_found
     end
   end
   
@@ -98,12 +101,29 @@ class BrowseController < ApplicationController
      
       @name = @node.tags_as_hash['name'].to_s 
       if @name.length == 0:
-       @name = "#" + @node.id.to_s
+          @name = "#" + @node.id.to_s
       end
        
       @title = 'Node History | ' + (@name)
     rescue ActiveRecord::RecordNotFound
-      render :nothing => true, :status => :not_found
+      @type = "way"
+      render :action => "not_found", :status => :not_found
+    end
+  end
+  
+  def changeset
+    begin
+      @changeset = Changeset.find(params[:id])
+      @node_pages, @nodes = paginate(:old_nodes, :conditions => {:changeset_id => @changeset.id}, :per_page => 20, :parameter => 'node_page')
+      @way_pages, @ways = paginate(:old_ways, :conditions => {:changeset_id => @changeset.id}, :per_page => 20, :parameter => 'way_page')
+      @relation_pages, @relations = paginate(:old_relations, :conditions => {:changeset_id => @changeset.id}, :per_page => 20, :parameter => 'relation_page')
+      
+      @title = "Changeset | #{@changeset.id}"
+      @next = Changeset.find(:first, :order => "id ASC", :conditions => [ "id > :id", { :id => @changeset.id }] ) 
+      @prev = Changeset.find(:first, :order => "id DESC", :conditions => [ "id < :id", { :id => @changeset.id }] ) 
+    rescue ActiveRecord::RecordNotFound
+      @type = "changeset"
+      render :action => "not_found", :status => :not_found
     end
   end
 end